fix(pty): close retained lifecycle review gaps

This commit is contained in:
Tianyi Cui
2026-07-22 23:17:53 +08:00
parent 58657db1b5
commit 90ac883512
8 changed files with 149 additions and 56 deletions

View File

@@ -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),
}))