ac4af582301a4e8a29245dbba767eba31334ddf9
12
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7da5b34aa4 |
sessions: Cindy's Pi sessions are read from its pi-agent-home (ldl123292 on X)
Cindy starts Pi with --session-dir <userData>/pi-agent-home/sessions
(resolvePiAgentHome in Cindy's app.asar), so its Pi sessions never
reached ~/.pi/agent and magpie showed none of them. They are read now from
the Cindy and CindyGlobal builds' folders and listed as Cindy's: list,
transcript, calls on Usage, Dirs, delete, and the gateway's own record of
a Cindy session merged with the file's.
Run (mote): go test ./internal/sessions ./internal/agent ./internal/usage
ok. go test ./internal/gui: two reds, both the same on origin/main
|
||
|
|
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
|
||
|
|
9474eaf9cb |
sessions: Raft's Pi agents' sessions are listed as Raft's, with their prompts, calls and delete
Raft (slock's raft-computer) runs its agents on Pi and keeps each one's Pi SDK session files in that agent's folder: <slock>/agents/<id>/ .pi-sessions/<ts>_<id>.jsonl, or .builtin-sessions/ for its built-in runtime. <slock> is $SLOCK_HOME or ~/.slock (%USERPROFILE%\.slock on Windows, the distro's ~/.slock under WSL). Read from raft-computer 1.0.14's PiDriver (buildPiSessionDir), BuiltInDriver and resolveSlockHome, and a read-only listing of ~/.slock here. runtime-sessions/ holds handoff notes, no sessions, and is not read. - The Sessions page lists them as Raft's (agent "raft", in agent.Clients' others), titled and opened with their prompts as Pi's are. - Their calls count on the Usage page as Raft's; calls through magpie stay the gateway's, as Pi's do. - Raft's Pi uses the user's own ~/.pi/agent, so a request it sends through magpie reaches the gateway as Pi's under the same session id. sessions.GatewayKeys gives a Raft session both "raft|ID" and "pi|ID", so the gateway's copy is not listed twice nor counted twice (Merge, stats, NativeIDs, the GUI's Via). - Delete and restore work as Pi's: the one file goes to the trash, and a folder beside it is left (the agent's workspace is not the session's). A session written in the last minutes is refused as active. - No resume command, no carry and no trace export: Raft starts its own agents, and nothing outside it can resume one. - SLOCK_HOME is passed through agentenv like the other agents' homes. Run (at 958ad9f10 on |
||
|
|
f594b452e3 |
sessions: a Claude fork after a compaction is a branch under its session, read from the start
neo_o11 (Discord, after v0.1.1809): one conversation still showed as ~9
rows with the same title, and opening one showed "Session start" and a
single turn.
Cause, reproduced with real Claude Code 2.1.312 in a sandbox
CLAUDE_CONFIG_DIR: the reporter's session was compacted, then forked
several times (headless --fork-session per task, or /branch). Each fork
starts at the compact boundary and summary, and copies the session's
last reply under the same uuid. So every fork holds the original's
Leaf, and ccCopies hid the original as a fork's copy, though it alone
holds the conversation before the compaction. Each fork had a Leaf of
its own and stayed a row, with the copied title. Opening a fork read
its own file: the summary and one turn.
Fix:
- cc_copies.go: ccFamily returns copies and branches. A file is a
copy of another only when that one holds its Leaf and its Root too,
so a file with what came before the other's start is never hidden.
The members of a family left visible pick a head (holds the other's
Root, then named in the other's forkedFrom, then the earlier start,
then the lower key); the rest are branches of it.
- sessions.go, manage.go: a branch has role "branch" and
parent_session = its head, in List, Find/get and ListAgent.
- transcript.go: a branch's transcript is its head up to the fork
point (the last line of the head holding one of the branch's
uuids), then the branch's own lines. Search still reads its file.
- stats.go: a branch counts only its own lines, so tokens are not
counted twice.
- GUI sessions plugin: the fold under a session names branches apart
("2 branches · 1 subagent"), in en/zh/zh-TW/ja/de.
- Fixtures in testdata/claude-forks/tasks*.jsonl are trimmed from real
2.1.312 output: a session compacted once, two --fork-session task
forks and a /branch copy with forkedFrom.
- docs/subsystems/gateway-sessions.md: copies and branches.
Run:
- go test ./internal/sessions -run 'TestClaude|TestQoder|TestMergeExternal'
on mote, at
|
||
|
|
b30734f964 |
sessions: Antigravity CLI (agy) conversations are listed, with title, folder, tokens and resume (RickyWei, #1718)
agy's conversations were on no Sessions page: internal/sessions had no lister for them, only the calls reader of #2097. Now each ~/.gemini/antigravity-cli/brain/<id>/.system_generated/logs/transcript_full.jsonl is a session (agy.go). Its steps give the start and last times, the first prompt (taken out of agy's <USER_REQUEST> wrapper), prompts, replies, tool calls, and tokens under the model "agy", since no step names one. A step written again replaces its tokens, read on or read whole. The title and folder come from the conversation's conversation_summaries.db row: title, and workspace_uris through agyFolder, which turns file:///C:/... and file:///c%3A/... into C:\... and a host into \\host\share on Windows. agy writes the title after the transcript, so the row is the file's rev. The database is read again only when it or its -wal changed, and a failed read keeps the rows read before. A row with conversations/<id>.db and no transcript (#1718's case) is listed from the row alone, with no tokens and no conversation to open. Resume is "agy --conversation <id>". When agy is set to use magpie, it is the agent's launch command (gateway variables and --model, the PowerShell form on Windows) with --conversation after it, through sessions.AgyStart, which package agent sets. The transcript (user text, thinking, text, tool calls, tool results) can be opened and searched. Format read from real files: agy 1.3.5 and 1.4.7 in a sandbox HOME against a fake Gemini endpoint, with plain replies, a read_file tool call with thinking, invalid tool calls, and a conversation picked up again with --conversation from another folder. testdata/agy-sessions is three of those conversations with paths rewritten to /work. Resume tried for real in the sandbox: `agy --conversation <id> -p again` from another folder appended steps 2-4 to the same transcript and kept the row's folder. Interactive `agy --conversation <id>` (in tmux) showed the earlier turns. Run at this tree, rebased on origin/main: - gofmt -l internal clean - go vet: darwin; GOOS=linux -tags nogui; GOOS=windows - GOOS=windows go build ./...; GOOS=linux go build -tags nogui ./... - go test -count=1 ./internal/sessions ./internal/gui ./internal/agent: ok before the row-only change. After it, sessions ok, and gui had one red, TestMainWindowCorners killed at its 40s deadline at load ~300 (#1936). It passes alone (47s). - GUI (playwright 1.62.0, chromium and webkit, en and zh): i18n-keys, gui-de, gui-ja, gui-zh-tw, session-terminal, sessions-bar-names, sessions-manage, sessions-talk, sessions-toolbar: 49 of 49. No GUI asset changed. Tab names come from the agent registry. Fails without the change (broken by hand, each one red): - agyFiles out of allFiles: TestAgySessions, TestAgyTitleLater, TestAgyTranscript - agy out of refresh's DBRevision check: TestAgyTitleLater - no dropUse of a rewritten step: TestAgyGrows (4510 input, want 3010) - AgyStart ignored: TestAgySessions (wired resume) - drive letter not handled: TestAgyFolder - agy out of HasTranscript: TestAgySessions, TestAgyTranscript - the row-only listing off: TestAgyRowOnly; readable() off: TestAgyRowOnly Not tried: agy on Windows. The Windows box (10.0.0.132) didn't answer ssh, so the Windows paths are covered by unit tests only (agyFolder, the Set-Location resume form). A wired resume through magpie's real gateway was not tried. Not done: subagents (parent_conversation_id), which I never saw agy write. The model name, which is only in conversations/<id>.db's protobuf (#3147). Deleting an agy session from magpie. agy in WSL: #3595. Side effect: agy's self-updater ran in the sandbox and replaced the live ~/.local/bin/agy, 1.3.5 -> 1.4.7. |
||
|
|
5618ade1e6 |
sessions: each reply in a session's conversation names the model its own line in the agent's file names (#2253, cnlove7777777-art)
Usage -> Sessions' conversation said only "Assistant", so which model wrote a reply couldn't be told, though the agents' files name it. - sessions.Part gains model (omitempty), set on assistant parts only, from the part's own line: Claude Code's message.model (the model that answered; none for its "<synthetic>" lines), Codex's turn_context.model (the model the turn was sent to; a /model between turns moves the next turn), Pi's and omp's message.model, OpenCode's modelID and OpenCode 2's model.id. - Kimi Code (its model is only on a usage.record written after the reply), Cursor (no model in the transcript) and gateway transcripts (GatewayTurn.Model is the model asked for, not the one that answered) name none. Nothing is guessed from nearby requests. - The reader (sessions client.js) says it muted after the role, once a reply at its first part and again only where it changes inside the reply; the tooltip is "Model: <id>" (an existing string, translated). ledSaid takes the model as an argument, so the Usage page's per-request content, whose row already names its model, is unchanged. No layout change: one muted span in the existing header line, ellipsized at narrow widths. Run: - TestTranscriptModelClaude/Codex/Pi/OpenCodeV2/OpenCodeFiles: all five fail on the old content.go/transcript*.go, pass on the new. - sessions-talk-model.test.cjs: 20/20 (chromium+webkit, en/zh/zh-TW/ ja/de, 1100 and 420). Fails on the old app.js/client.js, and with the once-a-reply rule removed by hand (label every assistant part). - sessions-talk, sessions-export, gateway-conversations, usage-ledger-content, usage-ledger-detail GUI tests: all pass. - go test -tags nogui ./internal/sessions ./internal/gui ./internal/gateway: ok. gofmt -l clean; go vet -tags nogui darwin/ linux/windows clean. Full suite for this push (#2257, #2251, #2254, #2253) at 53677ed8d: go test -tags nogui -p 4 -timeout 40m ./... with pipefail: every package ok. (An earlier full run caught davsync's TestSyncLibrary and profile's TestOldProfiles/TestProfileCarriesLibrary relying on a gone CLI after #2254; their sandboxes now have the CLIs, in #2254's commit.) Not tried: the real app against a live Codex rollout (fixtures follow the lines the readers already parse for usage). |
||
|
|
2d8f2a86a5 |
sessions: Kimi Code sessions open as a transcript (#2056)
infinitr0us: a Kimi Code session on the Sessions page had no transcript
to open. HasTranscript now lists kimi, and kimiTranscript reads the
session's main wire.jsonl:
- protocol 1.4/1.5: turn.prompt and turn.steer (a prompt not from the
user, a skill's activation or a background task's news, is folded as
context), and the loop events content.part (text, think), tool.call
and tool.result, a result named for its call. These are there for
every session, finished or running; agent.message.appended (1.5, only
at a turn's end) and the timed context.append_message records say the
same again and are passed over.
- kimi-cli imports (1.0, and the head of a ses_* session Kimi Code
reopened): the untimed context.append_message records, with an
assistant's toolCalls in both shapes (name/arguments and OpenAI's
function.{name,arguments}).
Search and markdown export read the same parts.
Run:
- TestKimiCodeTranscript on the #1607 reporter's wire files in testdata
(1.4, a cancelled 1.4, an early 1.5 started by a skill, a failed 1.5,
a kimi-cli import), and TestKimiCodeTranscriptOrder on a synthetic
file in the same record shapes, exact part order plus SearchSession.
- Broken by hand: kimi out of HasTranscript fails both tests; reading
the timed context.append_message records fails both (user/text 9,
not 3).
- A nogui build's `magpie web` under a sandbox HOME, KIMI_CODE_HOME on
the reporter's whole zip (8 sessions, the July subagent session and
a reopened ses_* among them): all 8 listed with a transcript;
/api/sessions/transcript gave 105, 13 and 205 parts for June, the
reopened ses_* and July; the markdown export worked.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows;
go test -tags nogui ./internal/sessions/ ./internal/gui/.
Not tried: a live Kimi Code session on this machine (none here; the kimi
installed is kimi-cli 1.52.0), the GUI's look of the transcript, WSL.
A subagent's own wire file isn't shown; the main agent's is.
|
||
|
|
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. |
||
|
|
260ded9af4 |
sessions: the Sessions page's search finds a session by what was said in it, and a gateway session is titled by what it was first asked (YOU on Discord)
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. |
||
|
|
c9b8263378 |
sessions, gateway: Sessions lists gateway sessions, and can keep their text on this computer when turned on (#1355, mu-zi-lee)
What changed: the Sessions page lists sessions seen only through the gateway (from the usage ledger, read-only, a native session of the same id wins), and shows in gateway mode. A Sessions switch, off by default and confirmed before it turns on, records each gateway exchange's text under the config dir (scrubbed, at most 7 days and 256 MiB, cleaned hourly). Settings sync and restore can't turn it on; POST /api/sessions/recording turns it on or off and can clear what was kept. Why: users of magpie as a gateway (gateway mode, LAN clients) had no way to see their conversations; the owner chose this design on the PR. Squashed from PR head 6a343ba1 onto origin/main. Conflicts: gui-shell.md (kept main's placeMenu text, took the PR's Sessions in gateway mode) and settings_keep_test.go (main's fields plus GatewayConversations). Run: go build ./..., go vet on gateway, gui, sessions, settings, usage; go test -race -timeout 900s on those five packages: all ok. |
||
|
|
67329b8d9c |
sessions, gui: a session's conversation is exported as Markdown from its details on the Sessions page (#1276)
Beside Show conversation, Export Markdown saves the whole conversation (Claude Code, Qoder, Codex, Pi, oh-my-pi: every agent whose transcript the page can show) as a Markdown file: a heading with the session's agent, id, folder, times, models and file, then each turn under User / Assistant, a tool's call by its name and arguments, its result, thinking and the agent's own notes folded in <details>. Parts are kept whole (the page's 8000-char cut doesn't apply), fences grow past any backticks in the text. In the app it goes to Downloads (never over an earlier export) and the status says where; in magpie web the browser downloads /api/sessions/markdown. The session is found as listed, never a path from the page; the file is only read. Verified: TestMarkdownClaude, TestMarkdownCodexAndPi, TestMarkdownUnsupported (sessions) and TestSessionExportMarkdown (gui) under a temp HOME. Without the routes TestSessionExportMarkdown fails "export: 404 404 page not found"; with the page's per-part cut TestMarkdownClaude fails on the long part. sessions-export.test.cjs (Chromium+WebKit, en/zh, app and web, 560px) fails on origin/main's sessions.js waiting for .sess-export; passes with it, as do sessions-talk, gui-ja, gui-de, gui-zh-tw and i18n-keys. Exported real Claude Code, Codex and Pi session copies: fences balanced, turns in order. go vet (darwin, GOOS=linux, GOOS=windows) -tags nogui on both packages. |
||
|
|
b96d55fc99 |
sessions: a session's conversation can be read in magpie, and a Pi session carried on in oh-my-pi (sxwedo, #845) — the Sessions page could resume a session only in the agent that wrote it, and showed nothing of what was said. A session's details now have Show conversation: magpie reads the agent's own session file (Claude Code, Qoder, Qoder CN, Codex, Pi, oh-my-pi; found by agent and id, never a path from the page; read only, no copy kept, 400 KB at most with "There was more than is shown here") and lists the user's words, the model's, each tool call by name and its result, thinking and summaries folded. For Pi and oh-my-pi it follows the branch the session is on (parentId from the last entry), not the turns left on an abandoned one. A Pi session also has Continue in, the app's menu (no <select>): oh-my-pi's omp --fork <file> in the session's folder, copied or opened in the session terminal (the server makes the command from the session it finds; the page sends agent, id, in), and the details say it. omp --fork loads the Pi file, migrates it and writes a new oh-my-pi session, leaving Pi's untouched; with the owner's Pi sessions copied into a sandbox HOME, oh-my-pi's own SessionManager forked them whole (4→5 and 46→47 messages, its system line added; text, thinking and tool calls kept) and the source files' sha256 didn't change. Only that pair is offered: Pi can't read an oh-my-pi file (it wants the session header first, oh-my-pi writes a title line first), oh-my-pi takes Claude Code and Codex only from its own import picker, not a given session, and the other agents' formats differ, so carrying them on would mean converting them, which isn't done. zh, ja, de strings. TestTranscriptClaude, TestTranscriptCodex, TestTranscriptPiBranch, TestTranscriptOmp, TestTranscriptUnsupported, TestTranscriptCut, TestCarryPiToOmp; sessions-talk.test.cjs (WebKit, en and zh) fails on the old code. sessions-*, click-scroll, gui-ja and gui-de pass on WebKit; session-terminal and session-identity fail the same on origin/main. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass.
|