perf: move mobile session cache cleanup to root ref

This commit is contained in:
Neil
2026-05-31 09:35:57 -07:00
committed by GitHub
parent 51c1ca5023
commit 71d6a30b09
+5 -14
View File
@@ -2146,17 +2146,6 @@ export default function SessionScreen() {
}
}, [client, connState])
// Why: only clear terminal cache on actual unmount. Running it whenever
// `client` changes — including the initial null → real-client transition
// from useHostClient's async open path — would unsubscribe terminals and
// wipe xterm state mid-subscribe on a normal session-screen mount.
useEffect(() => {
return () => {
clearTerminalCache()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
// Why: deviceToken is read from host record so feature code can pass
// `client.id` on subscribe/send for driver-state-machine identity.
// The shared client itself stays alive across screens; we just need
@@ -2971,15 +2960,17 @@ export default function SessionScreen() {
if (node !== null) {
return
}
// Why: route-level timers can outlive quick session changes; clear them
// from the root lifecycle without passive cleanup-only Effects.
// Why: terminal subscriptions and route-level timers must clear only on
// real route detach; client churn during mount can otherwise wipe xterm
// state mid-subscribe.
toastSeqRef.current += 1
clearTerminalCache()
clearToastHideTimer()
clearDelayedActionTimers()
clearTerminalLiveInputFocusTimer(liveInputFocusTimerRef)
stopAccessoryRepeat()
},
[clearDelayedActionTimers, clearToastHideTimer, stopAccessoryRepeat]
[clearDelayedActionTimers, clearTerminalCache, clearToastHideTimer, stopAccessoryRepeat]
)
const handleSelectionMode = useCallback((handle: string, active: boolean) => {