Skip to content

fix(desktop): prevent thinking block from closing mid-streaming - #38809

Merged
ethernet8023 merged 1 commit into
NousResearch:mainfrom
stremtec:fix/desktop-thinking-block-close-streaming
Jun 5, 2026
Merged

fix(desktop): prevent thinking block from closing mid-streaming#38809
ethernet8023 merged 1 commit into
NousResearch:mainfrom
stremtec:fix/desktop-thinking-block-close-streaming

Conversation

@stremtec

@stremtec stremtec commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a bug where the Thinking/Reasoning disclosure block auto-closes while reasoning text is still actively streaming. Reported as: block closes suddenly when thinking text gets long enough, during active streaming.

Root Cause

ReasoningAccordionGroup checks whether any reasoning part in a fixed range [startIndex, endIndex) is still pending:

s.message.parts
  .slice(startIndex, Math.min(s.message.parts.length, endIndex))
  .some(p => p?.type === 'reasoning' && p.status?.type !== 'complete')

During streaming, new reasoning parts can be appended to s.message.parts beyond endIndex (which was fixed at component mount time). When the original part completes and a new part starts beyond the range, .some() returns false → pending = false → block closes.

Fix

Remove the endIndex cap from slice() — check all parts from startIndex onward:

s.message.parts
  .slice(Math.max(0, startIndex))  // no endIndex cap
  .some(p => p?.type === 'reasoning' && p.status?.type !== 'complete')

Since startIndex still scopes to this reasoning group's beginning, and the p?.type === 'reasoning' filter excludes non-reasoning parts (tool calls, etc.), removing the end bound is safe — newly appended reasoning parts are now correctly detected.

Verification

  • TypeScript compiles cleanly
  • Existing behavior unchanged when no new parts are appended

When reasoning text grows during streaming, new parts can be appended
beyond endIndex.  The pending check used slice(startIndex, endIndex)
which excluded these new parts — if the original part completed, the
block would close while new reasoning was still streaming.

Fix: remove the endIndex cap from slice() so all parts from startIndex
onward are checked.  During non-streaming, the array is stable and
all parts are within range anyway.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Jun 4, 2026
@stremtec stremtec changed the title fix(desktop): prevent thinking block from closing mid-streaming fix(desktop): thinking block close mid-streaming + token-settle animation Jun 4, 2026
@stremtec
stremtec force-pushed the fix/desktop-thinking-block-close-streaming branch from 4e3170d to ead63ae Compare June 4, 2026 07:34
@stremtec stremtec changed the title fix(desktop): thinking block close mid-streaming + token-settle animation fix(desktop): prevent thinking block from closing mid-streaming Jun 4, 2026
@ethernet8023
ethernet8023 merged commit ea44011 into NousResearch:main Jun 5, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants