From 36005a7af62395b425b2800cb6883ec7dbb200e2 Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Wed, 29 Apr 2026 18:16:43 -0400 Subject: [PATCH] fix: resolve circular type inference in resubscribeWithoutFocus Use a ref to break the self-reference cycle that caused TS7022. Co-authored-by: Orca --- mobile/app/h/[hostId]/session/[worktreeId].tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mobile/app/h/[hostId]/session/[worktreeId].tsx b/mobile/app/h/[hostId]/session/[worktreeId].tsx index c7873390666..e1f09245d3d 100644 --- a/mobile/app/h/[hostId]/session/[worktreeId].tsx +++ b/mobile/app/h/[hostId]/session/[worktreeId].tsx @@ -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.