fix(native-chat): keep running tool groups from claiming completion

This commit is contained in:
Merge Sim
2026-09-07 16:51:43 -07:00
parent 0f4632c53e
commit f86fe671cb
2 changed files with 16 additions and 5 deletions
@@ -372,18 +372,28 @@ describe('NativeChatToolRun', () => {
expect(screen.getByText('shell git log -1')).toBeInTheDocument()
})
it('settles an orphaned running call when its turn lifecycle has ended', () => {
it('keeps a post-turn running call neutral until the item itself settles', () => {
const blocks: NativeChatBlock[] = [
{ type: 'tool-call', name: 'shell', input: { command: 'sleep 1' }, state: 'running' }
]
const { container } = render(
const { container, rerender } = render(
<NativeChatToolRun blocks={blocks} expandSignal={false} activeTurnIsWorking={false} />
)
expect(screen.queryByText('Running sleep 1')).toBeNull()
expect(container.querySelector('.lucide-check')).toBeInTheDocument()
expect(container.querySelector('.lucide-check')).toBeNull()
expect(container.querySelector('.lucide-circle-alert')).toBeNull()
rerender(
<NativeChatToolRun
blocks={[
{ type: 'tool-call', name: 'shell', input: { command: 'sleep 1' }, state: 'completed' }
]}
expandSignal={false}
activeTurnIsWorking={false}
/>
)
expect(container.querySelector('.lucide-check')).toBeInTheDocument()
})
it('shows the category glyph beside the word a classified row is named by', () => {
@@ -223,6 +223,7 @@ export function NativeChatToolRun({
? selectActiveToolCall(blocks, { activeTurnIsWorking })
: null
const isSettled = latestActiveCall == null
const hasRunningCall = blocks.some((block) => isToolCallBlock(block) && block.state === 'running')
// The turn caret opens the activity group, while each child tool remains
// collapsed. The global expand toolbar still opens child details together.
const expandToolLines = expandOverride === undefined ? open : false
@@ -309,8 +310,8 @@ export function NativeChatToolRun({
<span className="min-w-0 truncate font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/80">
{summary || fallbackLabel}
</span>
{/* Completion reads as a trailing mark so the leading glyph can stay fixed. */}
{structuredActivityUi ? (
{/* A running item cannot inherit completion from its turn. */}
{structuredActivityUi && !hasRunningCall ? (
<Check aria-hidden className="size-3 shrink-0 text-muted-foreground" />
) : null}
{/* Chevron is revealed on hover when collapsed and points down when open. */}