From 795eddccc39653c3014dda6aec65bc15dbe526ee Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 6 Sep 2026 02:15:17 -0700 Subject: [PATCH] test: exercise supported ConPTY keyboard protocol reset --- .../fixtures/golden-stub-agent/golden-stub-agent.js | 5 +++-- tests/e2e/helpers/golden-stub-agent.ts | 2 +- .../terminal-windows-conpty-keyboard-reset.spec.ts | 13 ++++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) mode change 100755 => 100644 tests/e2e/fixtures/golden-stub-agent/golden-stub-agent.js diff --git a/tests/e2e/fixtures/golden-stub-agent/golden-stub-agent.js b/tests/e2e/fixtures/golden-stub-agent/golden-stub-agent.js old mode 100755 new mode 100644 index 5c353ce2bc6..d22cbf43b79 --- a/tests/e2e/fixtures/golden-stub-agent/golden-stub-agent.js +++ b/tests/e2e/fixtures/golden-stub-agent/golden-stub-agent.js @@ -5,6 +5,7 @@ const EXIT_MARKER = 'GOLDEN_STUB_AGENT_EXITED' const ESC = '\x1b' const keyboardProtocolMode = process.argv.includes('--keyboard-protocol') +const keyboardProtocolAgent = process.argv.includes('--grok') ? 'Grok' : 'Codex' // Both match the bytes after ESC, so the control character stays out of the // pattern: a CSI/SS3 introducer still missing its final byte, and a complete // CSI/SS3 sequence. Shift+Enter is matched before either is consulted. @@ -20,7 +21,7 @@ function render() { const lines = composer.split('\n') const renderedComposer = lines.map((line, index) => `${index === 0 ? '> ' : ' '}${line}`) process.stdout.write( - `${keyboardProtocolMode ? '\x1b]0;\u280b Codex is thinking\x07\x1b[>1u' : '\x1b]0;Golden Stub Agent\x07'}${[ + `${keyboardProtocolMode ? `\x1b]0;\u280b ${keyboardProtocolAgent} is thinking\x07\x1b[>1u` : '\x1b]0;Golden Stub Agent\x07'}${[ '\x1b[H\x1b[2JGolden Stub Agent', `[${READY_MARKER}]`, '', @@ -40,7 +41,7 @@ function exitCleanly() { if (process.stdin.isTTY) { process.stdin.setRawMode(false) } - const idleTitle = keyboardProtocolMode ? '\x1b]0;Codex\x07' : '' + const idleTitle = keyboardProtocolMode ? `\x1b]0;${keyboardProtocolAgent}\x07` : '' process.stdout.write(`${idleTitle}\x1b[?1049l[${EXIT_MARKER}]\r\n`, () => process.exit(0)) } diff --git a/tests/e2e/helpers/golden-stub-agent.ts b/tests/e2e/helpers/golden-stub-agent.ts index 427a6a2560c..393b244cf8f 100644 --- a/tests/e2e/helpers/golden-stub-agent.ts +++ b/tests/e2e/helpers/golden-stub-agent.ts @@ -25,7 +25,7 @@ export function getGoldenStubAgentLaunchEnv(): NodeJS.ProcessEnv { export async function configureGoldenStubAgent( page: Page, options: { - agent?: (typeof GOLDEN_STUB_AGENTS)[number]['id'] + agent?: (typeof GOLDEN_STUB_AGENTS)[number]['id'] | 'grok' agentArgs?: string /** Windows default shell the launch command must survive; ignored elsewhere. */ windowsShell?: BuiltInWindowsTerminalShell diff --git a/tests/e2e/terminal-windows-conpty-keyboard-reset.spec.ts b/tests/e2e/terminal-windows-conpty-keyboard-reset.spec.ts index 5766c1e2d49..6c384fd6d2c 100644 --- a/tests/e2e/terminal-windows-conpty-keyboard-reset.spec.ts +++ b/tests/e2e/terminal-windows-conpty-keyboard-reset.spec.ts @@ -54,13 +54,19 @@ test('resets standard keyboard bytes after a protocol-mode agent exits on ConPTY await waitForSessionReady(orcaPage) await waitForActiveWorktree(orcaPage) await ensureTerminalVisible(orcaPage) - await configureGoldenStubAgent(orcaPage, { agentArgs: '--keyboard-protocol' }) - await launchGoldenStubAgentFromNewTab(orcaPage) + // Grok is the supported native ConPTY exception to Kitty protocol withholding. + await configureGoldenStubAgent(orcaPage, { + agent: 'grok', + agentArgs: '--keyboard-protocol --grok' + }) + await launchGoldenStubAgentFromNewTab(orcaPage, /^Grok(?:\s|$)/i) const ptyId = await waitForActivePanePtyId(orcaPage) await expect.poll(() => getKittyKeyboardFlags(orcaPage), { timeout: 10_000 }).toBe(1) await clearTerminalPtyWriteLog(electronApp) + // Kitty flag 1 preserves plain Enter; modified Enter proves CSI-u input. + await orcaPage.keyboard.press('Shift+Enter') await orcaPage.keyboard.type('exit') await orcaPage.keyboard.press('Enter') await waitForTerminalOutput(orcaPage, GOLDEN_STUB_EXIT_MARKER, 15_000) @@ -68,7 +74,8 @@ test('resets standard keyboard bytes after a protocol-mode agent exits on ConPTY .filter((entry) => entry.id === ptyId) .map((entry) => entry.data) .join('') - expect(protocolWrites.includes('\x1b[13u') || protocolWrites.includes('\x1b[13;1u')).toBe(true) + expect(protocolWrites).toContain('\x1b[13;2u') + expect(protocolWrites).toContain('\r') await expect.poll(() => getKittyKeyboardFlags(orcaPage), { timeout: 10_000 }).toBe(0) await clearTerminalPtyWriteLog(electronApp)