fix(app): archive orphaned sessions via server fallback - #1747
Open
saeedmusa wants to merge 1 commit into
Open
Conversation
A session whose CLI process died (crash or kill) kept active:true on the server, and Archive from the home session list dead-ended: it only sent the killSession RPC, which cannot reach a dead process, then surfaced an error - leaving an orphaned ghost session that stop and archive could not clear (slopus#1739). Extract the kill-then-server-archive fallback used by the session info and quick action surfaces into a shared op (sessionKillOrArchive) and use it in the home list rows (FlatSessionRow, CompactSessionRow). Also make the session view's Stop button tolerate a missing RPC target instead of crashing with an unhandled rejection.
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.
Summary
When a session's CLI process dies (crash or
kill), the server keeps the session markedactive, and Archive in the home session list dead-ends: it only sends thekillSessionRPC, which cannot reach a dead process — the caller waits out the RPC failure and then gets an error instead of an archive. Four other app surfaces (session info page, quick actions, side chats, draft-cleanup) already fall back from kill to the server-side force archive; the two home-list row components (FlatSessionRow,CompactSessionRow) were missing that fallback, so an orphaned session could not be cleared from the primary screen. This PR extracts the fallback into a shared op,sessionKillOrArchive(kill the CLI process; on failure, force-archive viaPOST /v1/sessions/:id/archive; throw only if both fail), uses it in both row components, and stops the session view's Stop button from dying with an unhandledRPC method not availablerejection when its RPC target is gone.Before
With the CLI process dead, Archive from the home list spun for ~15s and then errored (
RPC method not available). The session stayedactive: trueon the server: stop had no process to signal, archive refused to run, so the ghost session sat in the list with no way to clear it — the stop/archive deadlock from #1739.After
The same action on an orphaned session: the kill RPC fails as before, the fallback then force-archives via the server, and the session leaves the active list. Server state verified flipping
active: true → falsearound the action.Demo video and Proof: https://github.com/user-attachments/assets/836a99a8-fa6d-4ae5-9542-fc99aa1aadc5
Tests
ops.killOrArchive.test.ts: kill succeeds → no archive call; kill unreachable → server archive runs; both fail → throws with the server message.pnpm --filter happy-app typecheckpasses; full happy-app vitest suite passes (one pre-existing flakyencryption/blob.test.tsperf test unrelated to this change).Fixes #1739