Skip to content

Fix sticky workspace identity leaking into Cmd+N - #9031

Merged
austinywang merged 5 commits into
mainfrom
fix/issue-9027-sticky-identity-cmdn
Jul 28, 2026
Merged

austinywang merged 5 commits into
mainfrom
fix/issue-9027-sticky-identity-cmdn

Conversation

@austinywang

@austinywang austinywang commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add a regression test for fresh workspace creation inheriting cwd without inheriting sticky title/color
  • split fresh directory tracking from restore/recovery sticky identity application
  • keep restore/recovery reconciliation as the only path that reads stored directory customizations

Verification

  • ./scripts/reload.sh --tag issue-9027-sticky-cmdn
  • swift test --package-path Packages/macOS/CmuxWorkspaces
  • ./scripts/lint-pbxproj-test-wiring.sh
  • python3 scripts/swift_warning_budget.py --log /tmp/cmux-reload-issue-9027-sticky-cmdn.log

Fixes #9027


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Prevent sticky directory identity (title/color) from leaking into new workspaces (e.g., Cmd+N). New workspaces can inherit the CWD but start with a clean title and color; only restore/recovery reads and applies saved customizations. Fixes #9027.

  • Bug Fixes

    • Fresh workspaces now only track their directory; they do not read stored title/color.
    • Restore/recovery is the sole path that reads and applies saved customizations, overriding stale snapshot values.
    • Added regression coverage for Cmd+N inheritance and made the failed-restore customization test deterministic.
  • Refactors

    • Replaced shouldApplyWorkspaceDirectoryCustomization with WorkspaceDirectoryCustomizationCreationMode (.disabled | .trackDirectory) and moved it to its own file.
    • Renamed applyWorkspaceDirectoryCustomization to trackWorkspaceDirectoryCustomization.
    • Updated creation APIs and WorkspaceGroupHosting to use the new mode; default is .trackDirectory, with .disabled used for remote tmux and config-driven launches.

Written for commit 1d3d90e. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Added directory customization creation modes for new workspaces (enabled via a new mode enum).
    • Workspaces can now track their directory for persistent title/color changes, or opt out when appropriate.
  • Bug Fixes
    • Fixed cases where newly created or restored workspaces could incorrectly inherit previously stored directory titles and colors.
    • Improved consistency of customization behavior across workspace creation paths (including restore/remote mirror scenarios).
  • Tests
    • Updated and expanded workspace recovery coverage to match the new mode-based behavior.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Workspace creation replaces boolean directory-customization flags with explicit modes. Fresh workspaces track directories without applying stored identity, while restoration paths can disable or restore customization behavior. Recovery tests cover title, color, persistence, and snapshot restoration semantics.

Changes

Workspace customization creation flow

Layer / File(s) Summary
Creation mode contract and group wiring
Packages/macOS/CmuxWorkspaces/Sources/CmuxWorkspaces/Customization/*, Packages/macOS/CmuxWorkspaces/Sources/CmuxWorkspaces/Coordinators/*, Packages/macOS/CmuxWorkspaces/Tests/*, Sources/TabManager.swift
Introduces WorkspaceDirectoryCustomizationCreationMode and propagates it through workspace and workspace-group creation APIs.
Fresh workspace tracking behavior
Sources/TabManager*.swift
Fresh workspace creation tracks directory roots and records explicit titles without applying stored custom titles or colors.
Creation call-site propagation
Sources/AppDelegate.swift, Sources/CmuxConfigExecutor+WorkspaceLaunch.swift, Sources/RemoteTmuxController.swift, Sources/TabManager.swift
Workspace creation, remote mirroring, configuration commands, replacement workspaces, and closed-workspace restoration pass explicit customization modes.
Recovery and persistence validation
cmuxTests/WorkspaceRecoveryTests.swift
Recovery tests validate fresh workspace identity, directory record updates, explicit title and color persistence, and snapshot restoration.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

  • manaflow-ai/cmux-dev-artifacts#6634: Reports failures in WorkspaceRecoveryTests, which this change updates to validate the revised directory-customization and restoration behavior.

Possibly related PRs

  • manaflow-ai/cmux#8841: Introduces the sticky per-directory workspace customization behavior adjusted by this change.
  • manaflow-ai/cmux#9030: Changes workspace-group replacement creation argument wiring in the same coordinator path.
🚥 Pre-merge checks | ✅ 24 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (24 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address #9027 by separating fresh workspace creation from sticky identity restore logic and adding regression coverage.
Out of Scope Changes check ✅ Passed The refactors and API signature updates all support the sticky-identity fix; no clearly unrelated changes stand out.
Cmux Swift Actor Isolation ✅ Passed The diff only swaps a creation-mode enum in MainActor-only workspace APIs; no new shared-mutable Sendable type or background store access was introduced.
Cmux Swift Blocking Runtime ✅ Passed PASS: PR only swaps workspace customization API/mode and tracking calls; no new blocking waits, sleeps, main.sync, or locks appear in changed non-test Swift.
Cmux Browser Automation Off-Main ✅ Passed The commit only changes cmuxTests/WorkspaceRecoveryTests.swift; no browser/socket/control-command files or routing paths were touched.
Cmux Expensive Synchronous Load ✅ Passed Diff only swaps workspace directory customization plumbing and tests; no agent-history loads, JSONL/transcript parsing, or main-actor sync loads were added or moved.
Cmux Cache Substitution Correctness ✅ Passed PR diff only moves the enum to its own file; no fresh-read→cache substitution appears in any production persistence/history/snapshot path.
Cmux No Hacky Sleeps ✅ Passed PASS: the PR only touches Swift workspace-plumbing files; no non-Swift runtime/script code or new sleep/timer/polling logic was introduced.
Cmux Algorithmic Complexity ✅ Passed Current commit changes only a test fixture; no production code paths or scalable collection algorithms were introduced or worsened.
Cmux Swift Concurrency ✅ Passed No added background queues, Combine state, completion-handler APIs, or fire-and-forget Tasks; the PR is an API/behavior refactor plus tests only.
Cmux Swift @Concurrent ✅ Passed No touched Swift function adds/changes async isolation or @concurrent; the diff is sync UI-bound plumbing only.
Cmux Swift Package Boundaries ✅ Passed Changed app-target code is lifecycle/glue around TabManager and SessionWorkspaceSnapshot; the reusable customization mode/store live in CmuxWorkspaces.
Cmux Swiftpm Lockfiles ✅ Passed Diff from merge-base to HEAD only touches Swift source/tests; no .gitignore, Package.swift, or Package.resolved changes are present.
Cmux Swift Logging ✅ Passed PASS: The only changed Swift file is a test, and the diff adds no print/debugPrint/dump/NSLog/Logger usage or file-scoped Logger constants.
Cmux User-Facing Error Privacy ✅ Passed Only cmuxTests/WorkspaceRecoveryTests.swift changed; no production user-facing errors, alerts, or recovery copy were modified.
Cmux Full Internationalization ✅ Passed No new user-facing production strings were added; changes only rename APIs and tweak tests/comments, with no i18n resources or untranslated UI text touched.
Cmux Swiftui State Layout ✅ Passed PASS: The diff only changes workspace-creation plumbing and tests; no touched file adds SwiftUI views, GeometryReader, lazy rows, or new observable state.
Cmux Architecture Rethink ✅ Passed Pass: it’s a small owner-clear fix—fresh creation only tracks cwd, restore/recovery alone reconciles sticky identity, with no sleeps, polling, locks, observers, or duplicate wiring.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed Only a test file changed; no NSWindow/NSPanel/WindowGroup code or cmuxAuxiliaryWindowIdentifiers changes, so the rule doesn't apply.
Cmux Source Artifacts ✅ Passed All changed paths are intentional source/test files; no artifact directories or generated outputs appear in the diff.
Cmux No Test Or Debug Seam In Production Source ✅ Passed Production Swift changes only refactor workspace-directory customization APIs; no #if DEBUG/test-only members, test hooks, or visibility-widening seams appear in the diff.
Cmux No Ambient Global State ✅ Passed PASS: The new top-level type is a real enum with cases, and the other additions are methods on existing types; no new globals or singletons were introduced.
Title check ✅ Passed Clearly states the main fix: preventing sticky workspace identity from leaking into Cmd+N.
Description check ✅ Passed Includes the required Summary and Verification details, and explains the behavior change and tests; Demo Video, Review Trigger, and Checklist are missing.
✨ 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/issue-9027-sticky-identity-cmdn

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.

@cursor

cursor Bot commented Jul 28, 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.

@austinywang
austinywang merged commit 047e346 into main Jul 28, 2026
5 checks passed
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.

Cmd+N copies the current workspace's custom name and color onto the new workspace (sticky-identity regression after 0.64.20)

1 participant