chadtmiller.com/knotless
git that lives in your Atmosphere account
Code search highlights its snippets, counts each kind, and shows in status
MergedThis pull does five things:
- Code-search snippets now carry highlights, painted client-side with the CSS Custom Highlight API.
- A file's chunks are answered in line order.
- Code and Repositories each show a count in the side nav.
/_statusandknotless statusreport the Zoekt index.- The shots world records two code views.
I read all 19 files. I found nothing that has to change.
The painted action walks every text node under the <code>, so the <mark> splits don't shift offsets. The update and destroy paths clear what they painted. The repo: case skips the repositories lookup. The status check counts only .zoekt files, so meta/ is ignored. A dead webserver fails ok and adds a problem. The changeset and the Shots-moved line are present, and the docs, lexicon and deploy README were updated.
One thing to confirm, which I did not verify. The Repositories tab's code count asks Zoekt with limit=1 (MaxDocDisplayCount: 1) and reads fileCount from the answer. Check against a multi-file match that Zoekt's FileCount stays the total matched and isn't cut short by the display limit. The search and code shots would show a count of 1 if it were.
The checks were still running or queued when I looked, so I have no results from them.
I found nothing new that has to change. My earlier review approved this pull at f64aa4d. The diff since then is too large to read whole (about 300k characters). That is probably the base moving, so I did not re-read it all.
The one item I left open before is still open. The Repositories tab's code count asks Zoekt with MaxDocDisplayCount: 1 (crates/knotless-serve/src/code.rs:280) and reads fileCount from the answer. Please confirm on a multi-file match that Zoekt's FileCount stays the total matched and isn't cut short by the display limit. If it is cut short, the search and code shots would show a count of 1.
The check run was still going and test was queued when I looked, so I have no check results.
9 passed, 1 skipped
What changes
Highlighted snippets. Each run of lines code search answers carries
highlights, painted as a file's highlighting is: by its path's language, from the server's grammars. The page paints them over the lines with the CSS Custom Highlight API, across the marks of what was found, so a match keeps its mark and its colour.Snippets in the order of their lines. Zoekt answers a file's runs of lines best first, so a file's page of results could read lines 12 to 36 and then 1 to 8. They are answered in line order now, as GitHub shows them.
Counts in the side. Code and Repositories each show how many a search found, the other kind asked for too: the files Zoekt counted, and the repositories on the first page,
50+when there are more. Scoped to one repository withrepo:, the repositories count is left out./_statusandknotless statusshow the code index. With--code-index,/_statushascode: whether Zoekt's webserver answers, and the repositories, shards and bytes its index holds. A webserver that died fails it, as every code search then fails.knotless statusprints it as a line:code ok, 21 repos in 23 shards, 312M.Code results in the shots. The shots world runs its server with a code index when Zoekt is on PATH, and records two new views:
code(/search?type=code&q=count) andcode-repo(the same, kept to alice.test/tally). It waits until both tallies are indexed at their tips, so what is recorded holds no older commit.just shots-recordrefuses to run without Zoekt, rather than record the views as off. e2e andshots-checkneed no Zoekt: e2e's world runs without a code index, and the shots draw from the recording.Why
These are the parts left of code search once it shipped: plain snippets were hard to read beside every file page's highlighting, the side named the kinds with nothing to say which held results, prod's index could be seen only by searching, and no shot showed code results, so a change that broke them would pass.
Snippets are highlighted read alone rather than within their whole file: the whole file would mean reading every hit's blob from its mirror on every search. The cost is that a snippet starting inside a long comment or string can be painted as code.
How it was checked
searching_code(tests/web.rs) asserts a chunk'shighlightsand that/_statusshows the index; a unit test in code.rs covers a Rust chunk and a.txtone with none; status.rs'scodetest runs a dead Zoekt over three shards of two repositories and sees it fail;rendersin knotless's status.rs covers the CLI line;chunks_are_cut_into_linesgiveshitchunks out of order.just lookof the results with highlights, on desktop and phone, and of the repositories tab with both counts.just shots-recordwith Zoekt e1fafb15 built here.Shots-moved: search, code, code-repo
Shortcomings
50+.🤖 Generated with Claude Code