fix(shell): show active agent task count in prompt status bar#2041
fix(shell): show active agent task count in prompt status bar#2041
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the shell prompt status bar to reflect background work more accurately during multi-agent runs by showing separate counts for background bash tasks and background agent tasks.
Changes:
- Introduces
BgTaskCountsand changes the prompt session’s background-task provider from a singleintto(bash, agent)counts. - Renders up to two badges (
⚙ bash: N,⚙ agent: N) with overflow behavior that prefers keeping the bash badge. - Updates/extends prompt-toolbar tests and adds changelog entries (root + synced docs).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/kimi_cli/ui/shell/prompt.py |
Adds BgTaskCounts, updates provider type, and renders separate bash/agent badges in the toolbar. |
src/kimi_cli/ui/shell/__init__.py |
Updates background task counting logic to return BgTaskCounts (bash + agent) with a 1s cache. |
tests/ui_and_conv/test_prompt_tips.py |
Updates existing stub and adds regression tests for both badges, agent-only, and narrow-width behavior. |
CHANGELOG.md |
Adds an Unreleased entry describing the new agent badge in the status bar. |
docs/en/release-notes/changelog.md |
Synced changelog entry for the new status bar badges. |
docs/zh/release-notes/changelog.md |
Adds the corresponding zh changelog entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for kind_label, kind_count in (("bash", bg_counts.bash), ("agent", bg_counts.agent)): | ||
| if kind_count <= 0: | ||
| continue | ||
| bg_text = f"⚙ {kind_label}: {kind_count}" | ||
| bg_width = _display_width(bg_text) | ||
| if remaining >= bg_width + 2: | ||
| fragments.extend([(tc.bg_tasks, bg_text), ("", " ")]) | ||
| remaining -= bg_width + 2 | ||
| if remaining < bg_width + 2: | ||
| break | ||
| fragments.extend([(tc.bg_tasks, bg_text), ("", " ")]) |
| # With only ~width budget for one badge after CWD/mode, keeping bash and | ||
| # dropping agent is the documented priority. | ||
| prompt_session = _make_toolbar_session(tips=[]) | ||
| prompt_session._background_task_count_provider = lambda: BgTaskCounts(bash=5, agent=5) | ||
|
|
||
| lines = _render_toolbar_lines(prompt_session, 40, monkeypatch) | ||
|
|
||
| # Must never overflow and the bash badge is preferred over the agent badge. | ||
| assert _display_width(lines[1]) <= 40 | ||
| if "⚙ agent" in lines[1]: | ||
| # Only acceptable if bash also fit — otherwise priority is violated. | ||
| assert "⚙ bash" in lines[1], ( | ||
| f"agent badge appeared without bash badge at narrow width: {lines[1]!r}" | ||
| ) |
The existing `⚙ bash: N` badge only counted background Shell tasks and filtered out background Agent subagents, so when many subagents were running the prompt looked idle and users could not tell work was in progress. The toolbar now renders `⚙ bash: N` and `⚙ agent: N` as two independent badges (each hidden when its count is 0) and drops the agent badge first when the terminal is too narrow to fit both.
002a5c8 to
54abb59
Compare
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |

Related Issue
Related to #1768 — users report multi-agent runs making the CLI feel stalled. This PR doesn't fix the underlying provider-saturation behavior described there, but it addresses one clear symptom: when many background
Agentsubagents are running, the prompt status bar gives no indication that work is in progress, making the CLI look frozen.Description
The existing
⚙ bash: Nbadge (introduced in #1477) counts onlyShell(run_in_background=true)tasks —_bg_task_countinsrc/kimi_cli/ui/shell/__init__.py:430explicitly filters withv.spec.kind == ""bash"". When a root agent dispatches many backgroundAgentsubagents, the prompt shows no count and no hint, so the user reasonably concludes the shell has frozen.Change
Render two independent badges side by side:
_bg_task_count→_bg_task_counts, now returns a frozenBgTaskCounts(bash, agent)dataclass.CustomPromptSessionchanges fromCallable[[], int]toCallable[[], BgTaskCounts].prompt.pywalks(bash, agent)in order: each kind only renders when its count > 0 and there's room left; if space runs out after renderingbash, theagentbadge is dropped (preserves the existing overflow priority).BgTaskCountsis exported fromkimi_cli.ui.shell.promptfor reuse in tests.No changes to task manager, agent runner, or notification paths — this is purely a UI surface change.
Tests
lambda: 2stub intests/ui_and_conv/test_prompt_tips.pyto the new shape.2552 passed, 9 skipped, 1 xfailed(+52 passed, 4 skippede2e).make check-kimi-clireports 0 errors introduced by this PR.Checklist
make gen-changelogequivalent — Unreleased entries added manually toCHANGELOG.mdanddocs/zh/release-notes/changelog.md, with the EN docs synced vianode docs/scripts/sync-changelog.mjs.I have runN/A — no user-facing docs reference themake gen-docsto update the user documentation.⚙ bash:/⚙ agent:status bar badges (grep ofdocs/en,zh/**confirms only MCP, YOLO, plan, display_name badges are documented).