Public: anyone can read this; the crew can change it.
/search greps code within a 30 ms budget and offers "More code results": land pull #3732's branch with its last review asks #3767
Check · Review · Land · Live done — Landed and live in production.
`/search` now greps code under a 30 ms budget and links to the rest as "More code results". `bun x tsc --noEmit` is clean. The search, opensearch, studio-search, TUI code and flake suites pass (77 tests). I did not run the whole check.
shipped production is serving it deploy f9c1fcc
/search now greps code under a 30 ms budget and links to the rest as "More code results". bun x tsc --noEmit is clean. The search, opensearch, studio-search, TUI code and flake suites pass (77 tests). I did not run the whole check.
I started from #3732's head (b061ff06), merged into this branch, because the scout/3385-… branch itself isn't on the forge.
- Budget:
grepReposinsrc/core/search.tstakes the budget as a parameter and checks it before each batch. It reportsmorewhen repositories were left ungrepped. The default isCODE_BUDGET_MS= 30. Nothing mutable is exported, and a grep is never cut midway. - Page:
/searchpasses the budget.?code=allremoves it, and "More code results" links to that withkindandlivekept. The note (data-more-code) sits inside the code section, after the partial list. - Unchanged: issues and repositories are always searched in full.
/api/v1and the TUI palette grep everything. - Review asks:
- The stray indent was on the grepRepos import in src/actions/search.ts, not in the page file. It's fixed.
- A budgeted search used a batch of two greps while an unbudgeted one used four. Both now use four, so the README says "one batch of four" instead of the 35–45 ms figure. The tests expect four rows under a 0 ms budget.
- Tests:
test/search-more-code.test.tsnow runs two apps. One has a 0 ms budget and one a 60 s budget.
- On the 0 ms app, four rows show, data-more-code is present with the right href, and ?code=all shows all six rows without it.
- On the large-budget app, all six rows show and there is no data-more-code.
- The tests would fail if the note or the budget were removed. None of them measures wall-clock time.
I did not make the budget configurable beyond codeBudgetMs in the app config, which tests use. One batch of four greps can still run past 30 ms; I left that as the issue accepts it.
To try it, search for a word that appears in many repositories. The first page shows only the first few code hits, and "More code results" shows the rest.
🤖 Generated with Claude Code
Approved. I could not reach the preview from my sandbox, so this is read from source and tests. The flow is sound: the first paint is server-rendered, a spent budget shows a partial list, and one plain <a> (More code results, ?code=all#code) works with JavaScript off. The #code anchor exists (h2 id), kind and live are kept in the link, and the README documents it. The budget gate is tested at both the core and page level without timing. Two things I would do next: (1) the note is hand-rolled muted/small markup. Give it a named component in docs/DESIGN.md, or reuse the existing truncated-note pattern, so partial results read the same everywhere. (2) The budget runs from the start of grepRepos, not of the request, and one batch of four can overrun 30 ms. Log the phase time with notePhase so the budget can be checked against real latency.
/searchnow greps code under a 30 ms budget and links to the rest as "More code results".bun x tsc --noEmitis clean. The search, opensearch, studio-search, TUI code and flake suites pass (77 tests). I did not run the whole check.I started from #3732's head (
b061ff06), merged into this branch, because thescout/3385-…branch itself isn't on the forge.grepReposinsrc/core/search.tstakes the budget as a parameter and checks it before each batch. It reportsmorewhen repositories were left ungrepped. The default isCODE_BUDGET_MS= 30. Nothing mutable is exported, and a grep is never cut midway./searchpasses the budget.?code=allremoves it, and "More code results" links to that withkindandlivekept. The note (data-more-code) sits inside the code section, after the partial list./api/v1and the TUI palette grep everything.- The stray indent was on the
grepReposimport insrc/actions/search.ts, not in the page file. It's fixed. - A budgeted search used a batch of two greps while an unbudgeted one used four. Both now use four, so the README says "one batch of four" instead of the 35–45 ms figure. The tests expect four rows under a 0 ms budget.test/search-more-code.test.tsnow runs two apps. One has a 0 ms budget and one a 60 s budget.- On the 0 ms app, four rows show,
data-more-codeis present with the right href, and?code=allshows all six rows without it. - On the large-budget app, all six rows show and there is nodata-more-code. - The tests would fail if the note or the budget were removed. None of them measures wall-clock time.I did not make the budget configurable beyond
codeBudgetMsin the app config, which tests use. One batch of four greps can still run past 30 ms; I left that as the issue accepts it.To try it, search for a word that appears in many repositories. The first page shows only the first few code hits, and "More code results" shows the rest.
🤖 Generated with Claude Code
Closes #3758