TypeScript
perf(mobile): worktree setup updates commit the thread screen once (#25910)
Julius Marminge0d88fcf3d541
diff --git a/apps/mobile/src/features/threads/use-worktree-setup.ts b/apps/mobile/src/features/threads/use-worktree-setup.tsindex cc1c1af091c..5972dc7b281 100644--- a/apps/mobile/src/features/threads/use-worktree-setup.ts+++ b/apps/mobile/src/features/threads/use-worktree-setup.ts@@ -1,6 +1,6 @@import type { EnvironmentId, ThreadId, WorktreeSetupSnapshot } from "@t3tools/contracts";import { resolveVisibleWorktreeSetup } from "@t3tools/client-runtime/worktree-setup";-import { useEffect, useState } from "react";+import { useState } from "react";import { useEnvironmentQuery } from "../../state/query";import { vcsEnvironment } from "../../state/vcs";import { resolveWorktreeSetupSnapshot } from "./worktree-setup-state";@@ -26,10 +26,10 @@ export function useWorktreeSetup(input: {: null,);const snapshot = resolveWorktreeSetupSnapshot(input.threadId, query.data, live);- useEffect(() => {- // oxlint-disable-next-line react/set-state-in-effect -- Holds the last setup snapshot while the live subscription changes over.- if (snapshot && snapshot !== live) setHeld({ key, snapshot });- }, [key, live, snapshot]);+ // Hold the newest snapshot so it survives the subscription closing once setup stops running.+ // Set during render so each emission commits once; the resolver returns `live` by identity+ // on the next pass, which ends the update.+ if (snapshot && snapshot !== live) setHeld({ key, snapshot });return {snapshot,visible: resolveVisibleWorktreeSetup({