Skip to content

Fix main CI Swift file length budget - #3676

Merged
lawrencecchen merged 1 commit into
mainfrom
fix-main-ci-cli-budget
May 7, 2026
Merged

lawrencecchen merged 1 commit into
mainfrom
fix-main-ci-cli-budget

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Main CI is failing in the workflow guard because CLI/cmux.swift grew past its file length budget: https://github.com/manaflow-ai/cmux/actions/runs/25471460485\n\nThis splits the event command helpers and process runner out of CLI/cmux.swift without changing behavior.\n\nVerification:\n- ./scripts/swift_file_length_budget.py --budget .github/swift-file-length-budget.tsv\n- xcodebuild -project GhosttyTabs.xcodeproj -scheme cmux-cli -configuration Debug -destination 'platform=macOS' -derivedDataPath /tmp/cmux-fix-main-ci-cli-budget-cli build


Note

Low Risk
Primarily a refactor to move existing CLI helper code into separate files; behavior should be unchanged aside from possible access-level/compilation integration issues.

Overview
Refactors the CLI to satisfy the Swift file-length budget by moving the events command implementation (option parsing, frame parsing, cursor read/write, reconnect logic) out of CLI/cmux.swift into CMUXCLI+Events.swift.

Extracts the process execution utilities (CLIProcessRunner/CLIProcessResult) into a new CMUXCLI+Process.swift, updates Xcode project sources accordingly, and relaxes authenticateClientIfNeeded visibility so the extracted events code can call it.

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


Summary by cubic

Fixes main CI failure by bringing CLI/cmux.swift back under the file-length budget. Extracts event streaming and process runner code into dedicated files with no behavior changes.

  • Refactors
    • Split events command handling into CLI/CMUXCLI+Events.swift (options parsing, cursor I/O, frame parsing, reconnect/backoff).
    • Added CLI/CMUXCLI+Process.swift with CLIProcessRunner and CLIProcessResult; removed from CLI/cmux.swift and updated the project file.
    • Made CMUXCLI.authenticateClientIfNeeded non-private so extensions can call it.

Written for commit 061c2b3. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Expanded events subcommand with new command-line options: filtering by event name and category, cursor-based resumption across sessions, reconnection control, selective output filtering, and stream limiting capabilities.
    • Introduced process execution utility with configurable timeout and comprehensive result reporting.

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

@vercel

vercel Bot commented May 7, 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 7, 2026 2:57am
cmux-staging Building Building Preview, Comment May 7, 2026 2:57am

@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b39c8a3f-45f2-4621-962b-67862da7019e

📥 Commits

Reviewing files that changed from the base of the PR and between 82b4065 and 061c2b3.

📒 Files selected for processing (4)
  • CLI/CMUXCLI+Events.swift
  • CLI/CMUXCLI+Process.swift
  • CLI/cmux.swift
  • GhosttyTabs.xcodeproj/project.pbxproj

📝 Walkthrough

Walkthrough

This PR extends the events subcommand with full CLI option parsing, event-stream frame handling, and cursor-based resumption. A new process execution utility provides subprocess management with timeout support. The authenticateClientIfNeeded function is exposed for module-level reuse.

Changes

Events Command & Process Execution

Layer / File(s) Summary
Process Execution Types & Core
CLI/CMUXCLI+Process.swift
New CLIProcessResult struct captures process exit status, stdout, stderr, and timeout flag. CLIProcessRunner.runProcess() configures and executes a process with optional stdin, captures output via pipes, enforces timeout with DispatchSemaphore, and escalates to SIGKILL on timeout.
Events Command Core
CLI/CMUXCLI+Events.swift
runEventsCommand orchestrates event streaming: parses options, derives starting sequence from cursor file or --after flag, authenticates socket, constructs filtered stream request, processes frames in a loop, conditionally prints based on output flags, persists cursor after each event, counts events against --limit, and throws EventStreamLimitReached when limit is reached.
Events Options & Frame Parsing
CLI/CMUXCLI+Events.swift
parseEventsOptions interprets flags (--after, --cursor-file, --name, --category, --reconnect, --no-ack, --no-heartbeats, --limit) with validation. parseEventStreamFrame decodes each line as JSON, validates frame structure, and surfaces server errors when ok == false.
Events Cursor & Utilities
CLI/CMUXCLI+Events.swift
readEventCursor and writeEventCursor manage cursor persistence with tilde expansion and atomic writes. int64Value safely extracts numeric values from frame fields, handling both NSNumber and string representations.
Module API Exposure
CLI/cmux.swift
authenticateClientIfNeeded visibility changed from private to module-internal to enable reuse by event-streaming code.
Build Integration
GhosttyTabs.xcodeproj/project.pbxproj
Project file updated with PBXBuildFile, PBXFileReference, and PBXSourcesBuildPhase entries to compile CMUXCLI+Process.swift as part of the cmux-cli target.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A stream of events flows swift and true,
With cursors saved and limits too,
Process runners spawned with care,
Options parsed from here and there!
CLI magic, now complete,
Another feature, bittersweet! 🎉

✨ 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 fix-main-ci-cli-budget

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.

@lawrencecchen
lawrencecchen merged commit 042c4e2 into main May 7, 2026
20 of 24 checks passed
@lawrencecchen
lawrencecchen deleted the fix-main-ci-cli-budget branch May 7, 2026 02:58
@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extracts two groups of helpers out of CLI/cmux.swift — event-stream command logic into the existing CMUXCLI+Events.swift and the subprocess runner into a new CMUXCLI+Process.swift — so the main file drops below the CI file-length budget enforced by .github/swift-file-length-budget.tsv. All moved code is functionally identical to what was removed.

  • authenticateClientIfNeeded and runEventsCommand are widened from private to internal access, which is the minimal change required for cross-file Swift extensions to compile; there is no external consumer of these symbols since both live in the app CLI target.
  • CLIProcessRunner (98 lines) and the events helpers (~200 lines net in CMUXCLI+Events.swift) each stay well under the 400-line single-responsibility threshold in the file-boundary rule.
  • GhosttyTabs.xcodeproj/project.pbxproj correctly adds CMUXCLI+Process.swift to the cmux-cli Sources build phase.

Confidence Score: 5/5

Safe to merge — all moved code is byte-for-byte identical to what was removed, the Xcode project is wired correctly, and the only access-level changes are the minimum needed to cross Swift's file-private boundary.

The change is a pure extraction: no logic is added, removed, or reordered. The two access changes (private to implicit internal on authenticateClientIfNeeded and runEventsCommand) are structurally required and have no effect outside the CLI app target. The new file stays well within file-boundary thresholds, and the pre-existing DispatchSemaphore in the process runner is covered by the blocking-runtime rule's explicit exception for existing, unmoved code.

No files require special attention; all four changed files contain straightforward mechanical moves with no logic alterations.

Important Files Changed

Filename Overview
CLI/CMUXCLI+Events.swift Received runEventsCommand, parseEventsOptions, parseEventStreamFrame, readEventCursor, writeEventCursor, and int64Value moved verbatim from cmux.swift; added import CoreFoundation (needed for CFGetTypeID/CFBooleanGetTypeID); runEventsCommand access widened from private to internal to allow cross-file extension calls — necessary change, no behavior delta.
CLI/CMUXCLI+Process.swift New 98-line file housing CLIProcessResult and CLIProcessRunner extracted verbatim from cmux.swift; DispatchSemaphore usage is pre-existing, covered by the blocking-runtime rule's existing code not introduced or worsened exception; well under the 400-line file-boundary threshold.
CLI/cmux.swift Removed ~300 lines of code (process runner and events helpers) to pull the file below its CI budget; authenticateClientIfNeeded widened from private to internal so the moved extension in CMUXCLI+Events.swift can call it — required change with no runtime impact.
GhosttyTabs.xcodeproj/project.pbxproj Registers CMUXCLI+Process.swift with new PBXBuildFile and PBXFileReference UUIDs and adds it to the cmux-cli Sources build phase; straightforward, no conflicts with existing entries.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["CLI/cmux.swift\n(main entry, SocketClient, CMUXCLI body)"]
    B["CLI/CMUXCLI+Events.swift\n(runEventsCommand, cursor r/w,\nframe parsing, int64Value,\nwaitBeforeReconnect)"]
    C["CLI/CMUXCLI+Process.swift\n(CLIProcessResult,\nCLIProcessRunner.runProcess)"]

    A -->|"calls internal\nauthenticateClientIfNeeded"| B
    A -->|"calls internal\nrunEventsCommand"| B
    A -->|"calls static\nCLIProcessRunner.runProcess"| C
    B -->|"calls internal\nauthenticateClientIfNeeded\n(defined in cmux.swift)"| A

    style B fill:#d4edda,stroke:#28a745
    style C fill:#d4edda,stroke:#28a745
    style A fill:#fff3cd,stroke:#ffc107
Loading

Reviews (1): Last reviewed commit: "Split CLI helpers to restore main CI bud..." | Re-trigger Greptile

This branch was successfully deployed

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