Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
f817903
Add browser automation fixture suite + reliability regression UITests…
lawrencecchen Jun 10, 2026
24d529f
Fix browser CLI reliability: worker-lane JS methods, CSP eval fallbac…
lawrencecchen Jun 10, 2026
3c7a8d8
Address autoreview: restore discarded tabs instead of blanking; updat…
lawrencecchen Jun 10, 2026
6c8b8be
UITests: treat foreground as best-effort on hosted runners; gate on s…
lawrencecchen Jun 10, 2026
b20ef81
UITests: never activate() in socket-driven browser tests; track new f…
lawrencecchen Jun 10, 2026
de24e6c
UITests: wrap launch in non-strict XCTExpectFailure for headless-runn…
lawrencecchen Jun 10, 2026
07db958
Address autoreview: invalidate the blank-page kick KVO observation on…
lawrencecchen Jun 10, 2026
7b5b4eb
Address autoreview: run --snapshot-after off main; preserve about:bla…
lawrencecchen Jun 10, 2026
871a315
Address Greptile P1: flag isolated-world eval results instead of retu…
lawrencecchen Jun 10, 2026
26dbae0
Address autoreview: in-process browser dispatch, wait routing, gate C…
lawrencecchen Jun 10, 2026
3e65735
Address Codex P2: preserve cmux-diff-viewer:// URLs in open_split
lawrencecchen Jun 10, 2026
1a9d6fa
Address autoreview: external schemes in open_split, sidebar order, fi…
lawrencecchen Jun 11, 2026
e1e96b7
Merge remote-tracking branch 'origin/main' into feat-browser-reliability
lawrencecchen Jun 11, 2026
498ab45
Fix Swift warning budget after main merge: nonisolated JS constants, …
lawrencecchen Jun 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/swift-file-length-budget.tsv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# cmux-owned Swift file length budget.
# Format: max_lines<TAB>relative path
# Reduce counts as files shrink. CI fails if tracked files exceed this budget.
32553 CLI/cmux.swift
21996 Sources/TerminalController.swift
32573 CLI/cmux.swift
22172 Sources/TerminalController.swift

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.

P1 Badge Set TerminalController budget to its actual size

The CI workflow runs python3 scripts/swift_file_length_budget.py --budget .github/swift-file-length-budget.tsv (.github/workflows/ci.yml:88-89), but at this commit Sources/TerminalController.swift has 22220 physical lines while this entry allows only 22172. The budget check reports +48 Sources/TerminalController.swift and fails before the rest of CI can pass, so this needs to be raised to the actual count or the file reduced.

Useful? React with 👍 / 👎.

19875 Sources/Workspace.swift
19152 Sources/ContentView.swift
17920 Sources/AppDelegate.swift
Expand Down Expand Up @@ -104,6 +104,7 @@
830 Sources/TaskManagerTypes.swift
810 Packages/CmuxSwiftRender/Tests/CmuxSwiftRenderTests/SwiftViewInterpreterTests.swift
787 Sources/ClosedItemHistory.swift
769 cmuxUITests/BrowserFixtureInteractionUITests.swift

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.

P1 Badge Set fixture UI test budget to its actual size

The same Swift file-length CI check also fails on the new cmuxUITests/BrowserFixtureInteractionUITests.swift: the file has 774 physical lines at this commit, but this new budget entry allows only 769. Even after fixing the TerminalController entry, CI will still fail with +5 cmuxUITests/BrowserFixtureInteractionUITests.swift unless this budget is raised or the file is shortened.

Useful? React with 👍 / 👎.

768 Sources/MainWindowFocusController.swift
760 Packages/CMUXAgentLaunch/Tests/CMUXAgentLaunchTests/AgentLaunchSanitizerTests.swift
756 Sources/Panels/AgentSessionWebRendererCoordinator.swift
Expand Down
21 changes: 16 additions & 5 deletions CLI/cmux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11451,6 +11451,11 @@ struct CMUXCLI {
let (workspaceOpt, argsAfterWorkspace) = parseOption(subArgs, name: "--workspace")
let (windowOpt, argsAfterWindow) = parseOption(argsAfterWorkspace, name: "--window")
let (focusOpt, urlArgs) = parseOption(argsAfterWindow, name: "--focus")
// Reject unrecognized flags instead of folding them into the URL, where they
// would silently produce an unparseable URL (blank page) or a search query.
if let strayFlag = urlArgs.first(where: { $0.hasPrefix("--") }) {
throw CLIError(message: "browser \(subcommand) does not support \(strayFlag)")
}
let url = urlArgs.joined(separator: " ").trimmingCharacters(in: .whitespacesAndNewlines)
let respectExternalOpenRules: Bool = {
guard let raw = ProcessInfo.processInfo.environment["CMUX_RESPECT_EXTERNAL_OPEN_RULES"] else {
Expand Down Expand Up @@ -11507,10 +11512,12 @@ struct CMUXCLI {

if subcommand == "goto" || subcommand == "navigate" {
let sid = try requireSurface()
var urlArgs = subArgs
let snapshotAfter = urlArgs.last == "--snapshot-after"
if snapshotAfter {
urlArgs.removeLast()
// Accept --snapshot-after at any position, then reject any other flag instead
// of folding it into the URL, where it would silently turn into a search query.
let urlArgs = subArgs.filter { $0 != "--snapshot-after" }
let snapshotAfter = urlArgs.count != subArgs.count
if let strayFlag = urlArgs.first(where: { $0.hasPrefix("--") }) {
throw CLIError(message: "browser \(subcommand) does not support \(strayFlag)")
}
let url = urlArgs.joined(separator: " ").trimmingCharacters(in: .whitespacesAndNewlines)
guard !url.isEmpty else {
Expand Down Expand Up @@ -11662,7 +11669,11 @@ struct CMUXCLI {
params["timeout_ms"] = max(1, Int(seconds * 1000.0))
}

let payload = try client.sendV2(method: "browser.wait", params: params)
// Give the socket response timeout headroom beyond the wait deadline so long
// waits are reported by the app handler instead of dying at the socket layer.
let waitMs = (params["timeout_ms"] as? Int) ?? 5_000
let responseTimeout = max(10.0, Double(waitMs) / 1000.0 + 5.0)
let payload = try client.sendV2(method: "browser.wait", params: params, responseTimeout: responseTimeout)
output(payload, fallback: "OK")
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,55 @@ public enum ControlCommandExecutionPolicy: Sendable, Equatable {
// v2MainSync). Running on .mainActor would deadlock the UI for the
// entire simulation, defeating the profiling workload.
"debug.sidebar.simulate_drag",
// Browser methods that evaluate page JavaScript (or wait on it) run on
// the socket worker: on the main actor they block SwiftUI updates for
// their full duration, and on a not-yet-mounted webview that is a
// starvation deadlock (the JS can't run until SwiftUI mounts the
// webview, which can't happen while the handler holds the main
// thread). UI/model access inside the handlers stays on main via
// v2MainSync.
"browser.navigate",

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 Badge Preserve in-process browser cmux actions

Putting browser.navigate and the other browser automation methods in the socket-worker policy makes TerminalController.runV2CommandLine(_:) reject them with invalid_dispatch, because processV2Command only accepts .mainActor methods; CmuxSidebarActionDispatch invokes custom-sidebar cmux(...) actions through that in-process entrypoint on the main actor. Any sidebar button/action that navigates, clicks, waits, or evals in a browser now silently gets an error instead of performing the action, so this path needs a worker-capable in-process dispatch rather than only changing the socket policy.

Useful? React with 👍 / 👎.

"browser.back",
"browser.forward",
"browser.reload",
"browser.snapshot",
"browser.eval",

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.

P1 Badge Update policy tests for browser worker methods

This new worker classification makes ControlCommandExecutionPolicy(forMethod: "browser.eval") return .socketWorker, but the existing ControlCommandExecutionPolicyTests.everythingElseRunsOnTheMainActor still lists browser.eval and asserts .mainActor. Any macOS/CI run of the package tests will fail until the test expectations are updated to match the intended browser JS worker lane.

Useful? React with 👍 / 👎.

"browser.wait",
"browser.click",
"browser.dblclick",
"browser.hover",
"browser.focus",
"browser.type",
"browser.fill",
"browser.press",
"browser.keydown",
"browser.keyup",
"browser.check",
"browser.uncheck",
"browser.select",
"browser.scroll",
"browser.scroll_into_view",
"browser.get.text",
"browser.get.html",
"browser.get.value",
"browser.get.attr",
"browser.get.count",
"browser.get.box",
"browser.get.styles",
"browser.is.visible",
"browser.is.enabled",
"browser.is.checked",
"browser.find.role",
"browser.find.text",
"browser.find.label",
"browser.find.placeholder",
"browser.find.alt",
"browser.find.title",
"browser.find.testid",
"browser.find.first",
"browser.find.last",
"browser.find.nth",
"browser.highlight",
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
]

/// Socket-worker methods that are also safe to invoke from the main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ struct ControlCommandExecutionPolicyTests {
"feed.push", "browser.download.wait", "system.top", "system.memory",
"workspace.remote.pty_bridge", "sidebar.custom.reload",
"debug.sidebar.simulate_drag", "mobile.attach_ticket.create",
// JavaScript-evaluating browser methods block on page JS and must
// not hold the main actor (see socketWorkerMethods rationale).
"browser.eval", "browser.wait", "browser.snapshot", "browser.click",
"browser.fill", "browser.navigate", "browser.get.text",
"browser.find.text", "browser.highlight",
] {
#expect(ControlCommandExecutionPolicy(forMethod: method).runsOnSocketWorker, "\(method)")
}
}

@Test func everythingElseRunsOnTheMainActor() {
for method in [
"surface.list", "workspace.create", "window.list", "browser.eval",
"surface.list", "workspace.create", "window.list", "browser.url.get",
"browser.open_split", "browser.screenshot", "browser.cookies.get",
"mobile.terminal.create", "feed.jump", "vmx.create", "",
] {
let policy = ControlCommandExecutionPolicy(forMethod: method)
Expand Down
20 changes: 19 additions & 1 deletion Sources/CmuxSidebarActionDispatch.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import AppKit
import CmuxControlSocket
import CmuxSwiftRender
import CmuxSwiftRenderUI
import Foundation

/// Serial lane for in-process `cmux(...)` sidebar actions whose method runs on
/// the socket worker (browser JS, waits). Running those on the main actor
/// starves SwiftUI and deadlocks on a not-yet-mounted webview, which is exactly
/// why they were moved off the main-actor dispatch path. A serial queue keeps
/// the worker commands from one action ordered.
private let cmuxSidebarWorkerQueue = DispatchQueue(label: "com.cmux.sidebar-action-worker")

// The custom-sidebar rendering, interpreter, JSON DSL, resizable split, and
// the file-watching model now live in the `CmuxSwiftRender` (logic) and
// `CmuxSwiftRenderUI` (SwiftUI) packages. The app target keeps only the
Expand Down Expand Up @@ -35,7 +43,17 @@ func makeCmuxSidebarActionDispatch() -> SidebarActionDispatch {
}
guard let data = try? JSONSerialization.data(withJSONObject: payload),
let line = String(data: data, encoding: .utf8) else { continue }
_ = TerminalController.shared.runV2CommandLine(line)
if ControlCommandExecutionPolicy(forMethod: method).runsOnSocketWorker {
// Worker-lane methods (browser.navigate/click/eval/wait, etc.) must
// run off the main actor; runV2CommandLine would reject them with
// invalid_dispatch. handleSocketLine routes them through the same
// worker entrypoint the socket uses. Sidebar actions ignore the result.
cmuxSidebarWorkerQueue.async {
_ = TerminalController.shared.handleSocketLine(line)
}
} else {
_ = TerminalController.shared.runV2CommandLine(line)
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
case let .openURL(urlString):
if let url = URL(string: urlString) { NSWorkspace.shared.open(url) }
case .log:
Expand Down
Loading