Skip to content

Commit 0d88fcf

Browse files
perf(mobile): worktree setup updates commit the thread screen once (#25910)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2083a22 commit 0d88fcf

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎apps/mobile/src/features/threads/use-worktree-setup.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { EnvironmentId, ThreadId, WorktreeSetupSnapshot } from "@t3tools/contracts";
22
import { resolveVisibleWorktreeSetup } from "@t3tools/client-runtime/worktree-setup";
3-
import { useEffect, useState } from "react";
3+
import { useState } from "react";
44
import { useEnvironmentQuery } from "../../state/query";
55
import { vcsEnvironment } from "../../state/vcs";
66
import { resolveWorktreeSetupSnapshot } from "./worktree-setup-state";
@@ -26,10 +26,10 @@ export function useWorktreeSetup(input: {
2626
: null,
2727
);
2828
const snapshot = resolveWorktreeSetupSnapshot(input.threadId, query.data, live);
29-
useEffect(() => {
30-
// oxlint-disable-next-line react/set-state-in-effect -- Holds the last setup snapshot while the live subscription changes over.
31-
if (snapshot && snapshot !== live) setHeld({ key, snapshot });
32-
}, [key, live, snapshot]);
29+
// Hold the newest snapshot so it survives the subscription closing once setup stops running.
30+
// Set during render so each emission commits once; the resolver returns `live` by identity
31+
// on the next pass, which ends the update.
32+
if (snapshot && snapshot !== live) setHeld({ key, snapshot });
3333
return {
3434
snapshot,
3535
visible: resolveVisibleWorktreeSetup({

0 commit comments

Comments
 (0)