fix: unblock initial new session prompts

This commit is contained in:
Bohdan Triapitsyn
2026-06-03 14:51:17 +03:00
parent 2163c2e3f7
commit a649ba8df4
3 changed files with 66 additions and 13 deletions
@@ -0,0 +1,53 @@
import { beforeEach, describe, expect, mock, test } from 'bun:test';
const bootstrapStatusCalls: string[] = [];
let bootstrapStatusResult = { status: 'ready' as const, error: null, updatedAt: 1 };
mock.module('@/contexts/runtimeAPIRegistry', () => ({
getRegisteredRuntimeAPIs: () => ({
git: {
worktree: {
bootstrapStatus: (directory: string) => {
bootstrapStatusCalls.push(directory);
return Promise.resolve(bootstrapStatusResult);
},
},
},
}),
}));
mock.module('@/lib/gitApiHttp', () => ({
getGitWorktreeBootstrapStatus: (directory: string) => {
bootstrapStatusCalls.push(directory);
return Promise.resolve(bootstrapStatusResult);
},
}));
const {
clearWorktreeBootstrapState,
markWorktreeBootstrapPending,
waitForWorktreeBootstrap,
} = await import('./worktreeBootstrap');
describe('worktreeBootstrap.waitForWorktreeBootstrap', () => {
beforeEach(() => {
bootstrapStatusCalls.length = 0;
bootstrapStatusResult = { status: 'ready', error: null, updatedAt: 1 };
clearWorktreeBootstrapState('/repo');
clearWorktreeBootstrapState('/repo-wt');
});
test('does not poll directories that were not marked pending', async () => {
await waitForWorktreeBootstrap('/repo');
expect(bootstrapStatusCalls).toEqual([]);
});
test('polls when the directory was explicitly marked pending', async () => {
markWorktreeBootstrapPending('/repo-wt');
await waitForWorktreeBootstrap('/repo-wt');
expect(bootstrapStatusCalls).toEqual(['/repo-wt']);
});
});
@@ -93,6 +93,10 @@ export const waitForWorktreeBootstrap = async (directory: string, timeoutMs = DE
}
const current = state.get(key);
if (!current) {
return;
}
if (current?.status === 'ready') {
return;
}