Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
32f2a6e
fix(cli): draw OpenTUI tool confirmations inline as ink does
chiga0 Sep 11, 2026
85ec425
fix(cli): let a plain-text tool update replace OpenTUI's structured p…
chiga0 Sep 11, 2026
cc230a0
fix(cli): port ink's question dialog to OpenTUI in full
chiga0 Sep 11, 2026
074229c
fix(cli): keep a keystroke burst intact in OpenTUI's auth inputs
chiga0 Sep 11, 2026
ce46b45
fix(cli): draw ink's inline tool arguments row in OpenTUI
chiga0 Sep 12, 2026
19e2c25
docs: correct the row-budget claim the viewport fix overturned
chiga0 Sep 14, 2026
fc28b2d
docs: retire the two card gaps this change closed
chiga0 Sep 14, 2026
4ef811e
fix(cli): keep shell output within ink's history retention
chiga0 Sep 14, 2026
a39f6a2
fix(cli): keep OpenTUI's conversation inside the terminal
chiga0 Sep 14, 2026
c097497
docs: record the shell-output compaction this branch already ships
chiga0 Sep 14, 2026
b642795
Merge remote-tracking branch 'origin/main' into fix/opentui-parity-fo…
chiga0 Sep 14, 2026
7bee45a
docs: attribute the startup update-check notice to the runtime
chiga0 Sep 14, 2026
277f06d
fix(cli): freeze the waiting row's spinner while a confirmation is open
chiga0 Sep 14, 2026
8184e33
fix(cli): cancel a pending tab swap when a second answer lands inside…
chiga0 Sep 14, 2026
e11b9c4
fix(cli): drop the footer while a gated server holds the dialog slot
chiga0 Sep 14, 2026
f47fd98
fix(cli): hold ink's pending glyph on a call queued behind another ap…
chiga0 Sep 14, 2026
dfa63a5
Merge remote-tracking branch 'origin/main' into fix/opentui-parity-fo…
chiga0 Sep 14, 2026
772a23f
docs: record the inline-confirmation row reserves as named debt
chiga0 Sep 14, 2026
0cd2ce2
fix(cli): list mid-turn queued prompts above the composer
chiga0 Sep 14, 2026
f85567f
docs: correct the mutation counts recorded for the queued prompt rows
chiga0 Sep 14, 2026
85c100a
docs: state the queued row hint's cut-off and its assertion layers ex…
chiga0 Sep 14, 2026
2deca65
fix(cli): record the model dialog's outcome like ink does
chiga0 Sep 14, 2026
87ccc13
fix(cli): let OpenTUI dialog fields move the caret like ink's
chiga0 Sep 14, 2026
a842a44
docs: correct the cursor-cell frames recorded for the dialog caret
chiga0 Sep 14, 2026
aff5481
fix(cli): point the awaiting arrow at the call the queue can answer
chiga0 Sep 15, 2026
843d481
fix(cli): keep a keystroke burst intact across the dialog fields and …
chiga0 Sep 15, 2026
a2e4b8e
docs: record the keystroke-burst decisions and correct what the sweep…
chiga0 Sep 15, 2026
2e94387
fix(cli): read the loading-phrase setting for the waiting row
chiga0 Sep 15, 2026
eea432e
fix(cli): sanitize a queued prompt before the waiting row shows it
chiga0 Sep 15, 2026
7430c4f
refactor(cli): drop the @-mention card's unreachable arguments row
chiga0 Sep 15, 2026
a0fb2de
test(cli): stop handing React a null key in the dialog harnesses
chiga0 Sep 15, 2026
f1ec59c
docs(cli): correct what two source comments claim
chiga0 Sep 15, 2026
b702297
docs: record the pointer divergence and the pins review measured as l…
chiga0 Sep 15, 2026
77d3b0c
Merge remote-tracking branch 'origin/main' into fix/opentui-parity-fo…
chiga0 Sep 15, 2026
80c5614
fix(cli): keep a click on the transcript out of the composer's focus
chiga0 Sep 15, 2026
2ccebd8
fix(cli): stop the bare End key at its own line in dialog fields
chiga0 Sep 15, 2026
f87161c
fix(cli): fit the question dialog's chip row to the room it has
chiga0 Sep 15, 2026
9ee896b
fix(cli): erase a word for the byte a legacy terminal sends for it
chiga0 Sep 15, 2026
e2b325c
docs: correct what a resumed session brings back for a slash command
chiga0 Sep 15, 2026
76c07ac
fix(cli): keep a pasted newline inside the row the caret sits on
chiga0 Sep 15, 2026
28a457a
Merge remote-tracking branch 'origin/main' into fix/opentui-parity-fo…
chiga0 Sep 15, 2026
e2219b0
Merge remote-tracking branch 'origin/main' into fix/opentui-parity-fo…
chiga0 Sep 16, 2026
5a94b7b
fix(cli): hold a settled field closed and follow the tail its owner a…
chiga0 Sep 16, 2026
da4255e
fix(cli): mirror the question dialog's answers and lock a settled row
chiga0 Sep 16, 2026
e5f471b
fix(cli): pause the loading row's timer while a call is parked
chiga0 Sep 16, 2026
affcf80
docs(design): record the answer lock and the parked timer, correct th…
chiga0 Sep 16, 2026
32433ec
docs(design): correct the ctrl+C actor set and the unported key families
chiga0 Sep 16, 2026
912c9d2
test(cli): pin the wiring and placement the review measured as free
chiga0 Sep 16, 2026
2ccf2d1
test(cli): witness the ctrl+E routing the review measured as free
chiga0 Sep 16, 2026
5508926
fix(cli): bound the ask-user answer row and re-arm a wizard field aft…
chiga0 Sep 16, 2026
f337335
fix(cli): settle the answer row on the verdict that records it
chiga0 Sep 16, 2026
0d0abf2
refactor(cli): collapse the answer lock to the armed timer alone
chiga0 Sep 16, 2026
ae91c5f
docs: record the machine leg of the round-three fixes
chiga0 Sep 16, 2026
29d1d5d
Merge remote-tracking branch 'origin/main' into fix/opentui-parity-fo…
chiga0 Sep 16, 2026
f4a8f7d
docs: record the matrix re-run after merging main
chiga0 Sep 16, 2026
fef97a3
fix(cli): scope the answer row's re-arm, lock, width and caret cell
chiga0 Sep 17, 2026
f69b0be
docs: attribute the answer lock to the branches Decision 37 put it on
chiga0 Sep 17, 2026
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
803 changes: 728 additions & 75 deletions docs/design/2026-09-10-opentui-parity-defect-sweep.md

Large diffs are not rendered by default.

561 changes: 507 additions & 54 deletions docs/design/2026-09-10-opentui-parity-defect-sweep.zh-CN.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/cli/src/ui/components/LoadingIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { theme } from '../semantic-colors.js';
import { useStreamingContext } from '../contexts/StreamingContext.js';
import { StreamingState } from '../types.js';
import { RespondingSpinner } from './RespondingSpinner.js';
import { WAITING_SPINNER_FRAME } from '../constants.js';
import { formatDuration, formatTokenCount } from '../utils/formatters.js';
import { useTerminalSize } from '../hooks/useTerminalSize.js';
import { useAnimationFrame } from '../hooks/useAnimationFrame.js';
Expand Down Expand Up @@ -129,7 +130,7 @@ export const LoadingIndicator: React.FC<LoadingIndicatorProps> = ({
<RespondingSpinner
nonRespondingDisplay={
streamingState === StreamingState.WaitingForConfirmation
? '⠏'
? WAITING_SPINNER_FRAME
: ''
}
/>
Expand Down
47 changes: 31 additions & 16 deletions packages/cli/src/ui/components/messages/ToolMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,35 @@ export const TOOL_ARGS_INLINE_MAX_LINES = 2;

/**
* One-line JSON for the `ui.showToolCallArgs` row, or undefined when there is
* nothing worth adding.
* nothing worth adding. Serializes `args`, then defers to
* {@link formatInlineToolArgsJson} for the row itself.
*/
export function formatInlineToolArgs(
args: Record<string, unknown> | undefined,
description: string,
uncapped: boolean,
rowWidth?: number,
): string | undefined {
if (!args || Object.keys(args).length === 0) {
return undefined;
}

let json: string;
try {
json = JSON.stringify(args);
} catch {
// Circular or otherwise unserializable args — the header line is all we
// can honestly show.
return undefined;
}

return formatInlineToolArgsJson(json, description, uncapped, rowWidth);
}

/**
* The `ui.showToolCallArgs` row over an already-serialized `json`, so a renderer
* that carries the call's arguments as text (OpenTUI's `tool-args` event) draws
* the same row as this one rather than keeping a second copy of the policy.
*
* Skipped when `description` already IS the args JSON: MCP invocations return
* `safeJsonStringify(params)` from `getDescription()`, so rendering both would
Expand All @@ -1179,25 +1207,12 @@ export const TOOL_ARGS_INLINE_MAX_LINES = 2;
* component). When given, the row is bounded to `TOOL_ARGS_INLINE_MAX_LINES`
* wrapped rows rather than by character count alone — see that constant.
*/
export function formatInlineToolArgs(
args: Record<string, unknown> | undefined,
export function formatInlineToolArgsJson(
json: string,
description: string,
uncapped: boolean,
rowWidth?: number,
): string | undefined {
if (!args || Object.keys(args).length === 0) {
return undefined;
}

let json: string;
try {
json = JSON.stringify(args);
} catch {
// Circular or otherwise unserializable args — the header line is all we
// can honestly show.
return undefined;
}

const trimmedDescription = description.trim();
if (trimmedDescription.startsWith('{')) {
try {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/ui/components/shared/text-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function __resetWordSegmenter(): void {
* Returns an array of { start, end } where end is exclusive.
* @param codePoints - Optional pre-computed code points array to avoid redundant toCodePoints calls.
*/
function getWordBoundaries(
export function getWordBoundaries(
line: string,
codePoints?: string[],
): Array<{ start: number; end: number }> {
Expand Down Expand Up @@ -299,7 +299,7 @@ function binarySearchCpIndex(cpToStrIdx: number[], target: number): number {
* - Cursor inside a word → jump to that word's start
* - Cursor exactly at a word's start → jump to previous word's start
*/
function findPrevWordStart(
export function findPrevWordStart(
boundaries: Array<{ start: number; end: number }>,
col: number,
): number | null {
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/ui/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,10 @@ export const SPINNER_FRAMES = [
];

export const SPINNER_INTERVAL_MS = 80;

/**
* The frame drawn while a call is parked on a confirmation: ink's
* `LoadingIndicator` passes it as `nonRespondingDisplay`, so both renderers stop
* animating and show this one instead. Shared so the value cannot drift.
*/
export const WAITING_SPINNER_FRAME = '⠏';
171 changes: 168 additions & 3 deletions packages/cli/src/ui/opentui/dialogs-auth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ const mocks = vi.hoisted(() => {
const config = key === undefined ? props : { ...props, key };
const children = (config?.children ?? null) as React.ReactNode;
if (type === 'box' || type === 'text') {
// `bg` is the one style prop carried through: the dialog gives a
// background colour to exactly one cell, the software cursor.
const bg = (config as { bg?: string }).bg;
return React.createElement(
type === 'box' ? 'div' : 'span',
key === undefined ? null : { key },
{
key: key ?? null,
...(bg === undefined ? null : { 'data-bg': bg }),
},
children,
);
}
Expand Down Expand Up @@ -131,13 +137,26 @@ function lastKeyboardHandler(): (key: unknown) => void {
return handler;
}

async function press(name: string): Promise<void> {
async function press(
name: string,
overrides: Record<string, unknown> = {},
): Promise<void> {
const handler = lastKeyboardHandler();
await act(async () => {
handler(baseKeyEvent({ name, sequence: name }));
handler(baseKeyEvent({ name, sequence: name, ...overrides }));
});
}

/**
* The cell the software cursor is drawn on, or null with no focused field. The
* jsdom harness keeps the earlier renders of one row mounted beside the live one
* (the native renderer does not), so the newest cell is the last.
*/
function cursorCell(): HTMLElement | null {
const cells = document.querySelectorAll<HTMLElement>('[data-bg]');
return cells[cells.length - 1] ?? null;
}

async function typeText(text: string): Promise<void> {
// One act per character: the flow state lives in React state, so each
// keystroke must flush a render before the next handler closure is fresh.
Expand All @@ -149,6 +168,16 @@ async function typeText(text: string): Promise<void> {
}
}

/** Every character in one act, as a burst out of a single pty read arrives. */
async function typeBatched(text: string): Promise<void> {
const handler = lastKeyboardHandler();
await act(async () => {
for (const char of text) {
handler(baseKeyEvent({ name: char, sequence: char }));
}
});
}

async function pressEsc(): Promise<boolean> {
const handler = mocks.state.inputHandlers.at(-1);
if (!handler) throw new Error('no raw input handler registered');
Expand Down Expand Up @@ -445,6 +474,17 @@ describe('bracketed-paste into dialog inputs (#57)', () => {
await press('return'); // baseUrl → apiKey
}

it('keeps every character of a burst that shares one batch', async () => {
await runToApiKeyStep();
await typeBatched('sk-burst-key');
expect(
screen.getByText((_, element) => element?.textContent === 'sk-burst-key'),
).toBeTruthy();
// the burst is what the wizard carries forward, not its last character
await press('return'); // apiKey → models
expect(screen.getByText(/Enter model IDs directly/)).toBeTruthy();
});

it('inserts a paste into the API-key input and prevents default', async () => {
await runToApiKeyStep();
const event = await pasteText('sk-pasted-key');
Expand Down Expand Up @@ -498,3 +538,128 @@ describe('bracketed-paste into dialog inputs (#57)', () => {
expect(screen.getByText(/Step 6\/6 · Review/)).toBeTruthy();
});
});

describe('caret editing in dialog text fields (#107)', () => {
beforeEach(() => {
mocks.state.inputHandlers.length = 0;
mocks.state.keyboardHandlers.length = 0;
mocks.state.pasteHandlers.length = 0;
core.applyProviderInstallPlan.mockReset().mockResolvedValue(undefined);
core.logAuth.mockReset();
});

/** Walk to the base-URL step, whose field starts empty. */
async function runToBaseUrlStep(): Promise<void> {
renderDialog();
await press('down');
await press('down');
await press('return'); // main: CUSTOM_PROVIDER → protocol
await press('return'); // protocol: OpenAI-compatible → baseUrl input
}

/** Walk to the advanced-config step with the context-window row focused. */
async function runToContextWindowRow(): Promise<void> {
await runToBaseUrlStep();
await typeText('https://api.example.com/v1');
await press('return'); // baseUrl → apiKey
await typeText('sk-test');
await press('return'); // apiKey → models
await typeText('test-model');
await press('return'); // models → advancedConfig
await press('down'); // thinking → modality
await press('down'); // modality → context window (index 2 while it's closed)
}

/**
* The focused field's rendered text and the cell the cursor sits on, read off
* the cursor cell's neighbours so a row that labels its own field — the
* context-window row — contributes only the value. Valid while the field holds
* a value: an empty field puts the cell on its placeholder's first character,
* which is the row's first text element.
*/
function focusedField(): { text: string; cell: string } {
const cell = cursorCell();
if (!cell) throw new Error('no field renders a cursor cell');
const at = cell.textContent ?? '';
return {
text:
(cell.previousElementSibling?.textContent ?? '') +
at +
(cell.nextElementSibling?.textContent ?? ''),
cell: at,
};
}

it('inserts at the position the arrows left the caret', async () => {
await runToBaseUrlStep();
await typeText('abcdef');
await press('left');
await press('left');
await typeText('X');
expect(focusedField()).toEqual({ text: 'abcdXef', cell: 'e' });
});

it('keeps the caret at either end for ctrl+A and ctrl+E', async () => {
await runToBaseUrlStep();
await typeText('ab');
await press('a', { ctrl: true, sequence: '\x01' });
expect(focusedField()).toEqual({ text: 'ab', cell: 'a' });
await press('e', { ctrl: true, sequence: '\x05' });
// past the last code point ink draws a blank cell, which the text keeps
expect(focusedField()).toEqual({ text: 'ab ', cell: ' ' });
await typeText('c');
expect(focusedField()).toEqual({ text: 'abc ', cell: ' ' });
});

it('erases backward with backspace and forward with delete', async () => {
await runToBaseUrlStep();
await typeText('abcd');
await press('a', { ctrl: true, sequence: '\x01' });
await press('backspace');
// nothing left of the caret, so the value stands
expect(focusedField()).toEqual({ text: 'abcd', cell: 'a' });
await press('delete');
expect(focusedField()).toEqual({ text: 'bcd', cell: 'b' });
});

it('erases the word left of the caret with ctrl+W', async () => {
await runToBaseUrlStep();
await typeText('https://openai');
await press('w', { ctrl: true, sequence: '\x17' });
expect(focusedField()).toEqual({ text: 'https:// ', cell: ' ' });
// the edited value, not the typed one, is what the step submits
await press('return');
expect(screen.getByText(/Step 3\/6 · API Key/)).toBeTruthy();
});

it('sends End past the line break a paste leaves behind', async () => {
await runToBaseUrlStep();
await pasteText('https://one.test\nhttps://two.test');
await press('a', { ctrl: true, sequence: '\x01' });
expect(focusedField().cell).toBe('h');
await press('e', { ctrl: true, sequence: '\x05' });
Comment thread
chiga0 marked this conversation as resolved.
Resolved
await typeText('s');
// ink's End is the end of the value, not of the caret's own line
expect(focusedField()).toEqual({
text: 'https://one.test\nhttps://two.tests ',
cell: ' ',
});
});

it('edits the context-window field in place', async () => {
await runToContextWindowRow();
await typeText('1234');
await press('left');
await press('left');
await typeText('9');
expect(focusedField()).toEqual({ text: '12934', cell: '3' });
// The step's setter keeps digits only, so a letter never reaches the value.
// The caret still advances one cell, as ink's does; ink also keeps the letter
// on screen, because its field renders its own buffer rather than the value.
await typeText('x');
expect(focusedField()).toEqual({ text: '12934', cell: '4' });
await press('return');
expect(screen.getByText(/Step 6\/6 · Review/)).toBeTruthy();
expect(document.body.textContent).toContain('"contextWindowSize": 12934');
});
});
Loading
Loading