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 <orca-bug-scan-bot@stably.ai>
This commit is contained in:
buf0-bot[bot] 2026-05-13 11:12:30 -07:00 committed by GitHub
parent 75a28bb960
commit cd4aa06f85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -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<typeof setTimeout>[] = []
function addTimer(fn: () => void, ms: number) {