Skip to content

perf(renderer): scope editor Git subscriptions by worktree - #8107

Merged
nwparker merged 1 commit into
mainfrom
nwparker/renderer-perf-15
Jul 10, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/renderer-perf-15

Conversation

@nwparker

@nwparker nwparker commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Scope each mounted editor pane to the Git status and branch-change arrays for its active worktree.
  • Thread those scoped entries through editor content state and render-model code without changing active-worktree behavior.
  • Add selector coverage proving background worktree replacements stay invisible while owning-entry replacements still publish.

Why

EditorPanel subscribed to the complete gitStatusByWorktree and gitBranchChangesByWorktree maps. Zustand compares selector results by reference, so every immutable map replacement woke every mounted Monaco or rich-editor pane—even when only a different worktree changed.

The store already preserves unchanged per-worktree array references. Selecting those arrays directly keeps active data live and removes cross-worktree subscription fanout.

Performance evidence

Synthetic subscription scenario: 200 mounted editor panels, 200 background status-map replacements, and 200 background branch-map replacements.

Metric Before After
Whole-map/background invalidations 80,000 0

Owning status and branch entry replacements continue to publish. This measures subscription invalidations directly; it does not infer a render-time speedup from a microbenchmark.

Validation

  • 112 editor/container test files: 797 tests passed on the implementation state.
  • Focused post-format regression run: 3 files, 29 tests passed.
  • pnpm typecheck passed.
  • Targeted Oxlint and React Doctor checks passed.
  • Reliability gates, max-lines ratchet, formatting, and git diff --check passed.
  • Exact-branch Electron validation passed with two real rich-editor panes: 200 background status writes plus 200 branch writes left both documents unchanged, kept active entry-array references stable, and settled to a normal complete paint.
  • Full pnpm lint reaches only the unchanged mainline Japanese interpolation mismatch for components.native-chat.composer.uploadingAttachments.

ELI5

A Git refresh in one worktree used to wake editors that belonged to other worktrees. Editors now listen only to Git changes for the worktree they display.

@coderabbitai

coderabbitai Bot commented Jul 10, 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 93d550c5-9baa-4ef9-9a6b-b8856d78504d

📥 Commits

Reviewing files that changed from the base of the PR and between c5669cc and 605a989.

📒 Files selected for processing (7)
  • src/renderer/src/components/editor/EditorPanel.tsx
  • src/renderer/src/components/editor/editor-panel-git-entry-selector.test.ts
  • src/renderer/src/components/editor/editor-panel-git-entry-selector.ts
  • src/renderer/src/components/editor/editor-panel-render-model.test.ts
  • src/renderer/src/components/editor/editor-panel-render-model.ts
  • src/renderer/src/components/editor/useEditorPanelContentState.test.tsx
  • src/renderer/src/components/editor/useEditorPanelContentState.ts

📝 Walkthrough

Walkthrough

Editor Git status and branch data is now selected for the active file’s worktree using dedicated typed selectors. The editor content-state hook and render-model function accept scoped entries instead of whole worktree maps. Selector tests cover background-worktree invalidation, entry replacement, and missing worktrees, while related editor tests update their fixtures to pass active-worktree entries.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, rationale, performance, and validation, but misses required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections, including screenshots/no visual change, a detailed AI review report, a security audit summary, and notes.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: scoping editor Git subscriptions by worktree.
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

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.

@nwparker
nwparker merged commit 402274a into main Jul 10, 2026
3 checks passed
@nwparker
nwparker deleted the nwparker/renderer-perf-15 branch July 10, 2026 23:26
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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