Repository navigation
fix(web): project actions type into the thread they were started from - #45412
juliusmarminge wants to merge 1 commit into
Conversation
writeToTerminal read the hook's latest thread when it ran, so switching threads while a project action's terminal was opening sent the command to the newly open thread with the old terminal id, and the server rejected it. runProjectScript now passes the thread it started on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Project actions now send terminal input to their originating thread even if navigation occurs while the terminal opens. The change preserves permission checks and existing command behavior while narrowing the risk of misdirected input. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Running a project action and switching to another thread before its terminal finished opening sent the command to the newly open thread, with the first thread's terminal id. The server rejected it, so the action never ran. The action now types its command into the terminal of the thread it was started from.
writeToTerminaltakes an optional target thread, likecloseTerminalSessionalready does, andrunProjectScriptpasses the thread it started on.project-action-runs-on-its-thread.e2e.ts) switches threads while the terminal is opening and checks that the command reaches the right thread and runs.Fixes #36713
Reproduction on main
Commit: origin/main @ 3952ee3. Fresh worktree,
vp i, then copied the real-app scenario from the reporter's closed PR #36714 (scripts/scenarios/project-action-runs-on-its-thread.e2e.ts) into scripts/scenarios unchanged and ranT3CODE_DEV_SEED=0 vp run scenarios scenarios/project-action-runs-on-its-thread.e2e.ts. That scenario starts the real server and web app in Chromium, with fresh synthetic state and the Replay (dev) fixture. It seeds project 'demo' with a t3.json action 'Mark' (touch action-ran) and two threads, 'Other thread' and 'Action thread'. It opens Action thread, imports and runs Mark, and holds the outgoing terminal.open WebSocket request in the page. While the request is held it clicks 'Other thread' in the sidebar, then releases the request. Result: the scenario fails at the write-target assertion. The only terminal.write request went out with threadId = Other thread's id (expected [Action thread id], got [Other thread id]), andaction-ranwas never created. The browser console logged[atom-command] terminal write failedfrom the server's rejection. This matches the reportedUnknown terminal threadfailure: A's terminal stays idle and nothing runs in B.Evidence
Seed demo with a Mark action (
touch action-ran) and two Replay (dev) threads. Open Action thread, import Mark, hold the outgoing terminal.open request, run Mark, switch to Other thread, then release terminal.open. After a terminal.write is observed, return to Action thread and capture it. Assert the write targets Action thread and action-ran exists.Environment on both sides: real server and web app, Chromium 1280×800, light theme, fresh synthetic state, Replay (dev). Local prompt paths are redacted.
scenarios:prove exited 0: failsOnBase=true, passesOnHead=true.
Reproduction scenario
Tests
T3CODE_DEV_SEED=0 vp run scenarios scenarios/project-action-runs-on-its-thread.e2e.tson main without the fix: failed, the write targeted the other thread's id.vp run check:changed: all passed (format, lint, knip, typecheck, react compiler, tests).Not in this change
useThreadTerminalActions' other stable callbacks (launchTerminal,canWrite,allocateTerminalId) also read the latestthreadRef, but they run before any await, so they do not have this bug.Who did the work
Run by the t3code factory in T3 Code.