feat(desktop): configure where v2 port badges open (Settings → Links)

Merged
KI
4mo ago
+139-14

What

Adds a Ports entry under Settings → Links (v2) so you can choose where a detected-port badge's open affordance opens http://localhost:<port>:

  • Open in in-app browser (current tab)
  • Open in new browser tab (new in-app tab)
  • Open in default browser (system browser)

Previously the v2 DashboardSidebarPortBadge had a hardcoded modifier rule (⌘/⌃ → system browser, ⇧ → new tab, plain → in-app) that wasn't discoverable or configurable. This replaces it with a single portOpenAction user preference.

How

  • schema.ts — new scalar portOpenAction (LinkAction enum) on the v2 user-preferences row, default external (system browser). No tier map, so no special heal logic needed.
  • useV2UserPreferences — setPortOpenAction setter.
  • DashboardSidebarPortBadge — open handler reads portOpenAction instead of event modifiers.
  • LinksSettings — single dropdown (reuses the URL action labels).
  • settings-search — registers the LINKS_PORT item so it's searchable / visibility-gated.

Notes

  • v2 only; the sunset v1 MergedPortBadge is untouched.
  • Behavior change: default is now system browser. The old plain-click opened the in-app browser — existing users who plain-clicked will get the system browser until they change the dropdown. Easy to flip the default to pane if we'd rather preserve the old behavior.

Verification

  • bun run typecheck ✅
  • bun run lint ✅
  • schema + read-heal tests pass ✅

Open in Stage

Summary by cubic

Adds a Ports setting under Settings → Links (v2) to choose where detected-port badges open: in-app browser, new in-app tab, or the system browser. Also increases spacing between port items in the sidebar for readability.

  • New Features

    • Ports dropdown in Links settings (v2) to pick the open target.
    • Stores choice as portOpenAction in v2 user preferences (default: external).
    • DashboardSidebarPortBadge now uses the preference instead of key modifiers.
    • Added a searchable “Ports” item in settings; v1 port badges are unchanged.
    • Increased vertical spacing between items in the ports list.
  • Migration

    • Behavior change: plain-click now opens the system browser. Update Settings → Links → Ports to “In-app browser” or “New tab” if preferred.

Summary by CodeRabbit

  • New Features
    • Added a new Ports setting to control what happens when port badges are clicked.
    • Users can now choose whether ports open in the current pane, a new tab, or externally.
    • The sidebar honors this preference for port badge interactions.
  • UX Improvements
    • Port badge “open in browser” behavior no longer depends on keyboard/mouse modifier keys.
    • Added clearer “Ports” configuration UI with a saved confirmation toast.
    • Refined spacing in the expanded ports list.