Skip to content

fix(app): treat a daemon's stop-session error as a failed stop - #1853

Open
chphch wants to merge 1 commit into
slopus:mainfrom
chphch:fix/stop-session-error
Open

chphch wants to merge 1 commit into
slopus:mainfrom
chphch:fix/stop-session-error

Conversation

@chphch

@chphch chphch commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

machineStopSession reports success when the daemon answers "Session not found or failed to stop": the daemon's RPC layer returns a handler that throws as an ordinary reply with an error field (RpcHandlerManager.handleRequest), not as a failed call. machineResumeSession already checks for that field; this adds the same check, so every caller's fallback — the session's own killSession, then the server archive — actually runs when the daemon does not know the session. That is the case for every session after a daemon restart, which each CLI upgrade does, and until now the fallback was silently skipped and the session left running.

Proof

  • sources/sync/ops.stopSession.test.ts (new): the daemon-error case fails on main and passes with this change; ops.resume.test.ts still passes, and so does the whole app suite on a branch with this and feat(app): add Restart Session to the session menu #1854 applied (1922 tests; sessionPresentation.test.ts fails to load on main too, __DEV__ is not defined).
  • Running app, local stack with a real daemon and Claude session: restart the daemon only (the session process survives, the new daemon does not track it), then stop and resume the session from the app with the Restart Session action from feat(app): add Restart Session to the session menu #1854. Before: the stop "succeeded", nothing stopped the old process, and the resume was refused for 16 s — Session … may still have a running process from a previous daemon. After: the daemon's not found reads as a failure, the session's own kill runs (Kill session request received in its log), and the session is resumed 0.5 s after the press with the conversation intact.

Before: resume refused after 16 s. After: resumed in 0.5 s

The daemon's RPC layer answers a handler that throws with an ordinary
reply carrying `error` (RpcHandlerManager.handleRequest), not with a
failed call. machineResumeSession already checks for it;
machineStopSession did not, so a daemon that does not know the session
("Session not found or failed to stop") came back as success.

Its callers fall back to the session's own kill RPC, and then to the
server archive, when the daemon cannot stop a session. Those fallbacks
never ran for a session the daemon was not tracking, so the session
was left running while the app went on as if it had stopped.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant