Skip to content

[Bug]: setup action does not actually execute on first send in a new worktree thread #1527

Description

@neominik

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Create a project action and enable Run automatically on worktree creation.
  2. Use a command with an obvious side effect, for example: mkdir -p /tmp/t3code-wt-debug && printf '%s\n' "$(date -Is) cwd=$(pwd)" >> /tmp/t3code-wt-debug/runs.log
  3. Create a fresh new thread.
  4. Switch the environment from Local to New worktree.
  5. Send the first message.

Expected behavior

The action should execute once in the newly created worktree.

For the example above, /tmp/t3code-wt-debug/runs.log should be created.

Actual behavior

  • The worktree is created.
  • The thread continues normally in the new worktree.
  • The terminal opens, but the setup action command does not run.
  • No side effects from the action are observed.

Likely cause

This looks like a race between the setup-action launcher and the terminal drawer.

The setup-action path opens a PTY for the new worktree, but the terminal drawer appears to reopen the same terminal using stale pre-worktree thread state. Server-side, TerminalManager.open() resets the terminal session when cwd or env changes, which likely wipes the just-opened PTY before the setup command survives.

Impact

Major degradation or frequent failure

Version or commit

main @ a60daa1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions