fix: reduce grouped tool refreshes#1512
Conversation
🦋 Changeset detectedLatest commit: 5026e34 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5026e34835
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| tc.setSnapshotListener(() => { | ||
| this.scheduleRender(); | ||
| }); |
There was a problem hiding this comment.
Flush newly attached agents with no phase
When an Agent tool call is grouped before its subagent.spawned event, getSubagentSnapshot().phase is still undefined; the immediate listener callback now goes through scheduleRender(), where detectPhaseTransition() compares undefined to the missing lastFlushPhases entry and returns false. In the existing group path (tryAttachAgentToolCall), no other render is requested for cur.group.attach(...), so the newly attached agent can remain absent/stale until the 200 ms throttle fires; during solo-to-group upgrade it can even render the empty 0 agents finished snapshot produced by transcriptContainer.invalidate(). Keep an immediate first flush for new entries, or treat a missing phase entry as a transition even when the phase is undefined.
Useful? React with 👍 / 👎.
Related Issue
Fixes #1511
Problem
Grouped Agent and Read transcript components were doing redundant component-level refresh work when attaching a borrowed tool-call component. Actual terminal rendering is coalesced by the TUI scheduler, but the group components still rebuilt and requested render more often than needed.
What changed
attach().invalidate()path.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.Verification:
pnpm exec vitest run apps/kimi-code/test/tui/components/messages/agent-group.test.ts apps/kimi-code/test/tui/components/messages/read-group.test.tspnpm exec vitest run apps/kimi-code/test/tui/message-replay.test.tspnpm exec oxlint --type-aware apps/kimi-code/src/tui/components/messages/agent-group.ts apps/kimi-code/src/tui/components/messages/read-group.ts apps/kimi-code/test/tui/components/messages/agent-group.test.ts apps/kimi-code/test/tui/components/messages/read-group.test.tspnpm --filter @moonshot-ai/kimi-code run typecheck