Repository navigation
perf: reuse chat tab ownership across unrelated app updates - #26150
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughNative-chat tab-owner lookup now uses a memoized selector that recalculates when tab-map references change. File-link context and runtime environment selection use selectors built on that owner lookup. The file-link and runtime hooks, plus Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to This change reduces redundant ownership scans on unrelated store updates while preserving behavior. No actionable merge-blocking risk was found. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
ELI5
Chats kept open in hidden tabs still listen for app updates. They now reuse their owning workspace instead of searching every workspace again when terminal input, titles or status change.
What Changed
Each chat hook keeps one tab's owner until the relevant tab collection changes. Changing the queried tab creates a fresh selector. File links, launch directories and runtime routing still read the current state on every update.
The resolved-chat runtime selector reuses the same owner factory while preserving its terminal-only lookup. Structured-only chats remain excluded from that runtime lookup; terminal precedence and first-owner collision behavior remain unchanged.
Why
An isolated built Electron fixture with 870 workspace buckets and 20 retained chats showed repeated ownership searches on existing app actions. The original file-link/owner change removed 69,600 bucket scans per terminal-input publication: input went from 3.684 to 0.266 ms, title from 3.551 to 0.259 ms, and status from 3.680 to 0.286 ms. Its no-chat control remained around 0.13 ms.
The runtime follow-up covers a remaining caller after that original change. With 20 mounted resolved chats, one visible and 19 hidden, terminal input fell from 0.692 to 0.286 ms per publication, title from 0.690 to 0.293 ms, and status from 1.025 to 0.565 ms. It removed 17,400 bucket scans and 28,580 row probes per input publication. No-chat controls stayed near 0.19–0.43 ms. The runtime comparison used a temporary copy of the built renderer with only the equivalent memo expression changed; seven measured trials of 100 actual publications followed three warm-up trials.
The runtime follow-up fixture used generated two-turn chat text and provider-session IDs read from its retained chat props, with no PTYs. These measurements do not establish the cause of the reported local Codex typing pause.
Caching only the owner preserves current directory and host routing. The existing terminal-only index has different collision rules and cannot resolve structured chats; a global index or stopping hidden-chat subscriptions would require broader state or lifecycle changes.
Linked Issue
N/A — internal performance audit.
Visual Proof
N/A — rendered content, tab retention and file-link behavior are unchanged. Hidden CDP screenshots confirmed the fixture rendered its generated messages without revealing or focusing a window.
Testing
macOS hidden Electron/CDP production-bundle fixtures. The runtime follow-up passes 31 focused owner, runtime and file-link tests,
pnpm tc:web, ordinary lint/format and changed-code quality. Its repeated-scan regression fails against the frozen original with 101 tab-ID reads instead of one. Independent 40,000 runtime-selection comparisons cover collisions, missing/structured-only/empty IDs, 5,333 outer-map replacements and current active, detected, repo, folder, settings and runtime projections.The original change also passed 40,000 owner and 40,000 file-link-context comparisons, full native-plugin checks and lifecycle/context count regressions. The writer audit covers 68 publication properties in 45 modules plus dynamic writers: ownership changes replace outer tab collections; batches mutate private clones before publication. Linux/Windows remain for CI.
Review
Each selector retains the current collection reference(s) and one owner value for one hook and tab. It accumulates neither queried IDs nor historical collections. Cold imperative helpers remain unchanged. SSH and folder workspace context uses the existing resolver and current runtime/path rules.
Agent skill upstream boundary
Checklist