Skip to content

feat(checks-panel): auto-refresh on entering Checks tab#1688

Merged
AmethystLiang merged 1 commit into
mainfrom
refresh-on-checks-tab
May 11, 2026
Merged

feat(checks-panel): auto-refresh on entering Checks tab#1688
AmethystLiang merged 1 commit into
mainfrom
refresh-on-checks-tab

Conversation

@AmethystLiang
Copy link
Copy Markdown
Contributor

@AmethystLiang AmethystLiang commented May 11, 2026

Summary

  • Adds an entry-refresh effect to ChecksPanel that force-fetches PR metadata, checks, and comments whenever the user enters the Checks tab (open sidebar, switch to Checks tab, or switch active worktree/branch). A 30 s grace window suppresses duplicate fetches from rapid show/hide toggles.
  • Extracts the staleness decision into checks-entry-refresh.ts (pure function, fully unit-tested).
  • Fixes a stale-closure bug in handleRefresh: fetchPRChecks is now called with the freshly resolved headSha after a PR refresh, preventing stale checks when a PR was externally force-pushed.
  • 11 unit tests in checks-entry-refresh.test.ts; all passing.
  • Design doc at docs/refresh-on-checks-tab.md.

Test plan

  • Open Orca, navigate to a worktree with a PR, switch to another tab, then back to Checks — panel refreshes automatically.
  • Open the right sidebar while Checks tab is already selected — refresh triggers.
  • Switch active worktree while Checks is visible — refresh triggers for new worktree.
  • Re-enter Checks within 30 s (rapid hide/show) — only one refresh fires.
  • Worktree with no PR — no refresh triggered; panel shows "No PR" correctly.
  • pn test with checks-entry-refresh.test.ts — all 11 tests pass.

Made with Orca 🐋

Force a freshness check each time the user enters the Checks tab
(open sidebar, switch to Checks tab, or switch active worktree/branch)
so stale PR metadata, cached-null "no PR" results, stale checks, and
stale comments are surfaced immediately rather than waiting for the
cache TTL.

- Extracts entry-refresh logic into `checks-entry-refresh.ts` with a
  30 s grace window to suppress rapid show/hide duplicate fetches.
- Adds a `shouldEntryRefresh` effect in `ChecksPanel` keyed by
  `activeWorktreeId::repo.path::branch`; resets on panel hide so
  close-and-reopen re-evaluates freshness.
- Fixes a stale-closure bug in `handleRefresh`: `fetchPRChecks` is now
  called directly with the freshly resolved `headSha` after PR refresh
  instead of reusing the pre-refresh closure's captured sha.
- Adds 11 unit tests in `checks-entry-refresh.test.ts`.
- Design doc: `docs/refresh-on-checks-tab.md`.

Co-authored-by: Orca <help@stably.ai>
@AmethystLiang AmethystLiang merged commit 648f207 into main May 11, 2026
3 checks passed
@AmethystLiang AmethystLiang deleted the refresh-on-checks-tab branch May 11, 2026 06:16
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