Skip to content

perf: split BrowserPanelView's modifier chain so it type-checks quickly - #13130

Merged
teamleaderleo merged 3 commits into
mainfrom
perf/browser-panel-typecheck
Sep 20, 2026
Merged

teamleaderleo merged 3 commits into
mainfrom
perf/browser-panel-typecheck

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

Moved from #13105 with the same commits.

Summary

  • BrowserPanelView's body ended in one chain of 20 modifiers (coordinateSpace, three onPreferenceChange, two onReceive, onAppear/onDisappear, twelve onChange). The compiler type-checks that chain as a single expression, and it was the slowest expression in the app module.
  • This splits the chain into three computed views (browserPanelLifecyclePreferencesView -> browserPanelLifecycleNotificationsView -> the onChange group). The modifiers, their closures and their order are unchanged; nothing else in the file is touched.

Testing

Measured on one machine (MacBook Air M5, Xcode 27.0) with -Xfrontend -warn-long-expression-type-checking=200 -Xfrontend -warn-long-function-bodies=200:

Sources/Panels/BrowserPanelView.swift before after
sites over 200 ms 4 0
slowest expression (:1073) 8,120 ms in a cold build under load; 6.8 s in an unloaded profile under 200 ms
  • The threshold crossing is the result to rely on, not the millisecond values: the "before" number comes from a cold parallel build.
  • Whole-build wall clock: no measurable change on a 10-core machine (the file compiles in parallel with ~3,700 others). What it removes is a multi-second floor on every incremental build that recompiles this file.
  • xcodebuild -scheme cmux -configuration Debug build on this branch: BUILD SUCCEEDED.
  • Not tested: UI behaviour by hand (launching a tagged build needs dev credentials that are not on the benchmark machine). The change is a mechanical regrouping of modifiers in the same order.
  • Next slowest site in the module, not addressed here: Sources/Surfaces/SurfaceCatalog+CloudPorts.swift:37 (2.7 s).

Demo Video

Not applicable: no behaviour change.

Checklist

  • I tested the change locally
  • I added or updated tests for behavior changes (none: no behaviour change)
  • I updated docs/changelog if needed (not needed)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Speeds up type-checking of BrowserPanelView by splitting its 20-modifier chain into three computed views. Modifiers, closures, and order are unchanged, so there is no behavior change.

Testing

  • Slowest expression in Sources/Panels/BrowserPanelView.swift drops from ~8 s to under 200 ms.
  • Whole-build wall clock is unchanged; the win is on incremental rebuilds of this file.
  • xcodebuild -scheme cmux -configuration Debug build succeeds.

Written for commit 31ddfd6. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Refactor
    • Reorganized the browser panel’s internal view lifecycle structure without changing visible behavior or functionality.

The chain of preference, notification, appear and onChange modifiers on
BrowserPanelView's body was one expression that took about 7-8 s to
type-check. Split it into three computed views applied in the same order.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: manaflow-ai/cmux/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: c15a56f1-3184-4660-b76d-e611c45da241

📥 Commits

Reviewing files that changed from the base of the PR and between 02cd032 and 31ddfd6.

📒 Files selected for processing (1)
  • Sources/Panels/BrowserPanelView.swift

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The browser panel lifecycle view is decomposed into three nested private computed properties. The existing preference, notification, lifecycle, and change modifiers remain in the same order with the same handlers.

Changes

Browser panel lifecycle decomposition

Layer / File(s) Summary
Nested lifecycle view wrappers
Sources/Panels/BrowserPanelView.swift
browserPanelLifecycleView now delegates through notification and preference view properties. Existing modifiers and handler behavior remain unchanged.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Refactor

Suggested reviewers: austinywang

🚥 Pre-merge checks | ✅ 25
✅ Passed checks (25 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: splitting BrowserPanelView’s modifier chain to improve type-checking performance.
Description check ✅ Passed The description includes a detailed summary, rationale, testing results, build verification, and an appropriate explanation that no demo video is needed. It omits the template’s review-trigger block a…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
Cmux Cloud Persistent Session And Early Input ✅ Passed PASS: The pull request changes only Sources/Panels/BrowserPanelView.swift. The diff moves the existing preference, notification, lifecycle, and onChange modifiers into three computed views. It doe…
Cmux Swift Actor Isolation ✅ Passed PASS. The review range changes only Sources/Panels/BrowserPanelView.swift. The diff moves the existing coordinate-space, preference, notification, appearance, and onChange modifiers into three private…
Cmux Swift Blocking Runtime ✅ Passed PASS. The PR changes only Sources/Panels/BrowserPanelView.swift and only splits an existing SwiftUI modifier chain into computed views. The diff adds no semaphores, waits, sleeps, polling, synchrono…
Cmux Browser Automation Off-Main ✅ Passed PASS. The PR changes only Sources/Panels/BrowserPanelView.swift. The diff only splits existing SwiftUI lifecycle modifiers into computed views and preserves their order and handlers. It does not cha…
Cmux Expensive Synchronous Load ✅ Passed PASS. The authoritative diff changes only Sources/Panels/BrowserPanelView.swift and splits an existing SwiftUI modifier chain into computed views. The added lines contain no `RestorableAgentSessionI…
Cmux Cache Substitution Correctness ✅ Passed PASS. The pull request changes only Sources/Panels/BrowserPanelView.swift and only restructures the SwiftUI modifier chain into computed views. It does not replace a fresh authoritative read with a …
Cmux No Hacky Sleeps ✅ Passed PASS: The review-scoped diff changes only Sources/Panels/BrowserPanelView.swift, which is Swift and outside this check's non-Swift scope. The added lines only split SwiftUI computed views and add no…
Cmux Algorithmic Complexity ✅ Passed PASS. The pull request changes only Sources/Panels/BrowserPanelView.swift. It splits an existing 20-modifier SwiftUI chain into computed views. The verified modifier count and semantic order are unc…
Cmux Swift Concurrency ✅ Passed The pull request changes only Sources/Panels/BrowserPanelView.swift. The diff splits one existing SwiftUI modifier chain into three computed views and preserves the existing .onReceive, `.onAppear…
Cmux Swift @Concurrent ✅ Passed PASS. The PR changes only Sources/Panels/BrowserPanelView.swift and only splits an existing synchronous SwiftUI modifier chain into three computed some View properties. The diff adds no async, `…
Cmux Swift Package Boundaries ✅ Passed PASS. The only changed file is Sources/Panels/BrowserPanelView.swift. The diff only splits an existing SwiftUI modifier chain into private computed views within BrowserPanelView; it does not add i…
Cmux Swiftpm Lockfiles ✅ Passed PASS. The authoritative PR diff changes only Sources/Panels/BrowserPanelView.swift. It contains no Package.swift, Package.resolved, .gitignore, workflow, Xcode project, or dependency changes. …
Cmux Swift Logging ✅ Passed PASS: The review-scoped diff changes only Sources/Panels/BrowserPanelView.swift and only splits the existing SwiftUI modifier chain into computed views. It adds or changes no print, debugPrint, …
Cmux User-Facing Error Privacy ✅ Passed PASS. The review-scoped diff changes only Sources/Panels/BrowserPanelView.swift. It moves existing SwiftUI modifiers into three computed views. It adds no user-facing error, alert, command output, A…
Cmux Full Internationalization ✅ Passed PASS: The authoritative diff changes only Sources/Panels/BrowserPanelView.swift. It relocates the existing modifier chain into three computed views. The patch adds no user-facing Swift text, localiz…
Cmux Swiftui State Layout ✅ Passed PASS. The authoritative diff only reorganizes the existing modifier chain in BrowserPanelView into computed views. It adds no state declarations, store references, list rows, or geometry readers. Ba…
Cmux Architecture Rethink ✅ Passed PASS. The PR changes only Sources/Panels/BrowserPanelView.swift. It splits one existing modifier chain into private computed some View properties within the same BrowserPanelView. Base and head …
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed PASS: The PR changes only Sources/Panels/BrowserPanelView.swift and splits an existing SwiftUI modifier chain into computed views. The diff adds no NSWindow, NSPanel, NSWindowController, `Wind…
Cmux Source Artifacts ✅ Passed The pull request changes only Sources/Panels/BrowserPanelView.swift. The patch contains hand-written Swift source that splits view modifiers into computed properties. It adds no logs, screenshots, r…
Cmux No Test Or Debug Seam In Production Source ✅ Passed PASS — The authoritative PR diff changes only Sources/Panels/BrowserPanelView.swift. It only splits the existing SwiftUI modifier chain into three private computed views and adds no #if DEBUG or…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@greptile-apps

greptile-apps Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because the refactor preserves the existing SwiftUI modifier hierarchy and introduces no actionable issues.

Summary

Splits BrowserPanelView’s long SwiftUI modifier expression into three computed views to reduce type-checking time.

  • Preserves the original modifier ordering and closures.
  • Separates preference handling, notifications/lifecycle handling, and change observers.
  • Introduces no behavioral or security changes.

Reviews (2) · Last reviewed commit: "Merge branch 'main' into perf/browser-pa..."

@cursor

cursor Bot commented Sep 20, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@teamleaderleo
teamleaderleo added this pull request to the merge queue Sep 20, 2026
@teamleaderleo
teamleaderleo merged commit c7d961d into main Sep 20, 2026
43 of 45 checks passed
rustybret pushed a commit to rustybret/bmux that referenced this pull request Sep 20, 2026
34ecef4 perf: coalesce concurrent process snapshots across diagnostics and restore (manaflow-ai#13014)
150d7fa Add app-host test failure census (manaflow-ai#13124)
04ac7a4 Merge pull request manaflow-ai#12735 from manaflow-ai/feat-ios-connectivity-soak
c022438 fix: update Ghostty environment lifetime fix (manaflow-ai#13191)
eb18207 Fix mobile devices dashboard WebSocket failures and naming (manaflow-ai#13156)
c7d961d perf: split BrowserPanelView's modifier chain so it type-checks quickly (manaflow-ai#13130)
e188035 refactor: move the Computer Use runtime out of the app module into a package (manaflow-ai#13132)
cf2b850 Bound terminal markers and verify restored selection
2d7fc1c Measure terminal latency separately after reconnect
44dcd1e Reconcile iOS monitor stack with main
70034bc Merge pull request manaflow-ai#13116 from manaflow-ai/feat-ios-monitor-e2e-repair
deafe6e Skip release gate text scans without a probe
a1be46b Release terminal ownership from reader teardown
96d6574 Restore transport target after UI evidence
31ff358 Schedule terminal owner cleanup from deinit
e82f6f6 Keep bounded terminal text evidence reliable
ccbc4b2 Bound frame evidence scans and handshake setup
301dbad Make terminal evidence capture causal
6b50e3a Finish bounded release gate cleanup
14f2cd9 Stop stale release gate probes and bound frame inspection
cd64e8c Bound pairing bootstrap loading
035fd37 Harden release gate evidence and readiness
b6ca6e9 Close release gate review races
389026e Make release gate readiness and dismissal causal
aa2bb02 Restore main translations for the pairing preparation error
46bbfc9 Restore the pairing preparation handling already present on main
1bcbf60 Give the soak one owned terminal reader across steady-state commands
9d700f9 Test soak terminal consumer lifetime across commands and reconnects
1dd9f69 Fix existing Cloud test imports and nested macro compilation
bd5fee0 Give launch-request samples a distinct statistics key
bc68fbf Measure UI readiness from the actual simulator launch request
e5772e8 Test launch request timing across app initialization
8006ba9 Clear prior UI evidence before each retained-simulator launch
d8e1b4c Reuse isolated monitor devices while cold-launching the app
0968fcf Test the dedicated monitor simulator plan boundary
e7da214 Wait for the published pairing identity and inject screenshot capture
0af38fe Avoid the Swift task-group isolation checker defect in refresh test
48a0eb9 Own UI measurements per launch and capture composited terminal evidence
7e28e4e Mint pairing tickets with the active v2 device identity
f498caf Test pairing tickets against the current transport identity
95f931d Correct the foreground suspension entrypoint in the test
f5d5b2b Use the public foreground lifecycle for regression-test cleanup
0eded5a End the UI exercise only after terminal consumer ownership is released
c0a61bb Keep UI state on its actor across the task-group boundary
30000a5 Drive and measure the real workspace UI before each soak; decouple background discovery
0d896f5 test: foreground refresh must finish while secondary discovery is blocked
4e739bb test: require real UI selection and stable first-frame measurements
aeb554a Measure real iOS UI readiness timings (manaflow-ai#12887)
6a2c896 Record per-operation iOS soak latencies (manaflow-ai#12883)
39d7669 test: advertise workspace actions in the soak reconnect fixture
7e9a676 fix: disconnect the soak session before testing reconnect
c51a096 test: require stress reconnect to replace a healthy connection
e1a2767 fix: import the workspace model from its owning module
e6a6ba4 fix: import mobile workspace preview module
3361141 Merge remote-tracking branch 'origin/main' into feat-ios-connectivity-soak
dbfebac Merge remote-tracking branch 'origin/main' into feat-ios-connectivity-soak
3f8ceec fix: forward connection snapshots through deferred Iroh transport
d8f30dc test: require deferred transports to forward native path snapshots
3dce84c fix: observe soak path and identity on the native RPC connection
38ee330 test: require native connection path evidence throughout soak
055880c test: cover final soak deadline and name failed usage actions
b27046c fix: bound stalled soak cycles with an independent deadline
7f1f748 test: require stalled soak operations to report promptly
e116e6b Use accepted boolean spelling for the Mac relay setting
aa3dc13 Exercise relay setup command arguments in both modes
db17d3d Constrain current Iroh endpoints to relays in app gates
245b55e Reproduce release gate missing current Iroh relay policy
c9289ed Add focused Iroh soak harness test plan
aec8291 Support an isolated agent account for unattended soaks
915c080 Add deterministic iOS Iroh connectivity soak workloads

# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/iroh-v2.yml
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