Skip to content

Preserve worktree changes and clean up safe sessions (F-0199) - #702

Open
igorcosta wants to merge 2 commits into
mainfrom
cto/f0199-worktree-safety-20261023
Open

igorcosta wants to merge 2 commits into
mainfrom
cto/f0199-worktree-safety-20261023

Conversation

@igorcosta

Copy link
Copy Markdown
Contributor

Exiting a session worktree could delete uncommitted and untracked files without deletion approval. Sessions launched with --worktree also left their directories behind after a clean exit.

F-0199 preserves worktrees containing edits, untracked files or commits missing from the original branch, and reports their path and branch. Explicit discard_changes: true follows deletion permissions and is denied in restricted clients; keep: true takes precedence. Clean worktrees and branches created for the session are removed after shutdown across interactive, command, patch, RPC and ACP lifecycles. Pre-existing branches remain. Tmux and Zit behavior stays unchanged.

Validation:

  • Real-Git regressions reproduced file loss, commit preservation failures and the approval bypass before implementation.
  • AUTOHAND_TEST_WORKERS=1 bun run proof: lint, type checking, build and all 12,721 unit tests passed. The terminal phase passed 422 tests; two package-install cases failed because this isolated checkout lacked the ignored Zit bundle. Both failures reproduced on the untouched baseline and passed after preparing its verified local bundle. Two terminal cases were skipped.
  • Rebased onto current origin/main c20c96e; git range-diff confirms both commits are unchanged. Final lint, type checking, production build, 397 focused checks and all 63 selected built-terminal checks passed. Terminal coverage includes seven worktree lifecycle cases, resume/help, packaged Zit, and the updated theme/banner flows.

A separate prerequisite commit corrects the existing resume help assertion from [id] to the already-declared [reference]; that mismatch also reproduced on untouched main. No CLI flags, dependencies, version or release configuration changed. F-0159 remains separate.

Correct the existing terminal assertion to match the CLI definition. This prerequisite was reproduced on the unchanged baseline while validating F-0199.
Keep edited, untracked and uniquely committed work by default. Route explicit discard requests through deletion permissions and deny them in restricted clients. Remove clean session worktrees after shutdown, retain recovery paths for preserved work, and cover real Git and built terminal lifecycles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant