Skip to content

Commit d379c0f

Browse files
committed
fix: initialize git status atom with isPending: true to avoid false idle state on first render
The gitStatusStateAtom family was initialized with EMPTY_GIT_STATUS_STATE (isPending: false), but useEffect (which triggers watchGitStatus and markGitStatusPending) only fires after the first render. This caused a single-frame flash where consumers saw { data: null, isPending: false }, incorrectly signaling that loading was complete. Introduce PENDING_GIT_STATUS_STATE with isPending: true and use it as the initial value for per-cwd atoms so the first render correctly indicates a pending state.
1 parent fc50e65 commit d379c0f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

apps/web/src/lib/gitStatusState.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,16 @@ const GIT_STATUS_REFRESH_DEBOUNCE_MS = 1_000;
4444

4545
let sharedGitStatusClient: GitStatusClient | null = null;
4646

47+
const PENDING_GIT_STATUS_STATE = Object.freeze<GitStatusState>({
48+
data: null,
49+
error: null,
50+
cause: null,
51+
isPending: true,
52+
});
53+
4754
const gitStatusStateAtom = Atom.family((cwd: string) => {
4855
knownGitStatusCwds.add(cwd);
49-
return Atom.make(EMPTY_GIT_STATUS_STATE).pipe(
56+
return Atom.make(PENDING_GIT_STATUS_STATE).pipe(
5057
Atom.keepAlive,
5158
Atom.withLabel(`git-status:${cwd}`),
5259
);

0 commit comments

Comments
 (0)