fix(tui): bound the reasoning stream to a tail and skip it when collapsed - #1375
Conversation
…psed StreamingReasoning re-wrapped the entire accumulated reasoning string on every token flush, and paid that cost plus calculateTokens even while collapsed - the default - where nothing below the header renders. It now reuses computeStreamingTail, the bounded-tail helper StreamingMessage already had, and skips the wrap and the token count entirely when collapsed. Measured over 30 flushes of a ~150KB trace: 91.9ms to 11.6ms per flush collapsed, 99.2ms to 25.2ms expanded. Closes Nano-Collective#1329.
nc-review: nothing to raise@addyCooks — nothing to raise from the automated review. The PR ports the bounded-tail wrap pattern from 🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
|
Great work @addyCooks :) |
|
Thanks @will-lamerton : ) |
Closes #1329
Description
StreamingReasoningcalledwrapWithTrimmedContinuations(reasoning.trimEnd(), textWidth)on the entire accumulated reasoning string on every token flush, with no bound and no early exit.StreamingMessagealready solved this withcomputeStreamingTail; the reasoning component never adopted it. Worse,reasoningExpandeddefaults tofalse, so the full re-wrap pluscalculateTokensran on every flush for a panel that renders nothing.Fix:
computeStreamingTail(already exported fromstreaming-message.tsx) so each flush is O(tail) rather than O(history).expand === false.No new helper and no new file the bounded-tail logic stays in one place.
Measured, 30 flushes over a ~150KB trace (same shape as the harness in the issue):
Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Manual Testing
Checklist