Skip to content

Keep restored terminals out of another workspace cwd - #16248

Merged
teamleaderleo merged 2 commits into
mainfrom
fix/restore-missing-cwd-safety-15804
Oct 1, 2026
Merged

teamleaderleo merged 2 commits into
mainfrom
fix/restore-missing-cwd-safety-15804

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When a restored local terminal's saved worktree no longer exists, the startup resolver could fall through to the selected workspace's directory. An auto-resumed Claude/Codex command could then run in another repository.

Fixes #15804.

  • Resolve missing local paths to their nearest existing parent before considering the workspace fallback.
  • Prefer a live restored-agent cwd when the saved path is gone.
  • Keep remote startup paths exact; they are resolved on the remote host and must not be checked against the Mac filesystem.
  • Add behavior coverage for missing local paths, live cwd rescue, and exact remote paths.

Testing

  • python3 scripts/verify-local.py --affected mf/main — 2/2 applicable checks passed.
  • swiftc -parse Sources/RemoteTerminalWorkingDirectoryResolver.swift
  • swiftc -parse cmuxTests/WorkspaceTerminalWorkingDirectoryFallbackTests.swift
  • git diff --check
  • Standalone resolver harness passed for local ancestry, live rescue, and remote exact-path behavior.

Native app tests were not run on the MacBook Air; CI is intentionally not being monitored.

Changelog

Fixed: Restored agent terminals no longer resume in another workspace when their saved directory was deleted.


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

Fixes #15804: restored local terminals whose saved worktree no longer exists could resolve to the selected workspace's directory, letting an auto-resumed agent command run in a different repository.

  • Missing local paths now resolve to their nearest existing parent directory before the workspace fallback is considered.
  • A live restored-agent cwd is preferred when the saved path is gone.
  • Remote startup paths are kept exact since they resolve on the remote host, not the Mac filesystem.
  • Adds test coverage for missing local paths, live cwd rescue, and exact remote paths.

Written for commit ce64259. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: manaflow-ai/cmux/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 1cf74672-f3b8-4a7d-85c5-2d192c7b9c78

📥 Commits

Reviewing files that changed from the base of the PR and between 579a979 and ce64259.

📒 Files selected for processing (2)
  • Sources/RemoteTerminalWorkingDirectoryResolver.swift
  • cmuxTests/WorkspaceTerminalWorkingDirectoryFallbackTests.swift
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions

Copy link
Copy Markdown
Contributor

CI failure attribution

CI failed on ce64259068 (run 36781990447 attempt 3): 1 code.

Job Verdict Why
macos / macOS compile admission code a compile error
Matched log lines
macos / macOS compile admission: /tmp/cmux-ci/src/CLI/CMUXCLI+AutoNaming.swift:271:16: error: cannot find 'usesTemporaryConfig' in scope

Not re-run automatically: macos / macOS compile admission is not a machine failure.

Written by scripts/ci/classify_failures.py (ci-failure-attribution.yml); signatures are its SIGNATURES table. A machine verdict is the runner's fault, not this PR's.

@teamleaderleo
teamleaderleo enabled auto-merge (squash) October 1, 2026 19:10
@teamleaderleo
teamleaderleo merged commit ee0dc94 into main Oct 1, 2026
128 of 155 checks passed
@teamleaderleo
teamleaderleo deleted the fix/restore-missing-cwd-safety-15804 branch October 1, 2026 19:19
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Merge receipt for ce64259068, merged 2026-10-01 19:19:49 UTC

  • Not verified at merge: ci-status (failure), macOS compile admission (failure), macOS status (failure), tests (failure)
  • Verified: CI fast guards, CI timing, Fast static checks, GhosttyKit release check, guards (18), linux-preflight, macOS admission gate, Testbox broker trust boundary, Web complexity, web-validation
  • Skipped by policy: app-host unit tests, admission-placement, browser, Claude wrapper regressions, CLI product tests, Dogfood build #​${{ github.event.pull_request.number }}, full-suite-coverage, late-placement, release-admission, release-build, remote-daemon, suite-coverage, and 7 more
  • Full suite: runs on main after merge.

Labeled merged-unverified: if main breaks near this merge, look here first.

@github-actions github-actions Bot added the merged-unverified A judging check was not green at merge; see the merge receipt comment label Oct 1, 2026
teamleaderleo added a commit that referenced this pull request Oct 2, 2026
)

#16248 resolves a missing local startup cwd to its nearest existing
parent, so tests that requested fake /tmp or /repo paths saw "/tmp" or
"/". Create those directories so the tests keep checking inheritance.


Claude-Session: https://claude.ai/code/session_01FrR7YbsQtGw2eFtDeyiTcK

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
teamleaderleo added a commit that referenced this pull request Oct 2, 2026
#16248 resolves a missing local startup cwd to its nearest existing
parent, so a split from a made-up /tmp path now inherits "/tmp". #16538
fixed the other tests with this pattern; this one was missed.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-unverified A judging check was not green at merge; see the merge receipt comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restored terminal whose directory was deleted opens in the selected workspace's directory and resumes the agent there

1 participant