Skip to content

fix(cli): re-attach session handlers registered while offline after reconnecting - #1858

Open
rophy wants to merge 1 commit into
slopus:mainfrom
rophy:fix/offline-reconnect-handlers
Open

rophy wants to merge 1 commit into
slopus:mainfrom
rophy:fix/offline-reconnect-handlers

Conversation

@rophy

@rophy rophy commented Oct 3, 2026

Copy link
Copy Markdown

Summary. When a session starts while the server is unreachable, its message and RPC handlers (abort, kill) are registered on the offline stub. After reconnecting, the real session replaces the stub without them, so messages from the app, Stop and kill are ignored. This PR has the offline stub record those registrations, and setupOfflineReconnection attaches them to the real session before swapping it in. Fixes #1857.

Changes

  • utils/offlineSessionStub.ts: the stub records the latest onUserMessage handler and every registerHandler call; adds transferOfflineRegistrations(stub, session).
  • utils/setupOfflineReconnection.ts: calls it on reconnect, before onSessionSwap.
  • utils/setupOfflineReconnection.test.ts: 4 new tests. All fail on main and pass with this change.

Proof

main:       × 4 failed   (handlers called 0 times on the real session)
this PR:    ✓ 4 passed

No new failures across the wire, server, app, CLI and agent test suites.

Related: #1293.

…econnecting

Backends register their user-message and RPC handlers once, on the offline
stub when the server is unreachable at startup. The real session that replaces
it never got them, so app messages, abort and kill were ignored.

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.

Session started while server is unreachable doesn't receive messages from the app after reconnecting

1 participant