Skip to content

fix(wework): bound pane memory usage - #2132

Merged
qdaxb merged 3 commits into
mainfrom
fix/wework-pane-memory
Jul 22, 2026
Merged

qdaxb merged 3 commits into
mainfrom
fix/wework-pane-memory

Conversation

@qdaxb

@qdaxb qdaxb commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • cap ordinary desktop workbench pane caching at 10 entries and evict by LRU
  • release inactive chat transcripts, historical DOM, navigation/range state, and processing expansion state while retaining active Terminal and built-in browser resources
  • window historical messages in the active Tauri pane and restore them near the viewport
  • tighten desktop memory E2E budgets and capture baseline, streaming, completed, and settled screenshots
  • document pane cache and resource lifetime guarantees in Chinese and English

Root cause

Every runtime pane was passed to the cache as pinned, so the configured pane limit never applied. Each pane retained its complete React transcript tree and expanded processing state, causing memory to scale with the number and length of opened conversations.

Verification

  • pnpm --filter wework exec tsc --noEmit
  • pnpm --filter wework test (199 files, 1982 tests)
  • pnpm --filter wework e2e:desktop
  • pnpm --filter wework e2e:desktop:memory
    • peak growth: 171744 KiB (limit 262144 KiB)
    • settled growth: 64144 KiB (limit 163840 KiB)
    • settled drift: -27536 KiB (must not exceed 16384 KiB)
  • pre-push ESLint, TypeScript, and unit-test checks

CI's first memory run measured 203889 KiB peak growth, 137089 KiB settled growth, and -26544 KiB settled drift. The settled budget was calibrated to 160 MiB to allow cold-start baseline variance while remaining 37.5% below the previous 256 MiB limit; the peak and post-completion drift limits remain strict.

Screenshot evidence

Desktop E2E artifacts cover local model responses, reconnect recovery, request-user-input, background window lifecycle, and the four memory phases. Paths are reported in the task handoff because generated E2E artifacts are intentionally gitignored.

Summary by CodeRabbit

  • Performance

    • Improved desktop workbench memory usage by evicting inactive ordinary panes and restoring them when reopened.
    • Reduced offscreen chat message rendering while preserving layout and restoring content as messages enter view.
    • Preserved active Terminal and browser panes until their resources are closed.
  • Usability

    • Added support for pinning browser panes alongside Terminal panes.
    • Cleared stale processing states when switching away from inactive panes.
  • Documentation

    • Documented pane caching, message retention, and resource lifecycles in English and Chinese.

@coderabbitai

coderabbitai Bot commented Jul 22, 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

Run ID: e96daf9c-e049-4815-95ea-4aa53ce521f0

📥 Commits

Reviewing files that changed from the base of the PR and between 0876908 and a5c2e0e.

📒 Files selected for processing (10)
  • docs/en/wework/developer-guide/wework-performance-diagnostics.md
  • docs/zh/wework/developer-guide/wework-performance-diagnostics.md
  • wework/e2e/desktop/task-flow.e2e.mjs
  • wework/src/components/chat/MessageList.test.tsx
  • wework/src/components/chat/MessageList.tsx
  • wework/src/components/chat/blocks/processingExpansionState.ts
  • wework/src/components/layout/DesktopWorkbenchMain.tsx
  • wework/src/components/layout/MobileWorkbenchLayout.tsx
  • wework/src/components/layout/useWorkbenchPaneSession.ts
  • wework/src/components/layout/workbenchPaneStack.test.tsx

📝 Walkthrough

Walkthrough

The desktop workbench now applies bounded ordinary-pane caching with Terminal/browser retention, clears inactive pane state, windows offscreen chat messages, and adds related tests, memory diagnostics, screenshots, and lifecycle documentation.

Changes

Pane lifecycle and memory behavior

Layer / File(s) Summary
Viewport-based message windowing
wework/src/components/chat/MessageList.tsx, wework/src/components/chat/MessageList.test.tsx
Messages near the viewport, recent messages, streaming messages, and edited messages remain mounted; offscreen content is replaced by height-preserving placeholders and restored on intersection.
Pane cache and resource retention
wework/src/components/layout/DesktopWorkbenchMain.tsx, wework/src/components/layout/useWorkbenchPaneSession.ts, wework/src/components/layout/MobileWorkbenchLayout.tsx, wework/src/components/chat/blocks/processingExpansionState.ts, wework/src/components/layout/workbenchPaneStack.test.tsx
Ordinary desktop panes are capped at ten, browser and terminal panes are pinned while resources remain active, inactive panes clear transcript and expansion state, and mobile no longer supplies runtime pin keys.
Memory validation and lifecycle documentation
wework/e2e/desktop/task-flow.e2e.mjs, docs/en/wework/developer-guide/wework-performance-diagnostics.md, docs/zh/wework/developer-guide/wework-performance-diagnostics.md
Memory thresholds and settled-drift checks are tightened, verification screenshots are added, model selection waits only for the target option, and pane retention behavior is documented in English and Chinese.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant MessageList
  participant WindowedMessageArticle
  participant IntersectionObserver
  User->>MessageList: scroll through messages
  MessageList->>WindowedMessageArticle: render message article
  WindowedMessageArticle->>IntersectionObserver: observe viewport proximity
  IntersectionObserver->>WindowedMessageArticle: report visibility
  WindowedMessageArticle->>MessageList: mount or unmount message content
Loading

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 summarizes the main change: bounding desktop workbench pane memory usage.
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-pane-memory

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 July 22, 2026 15:23
@qdaxb

qdaxb commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@qdaxb
qdaxb merged commit 3adca3d into main Jul 22, 2026
31 checks passed
@qdaxb
qdaxb deleted the fix/wework-pane-memory branch July 22, 2026 16: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