fix(pty): close retained lifecycle review gaps
This commit is contained in:
@@ -171,10 +171,10 @@ export function apply(ctx: Context, config: Config): void {
|
||||
},
|
||||
execute(args, exec) {
|
||||
const id = validateTaskId(args.task_id)
|
||||
const snapshot = ctx.tasks.get(id, exec.agent)
|
||||
const result = ctx.tasks.kill(id, exec.agent, args.reason)
|
||||
if (result === 'already-finished') {
|
||||
// A snapshot describes terminal state without consuming pending output.
|
||||
const snapshot = ctx.tasks.get(id, exec.agent)
|
||||
return Promise.resolve([{
|
||||
type: 'text',
|
||||
text: fitWithSuffix(
|
||||
@@ -185,7 +185,15 @@ export function apply(ctx: Context, config: Config): void {
|
||||
),
|
||||
}])
|
||||
}
|
||||
return Promise.resolve([{ type: 'text', text: `requested cancellation of task ${id}` }])
|
||||
return Promise.resolve([{
|
||||
type: 'text',
|
||||
text: fitWithSuffix(
|
||||
`requested cancellation of task ${id}`,
|
||||
'',
|
||||
snapshot.outputLimitBytes,
|
||||
'\n[notice truncated]',
|
||||
),
|
||||
}])
|
||||
},
|
||||
presentCall: args => presentTaskCall(`Kill background task ${args.task_id}`, 'execute', args.task_id),
|
||||
}))
|
||||
|
||||
@@ -213,6 +213,16 @@ describe('task_kill', () => {
|
||||
expect(p.cancels).toEqual(['superseded'])
|
||||
})
|
||||
|
||||
it('applies the producer output limit to a cancellation acknowledgement', async () => {
|
||||
const { ctx } = await setup()
|
||||
const p = producer({ outputLimitBytes: 8 })
|
||||
ctx.tasks.start(p.spec)
|
||||
|
||||
const result = await call(ctx, 'task_kill', { task_id: 'bash-1' })
|
||||
expect(Buffer.byteLength(text(result))).toBeLessThanOrEqual(8)
|
||||
expect(p.cancels).toEqual([undefined])
|
||||
})
|
||||
|
||||
it('reports an already-finished task without consuming its pending delta', async () => {
|
||||
const { ctx } = await setup()
|
||||
let delta = 'unread tail'
|
||||
|
||||
Reference in New Issue
Block a user