3 Commits
Author SHA1 Message Date
木子不是木子狸 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.
2026-10-10 04:24:18 +08:00
yetone 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.
2026-10-08 17:38:03 +08:00
yetone 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. 2026-10-05 10:08:35 +08:00