Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Make the terminal shell's prompt take longer than about a second to draw. On any OS the server can be started with
SHELL=/bin/bash PROMPT_COMMAND='sleep 2'. In real setups the slow part is a git prompt (oh-my-zsh, starship) in a large repo, or any prompt on a loaded machine. - Add a project with a git repo and a project action with Run in the thread's worktree when the thread settles (
runOnSettle: true) and the commandecho $$ > /tmp/settle-shell.pid. Inside T3's wrapper,$$is the terminal's own shell. - Start a thread in a new worktree with any agent, for example
Replay (dev), and let its turn finish. - Open the thread's menu and choose Settle thread.
- Wait for
/tmp/settle-shell.pidto appear, then check whether that PID is alive (kill -0 "$(cat /tmp/settle-shell.pid)") after 15 seconds and after a few minutes.
Expected behavior
The settle action exits 0, so its terminal closes. docs/user/t3-json.md says of runOnSettle: "Terminal closes on success, stays open on failure."
Actual behavior
The shell stays alive at an idle prompt, with its working directory in the settled worktree, until the T3 server restarts. Any cleanup that checks whether a process is using the directory treats the worktree as in use, so settled worktrees are never removed.
Cause: when the action exits 0, ProjectSetupScriptRunner waits at most 1 s for the prompt and then calls TerminalManager.closeIdle once. If the prompt hook is still running at that moment, closeIdle keeps the shell. It also keeps the shell if the prompt redraws during the check, or if its ps query misses its 1 s budget. closeOnSettle ran before the settle terminal was opened and the thread is already settled, so nothing tries again.
With a fast prompt the shell closes as expected.
Impact
Major degradation or frequent failure
Version or commit
Nightly v0.1.14-nightly.20261127.5345; also on main at 337bb36869.
Environment
Found in the macOS desktop app (zsh with oh-my-zsh and a git prompt), when about 8 threads settled at once on a loaded machine (load average 14–36 on 16 cores). Reproduced with the web client and bash plus PROMPT_COMMAND='sleep 2', with no account and the Replay (dev) agent.
Logs or stack traces
$ ps -o pid,ppid,lstart,command -p <pid> # one of four, all children of the T3 server
69907 66452 Thu Nov 26 18:47:12 2026 /bin/zsh -o nopromptsp
$ lsof -a -d cwd -p 69907
zsh 69907 ... cwd DIR ... ~/.t3/worktrees/<project>/c0f67460-174575f87a6c9528
The end of that terminal's log (userdata/logs/terminals/…), 23 hours earlier:
__T3_SETUP_DONE___8230431c6f6347759a9e51588bc0dbea:0
➜ c0f67460-174575f87a6c9528 git:(review-exercise-motion-framework) 16 worktrees
The threads' settledAt was the shells' start time.
Screenshots, recordings, or supporting files
A scenario that settles a worktree thread from the thread menu and polls the settle shell's PID fails on main after 15 s with expected true to be false (the shell is still alive) when bash has PROMPT_COMMAND='sleep 2'. Without the slow prompt, it passes.
Workaround
Restart the T3 server, or find the leftover shells with lsof and kill them one at a time.
Activity