Files
magpie/docs
yetone 531b277836 claude: an idle run's session survives a restart, so the next turn resumes it (recih on X, #6292)
As the gateway ends (abortAll), keepShelf shelves every run idle between
turns and writes the shelf to claude-shelf.json (temp and rename): per
entry the conversation fingerprint (turnKey: account, model, settings,
messages), Claude Code's session id, its project folders (config folder
and work folder), the account, tools and cache marks. The next gateway's
unshelve reads the file once when its shelf has nothing for the turn
(loadShelf, which takes the file away) and starts Claude Code with
--resume, told the turn alone, instead of the whole transcript (~100k
cache-write tokens on a long conversation). A file that does not parse
whole, another version, a missing session file, a folder that is not a
Claude project folder, or an entry older than idleLongest is unknown and
falls back to today's replay. Rewritten-turn matching (looseTurn) is not
kept; runs in a turn or parked on tool results at the stop are not
either; a crash writes nothing.

Run (mote): gateway "Claude|Subscription" tests green (90s), gofmt, go vet
darwin/linux/windows (nogui) and gui. TestClaudeIdleRunSurvivesARestart
(two Servers on one HOME, fake claude) is red with keepShelf off (session
removed as the gateway ended) and green with it; the unreadable-file
cases fall back to replay. TestClaudeSessionFilesAreRemoved now expects
the sessions to stay until the shelf discards them.
Not tried: a real Claude Code (a sandbox HOME has no sign-in), the
full ./... suite before the tag, Windows.
2026-11-12 16:25:28 +08:00
..