Skip to content

[Bug]: Terminal daemon dies after batch worktree removal, terminating unrelated split-pane sessions #8275

Open

Description

@Razultull

Short summary

On Windows, Orca's protocol-v20 terminal daemon exited while several worktrees were being removed with orca worktree rm --force. Two unrelated split-pane sessions in a different repository were terminated with exitCode: -1, and their pane layout disappeared from the sidebar. The main Orca app stayed running and automatically started a replacement daemon.

The worktree-removal sequence is strongly correlated with the failure, but I have not reproduced it deterministically yet.

What happened?

An agent was retiring four completed worktrees in one repository using four sequential/chained commands of this form:

orca worktree rm --worktree path:C:/Users/<user>/orca/workspaces/<repo>/<worktree> --force --json

The targeted worktree sessions were killed as expected. Immediately after the last removal, the existing terminal daemon stopped logging and disappeared. Two active split panes belonging to a completely different repository were also lost.

When the unrelated repository was activated again, Orca showed only a newly created terminal instead of the previous split layout.

Timeline (UTC)

  • 12:21:28 — both unrelated split-pane sessions successfully attached.
  • 12:22:25, 12:22:29, 12:22:33 — daemon logged session-killed events for the worktrees intentionally being removed.
  • After the final removal event, the old daemon log ends abruptly. There is no daemon shutdown event and no normal session-exited event for the unrelated panes.
  • 12:24:00 — Orca started a replacement protocol-v20 daemon on the same named pipe.
  • 12:24:52 — the two unrelated sessions were recorded as ended with exitCode: -1.
  • 12:24:57 — activating the unrelated repository created a new single terminal session.

The main Orca Electron process remained alive throughout, so this appears isolated to the terminal daemon/PTY host rather than an application crash.

Expected behavior

Removing a worktree with --force should stop only terminals associated with that worktree. Unrelated terminals and split-pane layouts in other repositories should remain alive.

If the terminal daemon does fail, Orca should restore or clearly report affected sessions rather than silently replacing the layout with a fresh terminal.

Actual behavior

  • The protocol-v20 terminal daemon exited or was terminated.
  • Unrelated local terminal processes disappeared.
  • Two unrelated panes ended with exitCode: -1.
  • The split layout was lost from the sidebar.
  • The next activation created a new single terminal.
  • Terminal output history and checkpoints were preserved on disk.

Environment

  • Orca daemon host: 1.4.135
  • Terminal daemon protocol: 20
  • OS: Windows 11 Home, 10.0.26200, 64-bit
  • Shell: Windows PowerShell
  • Main Orca app remained running and the runtime/graph returned ready after recovery.

Diagnostic evidence

Old daemon:

pid: 38368
started: 2026-07-11T06:21:39Z
socket: \\?\pipe\orca-terminal-host-v20-...

Replacement daemon:

pid: 54832
started: 2026-07-11T12:24:00Z
socket: \\?\pipe\orca-terminal-host-v20-...

Both unrelated session metadata files ended similarly:

{
  "endedAt": "2026-07-11T12:24:52.983Z",
  "exitCode": -1
}

There was no Windows Error Reporting entry or crash dump for the daemon, and the daemon log contains no stack trace. This may indicate a forced termination or an unhandled failure path that exits before logging.

Reproduction candidate

  1. Open multiple local terminal panes in repository A.
  2. Create several worktrees with active terminal sessions in repository B.
  3. Remove the repository-B worktrees rapidly/sequentially using orca worktree rm --force --json.
  4. Watch whether the protocol-v20 daemon exits and whether repository-A panes disappear.
  5. Activate repository A again and inspect whether the old split layout is replaced by a new terminal.

I can provide a sanitized daemon-log excerpt and the preserved terminal metadata/checkpoints if useful.

Activity

  1. added theissue type on Jul 12, 2026
  2. added a commit that references this issue on Jul 15, 2026
  3. added
    pending_reproRepro attempted; still pending conclusive reproduction
    on Jul 16, 2026
  4. OrcaWin commented on Jul 17, 2026

    @OrcaWin
    Collaborator

    Agent reproduction package (Windows orchestration 2026-07-16)

    Host context: Windows 11 / Orca 1.4.143.0 / repo path used: docs/bug-reproductions/
    Labels applied: see issue labels (has_repro or cannot_repro).
    Security: Do not run user-uploaded binaries from issue attachments. Recreate fixtures from the steps/scripts below.


    Issue 8275 — Terminal daemon dies after batch worktree removal

    Status: cannot_repro
    Host: Windows 11, Orca app 1.4.143 / daemon-host materialization 1.4.142-rc.2, protocol-v22 daemon pid stable
    Label: cannot_repro

    Summary

    Reporter (1.4.135, protocol-v20): rapid orca worktree rm --force on several worktrees killed the terminal daemon; unrelated split panes in another repo ended with exitCode: -1 and layout was replaced.

    Attempt on this host (2026-07-16)

    1. Recorded daemon pid 7836 (started 2026-07-15), pidfile daemon-v22.pid appVersion 1.4.142-rc.2.
    2. Created survivor terminal + horizontal split on main (C:/Users/neil/orca/orca).
    3. Created four disposable worktrees repro-8275-batch-{1..4}-* each with a live terminal.
    4. Sequential force remove of all four:
    orca worktree rm --worktree path:<each> --force --json
    1. After all removes: same daemon pid 7836, main worktree still had 11 connected terminals (including survivors), orca status runtime/graph ready.

    Expected vs actual (this attempt)

    Expected (bug) Daemon dies / unrelated panes lost
    Actual Daemon survived; main connected count unchanged (11→11)

    Evidence

    • docs/bug-reproductions/evidence/8275-20260716-022546.json
    • docs/bug-reproductions/evidence/8275-20260716-022546-before.json
    • docs/bug-reproductions/evidence/8275-20260716-022546-after.json
    • docs/bug-reproductions/evidence/8275-20260716-022546-batchrm.log

    Notes

    • Original report was intermittent and on older daemon protocol (v20 / 1.4.135).
    • Fix-oriented worktree 8284 / agent notes in UI claim live Windows batch removal + witness panes passed on newer builds.
    • Single batch of 4 removes is not an exhaustive stress of the original race; re-run under load if regressions appear.

    How another agent should use this

    1. Read this comment fully (status, expected vs actual, blockers).
    2. If a script is included above, copy it to a temp file and run it on a Windows 11 host with Orca installed (prefer production install under %LOCALAPPDATA%\Programs\orca).
    3. Capture evidence (CLI --json, screenshots, logs) under a local folder; optionally comment results back here.
    4. If status is cannot_repro / needs_setup, satisfy the listed prerequisites first, then re-attempt and flip labels: remove cannot_repro, add has_repro when conclusive.
  5. nwparker commented on Aug 22, 2026

    @nwparker
    Contributor

    Likely fixed by #15755 — please re-test.

    Batch worktree removal fanned out 32 concurrent PowerShell process-table probes; the daemon died under that and took unrelated split panes with it. Both halves are gone: the probe is a 16ms native snapshot (#15749) and teardown no longer probes at all — it terminates a job object it has held since spawn.

  6. nwparker commented on Aug 22, 2026

    @nwparker
    Contributor

    Not fixed — recording what has been ruled out, so this does not sit as "maybe already handled".

    The recent Windows work (#15749, #15755, #15886) is all about terminating PTY trees exactly: job objects instead of a process-table scrape gating taskkill /T /F. None of it explains a daemon that exits by itself during batch removal and takes unrelated split panes with it.

    One thing worth ruling in or out explicitly, since it is adjacent: #15755 assigns the daemon process to a Win32 job with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, so the daemon now dies when the app that owns it dies. That is deliberate (it stops orphaned daemons surviving a crash), and it landed after this report, so it is not the cause here. It does mean that if the failure reproduces on a build newer than 1.4.185, "the app briefly lost the daemon" and "the daemon was reaped" become harder to tell apart from the outside — the daemon log is the thing to keep.

    The per-PTY job objects are scoped to individual panes and cannot reach the daemon or another pane's tree, so batch removal killing unrelated sessions is not that either.

    If you get a reproduction, the useful artifact is the daemon log around the exit — specifically whether it recorded a shutdown reason or simply stopped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingos:Windowspending_reproRepro attempted; still pending conclusive reproduction

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions