Skip to content

[Bug]: New terminal creation persistently fails with "Terminal cwd must be inside the selected worktree." toast #7239

Closed

Description

@motoki418

Operating system

macOS

Orca version

1.4.120

Details

Short summary:
In one of my workspaces, every attempt to open a new terminal from the UI fails with a red toast at the bottom of the window: Terminal cwd must be inside the selected worktree. No terminal is created, and the toast reappears on every retry (it has been reproducing for hours). Creating a terminal in the same workspace via the CLI works fine.

What happened?

  • The workspace is a local git worktree managed by Orca at ~/orca/workspaces/nakamuramotoki/Fableと議論 (note: display name / branch / path contain non-ASCII Japanese characters — unclear if relevant). It has three Claude Code agent sessions running in terminal panes.
  • Any attempt to open a new terminal in this workspace shows the red TerminalErrorToast with Terminal cwd must be inside the selected worktree. and the "file an issue" link (hence this issue).
  • The toast recurs every time; the workspace is effectively unable to open new terminals from the UI.

What I dug up (from app.asar of 1.4.120):

  • The message is thrown by resolveTerminalStartupCwd in out/shared/terminal-startup-cwd.js when the spawn's requested cwd fails isPathInsideOrEqual(worktreePath, resolvedCwd). The failing call path is the pty:spawn IPC handler → resolveGuardedPtySpawnCwd.
  • So for a plain user-initiated "new terminal", the renderer is passing some non-empty cwd that falls outside the selected worktree. I could not determine the offending value: the rejection is not logged anywhere (checked logs/main.trace.ndjson — no occurrence of the message), it only surfaces in the toast.
  • The worktree path resolution itself is fine: orca terminal create --worktree active from the CLI (which omits cwd) succeeds in the same workspace.
  • The live cwd of every existing pane shell in the workspace is inside the worktree (verified via lsof -d cwd on the pane shells), so the bad value is presumably a persisted/tracked one (terminal tabs persist startupCwd in the session schema) rather than the current state of any live pane.

How can we reproduce it?

I don't have a from-scratch recipe, but the failing state is fully reproducible on my machine:

  1. Workspace = local git worktree (non-ASCII path) with Claude Code agent sessions running in its panes.
  2. Try to open a new terminal in that workspace from the UI.
  3. Red toast Terminal cwd must be inside the selected worktree. appears and no terminal is created — every time.

Expected behavior / suggestions:

  • A user-initiated "new terminal" should never hard-fail on the cwd guard: if the remembered/inherited cwd is outside the selected worktree, fall back to the worktree root instead of refusing to create the terminal. (The guard makes sense for remote/session clients per the code comment, but for the local UI path it turns a stale value into a persistent, unrecoverable failure.)
  • Log (or show) the rejected cwd value. Right now the error gives no hint which path was rejected nor how to clear it, so there is no way for a user to self-recover.

Anything else that might help:

  • Orca 1.4.120 (production build), macOS 26.5.2 (arm64), local runtime (no SSH/remote pairing involved).
  • Agent panes are Claude Code 2.1.19x, which uses its new daemon/bg-pty-host architecture (the claude process in the pane is a thin client; the actual session process is a child of a claude daemon process detached from the pane) — mentioning it in case the cwd tracking interacts with that.
  • Workaround that works for me: orca terminal create --worktree active --json from the CLI inside the worktree.

Activity

  1. added
    os:macos
    on Jul 3, 2026
  2. aliuq commented on Jul 7, 2026

    @aliuq

    Version 1.4.126 still has this issue, and it obscures the normal terminal display.

    Image
  3. Shoma-DS commented on Jul 8, 2026

    @Shoma-DS

    Additional repro from another workspace.

    • Orca: 1.4.121
    • macOS: 26.5.1 (25F80)
    • Repo/workspace path: /Users/deguchishouma/Desktop/AI法人研修
    • Terminal handle where the toast appears: term_7113083a-8f05-4b4c-9033-0bc0434b09ba

    The selected terminal/workspace appears to be inside the selected worktree:

    $ pwd
    /Users/deguchishouma/Desktop/AI法人研修
    
    $ git rev-parse --show-toplevel
    /Users/deguchishouma/Desktop/AI法人研修
    

    However, trying to inspect that terminal through the CLI fails because the runtime becomes unavailable:

    $ orca terminal show --terminal term_7113083a-8f05-4b4c-9033-0bc0434b09ba --json
    {
      "ok": false,
      "error": {
        "code": "runtime_unavailable",
        "message": "Could not connect to the running Orca app. Restart Orca and try again."
      }
    }
    

    I also saw a related stale runtime state:

    1. orca status --json initially reported app.running: false, runtime.state: stale_bootstrap, reachable: false.
    2. orca open --json returned app.running: true, runtime.state: ready, reachable: true.
    3. Immediately after that, orca terminal show/read/list returned runtime_unavailable again.
    4. A follow-up orca status --json reported app.running: false, runtime.state: stale_bootstrap, reachable: false.
    5. At the same time, ps -p <pid> still showed /Applications/Orca.app/Contents/MacOS/Orca running.

    So in this case the toast is shown even though the cwd/git root are inside the worktree, and the CLI/runtime connection also seems to get into a stale bootstrap state while the app process remains alive.

  4. nwparker commented on Jul 8, 2026

    @nwparker
    Contributor

    Looking now!

  5. nwparker commented on Jul 8, 2026

    @nwparker
    Contributor

    Getting a fix in today

  6. nwparker commented on Jul 8, 2026

    @nwparker
    Contributor

    This is now fixed, in two parts:

    1. The exact toast reported here (Terminal cwd must be inside the selected worktree.) was eliminated by fix(terminal): allow terminals to spawn outside the worktree (#7685) #7750, which removed the startup-cwd containment guard entirely — a terminal now spawns at the requested folder even when it's outside the worktree. That shipped in v1.4.128.
    2. The remaining way to get "new terminal fails on every retry" — a remembered startup folder that no longer exists on disk (deleted after "Open in Terminal", a restored tab, or splitting from a shell in a removed directory) — is fixed by fix: recover fresh local terminal spawns from a deleted saved cwd #7847 (just merged, will be in the next release): a fresh local terminal now recovers by opening at the workspace root and prints a short note in the terminal explaining why. Reconnecting/SSH/remote/API terminals keep exact cwd semantics.

    @aliuq — 1.4.126 predates both fixes; updating to v1.4.128 or later removes the toast you hit, and the deleted-folder recovery lands in the release after this merge.

    @Shoma-DS — your rejection happened on 1.4.121, before #7750, so the same upgrade applies. The orca status flapping you captured (stale_bootstrap / runtime_unavailable while the app process is alive) is a separate bug from the cwd guard — I've split it out into #7848 with your data so it doesn't get lost when this closes.

    Thanks for the unusually detailed reports — the app.asar spelunking in the original report pointed straight at the failing call path.

  7. added theissue type on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

os:macos

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions