Skip to content

PR badges: background prefetch & cache (git-log style)#125

Merged
devlint merged 18 commits into
mainfrom
feat/pr-badge-prefetch-cache
Jul 10, 2026
Merged

PR badges: background prefetch & cache (git-log style)#125
devlint merged 18 commits into
mainfrom
feat/pr-badge-prefetch-cache

Conversation

@devlint

@devlint devlint commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes GitWand's branch-badge PR indicator, which previously capped at 10 open PRs (ensurePrsLoaded() fetched exactly one page and never drained further).
  • Mirrors the PR fix(desktop): fix git log pagination, caching, and prefetching #113 git-log caching pattern: a background, idle-scheduled drain loop past the first page (up to a 300-PR ceiling), an in-memory cache keyed by repo, and a cheap GitHub freshness signal (top-updated PR + open count) to validate the cache without redraining.
  • Scope: open PRs only. GitHub gets the full instant-restore cache fast path; other forges (GitLab/Bitbucket/Azure) get the breadth fix (background drain) but not the cache shortcut, since they have no equivalent cheap freshness signal yet.
  • Addendum: the app-dock "prs" badge now shows the true total open-PR count via a single cheap, forge-agnostic getPRCount() call fired at repo-open — independent of the branch-badge list above, which only populates on user interaction (branch popover / graph mode). Manually verified live against this repo (devlint/GitWand): dock badge showed the exact real count immediately at repo-open, with zero prior interaction.

Changes

Branch-badge prefetch & cache:

  • apps/desktop/src/utils/idleSchedule.ts (new) — shared whenIdle() extracted from useGitRepo.ts.
  • apps/desktop/src/composables/usePrPanel.ts — background drain loop (prefetchOpenPrs), in-memory PR_LIST_CACHE, freshness-signal fast path in ensurePrsLoaded(), cache invalidation in createPr()/mergePr().
  • apps/desktop/src-tauri/src/{types.rs,commands/gh.rs,commands/github_api.rs,lib.rs} — new PrFreshnessSignal + gh_pr_freshness_signal Tauri command (REST/token and gh CLI paths).
  • apps/desktop/src/utils/backend-pr.tsghPrFreshnessSignal() typed wrapper.
  • apps/desktop/dev-server.mjs — matching /api/gh-pr-freshness route for browser dev-mode.

Dock badge count addendum:

  • apps/desktop/src/composables/usePrPanel.tsdockPrCount/refreshDockPrCount(), wired into the cwd watcher (seeded from the cached remote so the correct forge resolves, not always GitHub), with a staleness guard against a repo-switch-mid-fetch race.
  • apps/desktop/src/App.vue, apps/desktop/src/components/PrListSidebar.vue — redirect the existing (previously mis-wired) :pr-count dock binding, wire the PR view's refresh button to refresh both the list and the dock count.

Docs: docs/superpowers/specs/2026-07-09-pr-badge-prefetch-design.md, docs/superpowers/plans/2026-07-09-pr-badge-prefetch.md, docs/superpowers/specs/2026-07-10-pr-dock-badge-count-design.md, docs/superpowers/plans/2026-07-10-pr-dock-badge-count.md.

Implemented via subagent-driven-development: 9 tasks total across both features, each with an independent implementer + reviewer pass, 3 fix rounds, plus a dedicated final whole-branch review for each feature.

Test plan

  • cargo test (apps/desktop/src-tauri): 145/145 passing
  • pnpm test (apps/desktop): 428/428 passing
  • pnpm build (apps/desktop): clean, vue-tsc 0 errors
  • dev-server.mjs real-boot smoke test: new routes confirmed in startup log
  • Manual QA via pnpm dev:web + chrome-devtools against this repo: dock badge shows the true open-PR count (6) immediately at repo-open with no prior interaction, matching gh pr list exactly; refresh button updates both list and badge; zero new console errors

Laurent Guitton added 10 commits July 9, 2026 21:22
Mirrors the PR #113 git-log caching pattern for the PR badge path,
which today caps at 10 open PRs and never drains further pages.
Task-by-task plan implementing the approved design: shared idle-schedule
util extraction, background drain loop, Rust freshness-signal command
(REST + gh CLI paths), TS wrapper, dev-server route, and in-memory cache
wiring with invalidation.
@devlint devlint marked this pull request as draft July 10, 2026 01:38
@devlint devlint requested a review from t1gu1 July 10, 2026 09:23
…t work

Multi-forge freshness parity, cursor-based PR-list pagination (already
flagged in-code as Phase 2/v2.9), and a dock badge staleness indicator —
all deliberately deferred, none blocking PR #125.
@devlint devlint marked this pull request as ready for review July 10, 2026 14:06
@devlint devlint removed the request for review from t1gu1 July 10, 2026 14:06
@devlint devlint merged commit 6bc170a into main Jul 10, 2026
4 checks passed
@devlint devlint deleted the feat/pr-badge-prefetch-cache branch July 10, 2026 14:18
devlint pushed a commit that referenced this pull request Jul 10, 2026
Combines the previously separate v3.5 (secrets scanner) and v3.6 (PR
Review 2.0) roadmap items into a single release, plus PR badge
background prefetch/cache, dock PR count, repo-tab reorder a11y fix,
and the File Explorer Save button move already merged to main.

- CHANGELOG.md: renamed Unreleased to 3.5.0, folded in the three extra
  merged PRs (#125, #122, #121)
- ROADMAP.md: moved v3.5/v3.6 to Shipped as one entry, renumbered every
  future planned version down by one to close the gap
- website/changelog.md: narrative mirror entry for v3.5.0
- New blog post (PR Review 2.0 + secrets scanner), wired into the blog
  index, sidebar, and homepage teaser; homepage hero-announce banner
  updated in all 5 locales
- New "Support GitWand" sponsor section on the homepage, all 5 locales
- Fixed a stale usePrPanel.test.ts mock missing detectClaudeCli
  (broke after PR Review 2.0 wired useReviewIntelligence into the
  usePrPanel import chain)
- Version bump via ./scripts/bump-version.sh 3.5.0

disabled
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