Retain last-known-good worktree list on git failure#118
Merged
Conversation
listWorktrees now returns WorktreeInfo list option: None when the git command fails (timeout / non-zero exit / failed-to-start), Some [] only for a genuinely empty repo. executeTask skips the state update on None so a transient git hiccup no longer blanks the repo's worktree list.
There was a problem hiding this comment.
Pull request overview
Preserves last-known-good worktrees when Git discovery fails.
Changes:
- Return optional discovery results from
listWorktrees. - Skip state updates on discovery failure.
- Add coverage for success, empty, and failure cases.
Show a summary per file
| File | Description |
|---|---|
src/Server/GitWorktree.fs |
Exposes discovery failures as None. |
src/Server/RefreshScheduler.fs |
Suppresses failed-list updates. |
src/Tests/CreateWorktreeServerTests.fs |
Tests real Git discovery outcomes. |
src/Tests/SchedulerTests.fs |
Tests mapping and state retention. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
listWorktreescollapsed two very different situations into an empty list:Because a failed
git worktree listreturned[],executeTaskpostedUpdateWorktreeList(repoId, [])and blanked the repo's last-known-good worktree list on any git hiccup — the dashboard would flicker to empty and back.Fix
Make the failure signal explicit and skip the update when discovery fails.
listWorktreesnow returnsAsync<WorktreeInfo list option>:None— the underlying git command failed.Some []— the repo genuinely has zero worktrees.Some [...]— the discovered worktrees.worktreeListUpdateinRefreshScheduler.fsmaps the discovery result to an optionalStateMsg, producingNone(no update) on a git failure.executeTaskposts the update only when present, so a transient git failure retains the existing worktree list instead of blanking it.Tests
ListWorktreesTests(CreateWorktreeServerTests.fs) — real-git repos:Somewith the main worktree for a valid repo;Nonefor a non-repo path.WorktreeListUpdateTests(SchedulerTests.fs) — successful, empty-but-successful, and failed (None) discovery mapping.StateAgentTests— a failed discovery (None) retains the last-known-good list and keeps the repo ready.