agents: a launched chat is snapshotted at birth, so a backend crash cannot lose a chat the user has not typed into yet - #145
Open
kai-openswarm wants to merge 1 commit into
Conversation
…annot lose a chat the user has not typed into yet Until its first turn ended (the turn snapshot), the chat was closed, or the backend shut down gracefully (persist_all_sessions), a launched session lived only in memory. After a crash or SIGKILL the respawned backend had no file to promote into the dashboard's list; with the renderer's own memory gone too (app restart, window reload) the board came back without the card, and the debounced layout save persisted the loss. A normal quit kept the same chat. Reproduced on 1.7.7 with the packaged app: open a chat, kill the backend, let it respawn, reload -> cards []; with this change the card is back. Launch now writes the same snapshot the turn end writes, so a respawn finds the session (reconcile_on_startup marks it stopped, the card returns as the parked chat it was). One atomic JSON write per launch. Backend tests cover the file at birth and the respawned list; an e2e spec kills the packaged backend for real. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A chat you open and have not typed into yet lived only in memory until its first turn ended (the turn snapshot), the chat was closed, or the backend shut down gracefully (
persist_all_sessions). After a crash or SIGKILL the respawned backend had no file to promote into the dashboard's list; with the renderer's own memory gone too (app restart, window reload) the board came back without the card, and the debounced layout save persisted the loss. A normal quit kept the same chat.AgentLaunch.launch_agentnow writes the same snapshot the turn end writes, right after the session is created. A respawn finds it (reconcile_on_startupmarks it stopped, the card returns as the parked chat it was) — exactly what a graceful shutdown already gave it. One atomic JSON write per launch.Reproduced / verified
dashboardLayout.cardsis[]. With this change the card is back. Same app, same steps, onlyAgentLaunch.pyswapped.backend/tests/test_launch_snapshots_session_at_birth.py(2 tests): the file exists at birth with the right dashboard id; a session map emptied as a respawned backend's would be still lists the parked session for its dashboard. Both fail without the change.e2e/tests/parked-chat-survives-backend-crash.spec.ts: kills the packaged backend for real, waits for the app's own respawn, reloads, expects the card. No provider key needed.