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:
@@ -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);
|
||||
};
|
||||
Reference in New Issue
Block a user