Skip to content

Fix split cwd inheritance while shell cwd is stale - #1403

Merged
austinywang merged 2 commits into
mainfrom
cmux/cwd-regression
Mar 14, 2026
Merged

austinywang merged 2 commits into
mainfrom
cmux/cwd-regression

Conversation

@austinywang

@austinywang austinywang commented Mar 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • bootstrap bash shell integration on the first interactive prompt for macOS bash
  • preserve requested working directories when creating splits before shell integration reports a live cwd
  • update the split cwd regression tests to assert explicit focus/tab selection instead of focus stealing

Verification

  • ./scripts/reload.sh --tag cwd-regression
  • local tests not run per repo policy

Summary by cubic

Fixes split pane cwd inheritance when the source shell hasn’t reported a cwd yet by falling back to the pane’s requested startup directory. Also bootstraps macOS bash shell integration at the first interactive prompt and standardizes close confirmation key equivalents.

  • Bug Fixes
    • Splits now inherit cwd in order: reported cwd → requested startup cwd → workspace cwd.
    • macOS /bin/bash loads Ghostty/cmux integration via PROMPT_COMMAND on first prompt when enabled.
    • Close confirmations: Enter confirms, Esc cancels; app is brought to front for alerts.
    • Tests updated to focus returned panes/tabs explicitly and verify cwd inheritance deterministically.

Written for commit 4bb2125. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes

    • Improved working directory inheritance when creating terminal splits—new splits now correctly use the source terminal's directory.
    • Enhanced keyboard navigation in close dialogs with standard shortcuts (Return to close, Escape to cancel).
    • Refined bash shell integration handling.
  • Tests

    • Added tests for working directory inheritance in terminal splits.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@vercel

vercel Bot commented Mar 14, 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 Mar 14, 2026 0:03am

@coderabbitai

coderabbitai Bot commented Mar 14, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR exposes terminal working directory information through new requestedWorkingDirectory properties, refines workspace split creation to prioritize per-panel working directories with a multi-tier fallback strategy, updates keyboard navigation in close confirmation dialogs (Enter/Escape bindings and initial responder focus), and adds/updates tests to verify split working directory inheritance behavior.

Changes

Cohort / File(s) Summary
Terminal Properties
Sources/GhosttyTerminalView.swift, Sources/Panels/TerminalPanel.swift
Expose previously private workingDirectory as public computed property requestedWorkingDirectory through terminal surface and panel layers for external access.
Dialog & Keyboard Behavior
Sources/TabManager.swift, Sources/Workspace.swift
Enhance close confirmation dialog keyboard navigation: bind Enter to primary (close) button, Escape to cancel, set close button as initial responder, and update app activation logic.
Split Working Directory Resolution
Sources/Workspace.swift
Refine splitWorkingDirectory fallback chain: prefer non-empty panelDirectories[panelId], then requestedWorkingDirectory, finally workspace currentDirectory; add requestedDir to debug logging.
Test Coverage
cmuxTests/CmuxWebViewKeyEquivalentTests.swift, tests/test_split_cwd_inheritance.py
Add new test class verifying split inherits requested working directory when reported cwd is stale; refactor Python integration test to use explicit surface/panel/tab tracking with _focus_first_surface helper and updated parameter handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A rabbit's splits now find their way,
With directories trimmed and preferences at play.
Enter confirms, Escape denies,
Working directories crystallize—no more surprise! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: fixing split working directory inheritance when the shell's reported cwd is not yet available.
Description check ✅ Passed The PR description includes a Summary section covering what changed and why, and a Verification section with testing steps, though a demo video is not applicable for backend changes and the bot review checklist appears incomplete.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cmux/cwd-regression
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@austinywang
austinywang merged commit 3891a78 into main Mar 14, 2026
9 of 13 checks passed

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 6 files

This branch was successfully deployed

1 active deployment
Preview — 4bb21251 Deployed Mar 14, 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