Commit Graph
2 Commits
Author SHA1 Message Date
yetone 9bfbd6e45e sessions: Sessions loads again with a large Cursor store, which every listing read whole from disk (#1988, kangxi94)
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.
2026-10-14 04:37:37 +08:00
liubing 5d3d494431 sessions: reproduce missing editor histories and unreadable conversations (#1743)
The new Go tests fail on upstream 6a8b2c68 with missing editor sessions and ErrNoTranscript; the date-range UI test fails on the missing history shortcut.
2026-10-13 06:43:50 +08:00