ac4af582301a4e8a29245dbba767eba31334ddf9
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b8270850df |
sessions: a kept parse's rarely set fields live in a StateMore made only when one is set (#2278)
Each of the ~18k files the Sessions cache keeps had a 760-byte state, and ~330 bytes of it were fields almost no file sets: the Codex spawn and agent maps, Named/Custom/First, the dsh and Claude conversation lists, Root/Leaf, Compacts, and the six per-agent tails (Grok, Droid, Kimi, Agy, Dsh, Cline). On the owner's real cache (18,331 files) Root and Leaf are set in 150, Named in 117, Compacts in 78, First in 35. They move to an embedded *StateMore, nil unless something is in it: reads go through more() (a shared empty one when nil), writes through own(). The JSON is the same (embedded fields are inlined), so the cache version stays. - parseWith drops an extra that only had empty values written to it, and share() drops one the decode made empty. - clone() deep-copies the extra, so growing a clone leaves the kept state alone. Copies that never write (withoutRevisions, the Agent rename) share it, as they shared the maps before. Run on mote at this tree: - gofmt -l internal/sessions: clean. go vet ./internal/sessions/ on darwin, GOOS=linux and GOOS=windows: ok. - go test -count=1 ./internal/sessions/: ok (26s). - Every selector was checked by renaming the embedding to a named field and compiling with -gcflags=-e until only the struct literals were left, so no field is reached through a nil *StateMore. - New tests in state_more_test.go: zero() knows every field (reflect), a read makes no extra and a write never reaches the shared empty one, a clone owns its extra, and a cache round trip keeps no empty extra. Broken by hand: dropping Cline from zero() and sharing the extra in clone() each turn their test red; restored. - Real-account idle heap (copy of the owner's config and 24.6MB sessions cache, gateway idle 180s, heap after GC): decodeCache's retained heap 35.0MB -> 22.5MB, reflect.unsafe_New 20.0MB -> 10.5MB. The total (128.7MB -> 133.6MB) moves by more than that between runs of one binary (118-140MB), from late passes that happened to be live. Not tried: the full ./... suite (state is unexported; only internal/sessions uses it, and the whole binary builds). |
||
|
|
532d054bee |
sessions: every Cursor row has a delete, and the right-hand column lines up
ysm119 (Discord), Sessions page, Cursor tab: some rows had a delete and
some had none, and the time / "N sessions" column stood at a different x
from row to row.
Causes:
- Delete: listAgentWith set Deletable = Deletable(agent) && !ReadOnly, so
every editor-transcript row (read only) came back deletable:false, and
client.js drew .sm-del only for deletable rows.
- Alignment: a folder adds its ⋯ only when it has actions, and a session
row's Resume / terminal / Continue in / delete come and go per row, so
.sm-when, .cost and .num moved with them. "Copied" is wider than
"Resume", and at <=600px the cost line wrapped at different places.
Change:
- rowDeletable decides per row. An editor transcript the editor no longer
keeps (no state.vscdb, or it was read and has no composer for that id)
is "loose" and deletable: Delete trashes only its <id>/ folder or
<id>.jsonl/.txt, never state.vscdb. A chat the editor keeps, or a store
that can't be read, stays undeletable with undeletable:"cursor-editor".
- In an agent magpie deletes from, every row has its delete. One it can't
delete is aria-disabled, says why in its title, and a click shows the
reason in the status line and sends nothing (en, zh, zh-TW, ja, de).
- A row without Resume, Continue in or a terminal, and a folder without
its ⋯, keep that room with an inert, aria-hidden slot. Resume reserves
the wider of Resume and Copied; at <=600px the cost keeps a min width.
- docs/subsystems/gui-shell.md says so.
Run (on mote via mote-run, base f44fa2ef6; origin/main 93d5c76c0's 3
commits since touch none of these files):
- go test ./internal/sessions: ok. go test ./internal/gui: ok except
TestMainWindowCorners/macOS_26_SDK, an AppKit titlebar red on macOS 27
already filed as #3949.
- gofmt -l clean; go vet native, GOOS=linux -tags nogui, GOOS=windows ok.
- New sessions-cursor-align.test.cjs: 10/10 (chromium + webkit x en, zh,
zh-TW, ja, de; widths 1100/660/420, hover, Copied).
- Sessions GUI set (sessions-*, session-*, gateway-conversations,
gateway-mode-sessions, account-mask-sessions, header-session-hint,
routing-session*, routing-ctx-sessions, usage-session*, i18n-keys,
gui-de, gui-ja, gui-zh-tw): 728/728, and 728/728 again after the
rebase onto
|
||
|
|
af8f3a9399 |
sessions: a new install reads no agent's session history until the user allows it (RustCats on X)
RustCats on X: a fresh magpie showed every agent's session history on
the Sessions page before anyone agreed to it, and asked for a per-agent
choice instead.
- sessions.Reads(agent) (internal/sessions/access.go) is the one gate,
from settings.SessionReads {Asked, All, Agents}. Every lister asks it,
the aggregators (allFiles, callFilesWith, callSourcesWith,
traceLineFiles, wslFiles, DesktopDataDirs) filter by it again, and
readers of an already-listed session (TranscriptOf, ContentOf,
SearchSession, SubagentTranscript, CarryOver, ReadCallSource) return
ErrNotRead, so a cache from before a switch was turned off goes no
further. The Sessions list, stats, /api/sessions/overview, the call and
trace indexes, Usage's agent-file calls and the Codex/Pi title readers
all pass it.
- SettleReads decides once and saves: an install with sessions.json or
a calls-v* cache read sessions before and keeps all on; a fresh one
reads none, not asked. A saved value is never replaced; save, sync and
restore keep it (KeepOwn); only SetSessionReads writes it. An
unwritable settings.json reads nothing this run.
- GUI: GET/POST /api/sessions/reads. While not asked, the Sessions page
shows a consent card: each agent found (by a stat of its folder only)
with a switch, Allow selected and Allow all. Settings > Privacy >
Agents' session history has "Agents found later" and a row per agent.
Strings in en, zh, zh-TW, ja, de.
- CLI: magpie sessions read [on|off all|<agent>...]; magpie sessions
says on stderr when nothing is allowed yet; the TUI's empty Sessions
page says how.
Read either way, because none of it lists or shows a session: the
gateway's own usage ledger, its projections and the conversations it
recorded (magpie's own records, so usage and cost keep working); the
agents' config and sign-in files; Claude Code's and Codex's
history.jsonl last-used time and a session file's mtime for a quota's
first use; Codex's newest rollout's last line before magpie restarts
Codex (codexTurnOpen).
Tests: TestFreshInstallReadsNoAgentUntilAllowed,
TestSettleReadsKeepsWhatWasThere, TestSessionReadsRoutes,
TestSessionsRead, TestSessionsNotAskedSaysHow, sessions-reads.test.cjs
(26 cases: consent and Settings in 5 languages, Chromium and WebKit,
390 to 900 wide).
Run on mote:
- full Go suite (gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui,
GOOS=windows go vet, go build, go test -timeout 45m ./...) at this
change on
|
||
|
|
4c1fb7758b |
sessions: copies an older magpie left are swept when a live store is read in place (#1988)
|
||
|
|
1dc20e73fc |
sessions: a live Cursor's state.vscdb is read in place, not copied (#1988)
Beside a running Cursor, every listing, count, transcript and search read the editor's state.vscdb from a copy in the temp folder, made again each time Cursor had written since the last. The store is often several GB, and on Windows, where no clone makes a copy free, Echo-Huang0010 measured ~10.6 GB written every few minutes. While the store has a non-empty -wal and a -shm beside it, Cursor's own processes share it as readers through the -shm, and magpie now opens it the same way, mode=ro with a 3s busy timeout: no copy. Nothing magpie shows comes from the store's file times (each chat carries lastUpdatedAt), so a reader's mark in -shm changes nothing it lists. With no -shm beside a live -wal, or if that open fails, it falls back to the copy as before. CLI chat stores keep the copy path. OpenUntouched's open is factored out as openSQLite. Thanks to Echo-Huang0010 for the report and the measurements; their patch capped the copy at 64 MiB, which would leave a larger history unread, so this takes the in-place read instead. The Cursor tests set TMPDIR only, which Windows' os.TempDir doesn't read (TMP, TEMP), so TestCursorLeftCopiesSwept's folder landed in the real temp folder and the next test counted it. cursorTempDir sets all three. Run at this head: - mote: go test -count=3 -run Cursor ./internal/sessions ok; go test -timeout 45m ./internal/sessions ./internal/agent ok; go vet ./internal/sessions for darwin, linux, windows ok; gofmt clean. - xiaomi-gpu (win-run): go test -count=3 -run Cursor ./internal/sessions ok (red before cursorTempDir, from the stray folder). - Broken by hand: in-place reads off, TestCursorEditorReadInPlaceWhileLive fails "a live state.vscdb was copied 3 times, want 0". - Windows, two processes: a writer holding a WAL store (~40 MB) with busy_timeout(0) wrote 200 times while a magpie process listed 40 times and read transcripts. 0 failed writes, every list saw the latest title (40 of 40), 0 copies in the temp folder. Not tried: a real Cursor install. Neither test machine has one, so the writer was a stand-in process, not Cursor itself. |
||
|
|
11dcc743f4 |
sessions: a listed file is 96 bytes, what only some agents' files have kept behind one pointer
A Sessions poll copies every agent's list of ~20k files several times (listedRollouts, heldFiles' clone, callFilesWith, allFiles, byKey, statsRead). Each file was 232 bytes, most of it fields only OpenCode, ZCode, Hermes, Alma, agy, Cursor's editor or WSL files fill. Those move into fileMore behind file.more (nil when a file has none); reads go through m(), writes through w(), which copies first, so copies of a file never see each other's writes, as before. A/B with the real ~/.codex and ~/.claude data (ab5.sh, 8 polls 15s apart, alloc_space between heap-0 and heap-1), base |
||
|
|
9bfbd6e45e |
sessions: Sessions loads again with a large Cursor store, which every listing read whole from disk (#1988, kangxi94)
v0.1.1227 (
|
||
|
|
9935119f1d |
sessions: search finds Cursor and OpenCode sessions read from their stores, and a Cursor chat's system prompt isn't shown as said (#1743)
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> |
||
|
|
1cd8140047 |
sessions: read Cursor editor history and Cursor/OpenCode conversations (#1743)
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. |