Skip to content

fix: derive branch live from git, skip stale PRs - #8

Merged
htcarr3 merged 2 commits into
mainfrom
fix-status-issue
Feb 15, 2026
Merged

fix: derive branch live from git, skip stale PRs#8
htcarr3 merged 2 commits into
mainfrom
fix-status-issue

Conversation

@htcarr3

@htcarr3 htcarr3 commented Feb 15, 2026

Copy link
Copy Markdown
Contributor

What

Two fixes for stale data in workspace status displays:

  1. Remove Branch from stored workspace state — derive it live from git
  2. Validate PR ancestry before showing PR badges

Why

Stale branch names: Branch was set once at workspace creation and never updated. Renaming a branch with git branch -m left the TUI, ws list, ws status, and MCP tools showing the wrong name.

Stale PR badges: gh pr view <branch> matches by name, not commit history. Reusing a branch name after a squash merge would incorrectly show the old merged PR.

How

Branch removal

  • Removed Branch string from state.Workspace struct
  • All callsites now call git.CurrentBranch(ws.Path) to get the live branch
  • Added Branch field to TUI's workspaceItem for derived (non-stored) data
  • JSON output structs retain "branch" in their contract, populated from git
  • In archive, branch is captured before worktree removal
  • Migration: Go's JSON decoder silently ignores unknown fields, so old state files with "branch" load fine

PR ancestry check

  • PRStatus now fetches headRefOid from the PR
  • Runs git merge-base --is-ancestor <head-sha> HEAD to verify the PR's head commit is in the branch's history
  • Returns nil for name collisions (e.g. branch reused after squash merge)

Test plan

  • bin/ci passes (build, vet, test, lint, tidy)
  • Manual: fr8 dashboard shows correct branch; rename a branch, refresh, confirm it updates
  • Manual: merge a PR (squash), create new branch with same name, confirm old PR badge is hidden

Branch was set once at creation and never updated, causing stale
values after `git branch -m`. All callsites now query
git.CurrentBranch() live. Old state files with "branch" are silently
ignored by Go's JSON decoder (no migration needed).
gh pr view matches by branch name, so reusing a branch name after a
squash merge would show the old merged PR. Now we fetch headRefOid
and verify the PR's head commit is an ancestor of the local branch
tip before returning it.
@htcarr3
htcarr3 merged commit 9a2406d into main Feb 15, 2026
6 checks passed
@htcarr3
htcarr3 deleted the fix-status-issue branch February 15, 2026 02:29
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