Skip to content

fix(mobile): accept a fresh terminal snapshot after a stream ends - #27539

Merged
Jinwoo-H merged 4 commits into
mainfrom
fix/mobile-resubscribe-accepts-snapshot
Oct 11, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
fix/mobile-resubscribe-accepts-snapshot

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​202 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​191
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8 $\color{#cf222e}{\Huge{\mathbf{−}}}$​41 $\color{#cf222e}{\Huge{\mathbf{−}}}$​33

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

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 17467e2d-36f8-4ad0-9b1f-b6d74e874b9b

📥 Commits

Reviewing files that changed from the base of the PR and between cb6197f and 6e21eb2.


📒 Files selected for processing (5)
  • mobile/src/session/use-mobile-native-chat-terminal-stream.test.ts
  • mobile/src/session/use-mobile-native-chat-terminal-stream.ts
  • mobile/src/session/use-mobile-session-terminal-resubscribe-snapshot.test.tsx
  • mobile/src/session/use-mobile-session-terminal-stream-display.ts
  • mobile/src/test-support/rpc-recording/adapters/terminal-mount-adapters.ts

💤 Files with no reviewable changes (3)
  • mobile/src/session/use-mobile-session-terminal-stream-display.ts
  • mobile/src/session/use-mobile-native-chat-terminal-stream.ts
  • mobile/src/session/use-mobile-native-chat-terminal-stream.test.ts

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 | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check Warning 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 Warning 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 Passed The title clearly describes the primary fix: accepting a fresh terminal snapshot after a stream ends.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H merged commit 50b3d2e into main Oct 11, 2026
20 checks passed
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.

1 participant