Skip to content

fix(wework): keep live reasoning preview visible - #2390

Merged
qdaxb merged 7 commits into
mainfrom
fix/wework-keep-live-reasoning-preview
Aug 3, 2026
Merged

qdaxb merged 7 commits into
mainfrom
fix/wework-keep-live-reasoning-preview

Conversation

@qdaxb

@qdaxb qdaxb commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Keep the latest reasoning summary attached to the active “正在思考” status for the whole running turn
  • Show the same live summary whether the thinking status is below a tool group or below assistant text
  • Remove reasoning processing blocks from the historical timeline and keep them absent after completion
  • Add deterministic desktop E2E coverage for the post-tool waiting state

Root cause

A reasoning item can finish before a tool call while the assistant turn remains active. The UI filtered the completed reasoning block immediately, so the later waiting row fell back to plain “正在思考” even though the latest reasoning summary was still the effective progress description.

The fix derives the latest reasoning summary from the running assistant message and passes it to the existing thinking status row. The turn lifecycle remains the visibility boundary: completion, failure, or cancellation removes the summary.

Impact

  • Running: “正在思考 · 当前 reasoning 摘要”
  • Completed: no reasoning placeholder or reasoning history
  • Tool aggregation behavior is unchanged

Validation

  • 203 focused Wework unit tests passed
  • TypeScript, ESLint, typography, and runtime lifecycle checks passed
  • Real Tauri desktop streaming-text E2E passed
  • Isolated ai:verify displayed “正在思考 · Planning safe file and git inspection” during execution and removed it after completion
  • Full pre-push Wework quality checks passed

Summary by CodeRabbit

  • New Features

    • Added live, readable previews of the assistant’s current reasoning while responses are generated.
    • Improved thinking indicators with concise, cleaned-up previews of the latest reasoning segment.
    • Retained the latest reasoning summary in tool activity displays after tool completion.
  • Bug Fixes

    • Reasoning previews now disappear when final assistant text begins streaming.
    • Improved synchronization across streaming responses and tool follow-ups for more consistent status updates.
    • Updated visual verification coverage for the revised thinking flow.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@qdaxb, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 91de9b96-0976-4f81-841e-8efb4d2d72ab

📥 Commits

Reviewing files that changed from the base of the PR and between 2428eeb and 17b0a95.

📒 Files selected for processing (6)
  • packages/chat-core/src/index.ts
  • packages/chat-core/src/workbench-message-reducer.ts
  • wework/e2e/desktop/scenarios/streaming-text.scenario.mjs
  • wework/src/components/chat/MessageList.tsx
  • wework/src/features/workbench/runtimeConversationTurns.test.ts
  • wework/src/features/workbench/runtimeConversationTurns.ts
📝 Walkthrough

Walkthrough

The chat now tracks streaming reasoning content across reducer and runtime state. MessageList displays it through AssistantThinkingIndicator in assistant and tool-processing rows. End-to-end tests synchronize tool completion with reasoning and final-text verification.

Changes

Streaming reasoning preview

Layer / File(s) Summary
Reasoning state propagation and lifecycle
packages/chat-core/src/workbench-message-reducer.ts, packages/chat-core/src/workbench-message-reducer.test.ts, wework/src/features/workbench/runtimeConversationTurns.ts, wework/src/features/workbench/runtimeConversationTurns.test.ts, wework/src/types/workbench.ts
Messages and runtime turns derive, preserve, expose, and clear streamingThinkingContent across assistant, tool, completion, cancellation, and error events.
Dynamic assistant and tool indicators
wework/src/components/chat/AssistantThinkingIndicator.tsx, wework/src/components/chat/MessageList.tsx, wework/src/components/chat/blocks/ToolBlocksDisplay.tsx, wework/src/components/chat/blocks/ToolBlockItem.tsx, wework/src/components/chat/MessageList.test.tsx, wework/src/components/chat/blocks/ToolBlocksDisplay.test.tsx, wework/src/components/chat/blocks/ToolBlockItem.test.tsx
The UI sanitizes and truncates reasoning previews. MessageList routes active reasoning to assistant and tool rows. Tool blocks no longer render separate thinking previews.
Tool-output verification synchronization
wework/e2e/desktop/scenarios/streaming-text.scenario.mjs
The scenario accepts custom completion text, coordinates tool follow-up and final completion promises, validates reasoning visibility during streaming, and updates screenshot names.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ToolOutputHandler
  participant VerificationFlow
  participant AssistantThinkingIndicator
  ToolOutputHandler->>VerificationFlow: signal tool follow-up receipt
  VerificationFlow->>AssistantThinkingIndicator: validate reasoning preview
  VerificationFlow->>ToolOutputHandler: release tool completion
  ToolOutputHandler->>VerificationFlow: signal final text streaming
  VerificationFlow->>ToolOutputHandler: release final completion
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving the live reasoning preview in Wework.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wework-keep-live-reasoning-preview

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qdaxb
qdaxb marked this pull request as ready for review August 3, 2026 12:18

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@wework/e2e/desktop/scenarios/streaming-text.scenario.mjs`:
- Line 702: Bound the tool follow-up wait at await toolFollowUpReceived by
reusing the existing Promise.race timeout pattern from requestReceived and the
shared 10-second step timeout. Ensure timeout rejection releases
toolCompletionRelease and produces a focused failure instead of waiting for the
outer CI timeout.

In `@wework/src/components/chat/AssistantThinkingIndicator.tsx`:
- Around line 39-41: Update the preview truncation logic in
AssistantThinkingIndicator so the returned string, including the ellipsis, never
exceeds THINKING_PREVIEW_MAX_LENGTH. When truncating, slice only up to the
maximum length minus the ellipsis length, while preserving the existing
untruncated behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a0d9f574-8bc4-494b-bc31-bc828956dcc9

📥 Commits

Reviewing files that changed from the base of the PR and between 29ab1a5 and 364e31c.

📒 Files selected for processing (8)
  • wework/e2e/desktop/scenarios/streaming-text.scenario.mjs
  • wework/src/components/chat/AssistantThinkingIndicator.tsx
  • wework/src/components/chat/MessageList.test.tsx
  • wework/src/components/chat/MessageList.tsx
  • wework/src/components/chat/blocks/ToolBlockItem.test.tsx
  • wework/src/components/chat/blocks/ToolBlockItem.tsx
  • wework/src/components/chat/blocks/ToolBlocksDisplay.test.tsx
  • wework/src/components/chat/blocks/ToolBlocksDisplay.tsx
💤 Files with no reviewable changes (1)
  • wework/src/components/chat/blocks/ToolBlockItem.test.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
wework/src/features/workbench/runtimeConversationTurns.ts (2)

94-99: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

assistant_cached does not clear streamingThinkingContent, unlike its counterpart.

This handler updates items and sets status: 'streaming', but it never resets streamingThinkingContent. The counterpart assistant_cached case in packages/chat-core/src/workbench-message-reducer.ts (line 256) explicitly clears the equivalent field for the same action type, per that file's own change notes ("Cached assistant responses now clear any stale streaming thinking content"). Because the turn's status stays 'streaming' after this action, a thinking summary computed from an earlier phase of the turn can remain attached to the freshly cached content until the next chunk or completion event overwrites it.

🐛 Proposed fix to clear the stale summary
 case 'assistant_cached':
   return updateTurn(turns, action.subtaskId, turn => ({
     ...turn,
     items: upsertBlocks(turn.items, action.blocks),
     status: 'streaming',
+    streamingThinkingContent: undefined,
   }))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wework/src/features/workbench/runtimeConversationTurns.ts` around lines 94 -
99, Update the assistant_cached handler in the runtime conversation turn reducer
to clear streamingThinkingContent while preserving its existing items upsert and
streaming status behavior. Match the equivalent assistant_cached handling in
workbench-message-reducer.ts so stale thinking content is removed when cached
assistant content is applied.

232-255: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Recompute streamingThinkingContent from the merged turn items.

When snapshot.status is streaming and assistant text has not changed, this merge can add newer blocks such as tools or thinking without changing assistant text. Keeping local.streamingThinkingContent can surface an outdated summary while items already has the newer content, so derive streamingThinkingContent from items instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wework/src/features/workbench/runtimeConversationTurns.ts` around lines 232 -
255, Update mergeRuntimeConversationTurn so the preserveStreamingThinking branch
derives streamingThinkingContent from the merged items value rather than reusing
local.streamingThinkingContent; keep snapshot.streamingThinkingContent for the
non-preserving branch.
🧹 Nitpick comments (1)
packages/chat-core/src/workbench-message-reducer.ts (1)

1020-1034: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Consolidate the streamed thinking-content derivation. packages/chat-core/src/workbench-message-reducer.ts and wework/src/features/workbench/runtimeConversationTurns.ts keep duplicate assistant_chunk summary logic that can diverge. Use one shared helper for the active thinking summary instead of maintaining both paths.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/chat-core/src/workbench-message-reducer.ts` around lines 1020 -
1034, Consolidate the duplicate assistant_chunk thinking-summary logic by
extracting or reusing one shared helper for the active thinking content. Update
getStreamingThinkingContent in
packages/chat-core/src/workbench-message-reducer.ts and the corresponding logic
at wework/src/features/workbench/runtimeConversationTurns.ts:621-630 to delegate
to that helper, preserving the existing reasoningChunk, content, tool-block, and
streaming fallback behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@wework/e2e/desktop/scenarios/streaming-text.scenario.mjs`:
- Line 735: After releaseToolFinalCompletion() in the streaming scenario, wait
for the observable completed-turn state—specifically the enabled send button
used later—before taking the snapshot and performing the final-processing-toggle
click. Keep the existing final assertions unchanged once completion is
confirmed.

---

Outside diff comments:
In `@wework/src/features/workbench/runtimeConversationTurns.ts`:
- Around line 94-99: Update the assistant_cached handler in the runtime
conversation turn reducer to clear streamingThinkingContent while preserving its
existing items upsert and streaming status behavior. Match the equivalent
assistant_cached handling in workbench-message-reducer.ts so stale thinking
content is removed when cached assistant content is applied.
- Around line 232-255: Update mergeRuntimeConversationTurn so the
preserveStreamingThinking branch derives streamingThinkingContent from the
merged items value rather than reusing local.streamingThinkingContent; keep
snapshot.streamingThinkingContent for the non-preserving branch.

---

Nitpick comments:
In `@packages/chat-core/src/workbench-message-reducer.ts`:
- Around line 1020-1034: Consolidate the duplicate assistant_chunk
thinking-summary logic by extracting or reusing one shared helper for the active
thinking content. Update getStreamingThinkingContent in
packages/chat-core/src/workbench-message-reducer.ts and the corresponding logic
at wework/src/features/workbench/runtimeConversationTurns.ts:621-630 to delegate
to that helper, preserving the existing reasoningChunk, content, tool-block, and
streaming fallback behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 29926eb5-814c-4f3b-a0f4-7f7304de865a

📥 Commits

Reviewing files that changed from the base of the PR and between 364e31c and e767d71.

📒 Files selected for processing (8)
  • packages/chat-core/src/workbench-message-reducer.test.ts
  • packages/chat-core/src/workbench-message-reducer.ts
  • wework/e2e/desktop/scenarios/streaming-text.scenario.mjs
  • wework/src/components/chat/MessageList.test.tsx
  • wework/src/components/chat/MessageList.tsx
  • wework/src/features/workbench/runtimeConversationTurns.test.ts
  • wework/src/features/workbench/runtimeConversationTurns.ts
  • wework/src/types/workbench.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • wework/src/components/chat/MessageList.tsx
  • wework/src/components/chat/MessageList.test.tsx

@qdaxb
qdaxb enabled auto-merge August 3, 2026 13:44
@qdaxb
qdaxb added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit c14d0a9 Aug 3, 2026
47 checks passed
@qdaxb
qdaxb deleted the fix/wework-keep-live-reasoning-preview branch August 3, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant