From cd4aa06f8515b595902cd494b4ac666534914a9a Mon Sep 17 00:00:00 2001 From: "buf0-bot[bot]" <252831055+buf0-bot[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 11:12:30 -0700 Subject: [PATCH] fix: pr-bug-scan validated finding from #1700 (#1728) Clear initializedHandlesRef on reconnect so the auto-resubscribed scrollback frame re-inits xterm instead of being dropped by the has(handle) guard. Co-authored-by: orca-bug-scan-bot --- mobile/app/h/[hostId]/session/[worktreeId].tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mobile/app/h/[hostId]/session/[worktreeId].tsx b/mobile/app/h/[hostId]/session/[worktreeId].tsx index eeccbaf57..925e95abc 100644 --- a/mobile/app/h/[hostId]/session/[worktreeId].tsx +++ b/mobile/app/h/[hostId]/session/[worktreeId].tsx @@ -1428,6 +1428,13 @@ export default function SessionScreen() { if (initializedHandlesRef.current.size === 0) { setTerminalsLoaded(false) } + // Why: on reconnect the RPC client auto-resends terminal.subscribe and + // the server sends a fresh scrollback frame. The subscribe handler drops + // scrollback when initializedHandlesRef already contains the handle, so + // we'd keep stale pre-disconnect content (and lose any output emitted + // during the disconnect). Clear the flag so the fresh snapshot calls + // ref.init(...) and replaces the buffer. + initializedHandlesRef.current.clear() let disposed = false const timers: ReturnType[] = [] function addTimer(fn: () => void, ms: number) {