Skip to content

Add browser.autoFocusMode: auto-enter Browser Focus Mode on pane focus - #5904

Open
erik-hunter wants to merge 21 commits into
manaflow-ai:mainfrom
erik-hunter:browser-auto-focus-mode
Open

erik-hunter wants to merge 21 commits into
manaflow-ai:mainfrom
erik-hunter:browser-auto-focus-mode

Conversation

@erik-hunter

@erik-hunter erik-hunter commented Jun 11, 2026 •

Copy link
Copy Markdown

Summary

  • What changed? Adds a new browser.autoFocusMode setting (off by default). When enabled, focusing a browser pane automatically activates Browser Focus Mode, so Cmd-shortcuts (Cmd+N, Cmd+F, Cmd+P, …) reach the embedded page instead of being captured by cmux. Focus mode still clears when the pane loses focus, and double-Escape still exits it; with the setting on, it re-arms on the next pane focus.
  • Why? Useful for routing any shortcuts to the web browser, but especially important for me because I embed a web IDE (code-server / VS Code Web) in a cmux pane. This makes the existing Focus Mode (v0.64.13) automatic for that workflow.

Wiring follows the existing settings patterns end to end:

  • BrowserCatalogSection key + cmux.schema.json entry + JSON path registration + parseBrowserSection parsing (browser.autoFocusMode in ~/.config/cmux/cmux.json, live-reloaded)
  • Settings UI toggle under Settings → Browser (between Browser Theme and Browser Memory Saver), with search alias
  • Runtime: BrowserAutoFocusModeSettings enum + @AppStorage hook in BrowserPanelView.handlePanelFocusChange, activating via the existing setBrowserFocusModeActive(_:reason:focusWebView:) path with focusWebView: false (the pane is already gaining focus, so no explicit first-responder request is needed)
  • Localized for all 20 supported locales in Resources/Localizable.xcstrings

Testing

  • How did you test this change? Built a tagged dev app (./scripts/reload.sh --tag auto-focus-mode) and dogfooded against a code-server pane: with the toggle on, entering the pane auto-enables Focus Mode and Cmd+N/Cmd+F reach VS Code Web; leaving the pane clears it; double-Escape exits as before. Verified the toggle in Settings → Browser and the browser.autoFocusMode key in cmux.json (live reload) both drive the behavior, and that everything is unchanged with the setting off (default).
  • What did you verify manually? Added four unit tests in AppDelegateShortcutRoutingTests: settings default/roundtrip with injected UserDefaults, focus-mode activation through setBrowserFocusModeActive with focusWebView: false, and idempotence on redundant activation. Note: the handlePanelFocusChange view-layer wiring itself isn't reachable from unit tests; that path was validated manually in the dev build. Localization audit: parsed Localizable.xcstrings and confirmed both new keys (settings.browser.autoFocusMode, .subtitle) have translated entries for all 20 locales.

Demo Video

For UI or behavior changes, include a short demo video (GitHub upload, Loom, or other direct link).

Screen.Recording.2026-06-11.at.1.48.02.PM.mov

Review Trigger (Copy/Paste as PR comment)

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

Checklist

  • I tested the change locally
  • I added or updated tests for behavior changes
  • I updated docs/changelog if needed - n/a
  • I requested bot reviews after my latest commit (copy/paste block above or equivalent)
  • All code review bot comments are resolved
  • All human review comments are resolved

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Summary by cubic

Adds a new browser.autoFocusMode setting that auto‑enters Browser Focus Mode when a browser pane gains focus so Cmd‑shortcuts go to the page instead of cmux. Off by default; focuses the web view on auto‑activation; exits on pane blur or double‑Escape; skips blank tabs and when the Command Palette is open; restores after the palette closes.

  • New Features

    • browser.autoFocusMode (default false). Toggle in Settings → Browser or set in ~/.config/cmux/cmux.json at browser.autoFocusMode (live reload). Indexed in settings search; added to the generated config template and schema; localized across all supported locales.
    • Auto‑activates on pane focus via setBrowserFocusModeActive(..., focusWebView: true); returns toggle result to callers for correct feedback.
  • Bug Fixes

    • Gate auto‑activation on: pane focused, focus mode inactive, address bar not focused, Command Palette hidden, non‑blank content, and no suppression; respect pending navigation.
    • Retry after address bar blur and on first render; reconcile on view appear; restore after the Command Palette closes.
    • Suppress auto‑activation until next focus gain after manual exits (toolbar, context menu, CLI, double‑Escape); temporary focus clears are non‑suppressing; clear suppression on focused, visible return.

Written for commit 1c66565. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Added an "Auto Focus Mode" browser setting (off by default). When enabled, the browser panel automatically enters focus mode upon gaining focus, improving workflow with browser content.
    • Setting is discoverable via settings search and available in localized languages.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Manaflow Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds an "Auto Focus Mode" setting for the browser that automatically enters Browser Focus Mode when a browser pane gains focus. The feature spans setting declaration, persistence infrastructure, UI, runtime activation, search indexing, and validation tests across multiple modules and configuration layers.

Changes

Browser Auto Focus Mode

Layer / File(s) Summary
Settings contract and schema
Packages/CmuxSettings/Sources/CmuxSettings/Keys/BrowserCatalogSection.swift, web/data/cmux.schema.json, Sources/CmuxSettingsJSONPathSupport.swift
Declares browser.autoFocusMode as a boolean setting (default false) in the settings catalog and JSON schema, and registers it as an explicitly-supported JSON configuration path.
Persistence helper and file parsing
Sources/Panels/BrowserPanel.swift, Sources/KeyboardShortcutSettingsFileStore.swift
Introduces BrowserAutoFocusModeSettings enum with UserDefaults accessors for the browserAutoFocusModeEnabled key, and adds parsing logic to recognize and persist browser.autoFocusMode from settings files.
Settings UI and localization
Packages/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/BrowserSection.swift, Resources/Localizable.xcstrings
Adds a new @State property and renders a "Auto Focus Mode" toggle in the browser settings with a localized subtitle and accessibility identifier; includes translated strings for multiple languages.
Runtime auto-activation on panel focus
Sources/Panels/BrowserPanelView.swift
Reads the auto-focus-mode setting via @AppStorage and automatically activates Browser Focus Mode when the browser pane gains focus if enabled and not already active.
Settings search and navigation
Sources/SettingsNavigation.swift
Adds the auto-focus-mode entry to the settings search index for discoverability in the settings search interface.
Unit tests for auto-focus behavior
cmuxTests/AppDelegateShortcutRoutingTests.swift
Four comprehensive test cases verify default-disabled behavior, enablement via UserDefaults, automatic focus-mode activation on panel focus, and idempotency of redundant activation calls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • manaflow-ai/cmux#5352: Modifies BrowserPanel/BrowserPanelView focus lifecycle; overlaps with auto-focus activation handling.
  • manaflow-ai/cmux#4573: Introduced Browser Focus Mode machinery used by this auto-activation feature.
  • manaflow-ai/cmux#4623: Also adjusts browser focus behavior and gating around omnibar/auto-focus interactions.

Poem

🐰 A browser hops with eager grace,
Focus mode springs at rapid pace,
When panes come into view so bright,
The rabbit toggles auto-light!
Settings bloom with translations new,
Tests keep every hop true. 🌟


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Cmux Full Internationalization ❌ Error web/data/cmux.schema.json adds browser.autoFocusMode with only schema.description (no descriptionKey); web docs reads description directly, so it won’t be localized for all web locales. Update cmux.schema.json to include descriptionKey for browser.autoFocusMode and add translated docs.configuration.schemaDescriptions.browser.autoFocusMode entries in web/messages/*.json for every locale in web/i18n/routing.ts.
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (19 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a new browser.autoFocusMode setting that automatically activates Browser Focus Mode when a pane gains focus. It matches the core functionality implemented across all modified files.
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 Swift Actor Isolation ✅ Passed Reviewed new code for browser.autoFocusMode: BrowserAutoFocusModeSettings is explicitly nonisolated, focus handling is in SwiftUI onChange using @AppStorage, and no new UI store/background sendabil...
Cmux Swift Blocking Runtime ✅ Passed PR Swift hunks contain no blocking/timing primitives flagged by swift-blocking-runtime.md (e.g., no DispatchSemaphore/Task.sleep/DispatchQueue.main.sync/asyncAfter/Timer/NSLock).
Cmux Expensive Synchronous Load ✅ Passed Checked PR-touched Swift files for RestorableAgentSessionIndex.load/sysctl and SharedLiveAgentIndex.shared; none were added. Auto-focus path only calls setBrowserFocusModeActive(..., focusWebView:f...
Cmux Cache Substitution Correctness ✅ Passed PR only adds a new UserDefaults-backed setting and uses cold-safe defaults (guard/object-for-key) plus fresh JSON parsing into snapshot.managedUserDefaults; no authoritative-read→cached/snapshot tr...
Cmux No Hacky Sleeps ✅ Passed PR appears to change only Swift/xcstrings and web/data/cmux.schema.json; no production TypeScript/JavaScript/shell/build runtime script edits detected, so no hacky sleeps introduced.
Cmux Algorithmic Complexity ✅ Passed Inspected PR changes: BrowserPanelView.handlePanelFocusChange adds only O(1) boolean guards before calling setBrowserFocusModeActive; BrowserSection adds a single toggle row—no loops/sorts/collecti...
Cmux Swift Concurrency ✅ Passed PR’s cmux Swift changes only add the browser.autoFocusMode setting, UI toggle, JSON parsing, and a synchronous focus-mode activation on pane focus—no added DispatchQueue/Combine/completion handlers...
Cmux Swift @Concurrent ✅ Passed PR #5904 Swift diffs add only the autoFocusMode setting/toggle and a sync focus-change call; no new nonisolated async lacking @concurrent or UI-triggered heavy async helpers were introduced.
Cmux Swift File And Package Boundaries ✅ Passed PR adds only small, focused Swift changes (e.g., +6 in BrowserCatalogSection, +16 in BrowserSection, +14/+4 in BrowserPanel/View); no new oversized Swift files or large additions/mixed responsibili...
Cmux Swift Logging ✅ Passed PR diff adds autoFocusMode setting/UI and focus-mode activation code, with no added print/debugPrint/dump/NSLog or Logger(...) constants detected in changed Swift hunks.
Cmux User-Facing Error Privacy ✅ Passed Inspected new setting wiring/localized strings and focus-change logic; the added Localizable entries are safe (no vendor/token/etc) and no new user-facing error/alert/recovery copy was introduced i...
Cmux Swiftui State Layout ✅ Passed Verified new auto-focus SwiftUI wiring uses @State (BrowserSection) and @AppStorage + event handler (BrowserPanelView); no new ObservableObject/@published, no new List/LazyVStack store refs, and no...
Cmux Architecture Rethink ✅ Passed Inspected Swift added autoFocusMode code paths (BrowserPanelView/BrowserSection); no sleeps/asyncAfter/polling/locks or observer registration/duplicate wiring found nearby—behavior reuses existing...
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed No SwiftUI/NSWindow/NSPanel/WindowGroup code changes in PR; it only adds browser.autoFocusMode and auto-activates focus mode via setBrowserFocusModeActive(focusWebView:false).
Cmux Source Artifacts ✅ Passed PR #5904’s “Files changed” list includes only .swift, .json, and .xcstrings; no logs/screenshots/recordings, caches, DerivedData, or other artifact directories were added per source-control-artifac...
Description check ✅ Passed The PR description matches the template with summary, testing, demo video, review trigger, and checklist sections filled out.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@erik-hunter

Copy link
Copy Markdown
Author

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Jun 11, 2026

Copy link
Copy Markdown

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

@erik-hunter I can't start this review because your workspace has reached its free monthly review limit. cubic has reviewed 241,260 of the 240,000 allowed lines of code this month. Reviews resume on 1 July 2026 (in 20 days). Paid plans include much higher monthly review limits. Upgrade now to resume reviews.

To help optimise your usage, you can tune cubic to get the most out of your usage limits:

Learn more →

@coderabbitai

coderabbitai Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

@erik-hunter Sure, I'll review the changes in this PR!

✅ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@greptile-apps

greptile-apps Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a browser.autoFocusMode setting (off by default) that automatically enters Browser Focus Mode whenever a browser pane gains focus, routing Cmd-shortcuts to the embedded page. The implementation is end-to-end: settings catalog, JSON path registration, live-reload parsing, Settings UI toggle with localization across all 20 locales, and a SwiftUI @AppStorage-driven activation path in BrowserPanelView.

  • Suppression model: all explicit-exit paths (toolbar button, context menu, CLI, double-Escape) now pass suppressAutoFocusUntilFocusGain: true so the setting does not re-arm until the next genuine pane focus-gain.
  • Activation guard: BrowserAutoFocusModeActivation.shouldActivate gates on five independent conditions plus an inline !isCommandPaletteVisibleForPanelWindow() check; the predicate is fully unit-tested.
  • Retry paths: activation is retried on address-bar blur, page-render state changes, command-palette close, and pane visibility returns.

Confidence Score: 4/5

The new feature is off by default and the core activation guard is well-tested; the outstanding concern is in the command-palette interaction path flagged in earlier review rounds.

The activation logic, suppression model, and all explicit-exit paths are correctly wired. The two AppDelegate command-palette clear sites (postCommandPaletteRequest line 5245 and setCommandPaletteVisible line 5403) still call setFocusedBrowserFocusModeActive(false, …) without suppressAutoFocusUntilFocusGain: true, and activateAutoFocusModeIfNeeded checks only committed-visible palette state rather than the broader isCommandPaletteEffectivelyVisible (which includes isPendingOpen). Both gaps were flagged in previous review rounds and remain open.

Sources/AppDelegate.swift — the two command-palette focus-mode clear sites at lines 5245 and 5403.

Important Files Changed

Filename Overview
Sources/Panels/BrowserPanel.swift Adds BrowserAutoFocusModeSettings and BrowserAutoFocusModeActivation enums, the isBrowserAutoFocusModeSuppressedUntilFocusGain flag, and suppression arm/clear helpers; extends setBrowserFocusModeActive and toggleBrowserFocusMode to thread suppressAutoFocusUntilFocusGain through all explicit-exit paths.
Sources/Panels/BrowserPanelView.swift Wires @AppStorage for autoFocusModeEnabled, adds reconcileFocusedPanelState, activateAutoFocusModeIfNeeded, and retryAutoFocusModeAfterAddressBarBlurIfNeeded; command palette re-arm race remains open from previous reviews.
Sources/AppDelegate.swift Adds suppressAutoFocusUntilFocusGainOnExit: true to the context-menu toggle; the two command-palette clear sites still lack suppressAutoFocusUntilFocusGain: true.
Sources/TabManager.swift Threads suppressAutoFocusUntilFocusGain parameter through toggleBrowserFocusModeForFocusedBrowser and setFocusedBrowserFocusModeActive; straightforward forwarding changes.
Sources/TerminalController.swift Adds suppressAutoFocusUntilFocusGain: true to CLI explicit-exit and toggle paths; correct parity with toolbar, context-menu, and double-Escape exits.
cmuxTests/AppDelegateShortcutRoutingTests.swift Adds unit tests covering all five shouldActivate guard branches, shouldRetryAfterAddressBarBlur, panel activation path, and idempotent double-activate; suppression state assertions added to existing double-Escape tests.
Resources/Localizable.xcstrings Adds settings.browser.autoFocusMode and .subtitle entries with translations for all 20 supported locales.

Reviews (20): Last reviewed commit: "Merge origin/main into browser-auto-focu..." | Re-trigger Greptile

Comment thread cmuxTests/AppDelegateShortcutRoutingTests.swift Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 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 `@cmuxTests/AppDelegateShortcutRoutingTests.swift`:
- Around line 11800-11825: The tests currently call
setBrowserFocusModeActive(...) directly which bypasses the real panel-focus
entrypoint and the auto-focus gating; update the tests created with
makeBrowserFocusModeHarness() so they simulate a real panel focus event by
invoking the actual focus-change entrypoint (e.g., handlePanelFocusChange or
whatever method routes panel focus events into the panel) instead of calling
setBrowserFocusModeActive directly, keep toggling
BrowserAutoFocusModeSettings.enabledKey via UserDefaults to verify the positive
path (autoFocusMode on activates via the real entrypoint) and add a negative
case with autoFocusMode off asserting no activation, and for the
redundant-activation test call the same real entrypoint twice to ensure it does
not clear or crash while panel.isBrowserFocusModeActive remains true.

In `@Sources/Panels/BrowserPanel.swift`:
- Around line 428-440: Extract the nonisolated enum BrowserAutoFocusModeSettings
(including its static properties enabledKey and defaultEnabled and methods
isEnabled and isEnabled(defaults:)) out of BrowserPanel.swift into a new
dedicated settings file/module alongside other settings persistence helpers;
move the type to that file, update any imports/visibility so callers of
BrowserAutoFocusModeSettings and its members continue to compile, and remove it
from BrowserPanel.swift so the panel file only contains runtime/panel code.
Ensure the new file is part of the app target or a shared settings module as
appropriate and run tests/compile to fix any references.

In `@Sources/SettingsNavigation.swift`:
- Line 400: The new "browser.autoFocusMode" search entry lacks an anchor mapping
in the settingsPathAnchorIDs dictionary, so anchorID(forSettingsPath:) can't
resolve it; add a key/value pair for "browser.autoFocusMode" in the same
settingsPathAnchorIDs dictionary alongside the other browser.* entries (use the
same anchor ID string style used for the other browser keys so jump/highlight
behavior works correctly), then run a quick search/jump test to confirm anchor
resolution for the new Auto Focus Mode setting.
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a97f3a5a-fe6e-40aa-9779-0634b35866ad

📥 Commits

Reviewing files that changed from the base of the PR and between 7258d10 and 45f3026.

📒 Files selected for processing (10)
  • Packages/CmuxSettings/Sources/CmuxSettings/Keys/BrowserCatalogSection.swift
  • Packages/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/BrowserSection.swift
  • Resources/Localizable.xcstrings
  • Sources/CmuxSettingsJSONPathSupport.swift
  • Sources/KeyboardShortcutSettingsFileStore.swift
  • Sources/Panels/BrowserPanel.swift
  • Sources/Panels/BrowserPanelView.swift
  • Sources/SettingsNavigation.swift
  • cmuxTests/AppDelegateShortcutRoutingTests.swift
  • web/data/cmux.schema.json

Comment thread cmuxTests/AppDelegateShortcutRoutingTests.swift Outdated
Comment thread Sources/Panels/BrowserPanel.swift Outdated
Comment thread Sources/SettingsNavigation.swift
@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a browser.autoFocusMode setting (off by default) that automatically enters Browser Focus Mode when a browser pane gains focus, routing Cmd-shortcuts to the embedded page instead of cmux. The wiring follows existing settings patterns end-to-end across the catalog key, JSON path registration, file-store parser, settings UI toggle, @AppStorage hook, and Localizable.xcstrings with all 20 locale entries.

  • BrowserAutoFocusModeSettings enum + @AppStorage(enabledKey) in BrowserPanelView activates focus mode via the existing setBrowserFocusModeActive(_:reason:focusWebView:) path with focusWebView: false whenever the pane gains focus and focus mode is not already active.
  • On pane blur the existing clearBrowserFocusMode path clears the mode; double-Escape still exits focus mode for the remainder of the focused session.
  • Four unit tests cover settings defaults, round-trip, activation, and idempotent re-activation; the view-layer wiring was validated manually.

Confidence Score: 4/5

Safe to merge; the new setting is off by default and the activation path is a small, well-isolated addition to an existing focus-change handler.

The implementation follows established patterns throughout. Two minor issues were found: spurious state transitions when a blank-tab pane gains focus (address bar auto-focus fires first, then focus mode activates, then gets cleared in the next SwiftUI cycle), and two tests that mutate UserDefaults.standard rather than an injected suite. Neither affects the primary use case (loaded pages like VS Code Web) or the off-by-default baseline.

Sources/Panels/BrowserPanelView.swift — the ordering of autoFocusOmnibarIfBlank() relative to the focus-mode activation block; cmuxTests/AppDelegateShortcutRoutingTests.swift — the two tests that write to UserDefaults.standard

Important Files Changed

Filename Overview
Sources/Panels/BrowserPanelView.swift Adds @AppStorage hook for autoFocusModeEnabled and activates focus mode in handlePanelFocusChange; minor state-ordering concern on blank tabs (see comment)
Sources/Panels/BrowserPanel.swift Adds BrowserAutoFocusModeSettings enum with nonisolated annotation that is redundant for a pure enum; settings logic is correct and consistent with peers
Packages/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/BrowserSection.swift Adds settings UI toggle for Auto Focus Mode using existing DefaultsValueModel/@State pattern; placed correctly between Browser Theme and Memory Saver rows
Sources/KeyboardShortcutSettingsFileStore.swift Parses browser.autoFocusMode from JSON section and writes to managedUserDefaults; consistent with adjacent parseBrowserSection patterns
Resources/Localizable.xcstrings Adds two keys (settings.browser.autoFocusMode and .subtitle) with translated entries for all 20 supported locales; coverage is complete
cmuxTests/AppDelegateShortcutRoutingTests.swift Four new tests: two use injected UserDefaults (correct), two write directly to UserDefaults.standard with defer-cleanup (test-suite pollution risk)

Sequence Diagram

sequenceDiagram
    participant User
    participant BrowserPanelView
    participant BrowserPanel
    participant NotificationCenter

    User->>BrowserPanelView: Focus browser pane
    BrowserPanelView->>BrowserPanelView: handlePanelFocusChange(true)
    BrowserPanelView->>BrowserPanelView: autoFocusOmnibarIfBlank() [no-op if page loaded]
    alt autoFocusModeEnabled and not isBrowserFocusModeActive
        BrowserPanelView->>BrowserPanel: setBrowserFocusModeActive(true, focusWebView: false)
        BrowserPanel->>BrowserPanel: "isBrowserFocusModeActive = true"
        BrowserPanel->>NotificationCenter: post(browserFocusModeStateDidChange)
    end

    User->>BrowserPanelView: Press Cmd+N / Cmd+F
    BrowserPanelView->>BrowserPanel: route shortcut to web view (focus mode active)

    User->>BrowserPanelView: Double-Escape
    BrowserPanel->>BrowserPanel: clearBrowserFocusMode(reason: escape)
    BrowserPanel->>NotificationCenter: post(browserFocusModeStateDidChange)
    Note over BrowserPanelView: stays off until next pane focus

    User->>BrowserPanelView: Unfocus browser pane
    BrowserPanelView->>BrowserPanel: clearBrowserFocusMode(reason: panelFocus.onChange.unfocused)
    BrowserPanel->>BrowserPanel: "isBrowserFocusModeActive = false"
Loading

Reviews (2): Last reviewed commit: "Add auto-focus mode setting for webView ..." | Re-trigger Greptile

Comment thread Sources/Panels/BrowserPanel.swift Outdated
Comment thread Sources/Panels/BrowserPanelView.swift Outdated
Comment thread cmuxTests/AppDelegateShortcutRoutingTests.swift Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@erik-hunter

Copy link
Copy Markdown
Author

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Jun 11, 2026

Copy link
Copy Markdown

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

@erik-hunter I can't start this review because your workspace has reached its free monthly review limit. cubic has reviewed 241,260 of the 240,000 allowed lines of code this month. Reviews resume on 1 July 2026 (in 20 days). Paid plans include much higher monthly review limits. Upgrade now to resume reviews.

To help optimise your usage, you can tune cubic to get the most out of your usage limits:

Learn more →

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

@erik-hunter Sure, I’ll review the changes in this PR.

✅ 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.

@erik-hunter
erik-hunter marked this pull request as ready for review June 11, 2026 21:56
@nbellowe

Copy link
Copy Markdown

This is great! I love the idea!

@austinywang

Copy link
Copy Markdown
Contributor

Addressed the CodeRabbit pre-merge i18n summary in 0bab3c1: web/data/cmux.schema.json now includes descriptionKey for browser.autoFocusMode, and docs.configuration.schemaDescriptions.browser.autoFocusMode is present in all 20 web/messages locale catalogs.

@vercel

vercel Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Jun 17, 2026 4:03am

Comment thread Sources/Panels/BrowserPanelView.swift
@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

austinywang and others added 9 commits June 16, 2026 21:31
# Conflicts:
#	.github/swift-file-length-budget.tsv
Resolved conflicts in:
- .github/swift-file-length-budget.tsv: merged budgets, taking max per file
- Resources/Localizable.xcstrings: kept blendMode.* and askWhereToSaveDownloads* from main, inserted autoFocusMode keys in alphabetical order
- cmuxTests/AppDelegateShortcutRoutingTests.swift: kept both auto-focus tests and new Cmd+I tests from main
- web/messages/en.json, web/messages/ja.json: kept both autoFocusMode and askWhereToSaveDownloads schema description entries
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 36 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="web/messages/da.json">

<violation number="1" location="web/messages/da.json:830">
P2: The Danish translation for `browser.autoFocusMode` uses "browserfane" (browser tab/surface) instead of the correct "browserpanel" or equivalent pane terminology. The English source states the feature activates "when a browser pane gains focus" — a pane is a split region that may contain multiple surfaces/tabs. The Danish text "skift til en browserfane" implies activation on tab switches, which understates/misstates the actual pane-focus behavior and could confuse users about when Focus Mode triggers. Consider aligning with the English "pane" semantics (e.g. "når et browserpanel får fokus").</violation>
</file>

<file name="Sources/Panels/BrowserPanelView.swift">

<violation number="1" location="Sources/Panels/BrowserPanelView.swift:409">
P2: If `browser.autoFocusMode` is toggled while the browser pane is already focused (for example, via `cmux.json` live reload), auto-focus mode will not activate until another transition such as blur/refocus or address-bar interaction occurs. The file already uses `.onChange(of:)` for other `@AppStorage` values like `browserThemeModeRaw`, so consider adding a matching handler for `autoFocusModeEnabled` that calls `reconcileFocusedPanelState` when the pane is focused:

```swift
.onChange(of: autoFocusModeEnabled) { _ in
    if isFocused {
        reconcileFocusedPanelState(reason: "autoFocusMode.settingChanged", isPanelFocused: true)
    }
}

This ensures live-reloaded settings take effect immediately for focused panes rather than waiting for the next focus transition.


</details>

<sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/manaflow-ai/cmux/5904/ai_pr_review_1782944750293_ed178d45-4fa6-4581-bc87-030dd32b1731?returnTo=https%3A%2F%2Fgithub.com%2Fmanaflow-ai%2Fcmux%2Fpull%2F5904)</sub>

<!-- cubic:review-post:ai_pr_review_1782944750293_ed178d45-4fa6-4581-bc87-030dd32b1731:1c665650df9361c7de97b6c9d01315981ed12b01:045a87e8-bd4b-4843-9fca-699ff82b43b5 -->

Comment thread web/messages/da.json
"customSearchEngineName": "Visningsnavn brugt når defaultSearchEngine er custom.",
"customSearchEngineURLTemplate": "Søge-URL brugt når defaultSearchEngine er custom. Medtag forespørgselspladsholderen eller %s for den kodede søgning. Uden en pladsholder tilføjer cmux q= til URLen."
"customSearchEngineURLTemplate": "Søge-URL brugt når defaultSearchEngine er custom. Medtag forespørgselspladsholderen eller %s for den kodede søgning. Uden en pladsholder tilføjer cmux q= til URLen.",
"autoFocusMode": "Når slået til, aktiverer skift til en browserfane automatisk fokustilstand, så Cmd-genveje når siden i stedet for cmux."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The Danish translation for browser.autoFocusMode uses "browserfane" (browser tab/surface) instead of the correct "browserpanel" or equivalent pane terminology. The English source states the feature activates "when a browser pane gains focus" — a pane is a split region that may contain multiple surfaces/tabs. The Danish text "skift til en browserfane" implies activation on tab switches, which understates/misstates the actual pane-focus behavior and could confuse users about when Focus Mode triggers. Consider aligning with the English "pane" semantics (e.g. "når et browserpanel får fokus").

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/messages/da.json, line 830:

<comment>The Danish translation for `browser.autoFocusMode` uses "browserfane" (browser tab/surface) instead of the correct "browserpanel" or equivalent pane terminology. The English source states the feature activates "when a browser pane gains focus" — a pane is a split region that may contain multiple surfaces/tabs. The Danish text "skift til en browserfane" implies activation on tab switches, which understates/misstates the actual pane-focus behavior and could confuse users about when Focus Mode triggers. Consider aligning with the English "pane" semantics (e.g. "når et browserpanel får fokus").</comment>

<file context>
@@ -826,7 +826,8 @@
           "customSearchEngineName": "Visningsnavn brugt når defaultSearchEngine er custom.",
-          "customSearchEngineURLTemplate": "Søge-URL brugt når defaultSearchEngine er custom. Medtag forespørgselspladsholderen eller %s for den kodede søgning. Uden en pladsholder tilføjer cmux q= til URLen."
+          "customSearchEngineURLTemplate": "Søge-URL brugt når defaultSearchEngine er custom. Medtag forespørgselspladsholderen eller %s for den kodede søgning. Uden en pladsholder tilføjer cmux q= til URLen.",
+          "autoFocusMode": "Når slået til, aktiverer skift til en browserfane automatisk fokustilstand, så Cmd-genveje når siden i stedet for cmux."
         },
         "workspaceGroups": {
</file context>
Suggested change
"autoFocusMode": "Når slået til, aktiverer skift til en browserfane automatisk fokustilstand, så Cmd-genveje når siden i stedet for cmux."
+ "autoFocusMode": "Når slået til, aktiverer det automatisk browserfokustilstand, når et browserpanel får fokus, så Cmd-genveje når siden i stedet for cmux."

@AppStorage(BrowserProfilePopoverDebugSettings.verticalPaddingKey)
private var browserProfilePopoverVerticalPaddingRaw = BrowserProfilePopoverDebugSettings.defaultVerticalPadding
@AppStorage(BrowserThemeSettings.modeKey) private var browserThemeModeRaw = BrowserThemeSettings.defaultMode.rawValue
@AppStorage(BrowserAutoFocusModeSettings.enabledKey) private var autoFocusModeEnabled = BrowserAutoFocusModeSettings.defaultEnabled

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: If browser.autoFocusMode is toggled while the browser pane is already focused (for example, via cmux.json live reload), auto-focus mode will not activate until another transition such as blur/refocus or address-bar interaction occurs. The file already uses .onChange(of:) for other @AppStorage values like browserThemeModeRaw, so consider adding a matching handler for autoFocusModeEnabled that calls reconcileFocusedPanelState when the pane is focused:

.onChange(of: autoFocusModeEnabled) { _ in
    if isFocused {
        reconcileFocusedPanelState(reason: "autoFocusMode.settingChanged", isPanelFocused: true)
    }
}

This ensures live-reloaded settings take effect immediately for focused panes rather than waiting for the next focus transition.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Sources/Panels/BrowserPanelView.swift, line 409:

<comment>If `browser.autoFocusMode` is toggled while the browser pane is already focused (for example, via `cmux.json` live reload), auto-focus mode will not activate until another transition such as blur/refocus or address-bar interaction occurs. The file already uses `.onChange(of:)` for other `@AppStorage` values like `browserThemeModeRaw`, so consider adding a matching handler for `autoFocusModeEnabled` that calls `reconcileFocusedPanelState` when the pane is focused:

```swift
.onChange(of: autoFocusModeEnabled) { _ in
    if isFocused {
        reconcileFocusedPanelState(reason: "autoFocusMode.settingChanged", isPanelFocused: true)
    }
}

This ensures live-reloaded settings take effect immediately for focused panes rather than waiting for the next focus transition.

@@ -406,6 +406,7 @@ struct BrowserPanelView: View { @AppStorage(BrowserProfilePopoverDebugSettings.verticalPaddingKey) private var browserProfilePopoverVerticalPaddingRaw = BrowserProfilePopoverDebugSettings.defaultVerticalPadding @AppStorage(BrowserThemeSettings.modeKey) private var browserThemeModeRaw = BrowserThemeSettings.defaultMode.rawValue + @AppStorage(BrowserAutoFocusModeSettings.enabledKey) private var autoFocusModeEnabled = BrowserAutoFocusModeSettings.defaultEnabled @AppStorage(BrowserImportHintSettings.variantKey) private var browserImportHintVariantRaw = BrowserImportHintSettings.defaultVariant.rawValue @AppStorage(BrowserImportHintSettings.showOnBlankTabsKey) private var showBrowserImportHintOnBlankTabs = BrowserImportHintSettings.defaultShowOnBlankTabs ```

@teamleaderleo teamleaderleo added area: browser The embedded browser, web surfaces, inline VS Code review: needs-attention Actionable automated review finding needs an author reply labels Sep 30, 2026
@teamleaderleo

Copy link
Copy Markdown
Collaborator

This opt-in browser focus setting remains distinct and live; leaving it open with the two review findings called out for follow-up.

This branch was successfully deployed

1 active (outdated) deployment
Preview – cmux — 0ed00d12 Deployed Jun 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: browser The embedded browser, web surfaces, inline VS Code review: needs-attention Actionable automated review finding needs an author reply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants