mirror of
https://github.com/stablyai/orca.git
synced 2026-09-29 08:03:20 +00:00
test: exercise supported ConPTY keyboard protocol reset
This commit is contained in:
Executable → Regular
+3
-2
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user