fix: wait for worktree bootstrap before prompt dispatch; resolve session directory for send/fork (#2708)

This commit is contained in:
Bruno Fantauzzi
2026-08-06 23:47:30 +03:00
committed by GitHub
parent 27c46aa0b9
commit e8caed45c9
4 changed files with 170 additions and 3 deletions
@@ -132,6 +132,43 @@ describe('OpenChamber control service', () => {
expect(sessionService[method]).toHaveBeenCalledWith('ses_1', { directory: '/repo', prompt: 'Continue' });
});
it('resolves the target session directory from the global session list when send omits it', async () => {
const { service, sessionService, client } = createService({
createClient: () => ({
...client,
experimental: {
session: {
list: vi.fn(async () => ({
data: [
{ id: 'ses_other', directory: '/repo/worktrees/other' },
{ id: 'ses_target', directory: '/repo/worktrees/target' },
],
})),
},
},
}),
});
sessionService.send.mockResolvedValue({ sessionId: 'ses_target', directory: '/repo/worktrees/target', promptDispatched: true });
await service.execute('session.send', { sessionId: 'ses_target', prompt: 'Continue' }, '/repo');
expect(sessionService.send).toHaveBeenCalledWith('ses_target', { directory: '/repo/worktrees/target', prompt: 'Continue' });
});
it('falls back to the context directory when the session is not in the global list', async () => {
const { service, sessionService, client } = createService({
createClient: () => ({
...client,
experimental: { session: { list: vi.fn(async () => ({ data: [] })) } },
}),
});
sessionService.send.mockResolvedValue({ sessionId: 'ses_unknown', directory: '/repo', promptDispatched: true });
await service.execute('session.send', { sessionId: 'ses_unknown', prompt: 'Continue' }, '/repo');
expect(sessionService.send).toHaveBeenCalledWith('ses_unknown', { directory: '/repo', prompt: 'Continue' });
});
it('waits past initial idle until a completed assistant result appears', async () => {
let timestamp = 1000;
const { service, client, sessionService } = createService({