Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/agent-finder-cli/tests/sessions-browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('SessionsBrowser', () => {
const { stdin } = render(<SessionsBrowser sessions={SESSIONS} loadTranscript={loadTranscript} nowMs={NOW} />);

await vi.waitFor(() => expect(loadTranscript).toHaveBeenCalledWith(SESSIONS[0].ref.sessionId));
stdin.write(''); // down arrow
stdin.write('\u001b[B'); // down arrow
await vi.waitFor(() => expect(loadTranscript).toHaveBeenCalledWith(SESSIONS[1].ref.sessionId));
});

Expand Down
4 changes: 2 additions & 2 deletions packages/agent-task-loop/src/commands/tui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { refineDescription } from '../services/refine-description-service';
import { App } from '../tui/components/app';
import { FsSessionProvider } from '../tui/data/fs-session-provider';

const ENTER_ALT_SCREEN = '[?1049h';
const LEAVE_ALT_SCREEN = '[?1049l';
const ENTER_ALT_SCREEN = '\u001b[?1049h';
const LEAVE_ALT_SCREEN = '\u001b[?1049l';

export const tuiCommand = defineCommand({
meta: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('SourceFilter', () => {
const onCancel = vi.fn();
const app = render(<SourceFilter options={options} selected={[]} onApply={onApply} onCancel={onCancel} />);
await tick();
app.stdin.write(''); // Esc
app.stdin.write('\u001b'); // Esc
await vi.waitFor(() => expect(onCancel).toHaveBeenCalled());
expect(onApply).not.toHaveBeenCalled();
app.unmount();
Expand Down
4 changes: 2 additions & 2 deletions packages/agent-task-loop/src/tui/components/tabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it, expect } from 'vite-plus/test';
import { render } from 'ink-testing-library';
import { Tabs } from './tabs';
import { TABS, type TabKey } from '../logic/status';
import { stripAnsi } from '../../../test/helpers';
import { ESC, stripAnsi } from '../../../test/helpers';

const counts: Record<TabKey, number> = {
active: 3,
Expand Down Expand Up @@ -40,7 +40,7 @@ describe('Tabs', () => {
// The active chip carries ANSI styling the plain text does not.
expect(raw).not.toEqual(plain);
// The active chip's text is wrapped in escape codes within the raw frame.
expect(raw).toMatch(/\[[0-9;]*m[^]*Needs Input\(1\)/);
expect(raw).toMatch(new RegExp(`${ESC}\\[[0-9;]*m[^${ESC}]*Needs Input\\(1\\)`));
});

it('renders zero counts without crashing', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('TaskForm', () => {
await tick();
app.stdin.write('\t'); // → source
await tick();
app.stdin.write(''); // right arrow → github
app.stdin.write('\u001b[C'); // right arrow → github
await tick();
app.stdin.write('\r'); // submit
await tick();
Expand All @@ -105,7 +105,7 @@ describe('TaskForm', () => {
const onCancel = vi.fn();
const app = render(<TaskForm onSubmit={vi.fn()} onCancel={onCancel} />);
await tick();
app.stdin.write(''); // Esc
app.stdin.write('\u001b'); // Esc
await vi.waitFor(() => expect(onCancel).toHaveBeenCalled());
app.unmount();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vite-plus/test';
import { render } from 'ink-testing-library';
import { WorkflowOverlay } from './workflow-overlay';
import { stripAnsi } from '../../../test/helpers';
import { ESC, stripAnsi } from '../../../test/helpers';

describe('WorkflowOverlay', () => {
it('renders nothing when not visible', () => {
Expand Down Expand Up @@ -33,6 +33,6 @@ describe('WorkflowOverlay', () => {
it('highlights the current status with inverse styling (raw frame)', () => {
const raw = render(<WorkflowOverlay visible currentStatus="待发布" />).lastFrame() ?? '';
// inverse SGR (7) wraps the active chip
expect(/\[[0-9;]*7[0-9;]*m/.test(raw)).toBe(true);
expect(new RegExp(`${ESC}\\[[0-9;]*7[0-9;]*m`).test(raw)).toBe(true);
});
});
8 changes: 8 additions & 0 deletions packages/agent-task-loop/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export function stripAnsi(input: string): string {
return input.replace(ANSI, '');
}

/**
* The ESC control character, built at runtime. ANSI-matching assertions compose
* their patterns from this string instead of regex literals: the linter rejects
* control characters in statically visible patterns, and string escapes such as
* `\u001b` inside a regex literal trip the same rule.
*/
export const ESC = String.fromCharCode(27);

/** Fixed clock for deterministic timeAgo / heartbeat assertions. */
export const FIXED_NOW = Date.parse('2026-06-07T12:00:00.000Z');
export const fixedNow = () => FIXED_NOW;
Expand Down
2,117 changes: 391 additions & 1,726 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ allowBuilds:
'@google/genai': false
protobufjs: false
catalog:
vite: npm:@voidzero-dev/vite-plus-core@1.3.0
vitest: 5.0.5
vite-plus: 1.3.0
vite: npm:@voidzero-dev/vite-plus-core@1.5.0
vitest: 5.1.0
vite-plus: 1.5.0
overrides:
vite@*: 'catalog:'
vitest@*: 'catalog:'
Expand Down
Loading