Skip to content

Fix the main build: four errors across three files - #8857

Closed
ejc3 wants to merge 4 commits into
manaflow-ai:mainfrom
ejc3:fix/dock-restore-missing-cmuxworkspaces-import
Closed

ejc3 wants to merge 4 commits into
manaflow-ai:mainfrom
ejc3:fix/dock-restore-missing-cmuxworkspaces-import

Conversation

@ejc3

@ejc3 ejc3 commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Building main fails. Three errors, all in the two Dock session-restore files that
arrived with #8690, and the first one hides the other two:

Sources/DockSplitStore+RestoredAgentLifecycle.swift:13:62: error: cannot find type 'PanelShellActivityState' in scope
Sources/DockSplitStore+SessionSnapshot.swift:44:43: error: generic parameter 'Key' could not be inferred
Sources/DockSplitStore+SessionSnapshot.swift:44:43: error: generic parameter 'Value' could not be inferred
Sources/DockSplitStore+SessionSnapshot.swift:332:47: error: generic parameter 'U' could not be inferred

Repro on a clean checkout of main at 4dc00ae:

xcodebuild -project cmux.xcodeproj -scheme cmux-unit -configuration Debug \
  -destination 'platform=macOS' build

The missing import. DockSplitStore+RestoredAgentLifecycle.swift declares
updatePanelShellActivityState(panelId:state:), whose state is a
PanelShellActivityState. That type is a public enum in the CmuxWorkspaces package, and
Swift resolves imports per file, so the app target depending on the package is not enough on
its own. Every other file under Sources/ that names the type imports CmuxWorkspaces; this
one imports only Foundation.

The two inference failures. Both are the same shape: a multi-statement closure whose
bail-out is a bare return nil, handed to something generic. Line 44 gives it to
Dictionary(uniqueKeysWithValues:), which then has to solve Key and Value; line 332 gives
it to Optional.flatMap, which has to solve U. A bare return nil carries no type, so the
closure's result type and the generic parameters each wait on the other. Naming the return
types breaks the cycle, using the types the surrounding code already fixes:
SessionSplitContainerSnapshot declares sourceWorkspaceIdsByPanelId as [UUID: UUID]?,
sessionRestoreWorkspaceId is a UUID, and observation is a
RestorableAgentSessionIndex.Entry?. Behaviour is unchanged.

A fourth error, in a third file. surfacePromptForResumeApproval builds an NSAlert over
several statements and ends with a bare switch alert.runModal() whose cases are .auto,
.prompt and .manual:

Sources/ControlSurfaceResumeTarget.swift:282:40: error: reference to member 'auto' cannot be resolved without a contextual type
Sources/ControlSurfaceResumeTarget.swift:283:41: error: reference to member 'prompt' cannot be resolved without a contextual type
Sources/ControlSurfaceResumeTarget.swift:284:19: error: reference to member 'manual' cannot be resolved without a contextual type

Swift gives a function body an implicit return only when the body is a single expression, so
in a multi-statement body that switch is an expression statement with nothing to type it, and
the leading-dot members have no SurfaceResumeApprovalPolicy to resolve against. Returning it
supplies the contextual type. Every other trailing switch of this shape under Sources/ is the
single-expression body of a computed property or a one-statement function, which is why this is
the only one that fails.

Worth saying how this got in, because it will happen again otherwise: ci.yml is
workflow_dispatch:-only, so no pull request is ever built. The checks that appear on a PR
are reviewers, not a compile, so a commit that does not build can land looking green.

Summary by CodeRabbit

  • Refactor
    • Streamlined how resume approval outcomes are processed for consistency.
    • Improved robustness of workspace/session snapshot mapping and related filtering behavior.
  • Tests
    • Updated workspace inheritance test setup to explicitly omit a restore source workspace ID where appropriate.
  • No user-visible changes
    • These changes are intended to be behavior-preserving for end-users, with improvements focused on reliability and internal consistency.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 91b474e9-42c0-499d-9f9d-0a0eff601d98

📥 Commits

Reviewing files that changed from the base of the PR and between 6e2938a and 62066a0.

📒 Files selected for processing (4)
  • Sources/ControlSurfaceResumeTarget.swift
  • Sources/DockSplitStore+RestoredAgentLifecycle.swift
  • Sources/DockSplitStore+SessionSnapshot.swift
  • cmuxTests/DockWorkingDirectoryInheritanceTests.swift

📝 Walkthrough

Walkthrough

The changes update modal-result return flow in resume approval and make Dock session restoration imports, closure return types, and detached transfer test initialization explicit. Existing snapshot construction and observation filtering logic remain unchanged.

Changes

Swift updates

Layer / File(s) Summary
Resume approval return flow
Sources/ControlSurfaceResumeTarget.swift
surfacePromptForResumeApproval now directly returns the policy selected by alert.runModal().
Dock session restoration typing and fixtures
Sources/DockSplitStore+RestoredAgentLifecycle.swift, Sources/DockSplitStore+SessionSnapshot.swift, cmuxTests/DockWorkingDirectoryInheritanceTests.swift
Adds the CmuxWorkspaces import, explicit closure typing, and sessionRestoreSourceWorkspaceId initialization without changing restoration logic.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

  • manaflow-ai/cmux-dev-artifacts#5724: Tracks the resume approval switch-return compilation issue addressed here.
  • manaflow-ai/cmux-dev-artifacts#5730: Tracks the missing return from surfacePromptForResumeApproval.
  • manaflow-ai/cmux-dev-artifacts#5688: Tracks the missing sessionRestoreSourceWorkspaceId test initializer argument.
  • manaflow-ai/cmux-dev-artifacts#5657: Covers the same detached transfer initializer build failure.
  • manaflow-ai/cmux-dev-artifacts#5734: Covers the missing test-helper initializer argument.
  • manaflow-ai/cmux-dev-artifacts#5735: Covers the detached transfer initializer argument failure.

Possibly related PRs

Suggested reviewers: austinywang


Important

Pre-merge checks failed

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

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
Cmux No Ambient Global State ❌ Error PR adds MobileHostEventTopicPolicy, a file-scope caseless enum namespace with static helpers, which the rule forbids. Nest the policy inside MobileHostConnectionEventQueue or replace it with private/fileprivate constants/helpers; keep state in owning types.
Description check ⚠️ Warning The description is detailed, but it does not follow the required template sections or include the review trigger and checklist. Reformat the PR description to include Summary, Testing, Demo Video, Review Trigger, and Checklist sections.
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.
✅ Passed checks (22 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing build errors across three files.
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 PASS: The diff only adds an import, type annotations, and a return switch; the touched production types are already @MainActor, and the test edit is test-only.
Cmux Swift Blocking Runtime ✅ Passed Diff only adds an import, type annotations, a return-switch, and a test nil arg; no new waits, sleeps, syncs, locks, or polling were introduced.
Cmux Browser Automation Off-Main ✅ Passed PR diff adds mobile-host/session-restore/test changes only; no browser.* socket commands, execution-policy moves, or missing policy tests are introduced.
Cmux Expensive Synchronous Load ✅ Passed Diff only adds import/type annotations/return switch and mobile event-queue plumbing; no new RestorableAgentSessionIndex.load(), disk/JSON/JSONL scans, or main-actor history loads.
Cmux Cache Substitution Correctness ✅ Passed The diff only adds type/import fixes and a transient render-grid cache with event-driven full-resync; no persistence/history/snapshot read was replaced by a stale cached value.
Cmux No Hacky Sleeps ✅ Passed No changed TS/JS/shell/build-runtime files; the diff is Swift/tests plus Rust, and the rule’s scope excludes Swift/out-of-scope Rust.
Cmux Algorithmic Complexity ✅ Passed Syntax/import/test-only edits; no new scalable scans, nested loops, or hot-path re-sorting/filtering were introduced in the touched code.
Cmux Swift Concurrency ✅ Passed The touched lines only add an import, clarify return types, and fix a test argument; no new DispatchQueue/Task/Combine lifecycle patterns were introduced.
Cmux Swift @Concurrent ✅ Passed Touched changes are sync/@MainActor-only; no @concurrent, nonisolated async, or heavy async UI calls were added or altered.
Cmux Swift Package Boundaries ✅ Passed Changes are compile-fix glue—one missing package import, two type annotations, and one test arg. No reusable domain logic was added or moved across targets.
Cmux Swiftpm Lockfiles ✅ Passed PASS: the only project-file edits add source file references; no SwiftPM package-reference, .gitignore, workflow, or Package.resolved changes are present.
Cmux Swift Logging ✅ Passed PASS: The diff adds only os.Logger error logs in MobileHostService; no print/debugPrint/dump/NSLog, no ad hoc stdout/file logging, and no sensitive data exposure.
Cmux User-Facing Error Privacy ✅ Passed The only touched file is a test helper, and it adds no user-facing error, alert, or recovery copy.
Cmux Full Internationalization ✅ Passed No new user-facing Swift copy or locale assets were added; the changed Rust UI text stays catalog-backed, and the rest is operational/test/token-only.
Cmux Swiftui State Layout ✅ Passed No changed SwiftUI views/state: touched files are service/logic/tests only, with no SwiftUI imports or new ObservableObject/@Published/GeometryReader/lazy-row store refs.
Cmux Architecture Rethink ✅ Passed Only import/type-annotation/return-expression fixes and a test-only nil arg were added; no sleeps, observers, locks, side channels, or split ownership.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed Touched files only adjust resume/session logic and a test; no added NSWindow/NSPanel/WindowGroup or cmux window-identifier/shortcut routing changes.
Cmux Source Artifacts ✅ Passed All changed paths are source/config/test files; none are logs, caches, build output, scratch dirs, or other checked-in artifacts.
Cmux No Test Or Debug Seam In Production Source ✅ Passed PASS: The full PR diff only adds an import, type annotations, a return switch, and a test-helper nil; no new DEBUG/test-only seams or widened test accessors appear in Sources/.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ejc3 ejc3 changed the title Fix the main build: import CmuxWorkspaces in the restored-lifecycle extension Fix the main build: three errors in the Dock session-restore files Jul 24, 2026
@ejc3 ejc3 changed the title Fix the main build: three errors in the Dock session-restore files Fix the main build: four errors across three files Jul 24, 2026
@ejc3
ejc3 marked this pull request as ready for review July 24, 2026 10:25
@ejc3

ejc3 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Verified on a clean worktree at 94a329e: ** BUILD SUCCEEDED **, 0 errors, building the cmux-unit scheme for macOS with SWIFT_COMPILATION_MODE=wholemodule so every remaining type error in the module would surface in one pass rather than one file per build. The same worktree at origin/main fails on the first of the four.

@cursor

cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@greptile-apps

greptile-apps Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes four Swift compiler errors that caused main to fail to build, all introduced by #8690. The fixes are minimal, targeted, and behavior-preserving.

  • Missing import: Adds import CmuxWorkspaces to DockSplitStore+RestoredAgentLifecycle.swift so PanelShellActivityState resolves at file scope.
  • Two generic inference failures: Annotates the compactMap and flatMap closure return types in DockSplitStore+SessionSnapshot.swift (to (UUID, UUID)? and RestorableAgentSessionIndex.Entry? respectively), breaking the circular inference dependency on return nil.
  • Missing return: Prefixes the bare switch alert.runModal() in ControlSurfaceResumeTarget.swift with return, giving Swift the contextual type it needs to resolve leading-dot SurfaceResumeApprovalPolicy members; and updates the DetachedSurfaceTransfer initializer call in the inheritance test to supply the new required sessionRestoreSourceWorkspaceId: nil argument.

Confidence Score: 5/5

All four changes are narrowly scoped compiler fixes with no logic changes; the builds that were broken on main are restored and no new behavior is introduced.

Every change is a minimal syntactic correction: adding a missing import, annotating return types to break circular type inference, prepending return to a switch expression, and supplying a required initializer argument in a test helper. None of the changes alter control flow, data flow, or observable behavior. The PR description's root-cause analysis is accurate and matches the diff.

No files require special attention; all four fixes are straightforward and correct.

Important Files Changed

Filename Overview
Sources/ControlSurfaceResumeTarget.swift Adds return keyword to the trailing switch alert.runModal(), turning it from a bare expression statement into a proper return expression and supplying the contextual type needed for leading-dot member resolution.
Sources/DockSplitStore+RestoredAgentLifecycle.swift Adds import CmuxWorkspaces so PanelShellActivityState — a public enum from that package — resolves at the file scope.
Sources/DockSplitStore+SessionSnapshot.swift Fixes two generic-parameter inference failures by annotating the Dictionary(uniqueKeysWithValues:) closure's return type as (UUID, UUID)? and the Optional.flatMap closure's return type as RestorableAgentSessionIndex.Entry?; behavior is unchanged.
cmuxTests/DockWorkingDirectoryInheritanceTests.swift Adds the new required sessionRestoreSourceWorkspaceId: nil argument to the DetachedSurfaceTransfer initializer in the test helper, matching the struct's updated memberwise init added by #8690.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["DockSplitStore+RestoredAgentLifecycle.swift\n+ import CmuxWorkspaces"] -->|"resolves PanelShellActivityState"| B["✅ Compiles"]
    C["DockSplitStore+SessionSnapshot.swift\ncompactMap { panel -> (UUID, UUID)? }"] -->|"breaks Key/Value inference cycle"| D["✅ Compiles"]
    E["DockSplitStore+SessionSnapshot.swift\nflatMap { entry -> Entry? }"] -->|"breaks U inference cycle"| D
    F["ControlSurfaceResumeTarget.swift\nreturn switch alert.runModal()"] -->|"provides contextual type for .auto/.prompt/.manual"| G["✅ Compiles"]
    H["DockWorkingDirectoryInheritanceTests.swift\nsessionRestoreSourceWorkspaceId: nil"] -->|"satisfies updated memberwise init"| I["✅ Test compiles"]
Loading

Reviews (3): Last reviewed commit: "cmuxTests: pass the new transfer field a..." | Re-trigger Greptile

@ejc3

ejc3 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Correction to my previous comment, and a fourth commit.

That ** BUILD SUCCEEDED ** came from xcodebuild build, which for the cmux-unit scheme compiles the app target but not cmuxTests. So it proved less than I implied. The test target was still broken by the same change:

cmuxTests/DockWorkingDirectoryInheritanceTests.swift:216:49: error: missing argument for parameter 'sessionRestoreSourceWorkspaceId' in call

DetachedSurfaceTransfer gained a sessionRestoreSourceWorkspaceId: UUID? stored property, and since the struct has no explicit init that became a required argument of the memberwise one. Four places under cmuxTests construct it; three were updated and this one was missed. It now passes nil, which is what the other three pass and is behaviour-preserving, because sessionRestoreWorkspaceId resolves to sessionRestoreSourceWorkspaceId ?? sourceWorkspaceId.

Giving the property a default would not work: a let with an initial value is excluded from the memberwise init, which would break the five call sites under Sources that pass it explicitly.

Re-verifying with build-for-testing so the check covers both targets.

ejc3 added 4 commits July 24, 2026 08:06
…eds it

Building main at 4dc00ae fails with a single error:

  Sources/DockSplitStore+RestoredAgentLifecycle.swift:13:62: error: cannot find
  type 'PanelShellActivityState' in scope

That file arrived with manaflow-ai#8690 and declares
updatePanelShellActivityState(panelId:state:), whose state parameter is
PanelShellActivityState. That type is a public enum in the CmuxWorkspaces
package, and Swift imports are per-file, so the app target linking the package
is not enough on its own. Every other file in Sources that names the type
imports CmuxWorkspaces; this one imports only Foundation.

ci.yml is dispatch-only, so no PR build runs and nothing caught it.
Second and third errors from the same build, after the missing import:

  Sources/DockSplitStore+SessionSnapshot.swift:44:43: error: generic parameter 'Key' could not be inferred
  Sources/DockSplitStore+SessionSnapshot.swift:44:43: error: generic parameter 'Value' could not be inferred
  Sources/DockSplitStore+SessionSnapshot.swift:332:47: error: generic parameter 'U' could not be inferred

Both are the same shape: a multi-statement closure whose bail-out is a bare
`return nil`, handed to something generic. At line 44 that is
Dictionary(uniqueKeysWithValues:), which has to solve Key and Value; at line 332 it
is Optional.flatMap, which has to solve U. A bare `return nil` carries no type, so
the closure result and the generic parameters each depend on the other and the
solver gives up.

Naming the return types breaks the cycle. The types are the ones already required
by the surrounding code: SessionSplitContainerSnapshot declares
sourceWorkspaceIdsByPanelId as [UUID: UUID]?, DetachedSurfaceTransfer's
sessionRestoreWorkspaceId is a UUID, and observation is a
RestorableAgentSessionIndex.Entry?. Behaviour is unchanged.
Fourth error from the same build:

  Sources/ControlSurfaceResumeTarget.swift:282:40: error: reference to member 'auto' cannot be resolved without a contextual type
  Sources/ControlSurfaceResumeTarget.swift:283:41: error: reference to member 'prompt' cannot be resolved without a contextual type
  Sources/ControlSurfaceResumeTarget.swift:284:19: error: reference to member 'manual' cannot be resolved without a contextual type

surfacePromptForResumeApproval builds an NSAlert over several statements and then
ends with a bare `switch alert.runModal()` whose cases are `.auto`, `.prompt` and
`.manual`. Swift gives a function body an implicit return only when the body is a
single expression, so in a multi-statement body that switch is an expression
statement with nothing to type it, and the leading-dot members have no
SurfaceResumeApprovalPolicy to resolve against.

Returning it supplies the contextual type. Every other trailing switch of this shape
under Sources is the single-expression body of a computed property or a one-statement
function, which is why this is the only one that fails.
…missed

The test target does not build either:

  cmuxTests/DockWorkingDirectoryInheritanceTests.swift:216:49: error: missing argument
  for parameter 'sessionRestoreSourceWorkspaceId' in call

DetachedSurfaceTransfer gained a `sessionRestoreSourceWorkspaceId: UUID?` stored
property. The struct has no explicit init, so that field became a required argument of
the memberwise one. Four places under cmuxTests construct the type and three of them
were updated; this one was missed.

`nil` is the behaviour-preserving value and the one the other three pass:
`sessionRestoreWorkspaceId` resolves to `sessionRestoreSourceWorkspaceId ?? sourceWorkspaceId`,
so nil keeps the restore id equal to the source id, as it was before the field existed.
Giving the property a default instead would not work, because a `let` with an initial
value is excluded from the memberwise init, which would break the five call sites under
Sources that pass it explicitly.
@ejc3
ejc3 force-pushed the fix/dock-restore-missing-cmuxworkspaces-import branch from 6e2938a to 62066a0 Compare July 24, 2026 15:08
@ejc3

ejc3 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (69b2c55e27), which had moved 15 commits ahead. Now 4 commits, 4 files, +10/-7.

I checked whether any of it had become unnecessary rather than assuming. All four errors are still present on main, so every commit still earns its place:

on current main
missing import CmuxWorkspaces still broken
two bare return nil closures still broken
trailing switch with no return still broken
missing memberwise arg in the test still broken

None of the four files this touches were modified by those 15 commits, so every line number cited in the commits and in the description above still points at the right line.

Re-verifying the build on the rebased tip, since my earlier ** TEST BUILD SUCCEEDED ** was measured against the older base and a rebase invalidates it. I will post the result either way.

@ejc3

ejc3 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Re-verified after the rebase onto current main (69b2c55e27):

** TEST BUILD SUCCEEDED **   errors=0   sha=62066a0bd6

build-for-testing with SWIFT_COMPILATION_MODE=wholemodule, so both the app and cmuxTests are covered and any remaining type error in the module would have surfaced in the same pass. The claim I withdrew when rebasing is now re-earned on the current base.

Incidental evidence of why this one matters: I tried to build an unrelated one-file test fix (#8867) on plain main an hour ago and it came back with 7 errors, every one of them from this list and none from the change itself. Nothing can be verified in isolation until this lands.

@azooz2003-bit

Copy link
Copy Markdown
Collaborator

Heads up: the three app-target fixes here (the CmuxWorkspaces import, the return switch in ControlSurfaceResumeTarget.swift, and the closure annotations in DockSplitStore+SessionSnapshot.swift) just landed via #8869 (merged as 34e7fa5) — I hit the same broken main from the reload builder and didn't find this PR until CodeRabbit cross-referenced it after mine was open, sorry for the duplication. The cmuxTests/DockWorkingDirectoryInheritanceTests.swift fix here is still needed (my reload builds only compile the app target, so I never hit it). After a rebase this PR should shrink to that one file.

@ejc3

ejc3 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

Closing: main has since fixed all four of these independently, so this PR is redundant.

Verified by reading the current code at all four sites rather than pattern-matching for this branch's text. Nothing left here to merge.

@ejc3 ejc3 closed this Jul 25, 2026
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.

2 participants