Skip to content

fix(wework): prevent sidebar title refresh rollback - #2548

Merged
qdaxb merged 6 commits into
mainfrom
fix/wework-sidebar-title-refresh-race
Aug 10, 2026
Merged

fix(wework): prevent sidebar title refresh rollback#2548
qdaxb merged 6 commits into
mainfrom
fix/wework-sidebar-title-refresh-race

Conversation

@qdaxb

@qdaxb qdaxb commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

What changed

  • stop runtime stream lifecycle events from refreshing the full sidebar work list
  • update only the affected task execution state in memory
  • preserve model-generated titles over stale in-flight cloud list responses until the local executor confirms them
  • document the runtime sidebar consistency invariant

Root cause

The generated title updated reducer state, but the local runtime-work ref retained the original title. A cloud background request that started earlier later merged from that stale ref and dispatched the full list, temporarily restoring the old title. Start and terminal stream events also triggered extra full-list refreshes, creating more opportunities for the stale snapshot to win.

Validation

  • pnpm --dir wework typecheck
  • pnpm --dir wework lint
  • pnpm --dir wework test (335 files, 3245 tests)
  • focused WorkbenchProvider/runtime stream tests (210 tests)
  • isolated Wework desktop verification with a real local task; sidebar title remained stable after completion
  • pre-push ESLint, TypeScript, and unit-test checks

Summary by CodeRabbit

  • Improvements

    • Runtime task statuses now update immediately as work starts, completes, fails, or is cancelled.
    • Generated task titles remain visible until confirmed by current runtime data.
    • Sidebar work lists stay stable during streaming activity.
    • Board statuses and task titles synchronize with live conversation events.
  • Bug Fixes

    • Prevented stale background data from overwriting newer streamed task titles or execution states.
    • Improved handling of terminal task statuses and stale runtime updates.

@coderabbitai

coderabbitai Bot commented Aug 10, 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: 30 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: 9c2dfb4f-d707-486d-8599-31113fe31cf7

📥 Commits

Reviewing files that changed from the base of the PR and between bda140e and d7bcdc7.

📒 Files selected for processing (2)
  • wework/src/features/workbench/runtimeTaskLifecycle/RuntimeTaskLifecycleStore.test.ts
  • wework/src/features/workbench/runtimeTaskLifecycle/reducer.ts
📝 Walkthrough

Walkthrough

Runtime stream events now update addressed tasks in memory. Runtime-work refreshes no longer run for stream lifecycle events. Local task titles remain visible until matching executor titles confirm them.

Changes

Runtime task synchronization

Layer / File(s) Summary
Runtime task update helpers
wework/src/features/workbench/workbenchRuntimeHelpers.ts, wework/src/features/workbench/workbenchRuntimeHelpers.test.ts
Added immutable task updates by device or remote host and task ID. Added title-update coverage.
Local refresh reconciliation
wework/src/features/workbench/useWorkbenchDataRefresh.ts
Added local title overrides and callbacks for execution-state, snapshot, and title updates. Cloud, bootstrap, and manual refreshes reapply overrides until executor confirmation.
Stale snapshot and lifecycle state handling
wework/src/features/workbench/runtimeTaskLifecycle/*
Added stale snapshot rejection and terminal Goal-status settlement.
Stream lifecycle state wiring
wework/src/features/workbench/WorkbenchProvider.tsx, wework/src/features/workbench/workbenchReducer.ts, wework/src/features/workbench/runtimePaneMessages.ts, wework/src/features/workbench/*test.ts, wework/DESIGN.md
Stream events update task status, running state, and titles without broad work-list refreshes. Tests and runtime guidance cover the behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: micro66

🚥 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 and concisely describes the primary change: preventing stale sidebar title refresh rollbacks 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-sidebar-title-refresh-race

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.

@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

🤖 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/src/features/workbench/WorkbenchProvider.test.tsx`:
- Around line 2728-2735: Update the deferred cloud response in the relevant
WorkbenchProvider test to include runtime-a with the same device and workspace
identity and the stale task title “解决冲突” instead of an empty projects list. Keep
the assertion that “解决分支冲突” remains visible, so the test exercises the
title-conflict handling and stale-response protection.
🪄 Autofix

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: c10e62cb-e0a1-4f03-95e6-a9faabe6df78

📥 Commits

Reviewing files that changed from the base of the PR and between 87598bb and e454290.

📒 Files selected for processing (9)
  • wework/DESIGN.md
  • wework/src/features/workbench/WorkbenchProvider.test.tsx
  • wework/src/features/workbench/WorkbenchProvider.tsx
  • wework/src/features/workbench/runtimePaneMessages.test.ts
  • wework/src/features/workbench/runtimePaneMessages.ts
  • wework/src/features/workbench/useWorkbenchDataRefresh.ts
  • wework/src/features/workbench/workbenchReducer.ts
  • wework/src/features/workbench/workbenchRuntimeHelpers.test.ts
  • wework/src/features/workbench/workbenchRuntimeHelpers.ts
💤 Files with no reviewable changes (1)
  • wework/src/features/workbench/runtimePaneMessages.ts

Comment thread wework/src/features/workbench/WorkbenchProvider.test.tsx
@qdaxb
qdaxb enabled auto-merge August 10, 2026 14:03

@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.

Caution

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

⚠️ Outside diff range comments (1)
wework/src/features/workbench/runtimeTaskLifecycle/reducer.ts (1)

17-36: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Settle execution when the task status is terminal.

If a snapshot has running: true and status: 'complete', Line 17 accepts it because terminal status bypasses stale rejection. Lines 19-36 then set executionPhase to 'running' and clear expectedExecutorRunning. Later identical snapshots keep the completed task running.

Treat a terminal status as idle regardless of running. Clear the turn state in the same branch. Add a regression test for a terminal snapshot that reports running: true.

Proposed fix
+      const isTerminal = isTerminalTaskStatus(event.task.status)
       const shouldIgnoreStaleSnapshot =
         snapshotRunning !== null &&
         expectedRunning !== null &&
         snapshotRunning !== expectedRunning &&
-        (!isTerminalTaskStatus(event.task.status) || hasIdentifiedActiveTurn)
+        (!isTerminal || hasIdentifiedActiveTurn)
       if (shouldIgnoreStaleSnapshot) return state

       const executionPhase =
-        snapshotRunning === null ? state.executionPhase : snapshotRunning ? 'running' : 'idle'
-      const turnPhase = snapshotRunning === false ? 'idle' : state.turnPhase
-      const activeTurnId = snapshotRunning === false ? null : state.activeTurnId
+        isTerminal || snapshotRunning === false
+          ? 'idle'
+          : snapshotRunning === true
+            ? 'running'
+            : state.executionPhase
+      const turnPhase = isTerminal || snapshotRunning === false ? 'idle' : state.turnPhase
+      const activeTurnId = isTerminal || snapshotRunning === false ? null : state.activeTurnId
🤖 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/runtimeTaskLifecycle/reducer.ts` around lines
17 - 36, Update the snapshot handling logic in the reducer branch containing
shouldIgnoreStaleSnapshot so terminal task statuses force executionPhase to
'idle' regardless of snapshotRunning. In the same terminal-status branch, clear
turn state by setting turnPhase to 'idle' and activeTurnId to null, and ensure
repeated terminal snapshots remain settled. Add a regression test covering a
terminal snapshot with running: true.
🤖 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.

Outside diff comments:
In `@wework/src/features/workbench/runtimeTaskLifecycle/reducer.ts`:
- Around line 17-36: Update the snapshot handling logic in the reducer branch
containing shouldIgnoreStaleSnapshot so terminal task statuses force
executionPhase to 'idle' regardless of snapshotRunning. In the same
terminal-status branch, clear turn state by setting turnPhase to 'idle' and
activeTurnId to null, and ensure repeated terminal snapshots remain settled. Add
a regression test covering a terminal snapshot with running: true.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c91786ae-a75f-4114-bbbf-10dad0b1a2d4

📥 Commits

Reviewing files that changed from the base of the PR and between 8067dba and bda140e.

📒 Files selected for processing (7)
  • wework/src/features/workbench/WorkbenchProvider.test.tsx
  • wework/src/features/workbench/WorkbenchProvider.tsx
  • wework/src/features/workbench/runtimeTaskLifecycle/RuntimeTaskLifecycleStore.test.ts
  • wework/src/features/workbench/runtimeTaskLifecycle/RuntimeTaskLifecycleStore.ts
  • wework/src/features/workbench/runtimeTaskLifecycle/reducer.ts
  • wework/src/features/workbench/useWorkbenchDataRefresh.ts
  • wework/src/features/workbench/workbenchReducer.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • wework/src/features/workbench/WorkbenchProvider.tsx
  • wework/src/features/workbench/WorkbenchProvider.test.tsx

@qdaxb
qdaxb added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit aba9712 Aug 10, 2026
47 checks passed
@qdaxb
qdaxb deleted the fix/wework-sidebar-title-refresh-race branch August 10, 2026 15:36
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