Commit graph

183 commits

Author SHA1 Message Date
Austin Wang
2d2d8da1c7
Merge pull request #2355 from manaflow-ai/issue-2352-shift-enter-tmux
Map Shift+Enter to raw newline in Ghostty
2026-03-30 18:10:57 -07:00
Lawrence Chen
dd54927cb9
Add React Grab inject button to browser toolbar (#2373)
* Add React Grab inject button to browser toolbar

Adds a toolbar button (cursor click icon) that injects the react-grab
script (unpkg.com/react-grab/dist/index.global.js) into the current
page. Hover over React elements and Cmd+C to copy component context
(file, component name, line number) for AI agents.

Button highlights when active, resets on navigation.

* Auto-activate selection mode on React Grab inject

First click: injects the script and auto-activates selection mode via
the react-grab:init event. Subsequent clicks toggle selection mode
on/off via window.__REACT_GRAB__.toggle().

* Bridge React Grab state back to Swift via WKScriptMessageHandler

Register a cmux-bridge plugin after injecting react-grab that posts
state changes back to Swift via webkit.messageHandlers. The button
now highlights accent color only when selection mode is actually
active (not just when the script is loaded), and deactivates when
the user exits selection mode via Escape or the react-grab toolbar.

* Fetch react-grab script via URLSession to bypass CSP

Sites like vercel.com block loading external scripts via CSP headers.
Fetch the script with URLSession (not subject to page CSP), cache it,
and inject inline via evaluateJavaScript. Also guard against duplicate
injection on repeated clicks.

* Prefetch react-grab script on first browser panel init

Kick off a low-priority background fetch of the react-grab script
when the first BrowserPanel is created. The script is cached
statically so clicking the button is instant.

* Eliminate react-grab button and callback lag

Three changes:
1. Fire-and-forget: use evaluateJavaScript with completionHandler
   instead of await, so button taps return immediately.
2. Single JS payload: combine bootstrap listener + script source
   into one evaluateJavaScript call (one IPC round-trip, not two).
3. Dedupe state callbacks: only post webkit message when isActive
   actually changes, not on every hover/drag state update.

* Fix duplicate state callback on react-grab toggle

toggleReactGrab was sending an explicit postMessage AND the plugin's
onStateChange hook was firing too, causing two @Published updates per
toggle. Remove the explicit postMessage since the plugin hook handles
it. Also add dlog instrumentation for debugging.

* Add Cmd+Shift+G shortcut for React Grab (configurable)

- Add toggleReactGrab to KeyboardShortcutSettings with Cmd+Shift+G default
- Add View menu item with customizable shortcut
- Add command palette entry (searchable as "react grab" or "inspect element")
- Simplify button to use toggleOrInjectReactGrab, remove local state tracking

* Fix Codex review findings: pin version, verify hash, fix retry and state

1. Pin react-grab to exact version (0.1.29) with SHA-256 integrity
   check. Script is verified before evaluation to prevent supply-chain
   attacks via compromised CDN responses.
2. Clear prefetchTask on failure so subsequent attempts retry the
   download instead of reusing a permanently failed task.
3. Remove premature isReactGrabActive=true. State is now only set
   by the onStateChange message handler callback after confirmed
   initialization, or explicitly reset on evaluation error.

* Extract React Grab into own file, make version configurable

Move all react-grab logic (settings, script loader, message handler,
BrowserPanel extension) into Sources/Panels/ReactGrab.swift.

Add a "React Grab Version" text field in Settings > Browser that lets
the user pin which npm version is fetched. Only versions with a known
SHA-256 integrity hash in ReactGrabSettings.knownHashes are accepted.
The cache invalidates when the configured version changes.

---------

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-30 18:00:45 -07:00
austinpower1258
9080248393 Gate Shift+Enter newline remap to tmux 2026-03-30 02:55:19 -07:00
Austin Wang
94cc865e83
Fix sidebar live refresh for branch and PR state (#2331)
* Add regression coverage for sidebar live refresh

* Refresh sidebar git metadata on active workspaces
2026-03-29 18:15:57 -07:00
Austin Wang
c4bc18d906
Fix ARC workspace inheritance crash and native Zig helper builds (#2283)
* Fix ARC workspace inheritance crash and native Zig helper builds

* Fix Nightly Cmd+N workspace creation crash

* Restore safe terminal config snapshots for Intel Nightly
2026-03-28 03:05:00 -07:00
Austin Wang
63904811f9
Revert "Fix Intel second-surface config inheritance crash (#2179)" (#2267)
This reverts commit 1f4fc476ab.
2026-03-27 20:07:12 -07:00
Austin Wang
1f4fc476ab
Fix Intel second-surface config inheritance crash (#2179) 2026-03-26 23:41:21 -07:00
Austin Wang
32124d9256
Revert "Merge pull request #1915 from elvistranhere/fix/split-crash-intel-1870" (#2221)
This reverts commit c5b306655d, reversing
changes made to 100612d96e.
2026-03-26 16:01:53 -07:00
Usman Ehtesham Gul
66b0260442
Add --name flag to new-workspace CLI command (#2160)
Allow naming a workspace at creation time instead of requiring a
separate rename-workspace call afterward.

Threads a title parameter through:
- CLI: --name <title> flag parsed and sent as "title" in v2 params
- V2 handler: extracts title, passes to TabManager.addWorkspace()
- TabManager: uses provided title instead of auto-generated
  "Terminal N" and calls setCustomTitle() to persist it
- V1 handler: accepts optional name argument

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 15:18:20 -07:00
Austin Wang
fe0443fa2b
Fix Cmd+N nightly crash: avoid local Workspace refs in ARC hotpath (#2204)
* test: reproduce Cmd+N snapshot workspace lifetime race

* fix: retain snapshot workspaces through Cmd+N creation

* fix: repair workspace lifetime regression test

* fix: extract workspace config through self to avoid Xcode 16.x ARC crash

The snapshot approach (c1998e34) navigated workspace → panel → surface
through local variables. Xcode 16.4's -O ARC optimizer aggressively
elides retains on these locals through inlined call chains, causing
use-after-free on every Cmd+N in CI-built nightlies.

Fix: extract preferredWorkingDirectory and inheritedTerminalFontPoints
through self (always retained) BEFORE capturing locals. The snapshot
is now purely value-typed with no Workspace references held in locals.

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 14:28:32 -07:00
Austin Wang
61e6a0e2b9
Fix Release-only Cmd+N workspace snapshot UAF (#2181)
* test: reproduce Cmd+N snapshot workspace lifetime race

* fix: retain snapshot workspaces through Cmd+N creation

* fix: repair workspace lifetime regression test
2026-03-25 19:12:24 -07:00
Austin Wang
b93be12b08
Fix Cmd+N crash from workspace creation config snapshots (#2178)
* Add workspace config sanitization regression test

* Sanitize workspace creation config snapshots

---------

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-25 18:10:25 -07:00
Lawrence Chen
8a3ab6b3f0
Fix command palette focus after terminal find (#2089)
* test: cover command palette focus guard

* fix: block terminal find from stealing palette focus

* test: cover text view focus-stealer fallback

* Add regression for hidden DevTools sync republish loop

* Avoid redundant DevTools visibility publishes

* test: cover browser find focus after workspace round-trip

* fix: restore browser find focus after workspace round-trip

* fix: keep browser find caret on workspace return

* Add workspace round-trip split find regressions

* Keep inactive find overlays from stealing focus

---------

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-25 17:27:54 -07:00
Austin Wang
cbf08459d6
Fix Cmd+N workspace creation snapshot crashes (#2173)
* Add regression tests for Cmd+N workspace snapshot mutations

* Fix Cmd+N workspace creation snapshot races
2026-03-25 16:52:04 -07:00
Austin Wang
9f2adce830
fix: guard inherited terminal config against stale surfaces (#2101)
* test: add stale inherited surface regression

* fix: guard inherited terminal config against stale surfaces

* fix: address stale surface review feedback
2026-03-25 16:49:54 -07:00
austinpower1258
17e8bb172d Fix Cmd+N crash from stale workspace creation snapshots 2026-03-25 02:38:20 -07:00
austinpower1258
ad2c65e0ac Add regression test for Cmd+N snapshot close race 2026-03-25 02:38:10 -07:00
Austin Wang
da70f3fa47
Add regression coverage for Cmd+N workspace creation crash (#2127)
* Add Cmd+N workspace snapshot regression coverage (#2017)

* Add dev flag to stress Cmd+N workspace creation
2026-03-25 01:50:57 -07:00
jorge g
68ff39c444
Fix Ghostty resize_split keybind support (#1899)
* test: add resize_split regression coverage

* fix: implement Ghostty resize_split behavior

* test: cover more resize_split cases

* test: deduplicate split snapshot helper

* Resolve merge conflict: keep both splitNodes and waitForCondition helpers

---------

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-25 00:26:27 -07:00
Austin Wang
3952c2588b
Fix workspace creation crash after restore (#1985)
Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-25 00:04:03 -07:00
Lawrence Chen
a7e5050552
Fix SSH control master cleanup on remote teardown (#2104)
* test: add SSH control master cleanup regressions

* fix: close SSH control master on remote teardown

* test: keep SSH workspace after child exit

* fix: keep SSH workspace after child exit

* fix: keep connecting SSH workspaces after child exit

* test: add SSH child-exit demotion regression

* fix: keep SSH workspace after connected shell exit

* fix: address SSH cleanup review feedback

* test: cover SSH cleanup without explicit controlpath

* fix: clean up SSH control masters without explicit controlpath

* test: cover remote detach cleanup edge cases

* fix: preserve SSH sessions during remote detach

---------

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-25 00:01:39 -07:00
Austin Wang
983ef2537d
Skip sidebar PR lookup on main/master (#2110) 2026-03-24 22:56:40 -07:00
Lawrence Chen
65867b86ee
fix: resolve workspace placement before init (#2099)
Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-24 21:38:48 -07:00
Austin Wang
7ffa447708
Fix sidebar badges not refreshing on workspace state change (#2046)
* Add regression test for stale sidebar PR refresh

* Refresh sidebar badges when workspace metadata changes

* Resolve gh for app-side PR probes

* Coalesce sidebar redraws during prompt updates
2026-03-24 19:18:18 -07:00
Lawrence Chen
1c45915a86
Avoid crash in workspace insert index 2026-03-23 19:10:33 -07:00
Lawrence Chen
c5b306655d
Merge pull request #1915 from elvistranhere/fix/split-crash-intel-1870
Fix #1870: prevent split crash on Intel Macs caused by stale font pointer
2026-03-22 17:14:03 -07:00
Lawrence Chen
01ffeb3f44
Merge pull request #1898 from manaflow-ai/feat-tmux-notification-attention-state
Improve tmux notification attention routing
2026-03-22 15:36:36 -07:00
Austin Wang
76c1e632f0
Merge pull request #1895 from manaflow-ai/issue-1863-pinned-workspace-close-protect
Confirm before closing pinned workspaces
2026-03-21 12:36:55 -07:00
Elvis Tran
a396242631 Address review feedback: guard TabManager call site, clarify malloc_size
- Add hasLiveSurface guard in TabManager.inheritedTerminalConfigForNewWorkspace
  to protect the cmuxInheritedSurfaceConfig call site missed in the initial fix
- Expand malloc_size comment to clarify it is a best-effort heuristic, not a
  lifetime guarantee (per Copilot review)
2026-03-22 00:06:15 +10:30
Austin Wang
5c4fab1296
Fix sidebar PR badge detection for workspace branches (#1896)
* test: cover sidebar PR probe selection

* fix: detect sidebar PR badges across github remotes
2026-03-20 21:10:08 -07:00
Lawrence Chen
2a04ac378c
Dismiss notification attention on focus 2026-03-20 20:59:56 -07:00
austinpower1258
0580de44a5 Confirm before closing pinned workspaces 2026-03-20 20:59:43 -07:00
Lawrence Chen
656786fb71
Fix tmux notification attention routing 2026-03-20 20:20:54 -07:00
austinpower1258
b10cddcb9b Protect pinned workspaces from close actions 2026-03-20 19:38:24 -07:00
Austin Wang
55cb5c6763
Fix sidebar workspace PR status display and false positives (#1636)
* test(sidebar): add failing PR checks regressions

* fix(sidebar): show workspace PR status

* refactor(sidebar): restore PR icon style

* refactor(sidebar): simplify PR check labels

* test(sidebar): cover focused workspace PR selection

* fix(sidebar): scope workspace PRs to current branch

* test(sidebar): cover stale PR after branch change

* fix(sidebar): clear stale PRs on branch changes

* test(sidebar): cover workspace PR false positives

* fix(sidebar): stop false-positive workspace PR badges

* test(cmuxTests): remove duplicate sidebar PR regressions
2026-03-17 22:57:12 -07:00
Austin Wang
bdd95902f2
Restore last-surface close preference toggle (#1679)
* test: cover last-surface close preference regression

* fix: restore last-surface close preference
2026-03-17 22:36:32 -07:00
Lawrence Chen
832426af56
Stabilize SSH remote flow after merging main 2026-03-16 23:57:48 -07:00
Lawrence Chen
03dc055138
Merge remote-tracking branch 'origin/main' into pr-ssh-stack-main
# Conflicts:
#	CLI/cmux.swift
#	Sources/Panels/BrowserPanel.swift
#	Sources/TabManager.swift
#	Sources/Workspace.swift
#	cmuxTests/GhosttyConfigTests.swift
2026-03-16 23:16:12 -07:00
Lawrence Chen
746fb8e5ec
Merge pull request #318 from manaflow-ai/issue-122-import-browser-cookies-history-settings
Browser: import data from detected installed browsers
2026-03-16 22:42:40 -07:00
Lawrence Chen
92cb42262c
feat: add browser profile mapping import flow 2026-03-16 21:22:39 -07:00
Austin Wang
7f220dc8e4
Fix sidebar PR badges for restored workspaces (#1570)
* test: cover sidebar PR explicit branch fallback

* fix: restore sidebar PR badges for workspace branches

* test: preserve sidebar PR badge on first prompt

* fix: keep sidebar PR badges through first prompt
2026-03-16 21:09:02 -07:00
Lawrence Chen
7a9a6a550c
Keep pinned workspaces above the sidebar pin boundary (#1503)
* test: cover pinned workspace reorder boundary

* fix: keep pinned workspaces above drag boundary

---------

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-15 21:31:30 -07:00
Austin Wang
bd1788639d
Fix terminal find overlay crash and focus handoff (#1487)
* Add regression tests for terminal find overlay races

* Fix terminal find overlay crash and focus handoff
2026-03-15 18:32:24 -07:00
Lawrence Chen
623262493b
Fix stale Claude sidebar status: add missing hooks, OSC suppression, PID sweep (#1306)
* Fix stale Claude status in sidebar by adding missing hooks and OSC suppression

The Claude Code integration only used 3 hooks (SessionStart, Stop, Notification),
leaving gaps that caused stale sidebar status. Now uses 6 hooks:

- SessionEnd: clears status when Claude exits (covers Ctrl+C where Stop doesn't fire)
- UserPromptSubmit: clears "Needs input" and sets "Running" on new prompt
- PreToolUse (async): clears "Needs input" when Claude resumes after permission grant

Also:
- Suppress OSC 9/99 desktop notifications for workspaces with active Claude hook
  sessions to prevent duplicates from the raw OSC path
- Store Claude process PID in status entries for stale-session detection
- Add 30-second sweep timer that checks agent PIDs and clears stale entries
  (safety net for SIGKILL/crash where no hook fires)
- Update wrapper test expectations for the new hook set

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

* Don't show "Running" status on Claude launch, only when actually working

SessionStart now registers the PID for tracking and OSC suppression via
set_agent_pid without setting a visible status entry. "Running" only
appears when the user submits a prompt (UserPromptSubmit) or Claude
starts using tools (PreToolUse).

Added set_agent_pid / clear_agent_pid socket commands to decouple PID
tracking from visible status entries. OSC suppression checks agentPIDs
instead of statusEntries so it works during the initial idle period.

* Don't restore status entries across app restarts

Status entries are ephemeral runtime state tied to running processes
(e.g. claude_code "Running"). Restoring them after restart shows stale
status for processes that no longer exist.

* Address PR review comments and remove debug logging

- session-end: only clear status/PID/notifications when Stop didn't fire first
- PID sweep: check errno == ESRCH instead of treating all kill(pid,0) failures as dead
- Validate CMUX_CLAUDE_PID > 0
- Propagate tracked PID in pre-tool-use setClaudeStatus
- OSC suppression: use tabManagerFor(tabId:) for multi-window support
- clearAgentPID: resolve tab UUID before async dispatch
- restoreSessionSnapshot: also clear agentPIDs alongside statusEntries
- Fix AskUserQuestion surfaceId overwrite (wrong workspace notification)
- Fix notification text matching for "Claude Code needs your attention"
- AskUserQuestion: render option labels as bracketed inline text
- Remove artificial text truncation limits
- Remove temporary JSONL debug logging from all handlers

* Use resolveTabIdForSidebarMutation in clearAgentPID
2026-03-13 20:47:42 -07:00
Lawrence Chen
5e7458b920 Fix SSH workspace priming and restore state 2026-03-13 20:01:26 -07:00
Lawrence Chen
2eae782739 Merge remote-tracking branch 'origin/main' into pr-ssh-stack-main
# Conflicts:
#	.github/workflows/ci.yml
#	CLI/cmux.swift
#	Sources/GhosttyTerminalView.swift
#	Sources/SocketControlSettings.swift
#	Sources/TabManager.swift
#	Sources/TerminalController.swift
#	Sources/Workspace.swift
#	ghostty
#	scripts/reload.sh
2026-03-13 17:56:38 -07:00
Lawrence Chen
5dd93a8ab1
Merge pull request #1401 from manaflow-ai/task-cmd-shift-u-exits-cmd-shift-enter-mode
Exit split zoom when jumping to unread
2026-03-13 17:28:34 -07:00
Lawrence Chen
09a98c911d
Guard notification focus failures 2026-03-13 17:21:40 -07:00
Austin Wang
3891a787f6
Merge pull request #1403 from manaflow-ai/cmux/cwd-regression
Fix split cwd inheritance while shell cwd is stale
2026-03-13 17:09:54 -07:00
Lawrence Chen
02854441e9
Clear split zoom when jumping to unread 2026-03-13 16:03:07 -07:00