Skip to content

fix(scripts): fork install waits until no agent turn is working - #51

Merged
maschwenk merged 1 commit into
mainfrom
max/fork-install-wait-idle
Nov 11, 2026
Merged

maschwenk merged 1 commit into
mainfrom
max/fork-install-wait-idle

Conversation

@maschwenk

Copy link
Copy Markdown
Owner

fork:install used to quit T3 Code (Fork) right away, which kills every agent session, terminal and dev server inside it. if an agent ran it from inside the app it was worse: the quit kills the installer itself, possibly after it deleted the old app and before it copied the new one in

now when the app is running, the build still happens in the foreground (so build errors show up where you ran it), then the install step moves to a detached background process and the command returns. that process reads the app's statev2.sqlite read-only every 5s and waits until no run is preparing, queued, starting or running, two checks in a row since a finished turn can hand straight to a queued one. then it quits, replaces and relaunches like before

  • runs that are waiting (approval or question for you) dont hold it up. they keep the question across the restart and you answer it after
  • --now skips the wait but still installs from the background process
  • running fork:install again stops an installer that's still waiting (pid recorded at spawn, command checked before killing)
  • log goes to release/fork/install.log, and if the background install fails it pops a macos alert since nobody is watching it

tradeoff: background tasks (dev servers, monitors) dont count as working, otherwise a long-running dev server would block the restart forever. t3 already tells the agent its background work got cancelled after a restart

checked against a fake app in /tmp with a copy of the script (fake app path + a harmless bundle id, so the real app was never touched): the handoff comes out detached (ppid 1, own process group), it waited on the 5 working turns in my real db read-only and named them in the log, a second run stopped the first, and with a controlled db it went ahead ~5s after the last busy run finished and swapped the app. the real quit/relaunch of T3 Code (Fork) hasn't been run with this yet

claude opus 5.5 in claude code did the work

Quitting T3 Code (Fork) ends every agent session and terminal inside it, so
fork:install cut off whatever agents were doing, and when an agent ran it
from inside the app the quit could kill the installer between removing the
old app and copying the new one.

When the app is running, the install step now moves to a detached process
and the command returns. It reads the app's database read-only and waits
until no run is preparing, queued, starting or running, then quits,
replaces and relaunches the app. Runs waiting on an approval or answer keep
their question across the restart, so they don't hold it up. --now skips
the wait, and a newer run replaces an install still waiting.
@maschwenk maschwenk added the coder-task-generated Created from a coding task label Nov 10, 2026
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 10, 2026
@maschwenk
maschwenk marked this pull request as ready for review November 11, 2026 00:01
@maschwenk
maschwenk merged commit 94038e3 into main Nov 11, 2026
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coder-task-generated Created from a coding task size:L vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant