Skip to content

Retain last-known-good worktree list on git failure#118

Merged
0101 merged 1 commit into
mainfrom
worktree-list-resilience
Jul 16, 2026
Merged

Retain last-known-good worktree list on git failure#118
0101 merged 1 commit into
mainfrom
worktree-list-resilience

Conversation

@0101

@0101 0101 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Problem

listWorktrees collapsed two very different situations into an empty list:

  • A repo that genuinely has no worktrees.
  • A transient git failure (timeout, non-zero exit, or the process failing to start).

Because a failed git worktree list returned [], executeTask posted UpdateWorktreeList(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.

  • listWorktrees now returns Async<WorktreeInfo list option>:
    • None — the underlying git command failed.
    • Some [] — the repo genuinely has zero worktrees.
    • Some [...] — the discovered worktrees.
  • New pure helper worktreeListUpdate in RefreshScheduler.fs maps the discovery result to an optional StateMsg, producing None (no update) on a git failure.
  • executeTask posts 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: Some with the main worktree for a valid repo; None for 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.

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.
Copilot AI review requested due to automatic review settings July 15, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@0101
0101 merged commit cf720b2 into main Jul 16, 2026
2 checks passed
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.

2 participants