mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-09 07:29:51 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user