GeezerVison is showing github.com — fix(desktop): a failed t3 launcher install no longer leaves temp files in its bin folder by spoukyii · Pull Request #31910 · pingdotgg/t3code
Conversation
Problem
The desktop app installs the t3 command by writing ~/.t3/bin/t3 (t3.cmd on Windows) to a <launcher>.<pid>.tmp staging file (t3.<pid>.tmp, or t3.cmd.<pid>.tmp on Windows) and renaming it over the launcher. If the write or the rename fails, the staging file stays in ~/.t3/bin. The name carries the process id, so every launch that retries the install while the failure persists adds another one. On Windows that folder is on the user's PATH once they install the t3 command. The leftovers are clutter rather than a broken command: .tmp is not in PATHEXT, so they do not run.
Change
DesktopCliShim.install now runs the write and the rename under Effect.ensuring(fs.remove(staging, { force: true })). This is the cleanup the settings writers have had since #29635, and DesktopConnectionCatalogStore.writeDocument already did it. After a successful rename the staging path is gone, so the remove does nothing. The install still logs a warning and reports that it could not set up the launcher, as before.
Scope and approval
A very small, focused fix for an obvious bug, so it has no prior issue. #29635 ("failed settings saves no longer leave temp files behind") fixed this defect in DesktopAppSettings and DesktopClientSettings. The launcher installer in the same app stages a per-process temp file the same way and was missed. Nothing else changes: same staging name, same mode, same errors. I checked the open PRs that touch the launcher (#31522, #31173, #24421, #13401, #22485). None changes this write. #22485's new WSL launcher writer already removes its staging file on failure (rm -f "$staging").
Verification
A new case in apps/desktop/src/app/DesktopCliCommand.test.ts puts a non-empty folder at the launcher path, so the rename fails, runs install, and lists ~/.t3/bin. It uses the same trick as #29635's tests.
-
Red on main, from apps/desktop, vp test run src/app/DesktopCliCommand.test.ts -t "staging file":
FAIL src/app/DesktopCliCommand.test.ts > DesktopCliCommand > removes its staging file when the launcher cannot be replaced
AssertionError: expected [ 't3', 't3.129292.tmp' ] to deeply equal [ 't3' ]
Tests 1 failed | 8 skipped (9)
-
Green with the fix, same command: Tests 1 passed | 8 skipped (9).
-
vp run check:changed: format, lint, knip and typecheck (2 packages) pass. The test step ran DesktopCliCommand.test.ts and DesktopCliShim.test.ts: 7 passed, 1 skipped, and 5 failed that fail the same way on main on my Windows machine. Three spawn /bin/sh launchers, and two build a :-separated PATH with POSIX executables. On main (202d5b5616) the same two files give 5 failed, 6 passed and 1 skipped; the only difference is the new test.
Not checked: a real Windows lock on t3.cmd, and a Linux or macOS run of these two files. The test forces the rename to fail with a folder collision instead. CI runs both files on Linux.
Bug: a failed t3 launcher install leaves .tmp staging files in ~/.t3/bin
This was written with Claude Opus 5.5 in Claude Code, driven from T3 Code.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Occupies the launcher path with a non-empty folder so the launcher
install's rename fails, then lists ~/.t3/bin. The staging file the
install wrote stays behind, so this fails here.
…s in its bin folder
The desktop app installs the t3 command by writing ~/.t3/bin/t3 (t3.cmd
on Windows) to a <launcher>.<pid>.tmp staging file and renaming it over
the launcher. When the write or the rename failed, the staging file
stayed. Its name carries the process id, so each launch that retried the
install left one more staging file in ~/.t3/bin, which is on the user's
PATH on Windows once they install the t3 command.
The write and the rename now run under Effect.ensuring, which removes
the staging file whether they succeed or fail, as the settings writers
do since pingdotgg#29635. After a successful rename there is nothing to remove.
Bug: a failed t3 launcher install leaves <pid>.tmp staging files in ~/.t3/bin
|
|
}).pipe(Effect.scoped),
|
|
|
);
|
|
|
|
|
|
it.effect("removes its staging file when the launcher cannot be replaced", () =>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests staging cleanup through the command wrapper, although DesktopCliShim.install is the lower layer that fails on main. Could you move this case to the shim tests and exercise install directly?
Posted via Macroscope — Test Signal
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving it in DesktopCliCommand.test.ts. DesktopCliShim.install needs the desktop environment, filesystem and path services. DesktopCliShim.test.ts has no Effect harness for those; it only renders the launcher and runs it in a shell. commandIn in this file already builds those layers, and this file's existing install-failure case lives here too. command.install reaches DesktopCliShim.install with nothing in between that touches the staging file, so this case fails on main for the shim's reason. Moving it would mean copying that harness into the shim tests for one case.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
macroscopeapp[bot] reacted with eyes emoji
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Approvability
Verdict: Approved at 377913b
Macroscope's review found this PR approvable — Launcher installation now attempts to remove its temporary staging file even when writing or replacing the launcher fails. Cleanup is limited to that staging path, with existing launcher safeguards and error handling preserved.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 6, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Walkthrough
-
The launcher installer now ensures that it removes the staging file after the write and rename sequence, including on failure. A test checks installation failure when the destination is an occupied directory and verifies that no staging file remains.
Changes: Launcher installation cleanup
| Layer / File(s) |
Summary |
Ensure staging-file cleanup apps/desktop/src/app/DesktopCliShim.ts, apps/desktop/src/app/DesktopCliCommand.test.ts |
The installer ensures staging-file removal after the write and rename sequence. The test checks the error message and confirms that the parent directory contains only t3 after failure. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: juliusmarminge
Merge Risk: Low · up to 37791
-
Overlapping launcher installs can produce a recoverable setup error. The change is mergeable with awareness of this race.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title clearly describes the launcher staging-file cleanup. |
| Description check |
 |
The description covers the problem, fix, scope, and verification. It records test failures and checks not performed. |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
.writeFileString(staging, content, { mode: 0o755 })
|
|
|
.pipe(
|
|
|
Effect.andThen(fs.rename(staging, shimPath)),
|
|
|
Effect.ensuring(fs.remove(staging, { force: true }).pipe(Effect.ignore)),
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I'm keeping this one out of scope, for the same reason as the CodeRabbit thread above. Two installs in one process already share <launcher>.<pid>.tmp on main. When they interleave, one rename moves the shared file and the other fails with ENOENT. With the cleanup, the losing attempt fails at a different step, but the result is the same: the launcher is installed and the other attempt reports it couldn't set it up. So this PR doesn't introduce the race or change its outcome. It only stops a failed install from leaving its staging file behind. Per-attempt staging names (like the settings writers' suffix) and a two-call regression would fix that older race, and I'd rather send that as its own PR than widen this one.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Closing this. I couldn't run the change in a packaged Windows desktop build here without risking the T3 Code install I use day to day, and it only takes effect in that build. I'd rather not ask for a merge on unit tests alone.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:XS
0-9 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|