Repository navigation
fix(remote): stream a terminal again after its PTY respawns - #312
Merged
Merged
Conversation
Switching a task to the built-in chat and back to the terminal starts a new PTY under the same agent ID. The old PTY's subscribers died with it, and its exit cleared the phone's subscription on the server, but the phone never unsubscribed: the task stayed listed under the same ID, as the chat. So it never subscribed again, and the task's terminal stayed black on the phone while every other task worked. Remember which agents each client asked to stream, and when a PTY spawns under one of those IDs, send that client the new terminal's snapshot and output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012boc2XLLaQiSeNwAqk8YYs
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Problem
On the phone, one task's terminal showed only a black area while every other task worked. That task had been switched to the built-in chat (UI mode) and back on the desktop.
Switching back starts a new PTY under the same agent ID (
restartAgent→spawnAgent). The old PTY's subscribers die with it, and itsexitevent clears the phone's entry inclientSubs. The phone never unsubscribed, because while the task was in chat mode it stayed listed under that same ID. So it never subscribed again, and on spawn the server only republished the agent list.The earlier Android-side fix (#311) didn't help because nothing reached the server.
Fix
electron/remote/server.tsclientWants). A subscribe adds to it and an unsubscribe removes it. UnlikeclientSubs, this outlives the PTY.spawn, every client still wanting that agent ID drops any stale subscriber and is streamed again from the new PTY's snapshot.streamAgent(ws, agentId)so thesubscribemessage and the spawn handler share it. Its behaviour is unchanged.This covers both the Android app and the phone web UI.
Tests
server-ws.test.ts, new tests:npm run checkpasses.npm run test:unit -- electron/remote electron/ipc/pty: 18 files, 484 tests pass.🤖 Generated with Claude Code
https://claude.ai/code/session_012boc2XLLaQiSeNwAqk8YYs
Generated by Claude Code