Skip to content

fix(wework): restore workspace panes across task switches - #2428

Merged
qdaxb merged 3 commits into
mainfrom
fix/wework-workspace-preview-restore
Aug 5, 2026
Merged

fix(wework): restore workspace panes across task switches#2428
qdaxb merged 3 commits into
mainfrom
fix/wework-workspace-preview-restore

Conversation

@qdaxb

@qdaxb qdaxb commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Preserve the selected file together with its actual workspace target when switching runtime tasks.
  • Preserve loaded review state, including the selected review mode and diff, and restart an in-flight review load after restoration.
  • Extend the existing CI-covered conversation-state desktop checkpoint to verify file preview, review, browser, and terminal isolation/restoration across task switches.
  • Document the right-workspace restoration contract in Chinese and English.

Root cause

The per-pane restorable workspace state stored only a derived file target key and did not store review state. An absolute file opened from an assistant message could therefore fall back to the task workspace when its pane was restored, while the review panel returned without its loaded diff or mode.

The existing desktop E2E checkpoint covered browser and terminal resources across task switches, but it closed the file preview before switching tasks and did not open or assert the review panel. The regression therefore remained outside its assertions.

Impact

Returning to a Wework runtime task now restores the same file preview and review content that was open before switching away, without leaking those resources into another task.

Validation

  • pnpm --filter wework exec vitest run src/components/layout/DesktopWorkbenchLayout.test.tsx -t "preserves (the open file|an absolute file opened from a message|the review) when switching runtime tasks"
  • pnpm --filter wework exec tsc --noEmit --pretty false
  • pnpm --filter wework exec eslint src/components/layout/DesktopWorkbenchMain.tsx src/components/layout/DesktopWorkbenchLayout.test.tsx e2e/desktop/task-flow.e2e.mjs
  • pnpm --filter wework exec prettier --check src/components/layout/DesktopWorkbenchMain.tsx src/components/layout/DesktopWorkbenchLayout.test.tsx e2e/desktop/task-flow.e2e.mjs
  • pnpm --filter wework e2e:desktop -- --segment conversation-state
  • Pre-push Wework ESLint, TypeScript, and full unit-test suite

Summary by CodeRabbit

  • New Features

    • Conversation switching restores selected files, including files outside the active workspace.
    • Review tabs restore their selected scope and previously loaded differences.
    • Browser, terminal, file preview, and review resources remain associated with the correct task.
  • Bug Fixes

    • Prevented files and review content from leaking between conversations.
    • Restored workspace state without unnecessary reloads.
  • Documentation

    • Updated English and Chinese workbench documentation to describe resource restoration.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c5db8f57-01e3-4933-adbc-9758f0fa9ed5

📥 Commits

Reviewing files that changed from the base of the PR and between 7206d1e and 555156c.

📒 Files selected for processing (1)
  • wework/e2e/desktop/task-flow.e2e.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • wework/e2e/desktop/task-flow.e2e.mjs

📝 Walkthrough

Walkthrough

The desktop workbench now persists selected file targets and review state across runtime-task switches. Tests verify file-preview and review restoration, task isolation, and reload behavior. Documentation describes the restored Files and Review tab state.

Changes

Workspace restoration

Layer / File(s) Summary
Persist workspace resource state
wework/src/components/layout/DesktopWorkbenchMain.tsx
Pane state now includes review state. Selected files store full WorkspaceTarget objects. File target matching uses device and path.
Restore reviews and validate task switching
wework/src/components/layout/DesktopWorkbenchMain.tsx, wework/src/components/layout/DesktopWorkbenchLayout.test.tsx
Previously loading reviews reload their diffs. Tests verify absolute file and review restoration without unnecessary reloads.
Verify and document restored resources
wework/e2e/desktop/task-flow.e2e.mjs, docs/en/wework/workbench.md, docs/zh/wework/workbench.md
End-to-end coverage verifies task isolation, file-preview restoration, review restoration, and resource-tab persistence. Documentation describes the restored state.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DesktopWorkbenchMain
  participant WorkspaceTabs
  participant ReviewPanel
  User->>DesktopWorkbenchMain: switch runtime task
  DesktopWorkbenchMain->>WorkspaceTabs: restore file target and review state
  WorkspaceTabs->>ReviewPanel: reload previously loading diff
  ReviewPanel-->>WorkspaceTabs: return review content
  WorkspaceTabs-->>User: display restored file and review tabs
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 restoring workspace panes when switching between runtime tasks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 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-workspace-preview-restore

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 5, 2026 04:37

@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/e2e/desktop/task-flow.e2e.mjs`:
- Around line 13946-13948: After the task switch performed by
control.command('click', `[data-testid="${secondTaskRowTestId}"]`), resolve the
currently selected workspace tab again instead of reusing
activeTaskWorkbenchSelector. Build a selector for the second task workbench from
that newly selected tab, then pass it to the snapshot command used to create
secondTaskWorkspaceSnapshot.
🪄 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: ce72d29f-cd76-4abe-a3b6-d70cfb7da9e1

📥 Commits

Reviewing files that changed from the base of the PR and between b930db5 and 12dbe99.

📒 Files selected for processing (5)
  • docs/en/wework/workbench.md
  • docs/zh/wework/workbench.md
  • wework/e2e/desktop/task-flow.e2e.mjs
  • wework/src/components/layout/DesktopWorkbenchLayout.test.tsx
  • wework/src/components/layout/DesktopWorkbenchMain.tsx

Comment on lines 13946 to +13948
await control.command('click', `[data-testid="${secondTaskRowTestId}"]`)
const secondTaskWorkspaceSnapshot = JSON.parse(
await control.command('snapshot', ACTIVE_WORKBENCH_SELECTOR)
await control.command('snapshot', activeTaskWorkbenchSelector)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Snapshot the second task workbench after the task switch.

activeTaskWorkbenchSelector still identifies the first task tab. Line 13948 therefore snapshots the first task after Line 13946 selects the second task. The following assertions cannot detect resources that leak into the second task.

Resolve the selected workspace tab again after the switch. Build a second-task selector from that tab before taking the snapshot.

Proposed fix
 await control.command('click', `[data-testid="${secondTaskRowTestId}"]`)
+await control.command('waitFor', activeWorkspaceTabSelector, {
+  timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
+})
+const secondTaskWorkspaceTabTestId = await control.command(
+  'getAttribute',
+  activeWorkspaceTabSelector,
+  { value: 'data-testid' }
+)
+const secondTaskWorkspaceTabId = secondTaskWorkspaceTabTestId.replace(
+  'workspace-tab-select-',
+  ''
+)
+const secondTaskWorkbenchSelector =
+  `[data-testid="workspace-tab-content-${secondTaskWorkspaceTabId}"] ` +
+  '[data-testid="desktop-workbench-main"]'
 const secondTaskWorkspaceSnapshot = JSON.parse(
-  await control.command('snapshot', activeTaskWorkbenchSelector)
+  await control.command('snapshot', secondTaskWorkbenchSelector)
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await control.command('click', `[data-testid="${secondTaskRowTestId}"]`)
const secondTaskWorkspaceSnapshot = JSON.parse(
await control.command('snapshot', ACTIVE_WORKBENCH_SELECTOR)
await control.command('snapshot', activeTaskWorkbenchSelector)
await control.command('click', `[data-testid="${secondTaskRowTestId}"]`)
await control.command('waitFor', activeWorkspaceTabSelector, {
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
})
const secondTaskWorkspaceTabTestId = await control.command(
'getAttribute',
activeWorkspaceTabSelector,
{ value: 'data-testid' }
)
const secondTaskWorkspaceTabId = secondTaskWorkspaceTabTestId.replace(
'workspace-tab-select-',
''
)
const secondTaskWorkbenchSelector =
`[data-testid="workspace-tab-content-${secondTaskWorkspaceTabId}"] ` +
'[data-testid="desktop-workbench-main"]'
const secondTaskWorkspaceSnapshot = JSON.parse(
await control.command('snapshot', secondTaskWorkbenchSelector)
🤖 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/e2e/desktop/task-flow.e2e.mjs` around lines 13946 - 13948, After the
task switch performed by control.command('click',
`[data-testid="${secondTaskRowTestId}"]`), resolve the currently selected
workspace tab again instead of reusing activeTaskWorkbenchSelector. Build a
selector for the second task workbench from that newly selected tab, then pass
it to the snapshot command used to create secondTaskWorkspaceSnapshot.

@qdaxb
qdaxb added this pull request to the merge queue Aug 5, 2026
Merged via the queue into main with commit 5064867 Aug 5, 2026
45 checks passed
@qdaxb
qdaxb deleted the fix/wework-workspace-preview-restore branch August 5, 2026 07:18
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