Files
aryx/tests/main/runTurnPending.test.ts
T
David KayaandCopilot 231be36e6c feat: add plan mode frontend support with mode toggle and plan review UI
- Add InteractionMode type and ExitPlanModeRequestedEvent to sidecar contracts
- Add PendingPlanReviewRecord domain type and interactionMode to SessionRecord
- Wire onExitPlanMode callback through SidecarClient and RunTurnPendingCommand
- Pass session interaction mode to RunTurnCommand for sidecar consumption
- Handle exit-plan-mode-requested events in AryxAppService
- Add setSessionInteractionMode and dismissSessionPlanReview IPC methods
- Create PlanReviewBanner component with summary, markdown content, and actions
- Add plan mode toggle pill in ChatPane composer area
- Wire implement action as follow-up message (graceful degradation)
- Clear pending plan review on new turn, turn completion, and cancellation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-26 23:39:48 +01:00

55 lines
1.7 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import {
markRunTurnPendingErrored,
shouldHandleRunTurnEvent,
type RunTurnPendingCommand,
} from '@main/sidecar/runTurnPending';
describe('run turn pending helpers', () => {
test('marks a run-turn pending command as errored and rejects it once', () => {
const rejected: Error[] = [];
const pending: RunTurnPendingCommand = {
kind: 'run-turn',
resolve: () => undefined,
reject: (error) => rejected.push(error),
onDelta: () => undefined,
onActivity: () => undefined,
onApproval: () => undefined,
onUserInput: () => undefined,
onExitPlanMode: () => undefined,
errored: false,
};
const first = markRunTurnPendingErrored(pending, 'boom');
const second = markRunTurnPendingErrored(pending, new Error('later'));
expect(first).toBeInstanceOf(Error);
expect(first.message).toBe('boom');
expect(second.message).toBe('later');
expect(pending.errored).toBe(true);
expect(rejected).toHaveLength(1);
expect(rejected[0].message).toBe('boom');
});
test('stops handling turn events after the pending command has errored', () => {
const pending: RunTurnPendingCommand = {
kind: 'run-turn',
resolve: () => undefined,
reject: () => undefined,
onDelta: () => undefined,
onActivity: () => undefined,
onApproval: () => undefined,
onUserInput: () => undefined,
onExitPlanMode: () => undefined,
errored: false,
};
expect(shouldHandleRunTurnEvent(pending)).toBe(true);
markRunTurnPendingErrored(pending, new Error('boom'));
expect(shouldHandleRunTurnEvent(pending)).toBe(false);
});
});