fix: resolve circular type inference in resubscribeWithoutFocus

Use a ref to break the self-reference cycle that caused TS7022.

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo-H
2026-04-30 18:03:55 -04:00
co-authored by Orca
parent d4e450719d
commit 36005a7af6
@@ -204,6 +204,8 @@ export default function SessionScreen() {
// We skip terminal.focus to avoid a race where the desktop renderer
// auto-fits the pane back to desktop dimensions before the override
// takes effect.
const resubscribeWithoutFocusRef = useRef<(handle: string) => void>(() => {})
const resubscribeWithoutFocus = useCallback(
(handle: string) => {
unsubscribeTerminal(handle)
@@ -248,7 +250,7 @@ export default function SessionScreen() {
return next
})
manuallyRestoredRef.current.add(handle)
resubscribeWithoutFocus(handle)
resubscribeWithoutFocusRef.current(handle)
setTimeout(() => getTerminalRef(handle)?.resetZoom(), 500)
}
}
@@ -262,9 +264,11 @@ export default function SessionScreen() {
subscribingHandlesRef.current.delete(handle)
})()
},
[client, getTerminalRef, unsubscribeTerminal, resubscribeWithoutFocus, updateFittedHandles]
[client, getTerminalRef, unsubscribeTerminal, updateFittedHandles]
)
resubscribeWithoutFocusRef.current = resubscribeWithoutFocus
// Why: extracted so both manual "Fit to Phone" and auto-fit-on-subscribe
// can share the same measure → resize → resubscribe logic. Takes explicit
// handle/rpcClient to avoid stale closure issues from subscribe callbacks.