fix: isolate concurrent OpenCode chat runs
This commit is contained in:
@@ -33,11 +33,26 @@ describe('opencode session run machine', () => {
|
||||
});
|
||||
expect(isSessionRunActive(posting)).toBe(true);
|
||||
|
||||
const running = transitionSessionRunState(posting, {
|
||||
const accepted = transitionSessionRunState(posting, {
|
||||
type: 'post_accepted',
|
||||
runId: 1,
|
||||
});
|
||||
|
||||
expect(accepted.phase).toBe('posting');
|
||||
expect(isSessionRunActive(accepted)).toBe(true);
|
||||
|
||||
const earlyIdle = transitionSessionRunState(accepted, {
|
||||
type: 'remote_idle',
|
||||
runId: 1,
|
||||
});
|
||||
|
||||
expect(earlyIdle).toEqual(accepted);
|
||||
|
||||
const running = transitionSessionRunState(earlyIdle, {
|
||||
type: 'remote_busy',
|
||||
runId: 1,
|
||||
});
|
||||
|
||||
expect(running.phase).toBe('running');
|
||||
expect(isSessionRunActive(running)).toBe(true);
|
||||
});
|
||||
@@ -47,7 +62,11 @@ describe('opencode session run machine', () => {
|
||||
createIdleSessionRunState<TestPrompt>(),
|
||||
{ type: 'send_started', runId: 2, promptId: 'msg_active' },
|
||||
);
|
||||
const withQueue = transitionSessionRunState(running, {
|
||||
const acknowledged = transitionSessionRunState(running, {
|
||||
type: 'remote_busy',
|
||||
runId: 2,
|
||||
});
|
||||
const withQueue = transitionSessionRunState(acknowledged, {
|
||||
type: 'queue_prompt',
|
||||
prompt: { id: 'queued_1', text: 'second' },
|
||||
});
|
||||
@@ -173,7 +192,11 @@ describe('opencode session run machine', () => {
|
||||
createIdleSessionRunState<TestPrompt>(),
|
||||
{ type: 'send_started', runId: 9, promptId: 'compact-ses_1' },
|
||||
);
|
||||
const completed = transitionSessionRunState(posting, {
|
||||
const running = transitionSessionRunState(posting, {
|
||||
type: 'remote_busy',
|
||||
runId: 9,
|
||||
});
|
||||
const completed = transitionSessionRunState(running, {
|
||||
type: 'remote_idle',
|
||||
runId: 9,
|
||||
});
|
||||
@@ -195,7 +218,7 @@ describe('opencode session run machine', () => {
|
||||
{ type: 'remote_failed' as const, runId: 10, error: 'POST failed after early idle' },
|
||||
{
|
||||
phase: 'idle',
|
||||
queue: [{ id: 'queued_1', text: 'second' }],
|
||||
queue: [],
|
||||
terminalReason: 'failed',
|
||||
error: 'POST failed after early idle',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user