Skip to content

Add CLI window targeting - #4211

Merged
lawrencecchen merged 36 commits into
mainfrom
feature-window-routing-cli
May 20, 2026
Merged

lawrencecchen merged 36 commits into
mainfrom
feature-window-routing-cli

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add --window routing to window-scoped CLI commands for workspace, pane, surface, SSH, VM, notifications, tree, and top flows.
  • Resolve workspace, pane, surface, and tab refs inside the targeted window.
  • Reject unresolved window refs and cross-window pane handles before mutating state.
  • Add socket coverage, CLI contract coverage, and a multi-window UI e2e for new-workspace --window.

Tests


Note

Medium Risk
Moderate risk: changes CLI argument parsing and handle normalization to be window-scoped, which can affect which surfaces/workspaces are mutated in multi-window setups if routing logic is wrong.

Overview
Adds explicit --window targeting to window-scoped CLI flows in CMUXCLI+MoveTabToNewWorkspace.swift, including updating move-tab-to-new-workspace help/usage.

Updates move-surface, split-off, and reorder-surface to parse --window, resolve workspace/surface/pane/before/after handles within the targeted window, and include window_id/window-scoped context in the socket params sent to methods like surface.split_off and surface.reorder.

Reviewed by Cursor Bugbot for commit edf08ea. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented May 15, 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 May 20, 2026 10:47pm
cmux-staging Building Building Preview, Comment May 20, 2026 10:47pm

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

@coderabbitai

coderabbitai Bot commented May 15, 2026 •

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds --window flag handling to CLI surface/workspace commands (move/split/reorder), threads window context into handle normalization and request params, implements window_id parsing/validation and per-window filtering in v2 system.tree/top, and adds tests (unit, integration, UI) validating routing and scoping.

Changes

Window flag support across CLI and backend

Layer / File(s) Summary
CLI window flag documentation and parsing
CLI/CMUXCLI+MoveTabToNewWorkspace.swift
Help now documents --window <id|ref|index>; runMoveSurface, runSplitOff, and runReorderSurface parse --window and pass windowHandle into surface/workspace/pane handle normalization and request param construction.
Backend window_id filtering for tree/top endpoints
Sources/TerminalController.swift
v2SystemTree and v2SystemTopBasePayload parse/validate window_id, reject window_id combined with all_windows, include window_id in identify params, filter per-window iterations to the requested window, and return not_found when the requested window is not encountered.
Test coverage for window flag routing and operations
cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift, cmuxTests/CMUXOpenCommandTests.swift, cmuxTests/VMSSHCommandTests.swift, cmuxTests/WorkspaceRemoteConnectionTests.swift, cmuxUITests/MultiWindowNotificationsUITests.swift
Adds integration tests for new-pane, set-status, and tree --window routing; unit test asserting top --window forwards window_id with all_windows=false; updates VM/SSH and SSH remote tests to pass and assert window_id; adds UI test verifying new-workspace --window targets a specific window.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as cmux CLI
  participant Parser as CLI Parser
  participant Normalizer as normalize*Handle
  participant Terminal as TerminalController
  participant Store as MainWindowSummaries
  CLI->>Parser: parse --window <id|ref|index>
  Parser->>Normalizer: compute windowHandle, normalize surface/workspace/pane handles
  Normalizer->>Terminal: RPC call with params.window_id (if present)
  Terminal->>Store: enumerate main-window summaries (filter by window_id)
  alt window found
    Store->>Terminal: return window summary
    Terminal->>CLI: scoped response
  else not found
    Terminal->>CLI: not_found (window_id/window_ref)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • manaflow-ai/cmux-dev-artifacts#1503: Related to control-socket helpers and bundled cmux runner used by the new UI test.
  • manaflow-ai/cmux-dev-artifacts#1502: Related to the added window-routing CLI support and the failing UI test for window-targeting.
  • manaflow-ai/cmux-dev-artifacts#1501: Matches CLI --window handling and window_id propagation concerns exercised by the UI test.

Possibly related PRs

  • manaflow-ai/cmux#3290: Overlaps with changes to system.top payload handling and window_id scoping in TerminalController.

Poem

A rabbit taps the window key,
Flags hop through parsers, light and free,
Handles line up, IDs find their place,
Trees lean to view a single space,
Hopping back to the targeted place. 🐇


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
Cmux Swift Logging ❌ Error Six print() statements in TerminalController.swift violate swift-logging.md. Ad hoc stdout logging in MainActor production code that duplicates proper Sentry error reporting already in place. Remove print() statements; use only reportSocketListenerFailure()/sentryBreadcrumb() for error logging.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The pull request includes a summary of changes and testing details, but misses several required template sections. Add the 'Demo Video' section with a video URL or link, include a completed 'Checklist' with all items marked, and ensure all testing steps are documented.
✅ Passed checks (13 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add CLI window targeting' directly describes the main objective: adding a --window flag to CLI commands. It is concise, specific, and clearly reflects the primary change across the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cmux Swift Actor Isolation ✅ Passed No actor isolation violations found. Changes in @MainActor TerminalController methods and CMUXCLI extensions only. No implicit MainActor types, Sendable without isolation, or background UI access.
Cmux Swift Blocking Runtime ✅ Passed No new blocking patterns introduced. Window_id parameter handling added to existing RPC methods without expanding blocking synchronization in socket paths.
Cmux No Hacky Sleeps ✅ Passed PR is primarily Swift code. Check applies to non-Swift production code only. Swift timing covered by separate rule. setTimeout calls use proper AbortSignal cancellation which is allowed per rule.
Cmux Swift Concurrency ✅ Passed PR introduces window-scoped CLI/RPC without violating concurrency rules. New production code is synchronous; test DispatchQueue usage is for test synchronization only (allowed).
Cmux Swift @Concurrent ✅ Passed All async functions correctly marked @MainActor. No violations: no missing @concurrent, no invalid @concurrent usage, no unsafe async from UI isolation.
Cmux Swift File And Package Boundaries ✅ Passed Adds 52 lines to oversized TerminalController and 21 net lines to CLI file. Focused window-scoping additions within existing protocol responsibility scope, not introducing mixed responsibilities.
Cmux User-Facing Error Privacy ✅ Passed All user-facing error messages comply with privacy policy. No vendor names, credentials, environment variables in errors, database details, or unredacted payloads exposed.
Cmux Swiftui State Layout ✅ Passed PR focuses on CLI window targeting. Key changes are in AppKit/Foundation code. No new SwiftUI state violations. ObservableObject classes present are pre-existing legacy patterns, not new to this PR.
Cmux Architecture Rethink ✅ Passed No violations found. PR uses clean parameter threading with backend-owned filtering. No timing constructs, mutable state issues, lifecycle splits, or side channels introduced.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed PR passes the rule. Linting script passed. CmuxMainWindow is main workspace (allowed). Debug controllers are test fixtures (allowed). No violations found.
✨ 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 feature-window-routing-cli

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 May 15, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends --window targeting to the remaining window-scoped CLI commands (workspace, pane, surface, SSH, VM, notifications, tree, top) and wires window_id into the corresponding V2 RPC calls. It also unifies window-routing validation in TerminalController through a new parseV2WindowRouting helper and fixes the window-vs-workspace not-found error ordering.

  • CLI/cmux.swift and CLI/CMUXCLI+MoveTabToNewWorkspace.swift: all listed commands now resolve workspace, pane, and surface handles within the targeted window; normalizeWindowHandle validates refs via window.list rather than passing them raw; resolveWorkspaceId gains a windowHandle parameter for current-workspace fallback; move-surface intentionally resolves the source surface in the caller context while destination handles use --window.
  • Sources/TerminalController.swift: parseV2WindowRouting consolidates window-selector validation for system.tree and system.top; the window-not-found check now fires before the workspace-not-found check; a cross-window pane guard is added to v2ResolveWorkspace; v2ResolveTabManager returns nil (instead of falling through) when window_id is present but invalid.
  • Sources/AppDelegate.swift: adds test-only scaffolding (runMultiWindowWindowRouteCLIIfNeeded) gated by CMUX_UI_TEST_WINDOW_ROUTE_CLI=1 to drive a new-workspace --window CLI call and list-workspaces checks from the multi-window UI test harness.

Confidence Score: 5/5

Safe to merge; all previously-flagged routing and error-ordering regressions are addressed and covered by new tests.

The window-not-found check now fires before workspace-not-found in both system.tree and system.top. notify/clear-notifications/sidebar-metadata fallback paths now fail explicitly via requireCurrentWorkspaceId. The cross-window pane guard in v2ResolveWorkspace closes a silent misrouting path. normalizeWindowHandle validates refs against window.list. Test coverage is broad across socket regressions, CLI contract, and multi-window UI e2e.

No files require special attention.

Important Files Changed

Filename Overview
CLI/cmux.swift Large set of --window additions across ~25 command paths; normalizeWindowHandle now validates refs via window.list and prefers UUIDs over refs in results; resolveWorkspaceId gains window-scoped current-workspace fallback; all changes look structurally consistent
CLI/CMUXCLI+MoveTabToNewWorkspace.swift move-surface intentionally resolves source surface in caller context (no workspace/window); split-off and reorder-surface correctly scope all handles to --window; before/after handles properly scoped to destination window
Sources/TerminalController.swift parseV2WindowRouting helper unifies window-selector validation; window-not-found check now fires before workspace-not-found check; cross-window pane guard added to v2ResolveWorkspace; v2ResolveTabManager returns nil on invalid window_id instead of falling through
Sources/AppDelegate.swift Adds runMultiWindowWindowRouteCLIIfNeeded for UI-test scaffolding (gated by env var); uses DispatchQueue.global + process.waitUntilExit following existing test-scaffolding patterns in this file
cmuxTests/AppDelegateIssue2907RoutingTests.swift New tests cover window-before-workspace error ordering in system.tree and cross-window pane-focus rejection
cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift Extensive regression coverage for notify/clear-notifications/workspace-action/sidebar-metadata with --window
tests/test_cli_layout_focus_contract.py Updated to use UUID for WINDOW_ID and ref for WINDOW_REF; adds window.list handler for the ref-resolution path
cmuxUITests/MultiWindowNotificationsUITests.swift New multi-window e2e tests for the window-routing CLI path

Sequence Diagram

sequenceDiagram
    participant CLI as CLI (cmux.swift)
    participant WN as normalizeWindowHandle
    participant WS as normalizeWorkspaceHandle
    participant SF as normalizeSurfaceHandle
    participant TC as TerminalController (RPC)

    CLI->>WN: --window ref/index/uuid
    WN->>TC: window.list (if ref or index)
    TC-->>WN: windows[]
    WN-->>CLI: resolved window UUID

    CLI->>WS: --workspace + windowHandle
    WS->>TC: workspace.current(window_id) if allowCurrent
    TC-->>WS: workspace_id
    WS-->>CLI: resolved workspace UUID

    CLI->>SF: --surface + workspaceHandle + windowHandle
    SF->>TC: surface.list(workspace_id, window_id) if index
    TC-->>SF: surfaces[]
    SF-->>CLI: resolved surface UUID

    CLI->>TC: RPC(window_id, workspace_id, surface_id)
    TC->>TC: parseV2WindowRouting validates window_id + all_windows
    TC->>TC: loop summaries, skip non-matching windows
    TC->>TC: check windowFound before workspaceFound
    TC-->>CLI: result or not_found(window/workspace)
Loading

Reviews (33): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

Comment thread CLI/cmux.swift
Comment thread CLI/cmux.swift Outdated
coderabbitai[bot]
coderabbitai Bot previously requested changes May 15, 2026

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/TerminalController.swift`:
- Around line 3230-3259: Both v2SystemTree and v2SystemTopBasePayload duplicate
the same window_id/all_windows parsing, conflict checks, identifyParams
augmentation and windowFound bookkeeping; extract this into a shared helper
(e.g., a new function like parseV2WindowRouting) that accepts params and
workspaceFilter and returns a struct/dictionary containing includeAllWindows,
requestedWindowId, identifyParams (including caller and window_id string),
windowFound initial value, and the resolved defaultWindowId logic; replace the
duplicated blocks in both handlers to call parseV2WindowRouting and use its
returned fields (refer to existing helpers v2Bool, v2UUID, v2Identify, v2UUIDAny
and variables identifyParams, windowFound, defaultWindowId) so routing behavior
is centralized and reused.
- Around line 3232-3236: Update the error responses that use .err when
validating window selectors (the branches checking params["window_id"],
requestedWindowId, and includeAllWindows) to follow the repo error-copy
contract: produce a user-facing cmux message that explains the problem in cmux
terms and gives 1–2 concrete next steps (e.g., "Use --window <id> to target a
specific window or --all-windows to target all windows; run `cmux windows list`
to see available windows and retry"), and put only the minimal diagnostics the
caller provided (include details: { "window_id": <value> } when the caller
supplied window_id; do NOT synthesize or return window_ref). Apply the same fix
to the other similar validation sites referenced (the branches around the checks
at the other ranges) so all window selector errors are consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a434c646-314f-49b8-904e-5e9317519b33

📥 Commits

Reviewing files that changed from the base of the PR and between c2c93a4 and 01001b6.

📒 Files selected for processing (8)
  • CLI/CMUXCLI+MoveTabToNewWorkspace.swift
  • CLI/cmux.swift
  • Sources/TerminalController.swift
  • cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift
  • cmuxTests/CMUXOpenCommandTests.swift
  • cmuxTests/VMSSHCommandTests.swift
  • cmuxTests/WorkspaceRemoteConnectionTests.swift
  • cmuxUITests/MultiWindowNotificationsUITests.swift

Comment thread Sources/TerminalController.swift
Comment thread Sources/TerminalController.swift Outdated
@lawrencecchen
lawrencecchen force-pushed the feature-window-routing-cli branch from 01001b6 to c4a1051 Compare May 15, 2026 14:15
Comment thread CLI/cmux.swift
coderabbitai[bot]
coderabbitai Bot previously requested changes May 15, 2026

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
Sources/TerminalController.swift (2)

3233-3236: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

window_id error responses don't follow the cmux user-facing error contract.

These invalid_params / not_found messages ("Missing or invalid window_id", "window_id cannot be combined with all_windows", "Window not found") are still too terse for a user-facing cmux API error and give the caller no recovery path. Two issues to address:

  1. Add a concrete next action in cmux terms (e.g. "Pass either --window <id|ref|index> or --all-windows; run cmux windows list to see available windows and retry.").
  2. In the not_found branch (Lines 3320-3329 and 3578-3587), the payload synthesizes window_ref even though the caller only supplied window_id — keep the diagnostics scoped to the selector the caller actually provided to avoid leaking an unrelated identifier shape back at them.

As per coding guidelines (.github/review-bot-rules/user-facing-errors.md): user-facing API error bodies must describe the issue in cmux terms, provide concrete next actions, and keep diagnostics minimal/safe.

Also applies to: 3320-3329, 3486-3489, 3578-3587

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Sources/TerminalController.swift` around lines 3233 - 3236, Update the
user-facing error returns for window selection to follow the cmux error
contract: replace terse messages in the branches that check window_id and
includeAllWindows (where code returns .err(... "Missing or invalid window_id"
and "window_id cannot be combined with all_windows") with a descriptive cmux
next-action message such as "Pass either --window <id|ref|index> or
--all-windows; run `cmux windows list` to see available windows and retry." and
keep the error code as "invalid_params"; and in the not_found branches (the
branches that return .err(code: "not_found", ...)) stop synthesizing a
window_ref when the caller only provided window_id — only include the selector
key that the caller actually supplied in the error payload (e.g., include
window_id diagnostics when window_id was provided, include window_ref only when
window_ref was provided), and ensure the message includes the concrete next
action in cmux terms as above; update uses around the window selection logic
(the checks referencing includeAllWindows and requestedWindowId) so all
user-facing error bodies follow this pattern.

3230-3267: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Duplicated window_id routing block across v2SystemTree and v2SystemTopBasePayload.

Both endpoints now repeat the same window_id parse, all_windows conflict check, identifyParams["window_id"] augmentation, windowFound bookkeeping, and defaultWindowId resolution. Extracting a shared helper (e.g. parseV2WindowRouting(params:) returning (includeAllWindows, requestedWindowId, identifyParams, initialWindowFound)) would prevent the two paths from drifting next time.

Also applies to: 3481-3521

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Sources/TerminalController.swift` around lines 3230 - 3267, The block that
parses window routing (includeAllWindows, requestedWindowId, window_id
validation, all_windows conflict check, building identifyParams, and initial
windowFound/defaultWindowId logic) is duplicated between v2SystemTree and
v2SystemTopBasePayload; extract a helper like parseV2WindowRouting(params:) that
returns (includeAllWindows: Bool, requestedWindowId: UUID?, identifyParams:
[String:Any], initialWindowFound: Bool, defaultWindowIdCandidate: UUID?) and
replace the duplicated code in both handlers with a call to that helper; ensure
the helper preserves the current validations (returning the same error
conditions when window_id is present but invalid, and when both all_windows and
window_id are supplied), includes caller and window_id into identifyParams the
same way, computes focusedWindowId/defaultWindowId the same, and update
v2SystemTree and v2SystemTopBasePayload to use the helper’s returned values (and
to still compute identifyPayload/focused/caller/focusedWindowId from
identifyParams as before).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmuxUITests/MultiWindowNotificationsUITests.swift`:
- Around line 605-607: The teardown silently ignores the result of
closeWorkspaceViaSocket; change the call that currently discards the return
value (when createdWorkspaceId and window2Id are used) to capture and assert the
result (e.g., assert success with XCTAssertTrue or XCTFail on false) so
workspace cleanup failures surface in the test instead of being ignored.

---

Duplicate comments:
In `@Sources/TerminalController.swift`:
- Around line 3233-3236: Update the user-facing error returns for window
selection to follow the cmux error contract: replace terse messages in the
branches that check window_id and includeAllWindows (where code returns .err(...
"Missing or invalid window_id" and "window_id cannot be combined with
all_windows") with a descriptive cmux next-action message such as "Pass either
--window <id|ref|index> or --all-windows; run `cmux windows list` to see
available windows and retry." and keep the error code as "invalid_params"; and
in the not_found branches (the branches that return .err(code: "not_found",
...)) stop synthesizing a window_ref when the caller only provided window_id —
only include the selector key that the caller actually supplied in the error
payload (e.g., include window_id diagnostics when window_id was provided,
include window_ref only when window_ref was provided), and ensure the message
includes the concrete next action in cmux terms as above; update uses around the
window selection logic (the checks referencing includeAllWindows and
requestedWindowId) so all user-facing error bodies follow this pattern.
- Around line 3230-3267: The block that parses window routing
(includeAllWindows, requestedWindowId, window_id validation, all_windows
conflict check, building identifyParams, and initial windowFound/defaultWindowId
logic) is duplicated between v2SystemTree and v2SystemTopBasePayload; extract a
helper like parseV2WindowRouting(params:) that returns (includeAllWindows: Bool,
requestedWindowId: UUID?, identifyParams: [String:Any], initialWindowFound:
Bool, defaultWindowIdCandidate: UUID?) and replace the duplicated code in both
handlers with a call to that helper; ensure the helper preserves the current
validations (returning the same error conditions when window_id is present but
invalid, and when both all_windows and window_id are supplied), includes caller
and window_id into identifyParams the same way, computes
focusedWindowId/defaultWindowId the same, and update v2SystemTree and
v2SystemTopBasePayload to use the helper’s returned values (and to still compute
identifyPayload/focused/caller/focusedWindowId from identifyParams as before).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f07a551a-d79f-40e2-b64d-1961da4be96e

📥 Commits

Reviewing files that changed from the base of the PR and between c4a1051 and 67e5d7f.

📒 Files selected for processing (8)
  • CLI/CMUXCLI+MoveTabToNewWorkspace.swift
  • CLI/cmux.swift
  • Sources/TerminalController.swift
  • cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift
  • cmuxTests/CMUXOpenCommandTests.swift
  • cmuxTests/VMSSHCommandTests.swift
  • cmuxTests/WorkspaceRemoteConnectionTests.swift
  • cmuxUITests/MultiWindowNotificationsUITests.swift

Comment thread cmuxUITests/MultiWindowNotificationsUITests.swift Outdated
Comment thread CLI/cmux.swift

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

♻️ Duplicate comments (1)
Sources/TerminalController.swift (1)

3232-3236: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Align window_id errors with the cmux user-facing error contract.

These responses are still too terse, and the not_found payload includes synthesized window_ref. Please add 1–2 concrete recovery actions in message and keep diagnostics minimal to caller-provided fields (e.g., window_id only when supplied).

Suggested shape
- return .err(code: "invalid_params", message: "Missing or invalid window_id", data: nil)
+ return .err(
+   code: "invalid_params",
+   message: "Invalid --window value. Use a window UUID, or run `cmux windows list` and retry.",
+   data: ["details": ["window_id": params["window_id"] as Any]]
+ )

- return .err(code: "invalid_params", message: "window_id cannot be combined with all_windows", data: nil)
+ return .err(
+   code: "invalid_params",
+   message: "Choose one scope: use `--window <id>` for one window, or `--all-windows` for all windows.",
+   data: ["details": ["window_id": requestedWindowId.uuidString]]
+ )

- message: "Window not found",
- data: [
-   "window_id": requestedWindowId.uuidString,
-   "window_ref": v2Ref(kind: .window, uuid: requestedWindowId)
- ]
+ message: "No cmux window matched --window. Run `cmux windows list` and retry, or use `--all-windows`.",
+ data: ["details": ["window_id": requestedWindowId.uuidString]]

As per coding guidelines "Error copy states what happened in cmux terms and gives 1–2 concrete next actions" and "details contains only safe, minimal diagnostics."

Also applies to: 3320-3327, 3485-3490, 3578-3585

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Sources/TerminalController.swift` around lines 3232 - 3236, The error
handlers for the window_id checks (the branch where params["window_id"] != nil
&& requestedWindowId == nil and the branch where includeAllWindows &&
requestedWindowId != nil) need to be changed to match the cmux user-facing error
contract: replace terse messages with one-to-two concrete recovery actions
(e.g., "Provide a valid window_id" or "Remove all_windows when targeting a
specific window"), set the error code to the appropriate cmux code (e.g.,
"not_found" or "invalid_params" as applicable), and move any diagnostics into a
minimal details payload that only echoes caller-provided fields (include
window_id only if it was supplied). Update the same pattern in the other
occurrences you noted (around the checks at the other ranges) so all
window-related errors use the same actionable message and minimal details
structure.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@Sources/TerminalController.swift`:
- Around line 3232-3236: The error handlers for the window_id checks (the branch
where params["window_id"] != nil && requestedWindowId == nil and the branch
where includeAllWindows && requestedWindowId != nil) need to be changed to match
the cmux user-facing error contract: replace terse messages with one-to-two
concrete recovery actions (e.g., "Provide a valid window_id" or "Remove
all_windows when targeting a specific window"), set the error code to the
appropriate cmux code (e.g., "not_found" or "invalid_params" as applicable), and
move any diagnostics into a minimal details payload that only echoes
caller-provided fields (include window_id only if it was supplied). Update the
same pattern in the other occurrences you noted (around the checks at the other
ranges) so all window-related errors use the same actionable message and minimal
details structure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0f0f91bf-859f-4466-ba7e-56205e491d1b

📥 Commits

Reviewing files that changed from the base of the PR and between 67e5d7f and 12728fd.

📒 Files selected for processing (8)
  • CLI/CMUXCLI+MoveTabToNewWorkspace.swift
  • CLI/cmux.swift
  • Sources/TerminalController.swift
  • cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift
  • cmuxTests/CMUXOpenCommandTests.swift
  • cmuxTests/VMSSHCommandTests.swift
  • cmuxTests/WorkspaceRemoteConnectionTests.swift
  • cmuxUITests/MultiWindowNotificationsUITests.swift

Comment thread CLI/cmux.swift
Comment thread CLI/cmux.swift

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 84418fd. Configure here.

Comment thread CLI/CMUXCLI+MoveTabToNewWorkspace.swift Outdated
Comment thread CLI/CMUXCLI+MoveTabToNewWorkspace.swift Outdated
@lawrencecchen
lawrencecchen dismissed stale reviews from coderabbitai[bot] and coderabbitai[bot] May 19, 2026 05:33

Stale CodeRabbit change request. The actionable threads were addressed or resolved in later commits, and the latest CodeRabbit check is passing/skipped.

…g-cli

# Conflicts:
#	CLI/cmux.swift
#	cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift
…g-cli

# Conflicts:
#	CLI/cmux.swift
#	cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift

This branch was successfully deployed

1 active deployment
Preview – cmux — edf08ea5 Deployed May 20, 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