)]}'
{
  "commit": "34ca370f8d0f897cd7f307c7bedfb1aa8ff7c5a8",
  "tree": "f75210bc51b1240ddac31a115a5c6b0c1aa99368",
  "parents": [
    "e0d8b45eb4afd832309243f743fd59925d925750"
  ],
  "author": {
    "name": "George Engelbrecht",
    "email": "engeg@google.com",
    "time": "Tue Sep 22 19:09:10 2026 +0000"
  },
  "committer": {
    "name": "George Engelbrecht",
    "email": "engeg@google.com",
    "time": "Thu Oct 22 17:34:05 2026 +0000"
  },
  "message": "Add a keyboard-driven file finder to the Gitiles header\n\nPressing \"/\" on any page that addresses a commit opens a palette that\nfuzzy-matches every blob path in that revision; Enter navigates\nstraight to the file.\n\nThe index is the paths_only tree listing, fetched on first open rather\nthan on page load, so a reader who never searches costs the server\nnothing. Its URL is pinned to the resolved commit SHA: BaseServlet\nonly marks a response cacheable when the revision is named by object\nID, so a branch-named URL would be refetched on every open, and\ncontent addressing retires a stale copy without a revalidation\nroundtrip.\n\nMatching runs in a Worker against a string-free index -- path bytes in\nflat buffers with Int32Array offsets -- so no amount of index work can\ndrop a frame on the main thread. Directories are interned, collapsing\nchromium/src from 506,237 paths to 46,286 directory runs, and the byte\nbuffers are trimmed to what was written. The whole index is then 28 MB\nagainst 37 MB of path text: smaller than the corpus it indexes.\n\nThere is no cap. Every path in the revision is held and considered; if\na path matches, either it is on screen or twenty strictly\nbetter-ranked paths are.\n\nRanking\n-------\n\nQueries run in tiers, cheapest first, and a tier is skipped only when\na cheaper one has already filled the display. That is exact rather\nthan heuristic, because the tiers are a strict ordering: nothing a\nlater one produces can displace what an earlier one found.\n\n  A  the whole path literally starts with the query\n  B  the basename starts with it\n  C  the basename contains it as a subsequence\n  D  the path contains it as a subsequence\n\nA comes first because B, C and D all score the basename alone, and a\nquery the directory has already absorbed leaves the basename scoring\nnothing. Without A, typing a path got monotonically worse the more of\nit you spelled: 1,254 paths start with \"base/t\" and none of them\nreached the top twenty. A is two binary searches, because the index is\nin byte order and so those paths are contiguous. It is case-sensitive\nby design -- a case-folded range would not be contiguous -- which is\nsound only because it promotes and never filters, so a reader who\ntypes the wrong case loses the promotion, not the result.\n\nGreedy directory consumption decides whether a file matches, not how\nwell. Consuming as much of the query as possible in the directory\nleaves the shortest remainder for the basename, which is what makes D\nsound and cheap, but it is forced rather than chosen: the directory of\nbase/base64.h eats \"base\" out of the query \"base64.h\", so the file\nscored as a directory-assisted match and took D\u0027s penalty for that.\nTyping a filename exactly then put it at position 9, behind eight\nunrelated test pages whose directories happened to contain none of the\nquery. A basename that carries the whole query on its own is scored as\nthe basename match it is, whatever the directory could also have\nsupplied. Only the order changes; the candidate set, and the monotone\nnarrowing it rests on, are untouched.\n\nSubsequence matching is monotone under query extension, so each\nkeystroke narrows the previous candidate set and backspace pops it.\nDirectory prefixes are memoised, which is what makes D affordable: the\n506k paths in chromium/src share only 46k distinct directories. D\nresumes each directory\u0027s greedy match from the length it shares with\nthe previous one, rejects a file whose basename alone cannot supply\nthe characters the directory failed to consume, and accepts a whole\ndirectory run wholesale once the directory has consumed the query.\n\nMeasured on that corpus (506,237 blobs) under node v22, on the worker\nthread: 480 ms to build the index, and 25 ms for the worst keystroke,\nwhich is a basename query. Path-directed queries are answered by A in\nunder a millisecond. End to end in a browser on the same corpus,\nincluding fetch, gzip, JSON.parse and the postMessage round trip:\n1,737 ms from \"/\" to a usable index and a median keystroke of 1.9 ms.\nAndroid\u0027s largest repository, toolchain/rustc at 223,429 paths, is\n718 ms and 2.1 ms. Typing does not depend on the link: shaping the\norigin to 5 Mbps and 150 ms of RTT leaves the median at 2.0 ms and\nmoves only the one-time open, to 2.95 s.\n\nWhen A or B fills the display the engine stops there, so its count is\nthen a lower bound and the display says so with a trailing \"+\".\n\nMatched characters are marked in the row. The engine measures in UTF-8\nbytes and the UI marks substrings of a JS string, whose indices are\nUTF-16 code units, so the offsets are only meaningful for an ASCII\npath; on anything else they drifted and marked characters that had not\nmatched. A path whose byte length differs from its string length is\ntherefore shown unmarked. That is four paths in chromium/src, and the\nlink is built from the whole path and was never affected.\n\nEmpty state\n-----------\n\nAn empty box offers the files this reader keeps returning to, best\nfirst, rather than the repository in tree order -- which on\nchromium/src means offering \".gn\". The score is an exponentially\ndecayed visit count: on each visit\n\n    s \u003c- s * 2^(-dt / HALF_LIFE) + 1\n\nwhich expands to the sum over past visits of 2^(-age/HALF_LIFE), with\na one-week half-life, so frequent files outrank once-opened ones and\nabandoned files fall away. Remembered paths are checked against the\nindex before they are shown, so a file deleted since it was last\nopened is dropped rather than offered as a row that 404s. Only files\nopened through the finder are recorded. Ranking for non-empty queries\nis untouched, so two readers typing the same query see the same\nresults in the same order. The store lives in localStorage, is keyed\nper repository, holds at most 200 entries, and is a record of what\nthis reader opened, so on a shared machine it is visible to anyone\nwith the browser profile. Storage being absent, denied, full or\ncorrupt falls back to the plain listing. The offered list is cut to\nthe display limit like every other channel: the UI paints exactly that\nmany rows but takes its selection bounds from what it was sent, so a\nlonger list let the selection run off the end of the rows onto nothing.\n\nWarming\n-------\n\nThe finder resolves a query in single-digit milliseconds and then\nhands the reader a link they still have to wait on, so the highlighted\ndestination is warmed. This is only possible because result links are\nSHA-pinned and therefore cacheable. Three mechanisms were measured in\nChrome under the access pattern the finder creates -- many warms on\none page, no reload in between:\n\n  link rel\u003dprefetch  warms some destinations and cancels others with\n                     ERR_ABORTED; unusable here\n  fetch, low prio    completes every time, lands on disk, but carries\n                     no Sec-Purpose\n  speculation rules  completes every time, lands in the prefetch\n                     cache, carries Sec-Purpose: prefetch\n\nSo the warm is a one-URL prefetch rule where the API exists, falling\nback to a low-priority fetch where it does not. The rule set is\nswapped rather than grown, so at most one destination is speculated on\nat a time, and it is torn down when the palette closes. A 250 ms\ndebounce, a dedupe set and a cap of 32 distinct destinations per\nsession keep it polite.\n\nGitiles sets no Content-Security-Policy of its own, so the policy\nbelongs to whoever deploys it. A script-src carrying neither\n\u0027strict-dynamic\u0027 nor \u0027inline-speculation-rules\u0027 blocks the rule set,\nand a blocked rule reports nothing to the code that installed it, so\nwarming would stop with no signal. A securitypolicyviolation listener\ndowngrades to the fetch path, which connect-src governs and which\ntherefore survives exactly the policy that kills the rule.\n\nReach\n-----\n\nThe finder is on every page that names a repository, not only trees.\nA keyboard shortcut only earns its keep once it is reflex, and a\nreader who hits \"/\" on the repository index and gets nothing has\nlearned not to try. Pages that address a revision search that\nrevision; the repository index and the ref list carry none, so they\nfall back to HEAD, which on the index is the tree already on screen. A\nrevision that peels to something other than a commit deliberately does\nnot fall back rather than silently answer about different content.\nBecause the URL is content-addressed, every page in a repository names\nthe same listing, so it is fetched once and reused across navigations.\n\nArrow keys, Ctrl-N/P and PageUp/PageDown move the selection; Escape\ncloses; Enter opens the file and Ctrl/Cmd-Enter opens it in a new tab.\nThe palette is closed on pagehide so that a page restored from the\nback/forward cache does not come back with a stale overlay covering\nit.\n\nFocus never leaves the input, so the input names the selected row with\naria-activedescendant -- without it a screen reader is told nothing at\nall as the selection travels, which for a feature that exists to be\ndriven from the keyboard is most of the feature. Rows are not tab\nstops and Tab is held, so focus cannot walk out of a dialog that\ndeclares itself modal.\n\nConfiguration\n-------------\n\nSetting gitiles.fileSearch (default true) to false turns the finder\noff. The index is linear in the number of paths in the revision and\ndeliberately uncapped, because a file that exists must be findable, so\na deployment whose repositories are larger than anything measured here\nneeds a switch rather than a patch.\n\nA deployment can also decline it without meaning to: a policy with a\nrestrictive worker-src rejects the Worker constructor synchronously,\nwith no event to observe. That is caught, because the overlay is\nalready on screen and the input is not yet focused when it throws --\nunhandled, it left a dialog the reader could neither type into nor\nclose. The reader is told instead, and asking again retries, so a\none-off failure loading the index does not disable the finder for the\nlife of the page.\n\nVerification\n------------\n\nFileSearchTest pins the things that break silently: the listing URL\nnaming a commit SHA rather than a branch or tag object, the script tag\ncarrying the request CSP nonce, Markdown documentation pages rendering\nthe trigger and overlay, and gitiles.fileSearch \u003d false rendering no\nfinder at all.\n\nThe CSP downgrade was driven in headless Chrome against a served\nscript-src \u0027self\u0027, paired against the same proxy without the header:\nthe hardened run reports a script-src-elem violation, drops the rule\nand still warms the highlighted destination exactly once; the control\nreports no violation, keeps the rule and also warms exactly once.\n\nThe engine was checked against a brute-force oracle over all 506,237\npaths of chromium/src: every path is findable by its own basename, no\ndisplayed row fails to match, and a reported total is exact whenever\nthe engine claims exactness and a true lower bound otherwise. The\nresumed directory pass was additionally compared against an\nindependent per-directory rescan for 3,021 queries across all 46,286\ndirectories, 139,830,006 comparisons, with no disagreement. The\npalette, the empty state and the warming were driven end to end in\nheadless Chrome against the same repository.\n\nRanking, the empty state at more than a screenful, the unmarked\nnon-ASCII row, aria-activedescendant tracking the selection, Tab being\nheld, and a refused Worker constructor were each driven in headless\nChrome against chromium/src. Scoring a basename-only match as one\ncosts nothing measurable: over eight queries spanning every channel,\nthe median keystroke moves by at most 0.05 ms either way and the index\nbuild is unchanged.\n\nEighteen unit tests drive the worker through its message protocol on\nthe js_test lane, covering the listing load and its failure, ranking,\nthe promoted path-prefix and basename-prefix channels, negative-scored\nweak matches, directory highlight ranges, the unmarked non-ASCII row,\nleading U+FEFF preservation, and the cut to the displayed row count.\nEach was checked against a mutant: reverting the basename-first\nscoring fix, the ASCII guard on highlight ranges, or the cut to LIMIT\nmakes the suite fail, and the unmutated worker passes 18 of 18.\n\nThirty-five more drive the palette itself. jstests/fake_dom.js is not\na browser and does not try to be one: it is a recording of the calls\nthe script makes -- attributes set, classes toggled, preventDefault\ncounts, timers queued, storage written -- and what it declines to\nmodel is listed in its header. That is the right shape here because\nwhat is worth pinning is this script\u0027s own bookkeeping rather than any\nbrowser semantics. The tests cover opening and dismissal, row reuse\nand the cut to twenty, selection clamping and aria-activedescendant,\nIME composition guards, the worker handshake and the ways it can fail,\nthe frecency store\u0027s decay, cap and empty fallback, and warming both\nunder speculation rules and after a policy has refused them.\n\nNine reverted fixes were each caught: not resetting the selection on a\nnew query, clamping it to the result count rather than to the rows on\nscreen, leaving rows in the tab order, dropping the row ids, dropping\naria-activedescendant, letting Tab escape the palette, leaving the\nWorker constructor unguarded, dropping the exponential decay, and\nleaving the store uncapped. Unmutated, 35 of 35 pass.\n\nBug: 564986686\nTAG\u003dagy\nCONV\u003d0b3e4b30-d902-4587-8bb2-ce23109d6955\nCONV\u003d60d1bfdf-34a4-460e-85ab-0f251e052543\nChange-Id: I32240619cb19aedb30cbf82f96c926031a242d74\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "c9c7448cefb9c452ddd7be87f8fbfead7e1c822b",
      "old_mode": 33188,
      "old_path": "Documentation/config.md",
      "new_id": "523c7fdf3997fede6dd60b94ed439d7827544083",
      "new_mode": 33188,
      "new_path": "Documentation/config.md"
    },
    {
      "type": "modify",
      "old_id": "fe22701862e652b3fa8664b9b5abfa699f59db9f",
      "old_mode": 33188,
      "old_path": "java/com/google/gitiles/Renderer.java",
      "new_id": "f21aec7da8f5792cb4f22933aca842344fa8a235",
      "new_mode": 33188,
      "new_path": "java/com/google/gitiles/Renderer.java"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "798316b64fab4ec01adca6d964ef1f0244b5f28a",
      "new_mode": 33188,
      "new_path": "javatests/com/google/gitiles/FileSearchTest.java"
    },
    {
      "type": "modify",
      "old_id": "27e10cc1f2c398553ec980f0c53c6c3306f31ba5",
      "old_mode": 33188,
      "old_path": "javatests/com/google/gitiles/TestGitilesAccess.java",
      "new_id": "c0a92aff64b281993cfdba41dee24835af47b260",
      "new_mode": 33188,
      "new_path": "javatests/com/google/gitiles/TestGitilesAccess.java"
    },
    {
      "type": "modify",
      "old_id": "b68ea87c7841daf2f5290cd32fca84ac01087c7a",
      "old_mode": 33188,
      "old_path": "javatests/com/google/gitiles/TestGitilesServlet.java",
      "new_id": "3cd234efdf2a7d3a781d55212dda200b31467662",
      "new_mode": 33188,
      "new_path": "javatests/com/google/gitiles/TestGitilesServlet.java"
    },
    {
      "type": "modify",
      "old_id": "a18ee552f26d52cc3aaf9e29d282a7a394b909fa",
      "old_mode": 33188,
      "old_path": "jstests/BUILD",
      "new_id": "62e29e8fc7e9b56cd15e6da95038ed472893e1f8",
      "new_mode": 33188,
      "new_path": "jstests/BUILD"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "2e4077e18c3f0a5335b8392e57def05ed6ba55bc",
      "new_mode": 33188,
      "new_path": "jstests/fake_dom.js"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "aefe3f471d9e775138d19180567103e0fe682a79",
      "new_mode": 33188,
      "new_path": "jstests/file_search_test.js"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "f4a0491fd29f771496ef9b0443d7c9aa4f2f12f8",
      "new_mode": 33188,
      "new_path": "jstests/file_search_worker_test.js"
    },
    {
      "type": "modify",
      "old_id": "8c21311969207d089e489a6b9747758d873c5949",
      "old_mode": 33188,
      "old_path": "resources/com/google/gitiles/static/base.css",
      "new_id": "e3814395162569afae77066b03f72dc8571cf4da",
      "new_mode": 33188,
      "new_path": "resources/com/google/gitiles/static/base.css"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "56ba5a4ff45e720b29964862ee4cc0d8b530558f",
      "new_mode": 33188,
      "new_path": "resources/com/google/gitiles/static/file-search-worker.js"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "7cbdb1317306cd814fce6f134b8be50d2b75af30",
      "new_mode": 33188,
      "new_path": "resources/com/google/gitiles/static/file-search.js"
    },
    {
      "type": "modify",
      "old_id": "0aca3dc8e40c03f56a3dd116336620ba7df9e499",
      "old_mode": 33188,
      "old_path": "resources/com/google/gitiles/templates/Common.soy",
      "new_id": "0caf2cceebee1685cc795e0f1deb6e1231650a4d",
      "new_mode": 33188,
      "new_path": "resources/com/google/gitiles/templates/Common.soy"
    },
    {
      "type": "modify",
      "old_id": "fab786bf75c5d3811622a949283bcdd5c24d5c35",
      "old_mode": 33188,
      "old_path": "resources/com/google/gitiles/templates/Doc.soy",
      "new_id": "5551dafbadeeb64edea9cb437749a4e86f82edd8",
      "new_mode": 33188,
      "new_path": "resources/com/google/gitiles/templates/Doc.soy"
    }
  ]
}
