interruptTurn only flushed the in-flight streaming chunk (bufRef) to the transcript before calling idle(), which wiped segmentMessages and pendingSegmentTools. Every tool call and commentary line the agent had already emitted in the current turn disappeared the moment the user cancelled, even though that output is exactly what they want to keep when they hit Ctrl+C (quote from the blitz feedback: "everything was fine up until the point where you wanted to push to main"). Append each flushed segment message to the transcript first, then render the in-flight partial with the `*[interrupted]*` marker and its pendingSegmentTools. Sys-level "interrupted" note still fires when there is nothing to preserve.
72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
import { terminalParityHints } from '../lib/terminalParity.js'
|
|
|
|
describe('terminalParityHints', () => {
|
|
it('warns for Apple Terminal and SSH/tmux sessions', async () => {
|
|
const hints = await terminalParityHints({
|
|
TERM_PROGRAM: 'Apple_Terminal',
|
|
TERM_SESSION_ID: 'w0t0p0:123',
|
|
SSH_CONNECTION: '1',
|
|
TMUX: '/tmp/tmux-1/default,1,0'
|
|
} as NodeJS.ProcessEnv)
|
|
|
|
expect(hints.map(h => h.key)).toEqual(expect.arrayContaining(['apple-terminal', 'remote', 'tmux']))
|
|
})
|
|
|
|
it('suggests IDE setup only for VS Code-family terminals that still need bindings', async () => {
|
|
const readFile = vi.fn().mockRejectedValue(Object.assign(new Error('missing'), { code: 'ENOENT' }))
|
|
|
|
const hints = await terminalParityHints({ TERM_PROGRAM: 'vscode' } as NodeJS.ProcessEnv, {
|
|
fileOps: { readFile },
|
|
homeDir: '/tmp/fake-home'
|
|
})
|
|
|
|
expect(hints.some(h => h.key === 'ide-setup')).toBe(true)
|
|
})
|
|
|
|
it('suppresses IDE setup hint when keybindings are already configured', async () => {
|
|
const readFile = vi.fn().mockResolvedValue(
|
|
JSON.stringify([
|
|
{
|
|
key: 'shift+enter',
|
|
command: 'workbench.action.terminal.sendSequence',
|
|
when: 'terminalFocus',
|
|
args: { text: '\\\r\n' }
|
|
},
|
|
{
|
|
key: 'ctrl+enter',
|
|
command: 'workbench.action.terminal.sendSequence',
|
|
when: 'terminalFocus',
|
|
args: { text: '\\\r\n' }
|
|
},
|
|
{
|
|
key: 'cmd+enter',
|
|
command: 'workbench.action.terminal.sendSequence',
|
|
when: 'terminalFocus',
|
|
args: { text: '\\\r\n' }
|
|
},
|
|
{
|
|
key: 'cmd+z',
|
|
command: 'workbench.action.terminal.sendSequence',
|
|
when: 'terminalFocus',
|
|
args: { text: '\u001b[122;9u' }
|
|
},
|
|
{
|
|
key: 'shift+cmd+z',
|
|
command: 'workbench.action.terminal.sendSequence',
|
|
when: 'terminalFocus',
|
|
args: { text: '\u001b[122;10u' }
|
|
}
|
|
])
|
|
)
|
|
|
|
const hints = await terminalParityHints({ TERM_PROGRAM: 'vscode' } as NodeJS.ProcessEnv, {
|
|
fileOps: { readFile },
|
|
homeDir: '/tmp/fake-home'
|
|
})
|
|
|
|
expect(hints.some(h => h.key === 'ide-setup')).toBe(false)
|
|
})
|
|
})
|