Why: the filter matched only titles, folders, ids and models, and a
session the gateway recorded was listed under its bare ses_… id, so one
couldn't be found by anything a person remembers about it.
What changed:
- sessions.GatewayTitle: the first user text of a recorded session (not
a <…> context tag, # AGENTS.md or an image), made one line. It reads at
most 8 complete turns of the oldest file of it, caches a finished
file's answer by path, and costs one stat when nothing is recorded.
gatewayListed applies it in every list (/api/sessions, /manage, /one,
the stats summaries); ExternalSession gained Title.
- GET /api/sessions/search?agent=&q= (searchSessions): an agent's
sessions, newest first, read by up to 4 workers, each only to its
first match. Native files go through a byte prefilter (mayHold: the
query's longest word, ASCII case folded without a copy, 1 MiB chunks,
skipped for zstd and for queries JSON may escape), and of a Claude or
Codex file only the lines holding every word are decoded
(readTranscriptOf; claudeContentOf/codexContentOf take an optional
line test, nil for every other caller); gateway sessions, and an
unreadable agent's sessions (unread: true), through their recorded
transcript. System prompts, tool definitions and images never match.
It stops at 200 hits or 8s (cut, searched of total) and when the
request's context ends. Each hit carries the match with 36 runes
before and 120 after.
- sessions.js: the field says "Search sessions"; title/folder/id/model
matches show at once, the server is asked 300ms after the last
keystroke, a new query aborts the request in flight and its answer is
dropped, under 2 letters asks nothing. A session found shows a line of
the words round its match with the match in <mark> (text nodes, no
innerHTML). A note says when it is searching, cut short, failed, or
limited to recorded text. New strings in zh, zh-TW, ja and de.
- docs/subsystems/gateway-sessions.md describes both.
Run:
- Go: TestSearchSession* (snippet, case and line breaks, said text
preferred over a tool call, cut ends, cancelled context, a Codex file,
only matching lines decoded: 1 part of 3), TestContainsFold,
TestMayHoldSkipsAFileWithoutTheWords (incl. a match across chunks),
TestGatewayTitleAndSearch (context tag and system prompt skipped),
TestSessionsSearchFindsGatewaySessionsByWhatWasSaid (endpoint + manage
titles), TestSessionsSearchStopsWhenItsRequestEnds. Without the
endpoint/title they fail (404, id as title).
- GUI: new sessions-search.test.cjs in chromium and webkit, en/zh at
1100, zh-TW/ja at 560, de at 420: title shown, one letter no request,
one debounced request, snippet mark, cancelled earlier request never
shown, cut note, empty state, Escape, every language's strings, no
overflow; 12/12, and 0/12 with the old sessions.js. The sessions-*,
sess-*, session-* and i18n-keys tests pass in both engines
(sessions-manage's placeholder updated to "Search sessions").
- gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., the builds: clean. go test -tags nogui
./... at load ~25-60 (other sessions' runs): every package passed but
internal/agent and internal/gateway, which hit the 30m timeout; run
again alone, agent passed and gateway's only red was
TestOTelWaterfallIncludesUnbilledFallback, filed as #1794 (passes
alone, -count=3).
- Real data, read-only (a temporary probe, not committed, pointed at
the owner's ~/.claude and ~/.codex; one worker, 8s, load ~50):
Claude, 58 sessions / 3 GB: before the line filter one 1.3 GB session
took the whole 8s ("redis": 1 of 58); after, all 58 in 4.7s ("redis",
13 hits), 7.4s ("gateway session"), 2.8s (no match). Codex, 11534
sessions / 65 GB: 245-656 sessions in 8s either way, which is what
the cut note ("latest n of total") is for.
Not verified: the endpoint and page against a real recorded gateway
store (only fixtures and temp homes); the timings above were taken on
a machine at load ~50 and vary run to run.