fix(ui): hide transient dirty state while a worktree bootstraps

A freshly created worktree transiently looks dirty until its setup
commands and initial git reset finish. The work status panel showed
those files as changes on the branch and the draft's worktree dropdown
flashed its dirty warning, and both then froze on that state because
nothing refetched after bootstrap. Make the bootstrap state (the
existing authority on unfinished creation) subscribable, suppress the
dirty probe and the changed-files row while it is pending, and force one
status fetch when it settles so the lifted gate shows the reset tree.
This commit is contained in:
Iuliia Ivashko
2026-09-04 02:35:56 +03:00
parent 0a47b306d6
commit acdf0c2e1f
6 changed files with 120 additions and 4 deletions
@@ -0,0 +1,18 @@
import React from 'react';
import { getWorktreeBootstrapState, subscribeWorktreeBootstrapState } from '@/lib/worktrees/worktreeBootstrap';
/**
* Whether `directory` is a worktree whose creation has not finished yet: the
* directory exists, but setup commands and the initial git reset are still
* running. Until that completes the working tree transiently looks dirty, so
* surfaces that report uncommitted changes consult this and show nothing
* instead of presenting bootstrap noise as real changes on the branch.
*/
export const useWorktreeBootstrapPending = (directory: string | null): boolean => {
const getSnapshot = React.useCallback(
() => (directory ? getWorktreeBootstrapState(directory)?.status === 'pending' : false),
[directory],
);
return React.useSyncExternalStore(subscribeWorktreeBootstrapState, getSnapshot, getSnapshot);
};