Repository navigation
perf(tui): cap subagent card wrapping to the tail - #4507
Conversation
🦋 Changeset detectedLatest commit: 5ab295c 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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e5be8f686d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let end = text.length; | ||
| for (let seen = 0; seen < maxLines; seen++) { | ||
| const start = text.lastIndexOf('\n', end - 1); | ||
| if (start === -1) return text; |
There was a problem hiding this comment.
Bound long logical lines before wrapping
When a long-running foreground subagent streams a thinking or answer paragraph with fewer than eight \n characters, this branch returns the entire accumulated buffer. PrefixedWrappedLine.render() then still calls Text.render() on all of it for every new frame, so wrapping cost and input latency continue growing with total output—the exact #4506 failure this commit is meant to bound. Retain incremental wrap state or otherwise bound the final logical line as well.
Useful? React with 👍 / 👎.
| const start = text.lastIndexOf('\n', end - 1); | ||
| if (start === -1) return text; | ||
| end = start; |
There was a problem hiding this comment.
Preserve leading newlines in short tails
When content begins with \n and contains fewer than maxLines separators (for example, \nanswer), reaching end === 0 makes the next lastIndexOf(..., -1) search index 0 again, so the same newline is counted repeatedly and the returned suffix drops it. In the two-row active window, the previous blank-first/answer-second layout becomes answer-first/padding-second even though the PR declares rows unchanged; stop before another lookup at end === 0.
AGENTS.md reference: AGENTS.md:L113-L113
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee75b3aa67
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
ee75b3a to
51dae62
Compare
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51dae62ada
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
fd470c3 to
731453b
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 731453b93a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- keep only the trailing slice of streamed subagent text for display - trim on append so wrapping cost no longer grows with the run - trim at a line boundary so the remaining rows keep their wrapping - cap the result summary and the failure text the same way Verified: pnpm --filter @moonshot-ai/kimi-code run typecheck (exit 0); 25 TUI test files / 551 tests passed; per-delta append + render stays ~0.1 ms at 1M chars; multi-line output renders byte-identically manual: 2h fullscreen subagent run stayed responsive
731453b to
5ab295c
Compare
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ 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". |
|
Thanks for the fix! |
Requirement or Bug
Resolve #4506
Bug Reproduction Steps
Long foreground subagent in fullscreen mode makes input latency grow over time;
backgrounding it (Ctrl+B) restores responsiveness.
Root Cause
The subagent card shows a fixed two-row window, but every streamed delta was
kept in an unbounded string and the whole accumulation was wrapped on each
frame before all but the last two rows were discarded. Frame cost therefore grew
with the run's total output. This is a fundamental fix, not a workaround: the
retained text is bounded, so wrapping a frame no longer depends on run length.
Code Changes
line: the retained lines then wrap exactly as they would unbounded
without their opener
at a terminal state, and their first line is what the grouped card shows
trailing-blank and ANSI-tail cases
Behavior Changes and Affected Users
Multi-line output renders exactly as before, including output past the cap. When
the retained slice ends in a single over-long line (or one long line followed by
a short one), that partial line is kept so the newest text is visible; the row
it occupies can then carry a different number of characters than the unbounded
render, because the line's start is no longer retained. Control sequences inside
the retained slice are dropped; the card applies its own styling and the
streamed subagent text is plain model output. No config, wire format or
persisted data changes; the full text remains in the session events.
Verification
pnpm --filter @moonshot-ai/kimi-code run typecheck-> exit 0vitest run test/tui/components/messages/tool-call.test.ts test/tui/components/messages/agent-group.test.ts-> 154 passedvitest run test/tui/components/messages test/tui/tasks-browser.test.ts-> 555 passedChecklist
/approve). Linked Fullscreen TUI gets progressively slower while a foreground subagent runs #4506; the issue awaits a maintainer's/approve.gen-changesetsskill, or this PR needs no changeset. (Added a patch changeset for@moonshot-ai/kimi-code.)gen-docsskill, or this PR needs no doc update.