Skip to content

Storage: Save & delete a worktree - #60

Merged
ziyadakl merged 4 commits into
custom-v2from
storage-save-and-delete
Nov 6, 2026
Merged

ziyadakl merged 4 commits into
custom-v2from
storage-save-and-delete

Conversation

@ziyadakl

@ziyadakl ziyadakl commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

The Storage page's Delete dialog gets a third button when a worktree has uncommitted files and a branch:

 Delete worktree?
 Its branch stays.
-3 uncommitted files will be lost.
+Delete loses 3 uncommitted files.
-[Cancel] [Delete]
+[Cancel] [Delete] [Save & delete]
storage.removeWorktree({ path, allowUncommittedFiles, saveChanges: true })
  existing guards and the recount, inside the workspace lease
  refuse when HEAD is detached ("no branch to save to")
  git add -A
    refuse and unstage when a .env / .env.* (not .env.example) would be saved
  git commit --no-verify -m "Saved before deleting the worktree"
    the user's own git identity; fill only a missing name or email
  recount must be 0, else refuse and delete nothing
  remove WITHOUT force → { bytesFreed, savedCommit }

The save is a commit on the worktree's own branch, on that machine only, and never pushed. That was the owner's pick on 2026-11-06 ("just go w ur pick"). When he next messages the thread, T3 rebuilds the folder from that branch, so the work comes back.

Different builds on different machines: the overview now reports canSaveChanges, and the button shows only for machines that report it. An older server would drop the unknown saveChanges key and force-delete instead, so the button stays hidden for it. savedCommit is optional, so a plain Delete against an older server still decodes.

Everything lives in the feature's own files, plus one line in the fork's own permission test inside RpcAuthorization.test.ts. There are no new upstream seams.

Evidence

  • Before: the dialog offered only Delete, so uncommitted files were lost.
    After: I ran it live on a dev server with a throwaway T3 home. The demo worktree had a tracked edit and a new notes/ folder holding 2 files.
    • The dialog showed "Delete loses 3 uncommitted files." with the new button.
    • Clicking the button removed the folder.
    • The branch tip became Saved before deleting the worktree, holding notes/plan.md, notes/todo.md and readme.md.
    • git show t3/5e6f7a8b:notes/plan.md printed the saved content.
  • Tests pass, 29/29 across StorageOverview.test.ts and RpcAuthorization.test.ts. The new tests:
    • save then delete keeps every file on the branch;
    • a detached worktree is refused and kept;
    • an unignored .env.local is refused, nothing stays staged, and the folder is kept;
    • only a missing identity part is filled.
  • tsc is clean (server, web). Lint and knip are clean.
  • An Opus review found that a mismatch between machine versions could force-delete. That and two smaller findings are fixed in 768564ef8.

How I proved it: a live click-through on a dev server, then reading the commit back out of git, plus real-git server tests.

Thermo review (4 axes + Opus merge): 1 blocker. Git quotes non-ASCII paths, so café/.env slipped past the .env guard. Fixed in 763a16a0e (diff --cached --name-only -z, and refuse when the listing fails). A new test fails without -z and passes with it; 30/30 pass. The re-check found 0 new blockers. The edit to the upstream permission test was dropped, so this PR touches only the feature's own files and CUSTOM.md.

Merge Danger

Door: two-way for the code. Each save adds a commit to a branch, which you can undo with git reset on that branch.

Blast Radius: contained

Only the Storage page's Delete dialog changes. The save commits every non-ignored file except .env files, so stray build output or other secrets in non-ignored files would land on the thread's branch and could be pushed later with it. --no-verify skips pre-commit hooks, but a post-commit hook still runs.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l only missing identity

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 6, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ziyadakl ziyadakl changed the title Storage: save changes and delete a worktree Storage: Save & delete a worktree Nov 6, 2026
…r can't be saved

git quotes non-ASCII paths by default, so café/.env reached the name check
as .env" and was committed. Use -z, and refuse when the listing fails.
Drop the unneeded edit to the upstream permission test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ziyadakl
ziyadakl merged commit 9eb9d34 into custom-v2 Nov 6, 2026
30 of 31 checks passed
@ziyadakl
ziyadakl deleted the storage-save-and-delete branch November 6, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants