diff --git a/src/cli/handlers/terminal.test.ts b/src/cli/handlers/terminal.test.ts index b13775dce00..18832ba28a6 100644 --- a/src/cli/handlers/terminal.test.ts +++ b/src/cli/handlers/terminal.test.ts @@ -5,6 +5,8 @@ import { printHelp } from '../help' import { COMMAND_SPECS } from '../specs' import { TERMINAL_HANDLERS } from './terminal' +const ORIGINAL_EXIT_CODE = process.exitCode + describe('terminal close CLI', () => { afterEach(() => { vi.restoreAllMocks() @@ -65,6 +67,7 @@ describe('terminal close CLI', () => { describe('terminal send CLI', () => { afterEach(() => { vi.restoreAllMocks() + process.exitCode = ORIGINAL_EXIT_CODE }) it('marks combined text and Enter as an agent prompt candidate', async () => { @@ -113,6 +116,7 @@ describe('terminal send CLI', () => { } }) vi.spyOn(console, 'log').mockImplementation(() => {}) + process.exitCode = undefined await TERMINAL_HANDLERS['terminal send']({ flags: new Map([ @@ -128,6 +132,7 @@ describe('terminal send CLI', () => { expect(console.log).toHaveBeenCalledWith( expect.stringMatching(/Structured Chat.*Switch it to Terminal.*orca terminal send/s) ) + expect(process.exitCode).toBe(1) }) it('keeps text-only and bare Enter sends as direct terminal input', async () => { diff --git a/src/cli/handlers/terminal.ts b/src/cli/handlers/terminal.ts index 00c0a5cd807..d0ced262a43 100644 --- a/src/cli/handlers/terminal.ts +++ b/src/cli/handlers/terminal.ts @@ -115,6 +115,9 @@ export const TERMINAL_HANDLERS: Record = { client: { id: 'orca-cli', type: 'desktop' } }) printResult(result, json, formatTerminalSend) + if (!result.result.send.accepted) { + process.exitCode = 1 + } }, 'terminal wait': async ({ flags, client, cwd, json }) => { const timeoutMs = getOptionalPositiveIntegerFlag(flags, 'timeout-ms') diff --git a/src/main/runtime/orchestration-structured-chat-lease.test.ts b/src/main/runtime/orchestration-structured-chat-lease.test.ts index 67469a480c2..c7e407b317f 100644 --- a/src/main/runtime/orchestration-structured-chat-lease.test.ts +++ b/src/main/runtime/orchestration-structured-chat-lease.test.ts @@ -287,10 +287,12 @@ describe('orchestration while Structured Chat owns an agent session', () => { expect(writes.mock.calls.filter(([ptyId]) => ptyId === WORKER.ptyId)).toHaveLength(0) }) - it('returns terminal.send typed refusal metadata without writing bytes', async () => { + it('reports a real gate refusal with typed metadata and zero bytes written', async () => { const response = await rpc('terminal.send', { terminal: WORKER.handle, text: 'new prompt', + enter: true, + agentPrompt: true, client: { id: 'test-client', type: 'desktop' } })