Stop active Codex child agents on abort (#615)

* fix(cli): stop active codex child agents

* chore: refresh bun lockfile for deploy

* fix(web): enable stop for active codex child agents

* test(cli): cover aborting active codex child agents
This commit is contained in:
SmallSpider
2026-05-12 23:25:41 +08:00
committed by GitHub
parent af3491e046
commit 088a712f1e
5 changed files with 183 additions and 28 deletions
+22
View File
@@ -47,6 +47,23 @@ function getOutlineTitle(session: Session): string {
return session.id.slice(0, 8)
}
function hasAbortableAgentRun(blocks: readonly ChatBlock[]): boolean {
for (const block of blocks) {
if (block.kind === 'tool-call') {
if (
block.tool.name === 'CodexAgent'
&& (block.tool.state === 'running' || block.tool.state === 'pending')
) {
return true
}
if (hasAbortableAgentRun(block.children)) {
return true
}
}
}
return false
}
export function SessionChat(props: {
api: ApiClient
session: Session
@@ -278,6 +295,10 @@ export function SessionChat(props: {
() => reconcileChatBlocks(reduced.blocks, blocksByIdRef.current),
[reduced.blocks]
)
const hasRunningChildAgent = useMemo(
() => hasAbortableAgentRun(reduced.blocks),
[reduced.blocks]
)
useEffect(() => {
blocksByIdRef.current = reconciled.byId
@@ -404,6 +425,7 @@ export function SessionChat(props: {
session: props.session,
blocks: visibleBlocks,
isSending: props.isSending,
isRunning: props.session.thinking || hasRunningChildAgent,
onSendMessage: handleSend,
onAbort: handleAbort,
attachmentAdapter,