Skip to content

fix: keep working spinner alive until all parallel tool calls finish#183

Open
mikenorgate wants to merge 1 commit intomasterfrom
mike/LLM-1574-kimi-tool-indicator
Open

fix: keep working spinner alive until all parallel tool calls finish#183
mikenorgate wants to merge 1 commit intomasterfrom
mike/LLM-1574-kimi-tool-indicator

Conversation

@mikenorgate
Copy link
Copy Markdown
Contributor

@mikenorgate mikenorgate commented May 8, 2026

What

Fix LLM-1574 — Kimi K2.5+ models execute tool calls correctly but the TUI shows zero progress during execution. With Claude the working spinner appears; with Kimi the session appears frozen.

Why it happened

The upstream ui.ts stops the working animation on message_start, which fires when assistant text begins streaming. With parallel tool calls (Kimi K2.5+, deepseek, etc.) the message starts before all tool results return, causing the indicator to flash and disappear while tools are still running.

Fix

Track in-flight tool calls with a counter in src/extensions/ui.ts:

  • tool_execution_start — increment counter, restart animation
  • tool_execution_end — decrement counter, hide indicator only when counter reaches 0
  • message_start — only stop animation when toolsInFlight === 0
  • session_start — reset counter to prevent stale state

Uses the existing orange spinner. No Kimi-specific code — works for any model doing parallel tool calls.

Verification

  • pnpm run typecheck
  • pnpm run lint
  • pnpm run test ✅ (1161 passed)

Related

Ghost pending indicator (separate upstream bug): Kimi parallel calls expose a rendering race in ToolExecutionComponent.updateDisplay() — the pending call renderer is unconditionally added to the render container even when a result exists, leaving ghost spinners above completed blocks. Fix belongs upstream in pi-coding-agent, tracked separately.

LLM-1574


Kimchi Summary

What changed

Fixes premature dismissal of the working indicator when assistant messages arrive while parallel tool calls are still executing. The UI extension now tracks in-flight tools and delays hiding the indicator until all active tool executions complete.

Why

Parallel tool calling (used by Kimi K2.5+, DeepSeek, and others) allows assistant messages to stream before all tool results return. Stopping the spinner on message_start caused a brief flash-and-clear while tools remained active.

Key changes

  • src/extensions/ui.ts: Added toolsInFlight counter to track active parallel tool executions.
  • src/extensions/ui.ts: Reset toolsInFlight to 0 on session_start, turn_start, and agent_end.
  • src/extensions/ui.ts: Added pi.on("tool_execution_start") handler to increment the counter and show the working indicator.
  • src/extensions/ui.ts: Added pi.on("tool_execution_end") handler to decrement the counter and hide the indicator only when toolsInFlight reaches zero.
  • src/extensions/ui.ts: Guarded the message_start animation stop so it only fires when toolsInFlight === 0.

Impact

  • Smoother UX for models with parallel tool execution; the working indicator now accurately reflects ongoing backend activity.
  • No breaking changes or migration steps required.

The upstream ui.ts stops the working animation on message_start, which fires
when assistant text begins streaming. With parallel tool calls (Kimi K2.5+,
deepseek, etc.) the message starts before all tool results return, causing
the indicator to flash and disappear while tools are still executing.

Fix by tracking in-flight tool calls with a counter. message_start now only
stops the animation when toolsInFlight === 0. tool_execution_start increments
the counter and restarts the animation; tool_execution_end decrements it and
hides the indicator only when the counter reaches zero.

LLM-1574

Co-Authored-By: Kimchi <noreply@kimchi.dev>
@kimchi-review
Copy link
Copy Markdown

kimchi-review Bot commented May 8, 2026

Kimchi Code Review

Property Value
Commit ba24470
Author @mikenorgate
Files changed 0
Review status Completed
Comments 0
Duration 65s

Summary

📊 Review Score: 90/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 1/5 (1 = trivial, 5 = very complex)

🧪 Tests: no — No tests were added or modified for the new tool_execution_end handler or the toolsInFlight counter logic.

No significant issues found. LGTM! 🎉

What to expect

Kimchi will analyze the changes in this pull request and post:

  • A summary of the overall changes
  • Inline comments on specific lines with findings categorized by issue type

The review typically completes within a few minutes. This comment will be updated once the review is ready.

Interact with Kimchi
  • @kimchi review — re-trigger a full review on the latest commit
  • @kimchi summary — regenerate the PR summary
  • @kimchi ignore — skip this PR (no review will be posted)
  • Reply to any inline comment to ask follow-up questions or request clarification
Configuration

Reviews are configured by your organization admin.
Review instructions, excluded directories, and severity thresholds can be adjusted per repository in the Kimchi dashboard.


Powered by Kimchi — AI-powered code review by CAST AI

Copy link
Copy Markdown

@kimchi-review kimchi-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Review Score: 90/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 1/5 (1 = trivial, 5 = very complex)

🧪 Tests: no — No tests were added or modified for the new tool_execution_end handler or the toolsInFlight counter logic.

No significant issues found. LGTM! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant