Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
00da345
CmuxControlSocket stage 3c-1: ControlCommandCoordinator + window domain
azooz2003-bit Jun 10, 2026
2383068
stage 3c: multi-protocol seam umbrella + shared param/ref helper port
azooz2003-bit Jun 10, 2026
b02c28d
stage 3c: extract App Focus + Feed + Notification domains
azooz2003-bit Jun 10, 2026
9bdae00
stage 3c: extract Mobile Host + Workspace Groups + Pane domains
azooz2003-bit Jun 10, 2026
4b8118f
stage 3c: fix int/double param helpers to match legacy NSNumber coercion
azooz2003-bit Jun 10, 2026
1905b38
stage 3c: integrate Workspace + Surface domains (full lifts)
azooz2003-bit Jun 10, 2026
8f7ac89
stage 3c: organize coordinator files into per-domain subfolders
azooz2003-bit Jun 10, 2026
487baaf
stage 3c: dedupe workspace.create onto the shared v2WorkspaceCreate body
azooz2003-bit Jun 10, 2026
6f2cba5
stage 3c: fix 8 divergences found by Workspace+Surface adversarial re…
azooz2003-bit Jun 11, 2026
fe419f0
Budget: entries for the two coordinator files grown by the divergence…
azooz2003-bit Jun 11, 2026
a94589d
Merge remote-tracking branch 'origin/main' into feat-ctl-coordinator-…
azooz2003-bit Jun 11, 2026
f731c27
Fix duplicate parameter name warning (sessionID sessionID) in workspa…
azooz2003-bit Jun 11, 2026
7d234dc
stage 3c: package side of System/Project/Debug/Sidebar/Browser domain…
azooz2003-bit Jun 11, 2026
39d111b
stage 3c: cut over System/Project/Debug/Sidebar/Browser domains to th…
azooz2003-bit Jun 11, 2026
ecd5148
stage 3c: dedupe file.open onto the shared v2FileOpen body
azooz2003-bit Jun 11, 2026
3178b68
stage 3c: fix browser.focus_mode.set/zoom.set error precedence; finis…
azooz2003-bit Jun 11, 2026
42f9332
Budget tsv: strip accidental leading whitespace
azooz2003-bit Jun 11, 2026
d47e003
Merge pull request #5909 from manaflow-ai/feat-ctl-3c-final-domains
azooz2003-bit Jun 11, 2026
29d8342
stage 3c: address review threads (handles observation, window.close t…
azooz2003-bit Jun 11, 2026
2be538e
Merge origin/main: adopt PR 5778's socket-worker browser JS lane; rev…
azooz2003-bit Jun 12, 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
2 changes: 1 addition & 1 deletion .github/swift-file-length-budget.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Format: max_lines<TAB>relative path
# Reduce counts as files shrink. CI fails if tracked files exceed this budget.
32655 CLI/cmux.swift
22074 Sources/TerminalController.swift
21522 Sources/TerminalController.swift
19820 Sources/Workspace.swift
19209 Sources/ContentView.swift
18011 Sources/AppDelegate.swift
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
internal import Foundation

/// The app-focus-domain slice of the control-command seam (a constituent of the
/// ``ControlCommandContext`` umbrella).
///
/// The app target (today `TerminalController`, the interim composition owner)
/// conforms by reading and mutating the app's `AppFocusState` override and by
/// re-running the `applicationDidBecomeActive` activation path. Every method is
/// `@MainActor` because its conformer lives on the main actor and the
/// coordinator runs there too, so these are plain in-isolation calls — the
/// per-read `v2MainSync` hop the legacy `v2AppSimulateActive` body used
/// disappears once this domain moves onto the coordinator.
@MainActor
public protocol ControlAppFocusContext: AnyObject {
/// Sets (or clears) the app-focus override for `app.focus_override.set`,
/// mirroring the legacy `AppFocusState.overrideIsFocused = …` assignment.
///
/// - Parameter focused: `true`/`false` to force the override, or `nil` to
/// clear it and fall back to the real `NSApp.isActive` state.
func controlSetAppFocusOverride(_ focused: Bool?)

/// Re-runs the `applicationDidBecomeActive` activation path for
/// `app.simulate_active`, exactly as the legacy body did by posting an
/// `NSApplication.didBecomeActiveNotification` to `AppDelegate.shared`.
func controlSimulateAppActive()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// The read-only seam through which ``ControlCommandCoordinator`` reaches live
/// app state to run control commands, without the package importing the app
/// target.
///
/// It is an umbrella of one protocol per command domain so the domains can be
/// built independently (each domain owns its own seam-protocol file and its own
/// app-conformance file). The coordinator stores `any ControlCommandContext`
/// and reaches every member through this inheritance. The app target (today
/// `TerminalController`, the interim composition owner; later
/// `TerminalControlComposition`) conforms by conforming to each constituent.
///
/// `AnyObject` so the coordinator can hold the conformer `weak` and avoid a
/// retain cycle with its composition owner.
@MainActor
public protocol ControlCommandContext:
AnyObject,
ControlWindowContext,
ControlAppFocusContext,
ControlFeedContext,
ControlNotificationContext
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
internal import Foundation

/// The app-focus domain (`app.focus_override.set`, `app.simulate_active`),
/// lifted byte-faithfully from the former `TerminalController.v2AppFocusOverride`
/// / `v2AppSimulateActive` bodies. Each payload is built directly as a
/// ``JSONValue`` (the typed twin of the legacy `[String: Any]` dictionaries);
/// the resulting Foundation object is identical, so the encoded wire bytes match.
extension ControlCommandCoordinator {
/// Runs one decoded request if it belongs to the app-focus domain, returning
/// the typed result; returns `nil` otherwise so the core dispatcher falls
/// through to other domains.
///
/// - Parameter request: The decoded request envelope.
/// - Returns: The command result, or `nil` if not owned by this domain.
func handleAppFocus(_ request: ControlRequest) -> ControlCallResult? {
switch request.method {
case "app.focus_override.set":
return appFocusOverride(request.params)
case "app.simulate_active":
return appSimulateActive()
default:
return nil
}
}

/// `app.focus_override.set` — force or clear the app-focus override.
///
/// Accepts either a `state` of `active` / `inactive` / `clear` (also `none`),
/// or a `focused` boolean (present-but-non-boolean, or explicit `null`,
/// clears). The two acceptance paths and their error shapes are byte-faithful
/// to the legacy body.
func appFocusOverride(_ params: [String: JSONValue]) -> ControlCallResult {
let override: Bool?
if let state = string(params, "state")?.lowercased() {
switch state {
case "active":
override = true
case "inactive":
override = false
case "clear", "none":
override = nil
default:
return .err(
code: "invalid_params",
message: "Invalid state (active|inactive|clear)",
data: .object(["state": .string(state)])
)
}
} else if params.keys.contains("focused") {
// Legacy: `params.keys.contains("focused")` — present (including an
// explicit JSON null) routes here; a non-boolean or null value
// clears the override.
override = bool(params, "focused")
} else {
return .err(code: "invalid_params", message: "Missing state or focused", data: nil)
}

context?.controlSetAppFocusOverride(override)
return .ok(.object(["override": override.map { JSONValue.bool($0) } ?? .null]))
}

/// `app.simulate_active` — re-run the app's `applicationDidBecomeActive` path.
func appSimulateActive() -> ControlCallResult {
context?.controlSimulateAppActive()
return .ok(.object([:]))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
internal import Foundation

/// The main-actor feed domain (`feed.jump`, `feed.list`), lifted byte-faithfully
/// from the former `TerminalController.v2Feed*` bodies. Each payload is built
/// directly as a ``JSONValue`` (the typed twin of the legacy `[String: Any]`
/// dictionaries); the resulting Foundation object is identical, so the encoded
/// wire bytes match.
///
/// The worker-lane feed methods (`feed.push`, `feed.permission.reply`,
/// `feed.question.reply`, `feed.exit_plan.reply`) block or await on the socket
/// worker and remain on the app-side worker path — they are deliberately NOT
/// dispatched here.
extension ControlCommandCoordinator {
/// Dispatches the feed methods this coordinator owns; returns `nil` for
/// anything else so the core `handle(_:)` can fall through.
///
/// - Parameter request: The decoded request envelope.
/// - Returns: The command result, or `nil` if not a feed method.
func handleFeed(_ request: ControlRequest) -> ControlCallResult? {
switch request.method {
case "feed.jump":
return feedJump(request.params)
case "feed.list":
return feedList(request.params)
default:
return nil
}
}

/// `feed.jump` — resolve whether a workstream id maps to a known surface.
func feedJump(_ params: [String: JSONValue]) -> ControlCallResult {
guard let workstreamID = rawString(params, "workstream_id") else {
return .err(
code: "invalid_params",
message: "feed.jump requires workstream_id",
data: nil
)
}
// MVP: resolve to a cmux surface via `SessionIndexStore` lands in
// the UI PR; for now we return whether the id is known so callers
// can show a toast.
let matched = context?.controlFeedResolvePossibleSurface(workstreamID: workstreamID) ?? false
return .ok(.object([
"workstream_id": .string(workstreamID),
"matched": .bool(matched),
]))
}

/// `feed.list` — snapshot the workstream feed items.
func feedList(_ params: [String: JSONValue]) -> ControlCallResult {
// Legacy used a plain `params["pending_only"] as? Bool`, so only a real
// JSON boolean counts; anything else (including coercible strings/numbers)
// falls back to `false`.
let pendingOnly: Bool
if case .bool(let value)? = params["pending_only"] {
pendingOnly = value
} else {
pendingOnly = false
}
let items = context?.controlFeedSnapshotItems(pendingOnly: pendingOnly) ?? []
return .ok(.object(["items": .array(items)]))
}
}
Loading