Skip to content

Perf/reduce GitHub api calls#11

Merged
42tg merged 3 commits into
mainfrom
perf/reduce-github-api-calls
Mar 18, 2026
Merged

Perf/reduce GitHub api calls#11
42tg merged 3 commits into
mainfrom
perf/reduce-github-api-calls

Conversation

@42tg

@42tg 42tg commented Mar 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Review actions in chat header: When a thread has an active PR review, a collapsible dropdown (matching Git/Jira action patterns) appears with "Approve" and "Request Changes" options that submit
    directly via the GitHub API
  • GitHub API rate-limit optimization: Server-side TTL caches for PR lookups (60s), repo clone URLs (5min), and PR head SHA (2min), plus relaxed client-side polling intervals

Polling interval changes

Query Before After
Git status stale 5s / refetch 15s stale 15s / refetch 30s
Git branches stale 15s / refetch 60s stale 30s / refetch 120s
Review requests stale 30s / refetch 60s stale 60s / refetch 120s

Server-side caches

Data TTL Impact
findLatestPr per (cwd, branch) 60s Eliminates 1-3 gh pr list calls per status poll
Repository clone URLs 5 min Avoids up to 4x redundant gh repo view per PR worktree
PR head SHA 2 min Avoids re-fetch per review comment publish

Test plan

  • Verify review Approve/Request Changes buttons appear on active review threads
  • Verify submitting a review shows success toast and dismisses the review request
  • Verify git status still updates after commits/pushes (cache invalidation works)
  • Verify PR creation still finds the created PR (cache invalidation on mutation)
  • Monitor gh API usage to confirm reduced call volume

42tg added 2 commits March 18, 2026 09:42
Add ReviewActionsControl component with a collapsible dropdown menu
(matching Git/Jira action patterns) that appears when the current
thread has an active PR review. Supports submitting APPROVE or
REQUEST_CHANGES via the GitHub API, then auto-dismisses the review
request locally.
- Cache findLatestPr results per (cwd, branch) with 60s TTL, avoiding
  1-3 gh API calls every git status poll
- Cache repository clone URLs for 5 minutes (essentially static data
  fetched up to 4x per PR worktree setup)
- Cache PR head SHA for 2 minutes during review comment publishing
- Increase git status polling from 15s to 30s (stale 5s to 15s)
- Increase git branches polling from 60s to 120s (stale 15s to 30s)
- Increase review request polling from 60s to 120s (stale 30s to 60s)
- Invalidate PR cache on PR creation to ensure fresh data after mutations
@github-actions github-actions Bot added size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Mar 18, 2026
- Extract createTtlCache to @t3tools/shared/cache (dedup GitManager + wsServer)
- Cache getDefaultBranch results for 15 minutes (essentially static)
- Server-side 60s cache for reviewRequestList (collapses multi-tab polls)
- Batch review comments into single POST /reviews call (N→1 API calls)
- Add refetchIntervalInBackground: false to all polled queries (stops
  polling when tab is in background)
- Add refetchOnWindowFocus to reviewRequestListQueryOptions
- Add stdin passthrough to GitHubCli.execute for batch API payloads
@42tg 42tg merged commit acbc148 into main Mar 18, 2026
6 of 7 checks passed
@42tg 42tg deleted the perf/reduce-github-api-calls branch March 18, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant