Skip to content

fix(pty): a missing-cwd pane must not auto-launch the agent (#2438) - #2441

Merged
kevinthelago merged 1 commit into
developfrom
2438-missing-cwd-no-launch
Jul 6, 2026
Merged

fix(pty): a missing-cwd pane must not auto-launch the agent (#2438)#2441
kevinthelago merged 1 commit into
developfrom
2438-missing-cwd-no-launch

Conversation

@kevinthelago

Copy link
Copy Markdown
Owner

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_settings wrote 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: when cwd_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 after Clear-Host/cls.
  • Wire-string tests updated + extended for all three shells: missing cwd ⇒ no launch, warning after the clear; normal path unchanged (byte-exact test still passes).

Gate: cargo clippy --workspace --all-targets -- -D warnings clean.

Closes #2438.

🤖 Generated with Claude Code

…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>
@kevinthelago
kevinthelago merged commit ffb5b16 into develop Jul 6, 2026
6 checks passed
@kevinthelago
kevinthelago deleted the 2438-missing-cwd-no-launch branch July 6, 2026 20:19
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