mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 00:39:32 +01:00
fix(web): scroll to the prompt on toolbar Enter, retire app.sendInput (#830)
submitFromToolbar() puts the CR on the FIFO, bypassing xterm scrollOnUserInput; scroll the focused pane before sending. Remove app.sendInput(), which has no production caller; update @dependency headers and test stubs. Retarget the codex predictive-echo recorders to _enqueueReliableInput. Correct the docs and the _sendInputAsync JSDoc for the session FIFO; drop stale _pendingInput stubs.
This commit is contained in:
1 parent
ddb5a647ba
commit
05fc2f990b
16 files changed
+86
-95
No files matched your search
@@ -40,6 +40,16 @@ let untrustedWorkdir: string;
|
||||
let sessionId: string;
|
||||
const createdSessions: string[] = [];
|
||||
|
||||
/** The transport edge the recorders wrap: every typed producer reaches it through the session FIFO. */
|
||||
type ReliableSend = (sid: string, data: string, opts?: unknown) => void;
|
||||
interface RecorderWindow {
|
||||
app: { _enqueueReliableInput: ReliableSend };
|
||||
__dbg: Array<[string, string]>;
|
||||
__trace: string[];
|
||||
__origSend?: ReliableSend;
|
||||
__origSend2?: ReliableSend;
|
||||
}
|
||||
|
||||
function hasCodex(): boolean {
|
||||
try {
|
||||
execSync(`PATH="${CODEX_BIN_DIR}:$PATH" codex --version`, { stdio: 'pipe' });
|
||||
@@ -324,12 +334,13 @@ d('codex predictive echo E2E (real codex TUI)', () => {
|
||||
await resetComposer();
|
||||
const pidBefore = execSync(`${TMUX} list-panes -a -F '#{pane_id} #{pane_pid}'`, { encoding: 'utf8' }).trim();
|
||||
await page.evaluate(() => {
|
||||
const app = (window as any).app;
|
||||
(window as any).__dbg = [];
|
||||
if (!(window as any).__origSend2) (window as any).__origSend2 = app._sendInputAsync.bind(app);
|
||||
app._sendInputAsync = (sid: string, data: string, opts?: unknown) => {
|
||||
(window as any).__dbg.push([sid.slice(0, 8), JSON.stringify(data)]);
|
||||
return (window as any).__origSend2(sid, data, opts);
|
||||
const w = window as unknown as RecorderWindow;
|
||||
const app = w.app;
|
||||
w.__dbg = [];
|
||||
const original = (w.__origSend2 ??= app._enqueueReliableInput.bind(app));
|
||||
app._enqueueReliableInput = (sid, data, opts) => {
|
||||
w.__dbg.push([sid.slice(0, 8), JSON.stringify(data)]);
|
||||
return original(sid, data, opts);
|
||||
};
|
||||
});
|
||||
await page.keyboard.type('abc', { delay: 30 });
|
||||
@@ -471,15 +482,16 @@ d('codex predictive echo E2E (real codex TUI)', () => {
|
||||
|
||||
const record = () =>
|
||||
page.evaluate(() => {
|
||||
const app = (window as any).app;
|
||||
(window as any).__trace = [];
|
||||
if (!(window as any).__origSend) (window as any).__origSend = app._sendInputAsync.bind(app);
|
||||
app._sendInputAsync = (sid: string, data: string, opts?: unknown) => {
|
||||
(window as any).__trace.push(data);
|
||||
return (window as any).__origSend(sid, data, opts);
|
||||
const w = window as unknown as RecorderWindow;
|
||||
const app = w.app;
|
||||
w.__trace = [];
|
||||
const original = (w.__origSend ??= app._enqueueReliableInput.bind(app));
|
||||
app._enqueueReliableInput = (sid, data, opts) => {
|
||||
w.__trace.push(data);
|
||||
return original(sid, data, opts);
|
||||
};
|
||||
});
|
||||
const trace = () => page.evaluate(() => ((window as any).__trace as string[]).join(''));
|
||||
const trace = () => page.evaluate(() => (window as unknown as RecorderWindow).__trace.join(''));
|
||||
|
||||
await record();
|
||||
await script();
|
||||
|
||||
@@ -191,7 +191,6 @@ function loadPasteHarness(options: PasteHarnessOptions = {}): Harness {
|
||||
if (options.localEchoPending !== undefined) {
|
||||
pendingEcho = options.localEchoPending;
|
||||
app._localEchoEnabled = true;
|
||||
app._pendingInput = '';
|
||||
app._localEchoOverlay = {
|
||||
get pendingText() {
|
||||
return pendingEcho;
|
||||
@@ -252,7 +251,6 @@ function loadImageInputApp() {
|
||||
const app = new CodemanApp();
|
||||
app.activeSessionId = 'session-1';
|
||||
app.showToast = vi.fn();
|
||||
app.sendInput = vi.fn(async () => {});
|
||||
app._sendInputAsync = vi.fn();
|
||||
app._normalizeImageForUpload = vi.fn(async (file) => file);
|
||||
app._uploadPasteImage = vi.fn(async (_sessionId, file: { path: string }) => file.path);
|
||||
@@ -473,7 +471,6 @@ describe('image upload insertion policy', () => {
|
||||
const paths = await app._uploadAndInsertImages(files, { insert: false });
|
||||
|
||||
expect(Array.from(paths)).toEqual(['/tmp/first.png', '/tmp/second.png']);
|
||||
expect(app.sendInput).not.toHaveBeenCalled();
|
||||
expect(app._sendInputAsync).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -483,15 +480,15 @@ describe('image upload insertion policy', () => {
|
||||
const paths = await app._uploadAndInsertImages([{ path: '/tmp/legacy.png' }]);
|
||||
|
||||
expect(Array.from(paths)).toEqual(['/tmp/legacy.png']);
|
||||
// The same delivery sendInput() uses (durable queue, useMux for the POST
|
||||
// fallback), but addressed to the session the batch was uploaded to.
|
||||
// Durable delivery with useMux for the POST fallback, addressed to the
|
||||
// captured session the batch was uploaded to.
|
||||
expect(app._sendInputAsync).toHaveBeenCalledWith('session-1', '/tmp/legacy.png', { useMux: true });
|
||||
});
|
||||
|
||||
it('inserts into the session the upload started in, even after a tab switch mid-upload', async () => {
|
||||
const app = loadImageInputApp();
|
||||
// The user switches tabs while the upload is in flight. sendInput() re-read
|
||||
// activeSessionId after the awaits, so the paths used to land in session-2.
|
||||
// The user switches tabs while the upload is in flight. The captured session
|
||||
// must remain the destination after the awaits, rather than the active tab.
|
||||
app._uploadPasteImage = vi.fn(async (_sessionId, file: { path: string }) => {
|
||||
app.activeSessionId = 'session-2';
|
||||
return file.path;
|
||||
@@ -501,7 +498,6 @@ describe('image upload insertion policy', () => {
|
||||
|
||||
expect(app._uploadPasteImage).toHaveBeenCalledWith('session-1', { path: '/tmp/shot.png' });
|
||||
expect(app._sendInputAsync).toHaveBeenCalledWith('session-1', '/tmp/shot.png', { useMux: true });
|
||||
expect(app.sendInput).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('uploads to and inserts into an explicitly named session', async () => {
|
||||
|
||||
@@ -236,6 +236,32 @@ describe('iOS native input served-app wiring (#830)', () => {
|
||||
});
|
||||
expect(viewport.viewportY).toBe(viewport.baseY);
|
||||
});
|
||||
|
||||
it(`toolbar Enter while scrolled back returns the viewport to the prompt (echo ${echo})`, async () => {
|
||||
await setup(echo);
|
||||
const scrolled = await page.evaluate(async () => {
|
||||
const terminal = (window as unknown as TestWindow).app.terminal;
|
||||
const written = Promise.withResolvers<void>();
|
||||
terminal.write('line\r\n'.repeat(200) + '❯ ', written.resolve);
|
||||
await written.promise;
|
||||
terminal.scrollToTop();
|
||||
return { viewportY: terminal.buffer.active.viewportY, baseY: terminal.buffer.active.baseY };
|
||||
});
|
||||
expect(scrolled.viewportY).toBe(0);
|
||||
expect(scrolled.baseY).toBeGreaterThan(0);
|
||||
await page
|
||||
.locator('button[onclick="app.sendEnterKey()"]')
|
||||
.evaluate((button: HTMLButtonElement) => button.click());
|
||||
// Echo on delivers the CR after the local-echo gap: wait for it on the wire.
|
||||
await page.waitForFunction(() => (window as unknown as TestWindow).__sent.some((x) => x.input === '\r'));
|
||||
const sent = await page.evaluate(() => (window as unknown as TestWindow).__sent.map((x) => x.input));
|
||||
expect(sent).toEqual(['\r']);
|
||||
const viewport = await page.evaluate(() => {
|
||||
const buffer = (window as unknown as TestWindow).app.terminal.buffer.active;
|
||||
return { viewportY: buffer.viewportY, baseY: buffer.baseY };
|
||||
});
|
||||
expect(viewport.viewportY).toBe(viewport.baseY);
|
||||
});
|
||||
}
|
||||
|
||||
for (const target of ['main', 'tile'] as const) {
|
||||
|
||||
@@ -606,7 +606,7 @@ describe('Send on Enter: a held answer goes out with Enter as its own write', ()
|
||||
it('types a single character, then Enter 120 ms later on the same session FIFO across a switch', () => {
|
||||
// Codex folds an Enter that arrives in the same burst as the text into a
|
||||
// paste, even for `1\r`; a selection dialog ignores a pasted digit. Same
|
||||
// split as TmuxManager.sendInput (submitsAsKeys).
|
||||
// split as the tmux manager's submitsAsKeys path.
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const { app, composed, writes } = promptApp();
|
||||
@@ -732,7 +732,6 @@ describe('composer nav keys from the bar', () => {
|
||||
const app = loaded.app as unknown as Record<string, unknown>;
|
||||
app._localEchoEnabled = true;
|
||||
app._localEchoOverlay = overlay;
|
||||
app.sendInput = vi.fn();
|
||||
app._flushedOffsets = new Map([['session-1', 3]]);
|
||||
app._flushedTexts = new Map([['session-1', 'dra']]);
|
||||
return { ...loaded, app, overlay };
|
||||
@@ -810,7 +809,6 @@ describe('composer nav keys from the bar', () => {
|
||||
bar.handleAction('arrow-right');
|
||||
|
||||
expect(sentKeys(app._enqueueInput as ReturnType<typeof vi.fn>)).toEqual(['\x1b[A', '\x1b[B', '\x1b[D', '\x1b[C']);
|
||||
expect(app.sendInput).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ function loadKeyboardModule() {
|
||||
terminal: { focus: vi.fn() },
|
||||
clearTerminalInput: vi.fn(),
|
||||
insertTerminalText: vi.fn(),
|
||||
sendInput: vi.fn(),
|
||||
_enqueueInput: vi.fn(),
|
||||
_sendInputAsync: vi.fn(),
|
||||
_focusedPane: () => ({ sessionId: 'session-1', isPrimary: true }),
|
||||
@@ -92,7 +91,6 @@ describe('accessory Tab key', () => {
|
||||
const { app, bar, fetchMock } = loadKeyboardModule();
|
||||
bar.handleAction('tab');
|
||||
|
||||
expect(app.sendInput).not.toHaveBeenCalled();
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
expect(app._enqueueInput).toHaveBeenCalledWith('session-1', [{ write: '\t' }]);
|
||||
});
|
||||
@@ -156,10 +154,8 @@ describe('toolbar Enter', () => {
|
||||
const context = vm.createContext({ CodemanApp: function () {} });
|
||||
vm.runInContext(`${sessionSource}\nglobalThis.__mixin = CodemanApp.prototype;`, context);
|
||||
const submitFromToolbar = vi.fn();
|
||||
const sendInput = vi.fn();
|
||||
context.__mixin.sendEnterKey.call({ submitFromToolbar, sendInput });
|
||||
context.__mixin.sendEnterKey.call({ submitFromToolbar });
|
||||
expect(submitFromToolbar).toHaveBeenCalledOnce();
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -169,7 +165,6 @@ describe('mobile filesystem picker actions', () => {
|
||||
bar.handleAction('clear-input');
|
||||
|
||||
expect(app.clearTerminalInput).toHaveBeenCalledOnce();
|
||||
expect(app.sendInput).not.toHaveBeenCalled();
|
||||
expect(keyboardSource).toContain('data-action="clear-input"');
|
||||
expect(keyboardSource).toContain('data-action="clear" title="/clear"');
|
||||
});
|
||||
@@ -189,7 +184,6 @@ describe('mobile filesystem picker actions', () => {
|
||||
});
|
||||
options.onSelect('/mnt/d/AI/project/file.ts');
|
||||
expect(app._sendInputAsync).toHaveBeenCalledWith('session-1', '/mnt/d/AI/project/file.ts', { useMux: true });
|
||||
expect(app.sendInput).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([false, true])(
|
||||
@@ -247,14 +241,12 @@ describe('mobile filesystem picker actions', () => {
|
||||
|
||||
it('inserts a selected path into the editable local-echo prompt without sending it', () => {
|
||||
const appendText = vi.fn();
|
||||
const sendInput = vi.fn();
|
||||
const focus = vi.fn();
|
||||
const app = {
|
||||
activeSessionId: 'session-1',
|
||||
_localEchoEnabled: true,
|
||||
_localEchoOverlay: { appendText },
|
||||
terminal: { focus },
|
||||
sendInput,
|
||||
_focusedPane: () => ({ terminal: app.terminal, sessionId: app.activeSessionId, isPrimary: true }),
|
||||
_prepareExternalInput: vi.fn(),
|
||||
};
|
||||
@@ -262,20 +254,17 @@ describe('mobile filesystem picker actions', () => {
|
||||
terminalHarness.mixin.insertTerminalText.call(app, '/mnt/d/AI/project');
|
||||
|
||||
expect(appendText).toHaveBeenCalledWith('/mnt/d/AI/project');
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
expect(focus).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('clears pending and already-flushed prompt text without invoking /clear', () => {
|
||||
const clear = vi.fn();
|
||||
const suppressBufferDetection = vi.fn();
|
||||
const sendInput = vi.fn(() => Promise.resolve());
|
||||
const showToast = vi.fn();
|
||||
const focus = vi.fn();
|
||||
const app = {
|
||||
activeSessionId: 'session-1',
|
||||
_inputFlushTimeout: null,
|
||||
_pendingInput: 'pending text',
|
||||
_localEchoEnabled: true,
|
||||
_localEchoOverlay: {
|
||||
getFlushed: () => ({ count: 4, text: 'a😀b' }),
|
||||
@@ -284,7 +273,6 @@ describe('mobile filesystem picker actions', () => {
|
||||
},
|
||||
_flushedOffsets: new Map([['session-1', 4]]),
|
||||
_flushedTexts: new Map([['session-1', 'a😀b']]),
|
||||
sendInput,
|
||||
_sendInputAsync: vi.fn(),
|
||||
_focusedPane: () => ({ terminal: app.terminal, sessionId: app.activeSessionId, isPrimary: true }),
|
||||
_prepareExternalInput: vi.fn(),
|
||||
@@ -301,7 +289,6 @@ describe('mobile filesystem picker actions', () => {
|
||||
expect(clear).toHaveBeenCalledOnce();
|
||||
expect(suppressBufferDetection).toHaveBeenCalledOnce();
|
||||
expect(app._sendInputAsync).toHaveBeenCalledWith('session-1', '\x7f'.repeat(3), { useMux: true });
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
expect(app._flushedOffsets.size).toBe(0);
|
||||
expect(app._flushedTexts.size).toBe(0);
|
||||
expect(showToast).toHaveBeenCalledWith('Input cleared', 'success');
|
||||
@@ -311,7 +298,6 @@ describe('mobile filesystem picker actions', () => {
|
||||
|
||||
it('sends a picked path to the tile or Pane B that holds the keyboard, never the parked main overlay', () => {
|
||||
const appendText = vi.fn();
|
||||
const sendInput = vi.fn();
|
||||
const _sendInputAsync = vi.fn();
|
||||
const mainFocus = vi.fn();
|
||||
const tileFocus = vi.fn();
|
||||
@@ -320,7 +306,6 @@ describe('mobile filesystem picker actions', () => {
|
||||
_localEchoEnabled: true,
|
||||
_localEchoOverlay: { appendText },
|
||||
terminal: { focus: mainFocus },
|
||||
sendInput,
|
||||
_sendInputAsync,
|
||||
_prepareExternalInput: vi.fn(),
|
||||
_focusedPane: () => ({ terminal: { focus: tileFocus }, sessionId: 'tile-2', isPrimary: false, tile: {} }),
|
||||
@@ -330,24 +315,20 @@ describe('mobile filesystem picker actions', () => {
|
||||
|
||||
expect(_sendInputAsync).toHaveBeenCalledWith('tile-2', '/mnt/d/AI/project');
|
||||
expect(appendText).not.toHaveBeenCalled();
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
expect(tileFocus).toHaveBeenCalledOnce();
|
||||
expect(mainFocus).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('clears the prompt of the tile or Pane B that holds the keyboard with Ctrl+U, leaving the main overlay alone', () => {
|
||||
const clear = vi.fn();
|
||||
const sendInput = vi.fn(() => Promise.resolve());
|
||||
const _sendInputAsync = vi.fn();
|
||||
const showToast = vi.fn();
|
||||
const tileFocus = vi.fn();
|
||||
const app = {
|
||||
activeSessionId: 'session-1',
|
||||
_inputFlushTimeout: null,
|
||||
_pendingInput: 'main pane text',
|
||||
_localEchoEnabled: true,
|
||||
_localEchoOverlay: { getFlushed: () => ({ count: 0, text: '' }), clear, suppressBufferDetection: vi.fn() },
|
||||
sendInput,
|
||||
_sendInputAsync,
|
||||
_prepareExternalInput: vi.fn(),
|
||||
showToast,
|
||||
@@ -358,22 +339,17 @@ describe('mobile filesystem picker actions', () => {
|
||||
terminalHarness.mixin.clearTerminalInput.call(app);
|
||||
|
||||
expect(_sendInputAsync).toHaveBeenCalledWith('tile-2', '\x15');
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
expect(clear).not.toHaveBeenCalled();
|
||||
expect(app._pendingInput).toBe('main pane text');
|
||||
expect(showToast).toHaveBeenCalledWith('Input cleared', 'success');
|
||||
expect(tileFocus).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('uses Ctrl+U to clear the TUI-owned prompt when local echo is disabled', () => {
|
||||
const sendInput = vi.fn(() => Promise.resolve());
|
||||
const app = {
|
||||
activeSessionId: 'session-1',
|
||||
_inputFlushTimeout: null,
|
||||
_pendingInput: '',
|
||||
_localEchoEnabled: false,
|
||||
_localEchoOverlay: null,
|
||||
sendInput,
|
||||
_sendInputAsync: vi.fn(),
|
||||
_focusedPane: () => ({ terminal: app.terminal, sessionId: app.activeSessionId, isPrimary: true }),
|
||||
_prepareExternalInput: vi.fn(),
|
||||
|
||||
@@ -49,7 +49,6 @@ function loadToolbar(sessionId: string | null = 'session-1', localEcho = true, k
|
||||
const app = new CodemanApp();
|
||||
app.activeSessionId = sessionId;
|
||||
app.showToast = vi.fn();
|
||||
app.sendInput = vi.fn(async () => {});
|
||||
app.terminal = { focus: vi.fn() };
|
||||
app._isMobileTerminalInputFocused = vi.fn(() => keyboardUp);
|
||||
app._blurMobileTerminalInput = vi.fn();
|
||||
|
||||
@@ -36,7 +36,6 @@ type Voice = {
|
||||
type Pane = { sessionId: string; isPrimary?: boolean; terminal?: { focus: () => void } };
|
||||
|
||||
function load(opts: { insertMode?: string; localEcho?: boolean; focused?: string; tiles?: boolean; pane?: Pane } = {}) {
|
||||
const sendInput = vi.fn(async () => {});
|
||||
const sendInputAsync = vi.fn();
|
||||
const appendText = vi.fn();
|
||||
const overlayClear = vi.fn();
|
||||
@@ -57,7 +56,6 @@ function load(opts: { insertMode?: string; localEcho?: boolean; focused?: string
|
||||
['session-a', {}],
|
||||
['session-b', {}],
|
||||
]),
|
||||
sendInput,
|
||||
_sendInputAsync: sendInputAsync,
|
||||
_enqueueInput: vi.fn(),
|
||||
_prepareExternalInput: vi.fn(),
|
||||
@@ -104,7 +102,7 @@ function load(opts: { insertMode?: string; localEcho?: boolean; focused?: string
|
||||
// Recording itself is out of scope: start() only has to pick the target.
|
||||
voice._resolveProvider = () => 'webspeech';
|
||||
voice._startWebSpeech = vi.fn();
|
||||
return { voice, app, sendInput, sendInputAsync, appendText, overlayClear, showToast, gear, doc };
|
||||
return { voice, app, sendInputAsync, appendText, overlayClear, showToast, gear, doc };
|
||||
}
|
||||
|
||||
function clickGreenSend(gear: { addEventListener: { mock: { calls: unknown[][] } } }) {
|
||||
@@ -114,23 +112,21 @@ function clickGreenSend(gear: { addEventListener: { mock: { calls: unknown[][] }
|
||||
|
||||
describe('dictation target', () => {
|
||||
it('sends to the session recording started in, even after a tab switch', () => {
|
||||
const { voice, app, sendInput, sendInputAsync } = load();
|
||||
const { voice, app, sendInputAsync } = load();
|
||||
voice.start();
|
||||
app.activeSessionId = 'session-b'; // user switched tabs while speaking
|
||||
|
||||
voice._insertText('fix the login bug');
|
||||
|
||||
expect(sendInputAsync).toHaveBeenCalledWith('session-a', 'fix the login bug', { useMux: true });
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('uses the session-bound path even while the target is still active', () => {
|
||||
const { voice, app, sendInput, sendInputAsync } = load({ pane: { sessionId: 'session-a', isPrimary: true } });
|
||||
const { voice, app, sendInputAsync } = load({ pane: { sessionId: 'session-a', isPrimary: true } });
|
||||
voice.start();
|
||||
|
||||
voice._insertText('hello');
|
||||
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
expect(sendInputAsync).toHaveBeenCalledWith('session-a', 'hello', { useMux: true });
|
||||
expect(app._prepareExternalInput).toHaveBeenCalledWith({ sessionId: 'session-a', isPrimary: true }, 'voice-send');
|
||||
});
|
||||
@@ -147,7 +143,7 @@ describe('dictation target', () => {
|
||||
});
|
||||
|
||||
it('still uses the local-echo overlay for the active session', () => {
|
||||
const { voice, app, appendText, sendInput } = load({
|
||||
const { voice, app, appendText } = load({
|
||||
localEcho: true,
|
||||
pane: { sessionId: 'session-a', isPrimary: true },
|
||||
});
|
||||
@@ -157,7 +153,6 @@ describe('dictation target', () => {
|
||||
|
||||
expect(appendText).toHaveBeenCalledWith('typed locally');
|
||||
expect(app._prepareExternalInput).toHaveBeenCalledWith({ sessionId: 'session-a', isPrimary: true }, 'voice-insert');
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('takes its target from the focused pane when one is reported', () => {
|
||||
@@ -170,7 +165,7 @@ describe('dictation target', () => {
|
||||
});
|
||||
|
||||
it('the green send button sends Enter to the dictation target', () => {
|
||||
const { voice, app, gear, sendInput, sendInputAsync } = load();
|
||||
const { voice, app, gear, sendInputAsync } = load();
|
||||
voice.start();
|
||||
voice._insertText('ship it');
|
||||
app.activeSessionId = 'session-b';
|
||||
@@ -179,25 +174,23 @@ describe('dictation target', () => {
|
||||
handler();
|
||||
|
||||
expect(sendInputAsync).toHaveBeenLastCalledWith('session-a', '\r', { useMux: true });
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('drops dictation for a session that closed meanwhile, with a toast', () => {
|
||||
const { voice, app, sendInput, sendInputAsync, showToast } = load();
|
||||
const { voice, app, sendInputAsync, showToast } = load();
|
||||
voice.start();
|
||||
app.activeSessionId = 'session-b';
|
||||
(app.sessions as Map<string, unknown>).delete('session-a');
|
||||
|
||||
voice._insertText('too late');
|
||||
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
expect(sendInputAsync).not.toHaveBeenCalled();
|
||||
expect(showToast).toHaveBeenCalledWith('That session has closed; dictation not sent', 'warning');
|
||||
});
|
||||
|
||||
it('with the tile grid open, dictation goes to the focused tile, not the parked overlay', () => {
|
||||
const tileTerminal = { focus: vi.fn() };
|
||||
const { voice, app, appendText, sendInput, sendInputAsync } = load({
|
||||
const { voice, app, appendText, sendInputAsync } = load({
|
||||
localEcho: true,
|
||||
tiles: true,
|
||||
pane: { sessionId: 'session-a', isPrimary: false, terminal: tileTerminal },
|
||||
@@ -207,7 +200,6 @@ describe('dictation target', () => {
|
||||
voice._insertText('into the tile');
|
||||
|
||||
expect(appendText).not.toHaveBeenCalled();
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
expect(sendInputAsync).toHaveBeenCalledWith('session-a', 'into the tile', { useMux: true });
|
||||
// The keyboard goes back to the tile; the main terminal is display: none.
|
||||
expect(tileTerminal.focus).toHaveBeenCalled();
|
||||
@@ -216,7 +208,7 @@ describe('dictation target', () => {
|
||||
|
||||
it('with the tile grid open, the green send button sends only Enter to the tile session', () => {
|
||||
const tileTerminal = { focus: vi.fn() };
|
||||
const { voice, app, gear, sendInput, sendInputAsync, overlayClear } = load({
|
||||
const { voice, app, gear, sendInputAsync, overlayClear } = load({
|
||||
localEcho: true,
|
||||
tiles: true,
|
||||
pane: { sessionId: 'session-a', isPrimary: false, terminal: tileTerminal },
|
||||
@@ -229,7 +221,6 @@ describe('dictation target', () => {
|
||||
clickGreenSend(gear);
|
||||
|
||||
expect(overlayClear).not.toHaveBeenCalled();
|
||||
expect(sendInput).not.toHaveBeenCalledWith('stale main-terminal text');
|
||||
expect(sendInputAsync).toHaveBeenLastCalledWith('session-a', '\r', { useMux: true });
|
||||
// The parked main terminal's predictions are not this pane's.
|
||||
expect(
|
||||
@@ -239,7 +230,7 @@ describe('dictation target', () => {
|
||||
|
||||
it('preserves Pane A pending text and dictation ordering when focus moves to B', () => {
|
||||
const paneB = { focus: vi.fn() };
|
||||
const { voice, app, appendText, overlayClear, gear, sendInput, sendInputAsync } = load({
|
||||
const { voice, app, appendText, overlayClear, gear, sendInputAsync } = load({
|
||||
localEcho: true,
|
||||
focused: 'session-a',
|
||||
});
|
||||
@@ -270,7 +261,6 @@ describe('dictation target', () => {
|
||||
{ write: '\r', useMux: true },
|
||||
]);
|
||||
expect(overlay.pendingText).toBe('');
|
||||
expect(sendInput).not.toHaveBeenCalled();
|
||||
expect(sendInputAsync).not.toHaveBeenCalled();
|
||||
expect(app._prepareExternalInput).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
|
||||
Reference in new issue
Block a user