fix(pty): a missing-cwd pane must not auto-launch the agent (#2438) - #2441
Merged
Conversation
…2438) When a pane's configured cwd is gone (e.g. a fleet worktree was removed), the init line fell back to the nearest existing ancestor and STILL ran the launch command — starting the agent ungated outside its project: for a fleet worktree the fallback ancestor is the parent of EVERY worktree, and the role gate (`ensure_session_settings`) was written into the missing configured path, so nothing bounded the session. Worse, the warning that was supposed to flag this printed BEFORE the final screen clear (bash `printf '\033[2J\033[H'`, PowerShell `Clear-Host`, cmd `cls`) — or before the launched agent's TUI took over — so the user saw a normal-looking session with no trace of the problem. Now all three shell init builders (`build_bash_init_line`, and the PowerShell + cmd branches of `non_bash_init`) suppress the launch when `cwd_missing` and print the red warning AFTER the clear, as the inert shell's banner, telling the user the agent was NOT started and to relaunch the fleet (recreating the worktree) or remove the pane. The normal path is unchanged: cd, clear, then launch. Tests lock the wire contract: no launch command in the missing-cwd init line even when a launch is configured, warning positioned after the clear sequence, and the non-missing path still appending the launch — for bash, PowerShell, and cmd. Closes #2438 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found reviewing the app log: restored panes whose fleet worktree was deleted logged
configured cwd does not exist — refusing the silent home fallback— but then launched Claude anyway in the nearest-ancestor fallback (for a fleet worktree,~/.base-studio-code/worktrees/<key>/— the parent of every worktree), with no role gate (ensure_session_settingswrote into the missing configured path), and the agent's TUI cleared the warning off screen. The PowerShell/cmd degraded paths additionally printed their warning before the clear, wiping it even without a launch.build_bash_init_line: whencwd_missing, the launch is suppressed and the red warning becomes the post-clear suffix — an inert shell whose banner states the agent was NOT started and how to recover (relaunch the fleet / remove the pane).non_bash_init(PowerShell + cmd): same suppression; warnings reordered afterClear-Host/cls.Gate:
cargo clippy --workspace --all-targets -- -D warningsclean.Closes #2438.
🤖 Generated with Claude Code