fix(dashboard): recover mobile chat reconnect - #61314
Closed
shannonsands wants to merge 2 commits into
Closed
Conversation
shannonsands
marked this pull request as ready for review
July 9, 2026 05:59
Two review fixes on the mobile input normalization path: - updatePtyInputLine appended the printable payload of escape sequences (the '[D' of a left-arrow) to the tracked line, and after any cursor movement the flat tracker no longer matched the visual line — the DELETE-repeat replacement could then be computed against a stale snapshot. Any chunk containing ESC now resets the tracker, disarming replacement normalization until a cleanly-tracked line starts. - Move the SGR mouse-report filter ahead of the blocked-input check so scrolling a disconnected terminal doesn't print the reconnect notice.
Collaborator
|
Merged via #61374 — your two commits were cherry-picked with authorship preserved (rebase merge on |
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.
What does this PR do?
Fixes Android/mobile dashboard Chat failures tracked in NS-591.
Root cause: the embedded dashboard chat relies on an xterm.js PTY WebSocket and browser timers. On Android, tab/background resume can leave the page showing a stale
code 1006reconnect state while the retry timer is throttled or the socket is gone. The terminal also stayed focusable, so users could type into what looked like a live chat even though input was being dropped. A follow-up report showed Google Keyboard suggestions could emit replacement-like IME input that xterm forwarded as normal append text, duplicating the current prompt line.This PR adds explicit PTY connection state, active page-resume recovery, a main-chat reconnect affordance, and mobile input normalization for replacement/suggestion events. It keeps the existing
/api/ptyprotocol and server-side attach/resume behavior intact.Related Issue
Fixes https://linear.app/nousresearch/issue/NS-591/mobile-chat-can-get-stuck-reconnecting-after-android-tab-switch
Related PR checked for overlap: #60829.
Type of Change
Changes Made
web/src/pages/ChatPage.tsx: track PTY state explicitly, recover onvisibilitychange/pageshow/focus/online, and show a main terminalReconnect nowaction for stuck reconnects.web/src/pages/ChatPage.tsx: block disconnected terminal input with a one-time hint instead of silently dropping typed text.web/src/pages/ChatPage.tsx: add mobile IME/replacement handling for xterm input so Gboard suggestions replace the current prompt line instead of appending the full line again.web/src/components/ChatSidebar.tsx: relabel the sidebar reconnect button asreconnect tools feedto make clear it only reconnects the sidecar/events feed, not the main PTY.web/src/lib/pty-reconnect.tsandweb/src/lib/pty-mobile-input.ts: add tested pure helpers for reconnect decisions and mobile input normalization.How to Test
npm --workspace web test -- src/lib/pty-mobile-input.test.ts src/lib/pty-reconnect.test.ts src/lib/api.test.tsReconnect now, and verify Gboard suggestions do not duplicate the prompt line.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Validation run locally: