Skip to content

End or recreate a stuck session from the sidebar - #26

Merged
tdwd merged 3 commits into
mainfrom
end-from-sidebar
Oct 26, 2026
Merged

tdwd merged 3 commits into
mainfrom
end-from-sidebar

Conversation

@tdwd

@tdwd tdwd commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

In the session view, x only stopped the agent, so a session whose worktree was deleted by hand could not be removed or restarted from the sidebar.

  • x and ^g x in the session view now stop a live agent as before, and on a session with nothing running they end it through the same modal as the dashboard.
  • When the worktree is gone and its branch still exists, the modal offers Recreate first. It checks the branch out again at the same path and links the project's ignored instruction files back in.
  • Removing a missing worktree no longer drops the only reference to a detached commit. Delete also works after git worktree prune, and on a branch that is already gone.

Three commits: the gitx fix to removal, a refactor with no behaviour change, then the feature.

make race passes locally. Every new guard has a test that fails when the guard is removed. Not tried in a real terminal; the UI tests drive the model directly.

tdwd added 3 commits October 26, 2026 13:17
`git worktree remove` on a tree deleted by hand drops git's record of
it and exits 0. On a detached HEAD that record can be the only
reference to a commit, which gc then collects. RemoveWorktree now reads
the record first and refuses when no ref contains its HEAD, naming the
commit and the `git branch` command that keeps it.

Two dead ends go with it. A missing tree whose record was already
pruned made Delete fail with "is not a working tree"; there is nothing
to remove, so it now succeeds. A branch already gone made DeleteBranch
fail, and the UI reported that as an unmerged branch kept; it now
succeeds, checked with the new HasBranch.
The choice between closing outright and asking moves into endSession,
which takes the session rather than reading the dashboard's cursor, so
a second caller can end a session it found another way. No behaviour
changes.
In the session view, x only stopped the agent and answered "session is
not running" otherwise, so a row there could not be removed. A session
whose worktree was deleted by hand never runs, which left it stuck. x
and ^g x now stop a live agent as before, and on a session with
nothing running they end it through endSession, as the dashboard does.

When the worktree is gone and its branch still exists, the end modal
offers Recreate first. gitx.RestoreWorktree checks the branch out again
at the same path, and the project's ignored instruction files are
linked back in. It needs the local branch, because `worktree add`
would otherwise take a remote branch or tag of that name. It clears
git's stale record through RemoveWorktree rather than prune or
--force, and retries only while the path is still empty.

Nothing claims a gone worktree is still on disk: the pane points at x
instead of ↵, and the Close row and notice no longer say it was kept.
Ending a session from the sidebar no longer moves the dashboard cursor
of another project.
@tdwd
tdwd merged commit 5f43442 into main Oct 26, 2026
3 checks passed
@tdwd
tdwd deleted the end-from-sidebar branch October 27, 2026 10:07
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