Skip to content

fix(pty): a missing-cwd pane still auto-launches Claude — ungated, in the all-worktrees parent dir #2438

Description

@kevinthelago

Observed (app log, every boot)

Restored panes whose fleet worktree was deleted (project p-mr7zkqjn-xoufes: avatars/ui-shell/llm/coop-net) error configured cwd does not exist — refusing the silent home fallback — but the session doesn't stop there:

The bug

resolve_session_cwd correctly flags missing and falls back to the nearest existing ancestor for the shell — but both init builders still append the launch command:

  • build_bash_init_line (console/pty/launch.rs): prints the red warning, cds to the ancestor, then runs claude anyway. Claude's TUI clears the warning off screen.
  • non_bash_init (platform/shell/mod.rs): same — and the PowerShell branch prints the warning before Clear-Host, so it's wiped even without Claude.

Consequences: each dead pane spawns a live Claude in ~/.base-studio-code/worktrees/<key>/ — the parent of EVERY worktree — with no role gate (ensure_session_settings wrote .claude/settings.json into the missing configured path, not the ancestor). Wrong scope, ungated, plus pointless sessions (the same log shows "13 concurrent sessions — high memory pressure").

Fix

  • When cwd_missing, suppress the launch command in both builders — the pane opens as an inert shell in the ancestor with the warning visible, extended to say the agent was NOT started and how to recover (relaunch the fleet to recreate the worktree, or remove the pane).
  • PowerShell/cmd: print the missing-cwd warning after the clear so it survives.
  • Update/extend the existing wire-string unit tests (bash + non-bash) to lock: missing cwd ⇒ no auto-launch + surviving warning.

Follow-up (separate): a pane-level "worktree missing — recreate / remove" affordance instead of a dead shell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions