Skip to content

fix(app): archive orphaned sessions via server fallback - #1747

Open
saeedmusa wants to merge 1 commit into
slopus:mainfrom
saeedmusa:fix/1739-orphan-session-archive
Open

fix(app): archive orphaned sessions via server fallback#1747
saeedmusa wants to merge 1 commit into
slopus:mainfrom
saeedmusa:fix/1739-orphan-session-archive

Conversation

@saeedmusa

@saeedmusa saeedmusa commented Sep 3, 2026

Copy link
Copy Markdown

Summary

When a session's CLI process dies (crash or kill), the server keeps the session marked active, and Archive in the home session list dead-ends: it only sends the killSession RPC, 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 via POST /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 unhandled RPC method not available rejection 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 stayed active: true on 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 → false around the action.

Demo video and Proof: https://github.com/user-attachments/assets/836a99a8-fa6d-4ae5-9542-fc99aa1aadc5

Tests

  • New 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 typecheck passes; full happy-app vitest suite passes (one pre-existing flaky encryption/blob.test.ts perf test unrelated to this change).

Fixes #1739

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.
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.

[Bug]: session stop / archive deadlock — orphaned remote session stuck active forever

1 participant