Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions .github/swift-file-length-budget.tsv
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# 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.
33454 CLI/cmux.swift
33857 CLI/cmux.swift

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Extract Codex hooks instead of raising the budget

The repo's .github/review-bot-rules/swift-file-package-boundaries.md says to report an existing production Swift file over 800 lines gaining more than 250 lines unless the change extracts responsibility or shrinks the oversized file. This commit adds hundreds of lines of Codex hook dispatch, persistence freshness, and socket/UI restore logic to the already 33k-line CLI/cmux.swift and accepts that growth by raising the budget here, so the smallest fix is to move the Codex hook freshness/fire-and-forget support behind a focused file or package boundary instead of increasing the monolith's allowance.

Useful? React with 👍 / 👎.

17914 Sources/AppDelegate.swift
16740 Sources/ContentView.swift
14612 Sources/TerminalController.swift
13595 Sources/Panels/BrowserPanel.swift
12088 Sources/GhosttyTerminalView.swift
12046 cmuxTests/AppDelegateShortcutRoutingTests.swift
11992 Sources/Workspace.swift
9345 cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift
9331 cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift
7911 Sources/Panels/BrowserPanelView.swift
7350 cmuxTests/WorkspaceUnitTests.swift
6944 cmuxTests/WorkspaceRemoteConnectionTests.swift
Expand Down Expand Up @@ -123,7 +123,7 @@
715 Sources/AppleScriptSupport.swift
710 Sources/TerminalSSHSessionDetector.swift
706 CLI/CMUXCLI+Config.swift
701 CLI/CMUXCLI+AgentHookDefinitions.swift
707 CLI/CMUXCLI+AgentHookDefinitions.swift
699 Sources/RightSidebarPanelView.swift
699 cmuxTests/TerminalNotificationClearAllTests.swift
698 cmuxTests/RestorableAgentHookProviderResumeTests.swift
Expand Down Expand Up @@ -187,6 +187,7 @@
528 cmuxTests/CLINotifyProcessTestSupport.swift
528 cmuxUITests/AutomationSocketUITests.swift
527 CLI/CLISocketPathResolver.swift
726 cmuxTests/CLICodexHookTimeoutRegressionTests.swift
523 Packages/CmuxRemoteSession/Sources/CmuxRemoteSession/Session/RemoteSessionCoordinator+PortScan.swift
520 CLI/CMUXCLI+AmpExtension.swift
520 cmuxTests/MainWindowVisibilityControllerTests.swift
Expand Down
14 changes: 10 additions & 4 deletions CLI/CMUXCLI+AgentHookDefinitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,15 @@ extension CMUXCLI {
}

static func hookCommandString(for def: AgentHookDef, event: AgentHookDef.HookEvent) -> String {
agentHookShellCommand("cmux hooks \(def.name) \(event.cmuxSubcommand)", for: def)
let command = "cmux hooks \(def.name) \(event.cmuxSubcommand)"
if def.name == "codex", codexHookCanRunFireAndForget(event.cmuxSubcommand) {
return codexFireAndForgetAgentHookShellCommand(command, for: def)
}
return agentHookShellCommand(command, for: def)
}

private static func codexHookCanRunFireAndForget(_ subcommand: String) -> Bool {
subcommand == "session-start" || subcommand == "prompt-submit"
}

static func feedHookCommandString(for def: AgentHookDef, agentEvent: String) -> String {
Expand All @@ -387,9 +395,7 @@ extension CMUXCLI {
private static let antigravityPinnedHookMarker = "cmux-antigravity-hook-v2"

private static func agentHookShellCommand(_ command: String, for def: AgentHookDef) -> String {
if usesPinnedHookDispatch(def) {
return pinnedAgentHookShellCommand(command, for: def)
}
if usesPinnedHookDispatch(def) { return pinnedAgentHookShellCommand(command, for: def) }
let routedArguments = command.hasPrefix("cmux ") ? String(command.dropFirst("cmux ".count)) : command
return "cmux_cli=\"${CMUX_BUNDLED_CLI_PATH:-}\"; if [ -z \"$cmux_cli\" ] || [ ! -x \"$cmux_cli\" ]; then cmux_cli=\"$(command -v cmux 2>/dev/null || true)\"; fi; if [ -n \"$CMUX_SURFACE_ID\" ] && [ \"$\(def.disableEnvVar)\" != \"1\" ] && [ -n \"$cmux_cli\" ]; then { if [ -n \"${CMUX_SOCKET_PATH:-}\" ]; then \"$cmux_cli\" --socket \"$CMUX_SOCKET_PATH\" \(routedArguments); else \"$cmux_cli\" \(routedArguments); fi; } || echo '{}'; else echo '{}'; fi"
}
Expand Down
12 changes: 12 additions & 0 deletions CLI/CMUXCLI+CodexFireAndForgetHooks.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extension CMUXCLI {
static func codexFireAndForgetAgentHookShellCommand(_ command: String, for def: AgentHookDef) -> String {
let routedArguments = command.hasPrefix("cmux ") ? String(command.dropFirst("cmux ".count)) : command
let runner = "payload=\"$1\"; shift; \"$@\" <\"$payload\" >/dev/null 2>&1 & child=\"$!\"; ( sleep 30; kill \"$child\" 2>/dev/null || true ) & watchdog=\"$!\"; wait \"$child\" 2>/dev/null || true; kill \"$watchdog\" 2>/dev/null || true; rm -f \"$payload\""
return [
"cmux_cli=\"${CMUX_BUNDLED_CLI_PATH:-}\"",
"if [ -z \"$cmux_cli\" ] || [ ! -x \"$cmux_cli\" ]; then cmux_cli=\"$(command -v cmux 2>/dev/null || true)\"; fi",
"agent_pid=\"${CMUX_CODEX_PID:-${PPID:-}}\"",
"if [ -n \"$CMUX_SURFACE_ID\" ] && [ \"$\(def.disableEnvVar)\" != \"1\" ] && [ -n \"$cmux_cli\" ]; then payload=\"$(mktemp \"${TMPDIR:-/tmp}/cmux-codex-hook.XXXXXX\" 2>/dev/null || mktemp -t cmux-codex-hook 2>/dev/null)\" || { echo '{}'; exit 0; }; cat >\"$payload\" || true; if [ -n \"${CMUX_SOCKET_PATH:-}\" ]; then CMUX_CODEX_PID=\"$agent_pid\" nohup sh -c '\(runner)' cmux-codex-hook \"$payload\" \"$cmux_cli\" --socket \"$CMUX_SOCKET_PATH\" \(routedArguments) >/dev/null 2>&1 & else CMUX_CODEX_PID=\"$agent_pid\" nohup sh -c '\(runner)' cmux-codex-hook \"$payload\" \"$cmux_cli\" \(routedArguments) >/dev/null 2>&1 & fi; echo '{}'; else echo '{}'; fi",
].joined(separator: "; ")
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Loading
Loading