You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): accept a fresh terminal snapshot after a stream ends - #27539
A phone terminal running Claude Code could show a garbled screen: stray letters in the left columns, words merged, lines missing. Seen after opening a workspace from a push notification.
When a terminal stream ended or errored, the phone tore the subscription down but kept the terminal marked as "snapshot already drawn". The next subscribe to the same terminal got a fresh snapshot from the desktop and dropped it, then painted live output on top of the old screen. Claude Code redraws by changing only the cells that differ, so on a stale screen those partial redraws leave old characters behind.
One way to reach it: two phone pages open for the same workspace (a push notification can stack one on top of another) subscribe to the same terminal and end each other's streams.
Fix
The "snapshot drawn" mark now belongs to one subscription: unsubscribeTerminal clears it, beside the layout-seq reset it already does. Every resubscribe accepts its first snapshot. The callers that cleared the mark themselves no longer do, and the native-chat stream no longer needs the mark at all. Only the foreground-recovery loop keeps its own clear, because it also covers mounted terminals it never unsubscribes.
Rides the page update; no app release and no desktop change.
Tests
New use-mobile-session-terminal-resubscribe-snapshot.test.tsx drives the real subscription hooks into a headless xterm with a Claude-Code-style cell-diff redraw, for a stream end and a stream error. On main both cases fail: the phone shows Fiaished in 3s where the desktop shows Finished in 3s. With the fix the screens match. Two test fakes of unsubscribeTerminal now clear the mark like the real one.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
📝 Walkthrough
Walkthrough
Unsubscription now clears initialized-handle state in unsubscribeTerminal. Session cleanup and tab-management paths no longer clear that state directly. Viewport refit interfaces no longer accept initializedHandlesRef, and their fallback resubscribe path no longer deletes the handle from that set. Tests update unsubscribe mocks and add coverage for terminal output during teardown and resubscription.
Priority: ➖ Normal
Merge Risk:⚪ Minimal · up to 6e21e
The changed terminal lifecycle paths clear initialization state before resubscribing, including viewport refits and native-chat recovery. No actionable merge-blocking issue is established; the PR appears ready for normal checks.
Pre-merge checks | 3 | 2
❌ Failed checks (2 warnings)
Check name
Status
Explanation
Resolution
Description check
The description explains the problem, fix, and tests, but it omits most required template sections, including ELI5, What Changed, Why, Linked Issue with an actual issue link, Visual Proof or N/A, Test…
Complete the required template sections. Add an ELI5 summary, explicit What Changed and Why sections, an actual linked issue, Visual Proof or N/A with a reason, Testing details and checkbox status, AI Disclosure if applicable, Review, Notes…
Docstring Coverage
Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 6 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name
Status
Explanation
Title check
The title clearly describes the primary fix: accepting a fresh terminal snapshot after a stream ends.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description explains the problem, fix, and tests, but it omits most required template sections, including ELI5, What Changed, Why, Linked Issue with an actual issue link, Visual Proof or N/A, Testing checkboxes, Notes, and the Checklist.
Resolution
Complete the required template sections. Add an ELI5 summary, explicit What Changed and Why sections, an actual linked issue, Visual Proof or N/A with a reason, Testing details and checkbox status, AI Disclosure if applicable, Review, Notes, and the Checklist.
Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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
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
A phone terminal running Claude Code could show a garbled screen: stray letters in the left columns, words merged, lines missing. Seen after opening a workspace from a push notification.
When a terminal stream ended or errored, the phone tore the subscription down but kept the terminal marked as "snapshot already drawn". The next subscribe to the same terminal got a fresh snapshot from the desktop and dropped it, then painted live output on top of the old screen. Claude Code redraws by changing only the cells that differ, so on a stale screen those partial redraws leave old characters behind.
One way to reach it: two phone pages open for the same workspace (a push notification can stack one on top of another) subscribe to the same terminal and end each other's streams.
Fix
The "snapshot drawn" mark now belongs to one subscription:
unsubscribeTerminalclears it, beside the layout-seq reset it already does. Every resubscribe accepts its first snapshot. The callers that cleared the mark themselves no longer do, and the native-chat stream no longer needs the mark at all. Only the foreground-recovery loop keeps its own clear, because it also covers mounted terminals it never unsubscribes.Rides the page update; no app release and no desktop change.
Tests
New
use-mobile-session-terminal-resubscribe-snapshot.test.tsxdrives the real subscription hooks into a headless xterm with a Claude-Code-style cell-diff redraw, for a streamendand a streamerror. On main both cases fail: the phone showsFiaished in 3swhere the desktop showsFinished in 3s. With the fix the screens match. Two test fakes ofunsubscribeTerminalnow clear the mark like the real one.