Skip to content

PR status indicators per worktree (open / draft / merged / closed) #14

Description

@davidtaing

Summary

Show each worktree branch's GitHub PR lifecycle state so you can tell at a glance which worktrees are done (merged), abandoned (closed), or still in flight (open/draft) — the key input to "can I delete this worktree?"

This is the networked half of worktree status; the offline local-sync half (ahead/behind/dirty) is tracked in #13.

Relationship to #13 — progressive enhancement

These two are designed as one layered feature, not two disconnected columns:

So the mental model is: worktree status always shows local sync; connect GitHub to additionally see PR state. Build #13 first; this layers on top.

States (first cut — states only)

Per branch with a PR:

  • none — no PR for this branch
  • draft — PR open, draft (not yet asking for review)
  • open — PR open, ready for review
  • merged — PR merged (worktree is likely safe to delete)
  • closed — PR closed without merge (abandoned — distinct from merged)

Why

"Merged" and "closed" are the strongest signals that a worktree is disposable; "draft" vs "open" distinguishes work-in-progress from review-ready. Pairs with #13: merged + synced = safe to remove.

Enablement

  • Gate on connecting GitHub: detect existing gh auth and turn the layer on via a flag/config (e.g. --pr / a config key). No bespoke auth flow — lean on gh.
  • Must degrade gracefully when unavailable, unauthenticated, offline, or the remote isn't GitHub: silently fall back to the Local sync indicators: ahead / behind / dirty per worktree #13 baseline, never error the whole view.

Implementation notes

  • Data source: gh / GitHub API. One batched call covers all branches: gh pr list --json number,headRefName,state,isDraft,... (plus a query for merged/closed). Avoid per-branch calls.
  • Likely restricted to -w live mode and/or behind the enable flag, given the cost. Cache results between refreshes; don't refetch every 2s tick — respect rate limits.
  • Render: a compact glyph/short label per worktree row (e.g. merged, draft, ↑PR#123), layered onto the Local sync indicators: ahead / behind / dirty per worktree #13 status column. Coordinate column layout with Local sync indicators: ahead / behind / dirty per worktree #13.
  • GitHub-only for now; design the lookup so a future GitLab/other forge backend could slot in.

Acceptance criteria

  • With GitHub connected, worktree rows show PR state: none / draft / open / merged / closed.
  • merged and closed are visually distinct.
  • Without GitHub connected (no gh, no auth, offline, non-GitHub remote), the view falls back to the Local sync indicators: ahead / behind / dirty per worktree #13 baseline with no errors.
  • PR data is cached, not refetched every refresh tick.
  • Feature is opt-in / gated on connecting GitHub; the default offline snapshot is unaffected.

Out of scope / follow-ups

  • CI check status (pending/passing/failing) on open PRs — future enhancement.
  • Review status (approved/changes-requested) — future enhancement.
  • Non-GitHub forges.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions