v0.1.1227 (0e39c8e7e) reads a live Cursor state.vscdb from an APFS clone
made whenever Cursor has written, which stopped the repeated copies. But
the editor's chat list was found with `key LIKE 'composerData:%'`. LIKE is
case-insensitive, so SQLite can't use the key's index and scans the whole
table: every bubble and checkpoint, often several GB. Before, the copy had
just been written and sat in the page cache; a fresh clone doesn't, so
each listing read the whole store from disk again. Cursor writes every few
seconds, so nearly every listing got a fresh clone, and /api/sessions and
/api/sessions/manage took longer than the pages' polls: Sessions and Usage >
Sessions showed skeletons for good.
The list is now read by a range on the key's index (cursorComposersQuery,
key >= 'composerData:' AND key < 'composerData;'), which reads only the
chats' rows.
Run:
- TestCursorComposersQueryUsesTheKeyIndex: Cursor's own schema, keys around
the range's edges; the plan must be a search on the index and only
composerData: keys come back. Red with the LIKE put back ("SCAN
cursorDiskKV").
- sqlite3 on a fresh clone of a 2.2 GB live-written store: LIKE 3.74s cold,
0.11s warm; the range 0.06s. A second repro (4.3 GB store, 1M small keys,
500 chats): range 0.01s vs LIKE 3.8s; on main /api/sessions took 40-60s
and /api/sessions/manage 86-121s every round.
- Built binaries against the 2.2 GB store with a writer every 2s, same
sandbox, machine at load ~25 from other work: /api/sessions 17/9/3.7s and
manage 16s with the fix, 34/26/9.4s and 31s on main. The rest is not
the Cursor scan (a sample shows no sqlite work); not measured on an idle
machine.
- go test ./internal/sessions ./internal/gui ok; gofmt; go vet darwin,
linux, windows.
Not tried on the reporter's machine or a real Cursor store.
Follow-up to liubing's #1743 patch, which put cursor and opencode in
HasTranscript. That moved their search from magpie's recorded
transcript to SearchSession, whose byte prefilter (mayHold) reads
s.Path. For these agents s.Path isn't the conversation:
- OpenCode's JSON storage: the session info file, without messages,
so every word missed;
- OpenCode's and Cursor's SQLite stores: the newest pages are in the
-wal, so a live chat's latest turns missed.
linesFile now skips the prefilter for them (a Cursor .jsonl still
gets it).
cursorTranscript also handed the CLI store's system message ("You
are a coding agent.") to the transcript as a said part; system
messages are skipped, as the listing already does.
The patch's tests commit left TestSearchSessionWithoutATranscript
red (it used cursor as the agent without a transcript; now gemini).
sessions-empty-range.test.cjs runs in every language, de at 420px.
Run: go test -tags nogui -count=1 ./internal/sessions/ ok, and -race
ok; sessions-empty-range 10/10 (Chromium+WebKit, en zh zh-TW ja de);
sessions-today/overview/toolbar/search/manage/calendar-fill/paging
GUI tests pass.
Broken by hand: prefilter always on -> TestSearchOpenCodeFiles and
TestSearchCursorLiveChat red; system skip removed ->
TestSearchCursorLiveChat red. Also broke the patch itself: editor
files not appended, readOnly Delete guard, stats message dates, CLI
dedupe, HasTranscript entries, parseCursor readOnly dispatch, and
the "All sessions" button (via MAGPIE_TEST_APP_JS); each went red.
Co-authored-by: liubing <lb0806@foxmail.com>
Discover editor project transcripts and cursorDiskKV histories without modifying the source. Share one SQLite/WAL snapshot across a scan, refresh metadata changes, deduplicate CLI histories, and reject deletion of read-only sessions.
Count message-only sessions and expose an all-dates action when a filter hides existing history. Read Cursor CLI text, reasoning and tool parts, and OpenCode v1/v2 transcripts through the existing transcript API.