Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Creating a new agent worktree starts .cursor/setup-worktree-unix.sh (~60s). If I switch to another agent chat or navigate in Glass within ~1 second, setup aborts with Canceled before a shell session starts. The UI shows “Setup script failed” / “Canceled” but gives no way to retry in-product.
The worktree directory and branch remain. Setup never completes unless you manually rerun the script in a terminal. I lost work because the failure looked like a throwaway incomplete setup.
Steps to Reproduce
Open a project in the Agents (Glass) window that has .cursor/worktrees.json with a setup-worktree-unix script (~60s runtime).
Create a New Worktree agent session.
Within ~1–2 seconds, switch to another agent chat or open Files in Glass.
Observe the worktree creation toast: “Setup script failed” / “Canceled”.
Check logs (see below).
Control case: repeat steps 1–2 but stay on the same agent chat for ~60s. Setup completes successfully.
Expected Behavior
Worktree setup should continue in the background even if I switch agent chats.
Or setup should auto-resume / offer retry if canceled mid-flight.
UI should clearly warn: “Stay on this chat until setup finishes (~60s)”.
A failed setup should not look like a disposable empty worktree when the user already has edits there.
Screenshots / Screen Recordings
Operating System
MacOS
Version Information
Version: 3.9.16
VS Code Extension API: 1.105.1
Commit: 042b3c1a4c53f2c3808067f519fbfc67b72cad80
Date: 2026-06-27T06:41:01.941Z
Layout: glass
Build Type: Stable
Release Track: Default
Electron: 40.10.3
Chromium: 144.0.7559.236
Node.js: 24.15.0
V8: 14.4.258.32-electron.0
xterm.js: 6.1.0-beta.256
OS: Darwin arm64 25.5.0
Additional Information
Actual behavior
Setup is canceled in ~6ms when Glass agent focus moves.
No shell-exec session is started.
No Worktrees Setup output channel appears in Output dropdown (only Window, Terminal, MCP, etc.).
Worktree directory persists in a half-provisioned state (no .envrc, no runtime, but user/agent edits may exist).
Related opposite bug already filed: agent steals focus back to worktree chat when setup finishes.
Log evidence
From ~/Library/Application Support/Cursor/logs/20260628T121549/window1_wb7/renderer.log:
Failed run (7ddc, agent e7dd3df4):
2026-06-29 19:20:57.699 [info] [WorktreeManager] Created worktree at …/7ddc for agent e7dd3df4-… in 1505ms
2026-06-29 19:20:57.700 [info] [worktree-setup] executing UNIX setup script file
2026-06-29 19:20:57.706 [error] [worktree-setup] failed executing setup script: Canceled
2026-06-29 19:20:58.232 [warning] [GlassTabPersistenceService] migration_tab_transition … e7dd3df4 → c94c2abf … “reason”:“file_launcher”
Note: no started shell-exec session line on the failed run.
Successful run 79 seconds later (hbiv, agent ece6a546, same repo):
2026-06-29 19:22:16.925 [info] [worktree-setup] started shell-exec session
2026-06-29 19:23:21.870 [info] [worktree-setup] setup script finished {“durationMs”:64948,“exitCode”:0}
Same failure pattern also seen on worktree qpy1 (2026-06-26 00:27:01, canceled in 4ms, then immediate GlassTabPersistenceService agent switch).
Impact
Worktree appears created but environment is broken (no runtime, no .envrc).
User may continue working in the agent assuming setup succeeded.
Data loss risk when treating failed-setup worktrees as disposable.
Docs reference Output → Worktrees Setup channel, but it does not appear in Glass UI Output dropdown in 3.9.16.
Requested fix
Decouple setup lifecycle from Glass agent focus (run to completion in background).
If cancel is unavoidable, show Retry setup in UI and block agent edits until setup succeeds or user confirms.
Expose worktree / Worktrees Setup logs consistently in Glass Output.
Show explicit in-progress setup state with time estimate (~60s).
Does this stop you from using Cursor
No - Cursor works, but with this issue
