Skip to content

fix: refresh history and PR state after off-tab watcher ref changes - #26

Merged
erwin-wee merged 2 commits into
mainfrom
fix/history-stale-refresh
Sep 22, 2026
Merged

erwin-wee merged 2 commits into
mainfrom
fix/history-stale-refresh

Conversation

@erwin-wee

@erwin-wee erwin-wee commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Two related fixes: watcher-detected ref changes did not refresh derived UI state, so state updated by an agent or from a terminal appeared stale.

1. History tab did not reload after off-tab commits

Commits made while the History tab was inactive (e.g. by a background agent) did not appear until an unrelated later watcher event.

  • handleRepoChanged reloaded history only when view === 'history'.
  • setView('history') reloaded only when the list was empty.
  • window.focus refreshes status only.

Fix: a stale flag on HistoryState — set on off-tab ref changes, consumed on History tab entry, cleared on a reset load (preserving a flag re-raised mid-request; never cleared on paginated append).

2. "View Pull Request" reported no PR after an external PR

view-pull-request reads cached prs.current, populated only on repo open, in-app push/checkout/PR actions, and a 3-minute background poll. A PR created outside gitgood was invisible until that poll ticked, so the command could say "No pull request for this branch" despite an open PR.

Fix: fetchRemote() and pull() now force-refresh the current PR. An explicit remote sync surfaces an externally-created (or merged/closed) PR immediately, without checking on every local commit. In-app branch switches already refresh it (checkoutBranch), and the 3-minute poll still covers passive discovery.

Notes

  • History fix reviewed by a reviewer agent; the mid-flight/append clearing edge case was caught and folded into the loadHistory expression.
  • npm run typecheck passes.

Commits made while the History tab was inactive (e.g. by an agent) did
not appear until an unrelated later watcher event. handleRepoChanged only
reloaded history when view === 'history', setView reloaded only when the
list was empty, and window.focus refreshes status only.

Track a stale flag on HistoryState: set it when refs change off-tab,
consume it on History tab entry, and clear it on a reset load (preserving
a flag re-raised mid-request and never clearing on paginated append).
@erwin-wee erwin-wee changed the title fix(history): reload commit list after off-tab ref changes fix: refresh history and PR state after off-tab watcher ref changes Sep 22, 2026
The View Pull Request command read a cached prs.current that was only
populated on repo open, push/checkout/PR actions in-app, and a 3-minute
background poll. A PR created outside gitgood was invisible until that
poll ticked, so the command could report "No pull request for this
branch" despite an open PR.

fetchRemote() and pull() now force-refresh the current PR, so an explicit
remote sync surfaces an externally-created (or merged/closed) PR
immediately, without checking on every local commit.
@erwin-wee
erwin-wee force-pushed the fix/history-stale-refresh branch from 85a5910 to fcf49ec Compare September 22, 2026 10:28
@erwin-wee
erwin-wee merged commit defb961 into main Sep 22, 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.

1 participant