Skip to content

fix(sidebar): use dedicated setting for port link browser preference - #2219

Merged
lawrencecchen merged 1 commit into
mainfrom
followup-1844-port-links
Mar 27, 2026
Merged

lawrencecchen merged 1 commit into
mainfrom
followup-1844-port-links

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds a dedicated openSidebarPortLinksInCmuxBrowser setting so port links and PR links can be controlled independently in Settings
  • openPortLink was reusing openSidebarPullRequestLinksInCmuxBrowser, meaning toggling the PR-link preference also affected port-click behavior (identified by Greptile, CodeRabbit, and cubic in feat(sidebar): make listening ports clickable to open in browser #1844)
  • Adds the new toggle to Settings UI with localized strings for all 16 supported languages

Test plan

  • Open Settings, verify new "Open Sidebar Port Links in cmux Browser" toggle appears below the PR links toggle
  • Toggle it off, click a port in the sidebar, verify it opens in the system browser
  • Toggle it on, click a port, verify it opens in the cmux browser pane
  • Verify PR link toggle still controls PR links independently
  • Reset defaults, verify both toggles return to on

Summary by CodeRabbit

  • New Features
    • Added a new settings toggle to control sidebar port link behavior, allowing users to choose whether links open in the cmux browser or their default browser
    • Includes comprehensive multi-language localization with descriptive on/off state explanations

Summary by cubic

Port links now have their own browser preference, separate from PR links. This fixes unexpected behavior and lets users choose where port clicks open without affecting PR links.

  • New Features

    • Added openSidebarPortLinksInCmuxBrowser with a Settings toggle and localized strings for 16 languages.
  • Bug Fixes

    • Port clicks no longer reuse openSidebarPullRequestLinksInCmuxBrowser; default remains opening in the cmux browser unless toggled.

Written for commit 10d7fe6. Summary will update on new commits.

Port links were reusing the PR-link preference
(openSidebarPullRequestLinksInCmuxBrowser), causing inconsistent
behavior when users toggled that setting. Adds a dedicated
openSidebarPortLinksInCmuxBrowser setting with its own toggle in
Settings so port and PR link behavior can be controlled independently.

Addresses review feedback from #1844
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@vercel

vercel Bot commented Mar 26, 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 Mar 26, 2026 10:58pm

@coderabbitai

coderabbitai Bot commented Mar 26, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces a new configurable setting that allows users to control whether sidebar port links open in the cmux browser. The implementation spans localization strings, settings infrastructure, UI controls, and link-opening behavior routing.

Changes

Cohort / File(s) Summary
Localization Strings
Resources/Localizable.xcstrings
Added three new localized string keys (settings.app.openSidebarPortLinks, subtitleOff, subtitleOn) with translations across 18+ languages describing the port-link opening behavior.
Settings Infrastructure
Sources/Panels/BrowserPanel.swift
Extended BrowserLinkOpenSettings with a new UserDefaults key, default value (true), and accessor function for the sidebar port links in cmux browser setting.
Settings UI & Link Opening
Sources/cmuxApp.swift, Sources/ContentView.swift
Added a new toggle control in the settings UI and updated the port link-opening logic in TabItemView to use the dedicated port-links setting instead of the PR-links setting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A port link skipped through the sidebar so bright,
A toggle appeared to set things just right,
With locales galore and languages wide,
The browser now bows to the user's guide! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding a dedicated setting for port link browser preference, which is the primary purpose of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description includes a clear summary of changes, a test plan with specific steps, and references the related issue #1844. However, it lacks some template items like a demo video, explicit bot review request, and completion of the provided checklist.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 followup-1844-port-links

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 and usage tips.

@greptile-apps

greptile-apps Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a long-standing bug where openPortLink was reading from openSidebarPullRequestLinksInCmuxBrowser instead of its own dedicated key, meaning the PR-link browser preference inadvertently controlled port-click behaviour as well. The fix introduces a new openSidebarPortLinksInCmuxBrowser setting end-to-end: settings model, @AppStorage bindings, Settings UI toggle, reset-to-defaults, and 18-locale string catalogue entries.\n\nKey changes:\n- BrowserPanel.swift: new openSidebarPortLinksInCmuxBrowserKey constant, default value (true), and a nil-guarded static accessor — consistent with every other entry in BrowserLinkOpenSettings.\n- ContentView.swift (TabItemView): adds @AppStorage binding for the new key and corrects openPortLink to branch on openSidebarPortLinksInCmuxBrowser.\n- cmuxApp.swift (SettingsView): exposes the toggle in Settings UI with a dynamic subtitle and .disabled(sidebarHideAllDetails) guard, and includes it in the reset-defaults path.\n- Localizable.xcstrings: adds settings.app.openSidebarPortLinks, .subtitleOn, and .subtitleOff for all 18 supported locales.\n\nMinor observation: The new toggle is positioned in the PR links block (after openSidebarPRLinks) rather than directly below the showPorts visibility toggle, which breaks the visual grouping pattern used for PR links. This is a cosmetic UX issue with no functional impact.

Confidence Score: 5/5

Safe to merge — the core bug fix is correct and all integration points (model, binding, UI, reset, localisation) are complete.

The change is self-contained: one wrong settings key swapped for the right one, backed by a properly defined constant and accessor. All call sites (ContentView, SettingsView, reset-defaults) are updated consistently. No regressions to existing PR-link behaviour. The only open item is a P2 toggle-ordering nit that has no functional consequence.

No files require special attention; Sources/cmuxApp.swift has the minor placement concern noted in the inline comment.

Important Files Changed

Filename Overview
Sources/ContentView.swift Adds @AppStorage binding for the new port key in TabItemView and fixes openPortLink to use openSidebarPortLinksInCmuxBrowser instead of the incorrect openSidebarPullRequestLinksInCmuxBrowser — the core bug fix.
Sources/Panels/BrowserPanel.swift Adds new openSidebarPortLinksInCmuxBrowserKey/defaultOpenSidebarPortLinksInCmuxBrowser constants and a openSidebarPortLinksInCmuxBrowser(defaults:) static function, following the identical nil-guard pattern used by the PR links function.
Sources/cmuxApp.swift Wires up the new setting in SettingsView: @AppStorage binding, SettingsCardRow toggle (with subtitle, disabled guard), and reset-to-defaults inclusion. Toggle is placed in the PR links block rather than adjacent to the ports visibility toggle (minor ordering inconsistency).
Resources/Localizable.xcstrings Adds three new string keys (settings.app.openSidebarPortLinks, .subtitleOn, .subtitleOff) with translations for 18 locales. Arabic omits 'sidebar' in the title key, but this matches the pre-existing pattern for the Arabic PR links translation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User clicks port in sidebar] --> B[openPortLink called]
    B --> C{openSidebarPortLinksInCmuxBrowser?}
    C -- true --> D[tabManager.openBrowser]
    D -- success --> E[Opens in cmux browser pane]
    D -- nil / failure --> F[NSWorkspace.shared.open]
    F --> G[Opens in system browser]
    C -- false --> G

    H[User clicks PR link in sidebar] --> I[openPullRequestLink called]
    I --> J{openSidebarPullRequestLinksInCmuxBrowser?}
    J -- true --> K[tabManager.openBrowser]
    K -- success --> L[Opens in cmux browser pane]
    K -- nil --> M[NSWorkspace.shared.open]
    M --> N[Opens in system browser]
    J -- false --> N

    subgraph Settings
        S1[openSidebarPortLinksInCmuxBrowser toggle]
        S2[openSidebarPullRequestLinksInCmuxBrowser toggle]
    end

    S1 -.controls.-> C
    S2 -.controls.-> J
Loading

Reviews (1): Last reviewed commit: "fix(sidebar): use dedicated setting for ..." | Re-trigger Greptile

Comment thread Sources/cmuxApp.swift
Comment on lines +4753 to +4763
SettingsCardRow(
String(localized: "settings.app.openSidebarPortLinks", defaultValue: "Open Sidebar Port Links in cmux Browser"),
subtitle: openSidebarPortLinksInCmuxBrowser
? String(localized: "settings.app.openSidebarPortLinks.subtitleOn", defaultValue: "Port clicks open inside cmux browser.")
: String(localized: "settings.app.openSidebarPortLinks.subtitleOff", defaultValue: "Port clicks open in your default browser.")
) {
Toggle("", isOn: $openSidebarPortLinksInCmuxBrowser)
.labelsHidden()
.controlSize(.small)
}
.disabled(sidebarHideAllDetails)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Settings toggle placement is inconsistent with PR links pattern

The existing PR links behavior toggle (openSidebarPRLinks) is placed immediately after the showPullRequest visibility toggle — behavior follows visibility. The new port links toggle is placed in the PR links block rather than adjacent to showPorts, so the order ends up:

openSidebarPRLinks   ← behavior for PR
openSidebarPortLinks ← behavior for port  [NEW]
showSSH
showPorts            ← visibility for port  (3 rows later)

For consistency, consider moving openSidebarPortLinks to sit directly after showPorts (mirroring the PR pattern where openSidebarPRLinks sits directly after showPullRequest). This also makes the UX more discoverable — a user enabling port forwarding visibility will find the link-behavior toggle right below it.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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

1 issue found across 4 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="Sources/Panels/BrowserPanel.swift">

<violation number="1" location="Sources/Panels/BrowserPanel.swift:556">
P2: Migrate the new port-link preference from the old PR-link setting when the new key is absent, otherwise existing users get port links forced back to the default.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +556 to +559
if defaults.object(forKey: openSidebarPortLinksInCmuxBrowserKey) == nil {
return defaultOpenSidebarPortLinksInCmuxBrowser
}
return defaults.bool(forKey: openSidebarPortLinksInCmuxBrowserKey)

@cubic-dev-ai cubic-dev-ai Bot Mar 26, 2026 •

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: Migrate the new port-link preference from the old PR-link setting when the new key is absent, otherwise existing users get port links forced back to the default.

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

<comment>Migrate the new port-link preference from the old PR-link setting when the new key is absent, otherwise existing users get port links forced back to the default.</comment>

<file context>
@@ -549,6 +552,13 @@ enum BrowserLinkOpenSettings {
     }
 
+    static func openSidebarPortLinksInCmuxBrowser(defaults: UserDefaults = .standard) -> Bool {
+        if defaults.object(forKey: openSidebarPortLinksInCmuxBrowserKey) == nil {
+            return defaultOpenSidebarPortLinksInCmuxBrowser
+        }
</file context>
Suggested change
if defaults.object(forKey: openSidebarPortLinksInCmuxBrowserKey) == nil {
return defaultOpenSidebarPortLinksInCmuxBrowser
}
return defaults.bool(forKey: openSidebarPortLinksInCmuxBrowserKey)
if defaults.object(forKey: openSidebarPortLinksInCmuxBrowserKey) != nil {
return defaults.bool(forKey: openSidebarPortLinksInCmuxBrowserKey)
}
if defaults.object(forKey: openSidebarPullRequestLinksInCmuxBrowserKey) != nil {
return defaults.bool(forKey: openSidebarPullRequestLinksInCmuxBrowserKey)
}
return defaultOpenSidebarPortLinksInCmuxBrowser
Fix with Cubic

@lawrencecchen
lawrencecchen merged commit 1b03d23 into main Mar 27, 2026
19 checks passed
bn-l pushed a commit to bn-l/cmux that referenced this pull request Apr 3, 2026
…anaflow-ai#2219)

Port links were reusing the PR-link preference
(openSidebarPullRequestLinksInCmuxBrowser), causing inconsistent
behavior when users toggled that setting. Adds a dedicated
openSidebarPortLinksInCmuxBrowser setting with its own toggle in
Settings so port and PR link behavior can be controlled independently.

Addresses review feedback from manaflow-ai#1844

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — 10d7fe60 Deployed Mar 26, 2026 by vercel[bot]
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