Commit graph

53 commits

Author SHA1 Message Date
Lawrence Chen
5ae36fcb91
Merge pull request #203 from cmer/browser-whitelist
Add wildcard hostname allowlist for built-in browser routing
2026-02-20 20:47:51 -08:00
Lawrence Chen
cf38330483 Address review: allow favicon refresh across history URL changes 2026-02-20 20:23:16 -08:00
Lawrence Chen
26a88a4b2e Fix favicon race during back/forward navigation 2026-02-20 20:17:58 -08:00
Lawrence Chen
01313b6c9a Expand default HTTP host allowlist for local dev 2026-02-20 19:55:59 -08:00
Lawrence Chen
1d5be22820 Normalize IDN host allowlist entries 2026-02-20 19:34:34 -08:00
Lawrence Chen
7cc94ffa29 Merge remote-tracking branch 'origin/main' into pr-203-browser-whitelist 2026-02-20 19:25:56 -08:00
Lawrence Chen
ce6b5e3999 Harden terminal URL host allowlist routing 2026-02-20 19:25:51 -08:00
Lawrence Chen
64f6e34e7b Merge origin/main into pr-203-browser-whitelist 2026-02-20 19:10:59 -08:00
Austin Wang
41e9b8081f
Increase hit area for browser panel buttons
Merged by manaflow for task kn71ngz7871bej8k7m9ka2qy7d81kxqd.
2026-02-20 19:10:48 -08:00
Lawrence Chen
39c16183ee
Merge pull request #222 from manaflow-ai/feat-pr117-review-followup
Follow up browser DevTools and portal review comments from PR 117
2026-02-20 19:03:38 -08:00
Austin Wang
04431751ce
Fix file drag-and-drop and file input in browser panel (#214)
* Fix file drag-and-drop and file input in browser panel (#194)

Two fixes for the browser panel:

1. File drag-and-drop from Finder: CmuxWebView previously suppressed ALL
   drag type registration as a no-op to prevent bonsplit tab drags from
   being intercepted. Now it selectively filters out only the text-based
   types that conflict with bonsplit (public.text, public.utf8-plain-text,
   public.plain-text) and the custom tab transfer types, while allowing
   file URL types through so Finder drops work.

2. File <input> elements: Added the WKUIDelegate runOpenPanelWith method
   to BrowserUIDelegate so clicking a file input opens the native macOS
   file picker (NSOpenPanel), with support for multiple selection and
   directory picking as specified by the HTML element.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore(claude-opus-4-6): take a look at https://github.com/manaflow-ai/cmux/issues...

* ok

* wok

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 18:26:23 -08:00
Lawrence Chen
f294699670 Fix browser DevTools retry and portal visibility follow-ups 2026-02-20 18:00:20 -08:00
Lawrence Chen
438b7a6a41 Merge remote-tracking branch 'origin/main' into fix/browser-devtools-shortcuts-pr
# Conflicts:
#	Sources/Panels/BrowserPanel.swift
#	Sources/cmuxApp.swift
#	cmuxTests/CmuxWebViewKeyEquivalentTests.swift
#	vendor/bonsplit
2026-02-20 15:48:27 -08:00
Lawrence Chen
ea0593475c
Merge pull request #206 from manaflow-ai/issue-180-http-nonsecure-hosts
Allow HTTP in built-in browser for local dev hosts
2026-02-20 15:39:22 -08:00
Austin Wang
270115ccbb
Fix Cmd+Enter being routed as browser reload (#213) 2026-02-20 15:36:24 -08:00
Lawrence Chen
6133da0b20 Prefer navigate row over switch-to-tab for identical URL 2026-02-20 15:19:06 -08:00
Lawrence Chen
3ffceb7e8e Fix insecure HTTP proceed to be one-time unless saved 2026-02-20 15:16:12 -08:00
Lawrence Chen
79b34052cb Persist HTTP allowlist selection when opening externally 2026-02-20 15:00:54 -08:00
Lawrence Chen
821e3ab4c3 Guard insecure HTTP in browser with allowlist and proceed flow 2026-02-20 14:55:26 -08:00
Carl Mercier
5e74161324
Add wildcard hostname allowlist for built-in browser routing (#195)
Adds a configurable host allowlist in Settings > Browser that controls
which terminal links open in the cmux embedded browser vs the system
default browser. Supports exact match and wildcard prefix patterns
(e.g. localhost, 127.0.0.1, *.localtest.me). Empty list preserves
existing behavior of opening all web links in cmux.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 16:24:50 -06:00
Lawrence Chen
cae40d1a4c
Sidebar ports on own line, wider sidebar, CMUX_PORT env vars (#160)
* Sidebar ports on own line, wider sidebar, CMUX_PORT env vars

- Move listening ports to dedicated sidebar row (removed from branch/directory line)
- Allow sidebar to resize up to 2/3 of screen width (was capped at 360px)
- Add CMUX_PORT, CMUX_PORT_END, CMUX_PORT_RANGE env vars per workspace
- Each workspace gets a dedicated port range (default: base 9100, range 10)
- Add settings UI for port base and range size
- Add portOrdinal to Workspace, monotonic counter in TabManager

Closes #129

* Make port ordinal counter static to avoid overlap across windows

Each window creates its own TabManager, so a per-instance counter
would reset and reuse port ranges. Making it static ensures unique
ranges across all windows.

* Fix portOrdinal race: pass through Workspace init instead of setting after

The first TerminalPanel is created inside Workspace.init, so setting
portOrdinal after init returns meant the initial terminal always got
ordinal 0. Pass portOrdinal as an init parameter and set it before
the TerminalPanel is created.

* Fix P2/P3: snapshot port settings at surface creation, use window screen for sidebar cap

P2: Port base/range are now snapshotted on TerminalSurface when the
panel is created, so changing settings mid-session won't cause
inconsistent CMUX_PORT values across terminals in the same workspace.

P3: Sidebar max width now uses NSApp.keyWindow?.screen instead of
NSScreen.main, so multi-monitor setups get the correct 2/3 cap for
the display the window is actually on.

* Fix P1: snapshot port base/range once per app session, not per panel

Port base and range size are now static properties on TerminalSurface,
initialized once from UserDefaults at first access. This prevents
overlapping port ranges across workspaces when settings are changed
mid-session (e.g., workspace 1 with range=10 at 9110-9119, then
range changed to 5, workspace 2 would overlap at 9110).
2026-02-20 14:12:14 -08:00
Lawrence Chen
5560492d27
Add preference to disable in-app browser for terminal links (#174)
* Add preference for terminal link browser target

Fixes https://github.com/manaflow-ai/cmux/issues/172

* Route non-web terminal links to external opener

Only route http/https terminal links to cmux's embedded browser.
Absolute paths, file:// URLs, and non-web schemes now open via NSWorkspace.

Refs https://github.com/manaflow-ai/cmux/issues/172
2026-02-20 13:58:39 -08:00
Lawrence Chen
eb5c52d239 Render unread notification ring above portal-hosted terminal view 2026-02-20 02:41:52 -08:00
Lawrence Chen
4588c3b0d1 Avoid O(N) re-renders by passing derived Bool instead of ObservableObject
Replace @ObservedObject notificationStore in TerminalPanelView and
PanelContentView with a plain `let hasUnreadNotification: Bool`.
The parent WorkspaceContentView already subscribes to the store
via @EnvironmentObject; it now computes the per-panel Bool and
passes it down, so child views only re-render when their own
notification state actually changes.
2026-02-20 02:41:52 -08:00
Lawrence Chen
cef1513ceb Fix notification ring not appearing on terminal panes
TerminalPanelView and PanelContentView held notificationStore as a
plain `let` property. Since it's a reference type (class), SwiftUI's
structural diffing saw no change when notifications were added and
skipped re-evaluating the view body. Changed to @ObservedObject var
so the views properly subscribe to the store's @Published changes.

Closes #126
2026-02-20 02:41:52 -08:00
Lawrence Chen
153b73c952 Add earlier devtools shortcut snapshots and geometry probes 2026-02-20 01:04:16 -08:00
Lawrence Chen
5b2be45f3a
Fix browser panel mouse back/forward buttons and middle-click (#131) (#139)
Handle multi-button mouse events in the browser panel's WKWebView:

- Mouse back button (button 3) triggers goBack(), forward button
  (button 4) triggers goForward(), enabling side-button navigation
  on mice like Logitech
- Middle-click (button 2) on a link opens it in a new browser tab
  by hit-testing the click position via JavaScript and routing through
  the existing openLinkInNewTab mechanism
2026-02-19 23:38:21 -08:00
Lawrence Chen
db66fc4bb0 Stabilize browser portal bounds and log inspector height metrics 2026-02-19 23:19:00 -08:00
Lawrence Chen
943858acff Defer and auto-arm devtools refresh across reparent 2026-02-19 21:17:55 -08:00
Lawrence Chen
54a0f78d75 Harden browser devtools split reparent flow 2026-02-19 21:13:41 -08:00
Lawrence Chen
6170143b6d Add deep split/devtools reparent diagnostics 2026-02-19 20:41:22 -08:00
Lawrence Chen
f546c289c3 Preserve devtools webview during split teardown 2026-02-19 20:38:31 -08:00
Lawrence Chen
397e46a667 Add devtools split diagnostics and restore retries 2026-02-19 20:31:00 -08:00
Lawrence Chen
743cfcdc6d Fix browser devtools persistence and Safari shortcut wiring 2026-02-19 20:21:01 -08:00
Lawrence Chen
de666ff05b Fix split blackout race and stabilize focus handoff 2026-02-19 17:10:27 -08:00
Lawrence Chen
1d246b2bbd Fix omnibar focus intent races for Cmd+L 2026-02-19 00:35:25 -08:00
Lawrence Chen
5fc4df467a
Fix omnibar Cmd+L infinite focus loop causing 100% CPU (#97)
The browser omnibar's updateNSView and controlTextDidEndEditing
were both dispatching makeFirstResponder calls without any guard
against re-dispatch. Each makeFirstResponder triggers SwiftUI's
FirstResponderObserver, which re-evaluates the view graph, which
calls updateNSView again, creating an infinite loop via the main
dispatch queue.

Fix: Add a pendingFocusRequest flag on the coordinator to prevent
re-dispatching while a focus/blur request is already in flight.
Also add nsView.currentEditor() != nil to the isFirstResponder
check so the field is recognized as focused during the transition
when the field editor (not the field itself) is first responder.
2026-02-18 23:18:08 -08:00
Lawrence Chen
d08f28d770
Merge pull request #83 from manaflow-ai/perf/portal-hosting-selected-mount
Reduce terminal input latency via portal hosting + selected-only workspace mounting
2026-02-18 22:31:45 -08:00
Lawrence Chen
ee4848c008 Speed up workspace switching: reduce portal churn and enforce selected z-order 2026-02-18 22:13:40 -08:00
Austin Wang
ab89fab897
Fix browser opening new tabs on link click (#92)
* Fix browser panel opening new tabs on every link click

Navigate target=_blank and window.open() links in the current webview
instead of spawning new browser tabs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Preserve cmd+click new tab behavior in createWebViewWith

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 21:53:36 -08:00
Austin Wang
2d64ecfc44
fixes crashes and filedrop fatal issue 2026-02-18 20:46:31 -08:00
Lawrence Chen
27df9cd171 Remove SwiftUI dimming fallback for portal terminals 2026-02-18 20:28:00 -08:00
Lawrence Chen
b05347884d Restore unfocused pane dimming for portal-hosted terminals 2026-02-18 20:24:54 -08:00
Austin Wang
0cca513eac
Browser searchbar bugs (#51)
* Add "+" menu button to horizontal tab bar for new terminal/browser tabs

Adds a "+" button to the tab bar (next to split buttons) that shows a
dropdown menu with "New Terminal ⌘T" and "New Browser ⌘⇧L" options.

- Uses native NSButton + NSMenu so the icon matches the split buttons
- Menu appears below the button
- Routes tab creation through new didRequestNewTab delegate method

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* works

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 16:26:42 -08:00
Lawrence Chen
c2fdd48290
Release v1.36.0 (#47)
* Fix multi-workspace drag/drop, WebView click focus, and add regression tests

- Wire bonsplit isInteractive to workspace active state so inactive
  workspace NSViews are hidden from AppKit event routing
- Add CmuxWebView.mouseDown notification for browser panel focus
  tracking (AppKit delivers clicks to WKWebView, not SwiftUI overlays)
- Add multi-workspace focus regression test covering isHidden fix,
  rapid workspace switching, and browser panel focus routing

* Bump version to 1.36.0
2026-02-17 04:04:29 -08:00
Lawrence Chen
2678606a20
Fix omnibar tracking timeout using background queue (#46)
The 3-second safety net that posts a synthetic mouseUp to break out of
NSTextView's stuck tracking loop was dispatched on the main queue. Since
super.mouseDown blocks the main thread in the tracking loop, the timeout
could never fire. Use a background queue instead (NSApp.postEvent is
thread-safe). Use DispatchWorkItem.isCancelled for atomic cancellation.
2026-02-17 03:35:49 -08:00
Lawrence Chen
484b66c8ac
Fix terminal keys swallowed after opening browser (#45)
* Fix terminal keys (arrows, Ctrl+N/P) swallowed after opening browser

After a browser panel is shown, SwiftUI's internal focus system activates
and its _NSHostingView starts consuming arrow keys and other non-Command
key events via performKeyEquivalent, preventing them from reaching the
terminal's keyDown handler.

Fix: In the NSWindow performKeyEquivalent swizzle, when GhosttyNSView is
the first responder and the event has no Command modifier, route directly
to the terminal's performKeyEquivalent — bypassing SwiftUI's view hierarchy
walk entirely.

Also clear stale browserAddressBarFocusedPanelId when a terminal surface
has focus, preventing Cmd+N from being eaten by omnibar selection logic
after focus transitions away from a browser.

Adds DEBUG-only keyboard event ring buffer (KeyDebugLog) that dumps to
/tmp/cmux-key-debug.log for diagnosing future key routing issues.

* Fix split focus and Cmd+Shift+N swallowed after opening browser

Split focus: capture the source terminal's hostedView before bonsplit
mutates focusedPaneId, so focusPanel moves focus FROM the old pane
instead of from the new pane to itself. Also retry ensureFocus when the
new terminal's view has no window yet (matching the existing retry
pattern for isVisibleInUI).

Cmd+Shift+N: after WKWebView has been in the responder chain, SwiftUI's
internal focus system can intercept Command-key events in the content
view hierarchy (returning true) without firing the CommandGroup action
closure. Fix by dispatching Command-key events directly to NSApp.mainMenu
when the terminal is first responder, bypassing the broken SwiftUI path.
Also add Cmd+Shift+N to handleCustomShortcut so it's customizable and
doesn't depend on SwiftUI menu dispatch at all.

* Unified debug event log: merge key/mouse/focus into /tmp/cmux-debug.log

- Delete KeyDebugLog, MouseDebugLog, klog(), mlog() from AppDelegate
- Replace all klog/mlog calls with dlog() (provided by bonsplit)
- Remove debugLogCallback wiring from Workspace
- Add focus change logging: focus.panel, focus.firstResponder,
  split.created, focus.moveFocus
- Add import Bonsplit where needed for dlog access
- Fix stale drag state on cancelled tab drags (bonsplit submodule)

* Fix split focus stolen by re-entrant becomeFirstResponder during reparenting

During programmatic splits (Cmd+D / Cmd+Shift+D), SwiftUI reparents the old
terminal view, which fires becomeFirstResponder → onFocus → focusPanel for the
OLD panel, stealing focus from the newly created pane.

Add programmaticFocusTargetPanelId guard to suppress re-entrant focusPanel
calls for non-target panels during split creation.

Also document the unified debug event log in CLAUDE.md.

* Clear stale title/favicon when browser navigation fails

When a page fails to load (e.g. connection refused), the tab was still
showing the previous page's title and favicon. Now didFailProvisionalNavigation
resets pageTitle to the failed URL and clears faviconPNGData.

* Fix Cmd+N swallowed by browser omnibar and improve split focus suppression

- Only Ctrl+N/P trigger omnibar navigation, not Cmd+N/P (Cmd+N should
  always create new workspace regardless of address bar focus)
- Move split focus suppression from workspace-level guard to source:
  suppress becomeFirstResponder side-effects (onFocus + ghostty_surface_set_focus)
  directly on the old GhosttyNSView during reparenting, preventing both
  model-level and libghostty-level focus divergence
- Remove programmaticFocusTargetPanelId from Workspace.focusPanel

* Fix omnibar hang, WebView white flash, drag-over-browser, and idle CPU spin

- Omnibar: first click selects all without entering NSTextView tracking loop;
  subsequent clicks have 3s synthetic mouseUp safety net to prevent hang
- WebView: set underPageBackgroundColor to match window so new browsers don't
  flash white before content loads
- Drag/drop: register custom UTType (com.splittabbar.tabtransfer) in Info.plist
  so WKWebView doesn't intercept tab drags; override registerForDraggedTypes
  on CmuxWebView as belt-and-suspenders
- CPU: fix infinite makeFirstResponder loop in controlTextDidEndEditing by
  checking both the text field and its field editor (the actual first responder)
2026-02-17 03:21:08 -08:00
austinpower1258
bd54d06213 fixes browser issue with localhost 2026-02-16 16:21:31 -08:00
Lawrence Chen
3fa72a0b0b Add sidebar metadata (git branch, ports, logs, progress), fix localhost URL resolution, simplify analytics
- Sidebar now shows git branch, listening ports, log entries, progress bars, and status pills with expand/collapse
- Fix localhost/127.0.0.1 URL parsing by checking before generic URL(string:) which misinterprets the scheme
- Remove custom Keychain distinct ID in favor of PostHog SDK's built-in anonymous ID
- browser open now defaults to caller's workspace via CMUX_WORKSPACE_ID env var
- Improve CLI help text for environment variables
2026-02-16 02:46:39 -08:00
Lawrence Chen
de6cfededa Fix inline completion showing "news." instead of "news.ycombinator.com"
Reject URLs whose host lacks a TLD (no internal dot) from autocompletion
candidates, history recording, and clean up existing bogus entries on load.
2026-02-15 21:13:31 -08:00