Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/mobile/src/features/threads/use-worktree-setup.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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({
Expand Down
Loading