Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions electron/ipc/pty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,21 @@ describe('spawnAgent output batching', () => {
expect(expected[expected.length - 1]).toBe(lines[99]);
});

it.each([
{ name: 'a clean exit (signal 0)', exitCode: 0, signal: 0, expected: null },
{ name: 'no signal', exitCode: 1, signal: undefined, expected: null },
{ name: 'a kill', exitCode: 0, signal: 15, expected: '15' },
])('reports $name as signal $expected', async ({ exitCode, signal, expected }) => {
const { notify, proc } = await launch(`agent-exit-signal-${String(signal)}`);
proc.emitExit({ exitCode, signal });

const exit = vi
.mocked(notify)
.mock.calls.map(([, message]) => message as { type: string; data?: unknown })
.find((payload) => payload.type === 'Exit');
expect(exit?.data).toMatchObject({ exit_code: exitCode, signal: expected });
});

it('sends raw bytes to the window and base64 to subscribers', async () => {
const { notify, proc } = await launch('agent-batch-subscriber');
const sub = vi.fn();
Expand Down
4 changes: 3 additions & 1 deletion electron/ipc/pty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,9 @@ function attachPtyOutputHandlers(
type: 'Exit',
data: {
exit_code: exitCode,
signal: signal !== undefined ? String(signal) : null,
// node-pty reports signal 0 for a normal exit on Unix; only a real
// signal number is one, or the renderer reads a clean exit as killed.
signal: signal ? String(signal) : null,
last_output: lines,
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/TaskAITerminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ function AgentTerminalPane(props: {
props.task.codexChatHandoff
) {
const threadId =
code.exit_code === 0 && (!code.signal || code.signal === '0')
code.exit_code === 0 && !code.signal
? codexResumeId(code.last_output.join('\n'))
: undefined;
// /new and /model in the CLI may change the session or its settings.
Expand Down