From 2e050316956c170ca8c998c2c890f4aecb1fcba3 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 31 May 2026 09:12:47 -0700 Subject: [PATCH] perf: move mobile source control cleanup to root ref --- .../h/[hostId]/source-control/[worktreeId].tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mobile/app/h/[hostId]/source-control/[worktreeId].tsx b/mobile/app/h/[hostId]/source-control/[worktreeId].tsx index 01f362890bb..cce6bf253c2 100644 --- a/mobile/app/h/[hostId]/source-control/[worktreeId].tsx +++ b/mobile/app/h/[hostId]/source-control/[worktreeId].tsx @@ -288,12 +288,16 @@ export default function MobileSourceControlScreen() { currentStatusIdentityRef.current = statusIdentityKey currentBranchCompareIdentityRef.current = statusIdentityKey - useEffect(() => { - return () => { - mountedRef.current = false - loadGenerationRef.current += 1 - branchCompareGenerationRef.current += 1 + const setMobileSourceControlRootRef = useCallback((node: View | null): void => { + if (node !== null) { + mountedRef.current = true + return } + // Why: source-control RPC loads can outlive the route; invalidate pending + // writes when the screen detaches without a passive cleanup-only Effect. + mountedRef.current = false + loadGenerationRef.current += 1 + branchCompareGenerationRef.current += 1 }, []) useEffect(() => { @@ -1336,7 +1340,7 @@ export default function MobileSourceControlScreen() { }, [branchDiffPreview]) return ( - +