~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

Search finds code, with a filter down the side

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:web/code-search

What changes

Code on the results page. /search has a "Filter by" side with Code and Repositories, laid out as settings' sections are, and a row of tabs on a phone. Code shows each file found in a box: the repository and path over the lines around each match, with matches marked. Each line number links to that line of the file at the commit that was searched. Under Code, the side also lists the languages of the files found, each narrowing the search with lang:. repo:owner/name in the query searches one repository: the count line then says which, with a link to search all of knotless, and a repo: naming no repository says so rather than blaming the query. Empty, off, and unreadable searches each say so in the list's box, as does a repo: naming no repository.

In the palette. With text typed, a "code containing …" row searches code everywhere. On a repository's pages it searches that repository's code instead.

commit in searchCode. Each file now carries the commit its default branch was indexed at, so its links show the lines that were searched even after the branch moves.

It builds on knotless-serve's code search, knotless-serve searches public repositories' code with Zoekt.

A retry for Go's download. The test check's Zoekt step retries go.dev, whose 503 failed one run of this pull.

Why

This is the search page from the design: GitHub's layout, a type picked down the side, over our own searchCode.

How it was checked

Drawn with just look from answers given by hand, on desktop light and phone dark: results of every kind (a long repository name and path, two runs of lines in one file, a file found by its path alone, non-ASCII text), no results, a repo: naming no repository, and the palette with text typed. Pictures attached. An agent that had not seen the code critiqued them. Long paths now break at slashes, and a match on the path alone now says so. The serve test asserts the new commit. svelte-check, layers and contrast pass.

Shots-moved: search

Shortcomings

  • The shots world has no code search, so no recorded page shows code results. The pictures here show them. Recording one needs Zoekt in the world, which e2e would need too.
  • Matched lines are not syntax highlighted.
  • The repositories tab shows no counts, and neither does the side.

🤖 Generated with Claude Code

code-results-desktop-light.png

code-results-phone-dark.png

code-scoped-desktop-light.png

code-missing-repo-phone-dark.png

code-empty-desktop-light.png

palette-code-row.png

Approved

This adds a "Filter by" side (Code and Repositories) to /search. It adds a CodeResults box per file, lang: narrowing from the languages of the files found, and repo:owner/name parsing. It adds a "code containing …" row to the palette, scoped to the repository on its pages. It also exposes commit on searchCode so line links point at the searched commit.

I read the web changes (+page.ts, +page.svelte, CodeResults.svelte, SearchPalette.svelte, app.css) and web/search.rs. I found nothing that must change:

  • The repo: → at://…/dev.knotless.repo/<name> conversion matches what repo::found accepts.
  • The byte-range marking in pieces handles overlaps and non-ASCII text.
  • The palette's index arithmetic for the new row is consistent in the scoped and unscoped cases.
  • A 501 or a Zoekt parse error is shown on the page rather than failing it.

I did not read code.rs, index.rs, lib.rs, the tests, the docs or the workflow/Docker files. They belong to the base code-search pull (3mzfcggqsmjuj), which this branch includes, so it should be reviewed there.

At the time of review only web had passed. check, test, shots, lexicons, docs and e2e were still queued or running, so they are not covered here.

Approved

The one new commit (4b5b47f) answers a repo: that names no repository with its own message, instead of blaming the query. +page.ts now returns kind: 'missing' for a 404 when repo: was given. +page.svelte renders it with a link that drops the repo: term and searches everywhere.

I found nothing that must change:

  • searchCode calls repo::found for repo, which is where an unknown repository fails. I did not confirm that the 404 comes from there. If it comes back as another status, the page shows the generic "can't be read" message, which is the old behaviour.
  • The link strips repo: with a regex that matches the one in +page.ts apart from its trailing lookahead. Where the two differ, the link just leaves a malformed repo: term in the query.

My earlier approve stands. At this head, check is still queued and test is running, so neither is covered here.

Approved

There are two new commits since my last review. d606011 makes the page say which repository a code search is kept to, with a "Search all of knotless" link. The second is a merge of main, which now holds the base code-search pull. After the merge, the diff is the web work plus commit on searchCode: the Hit and ZFile fields, FileView, the lexicon, docs/reference/api.md, docs/guide/server.md, and a test assertion.

I found nothing that must change.

  • commit comes from Zoekt's version, which defaults to empty. FileView omits it when empty and CodeResults falls back to HEAD, so older shards still link.
  • The searching_code test compares commit to rev-parse HEAD of the mirror, which matches what the indexer reads.
  • The "within" and "everywhere" links on the page use the same repo: regex as +page.ts. The everywhere strip regex has no trailing lookahead, which is the difference I noted before. It only matters for a malformed repo: term.
  • The palette's row index (hrefs.length - (everywhere ? 2 : 1)) matches where code sits in hrefs.

I did not confirm that searchCode answers 404 for an unknown repo. If it doesn't, the page shows the generic "can't be read" message instead of the new one.

At this head check and docs are running, and web, test, shots, lexicons and e2e are queued, so none of them is covered here.

Merged as 360dae8