Repository navigation
feat(forge): GitHub rate budget, batched PR status and Todos lists - #455
Merged
Merged
Conversation
Merged and closed PRs on unarchived tasks kept taking the background poller's eight slots per tick, so open PRs waited behind them and a merge could take several minutes to show. A PR whose live lookup is merged or closed is now re-checked hourly (and still on focus). The remembered snapshot does not count, so a launch still polls every task once. Signed-off-by: Alex Goodman <[email protected]>
Termic now knows what the gh token's GitHub limits are, what is left, and what termic itself spent this hour, per host and per feature. - `forge_rate` keeps GitHub's window (from `x-ratelimit-*` headers and the GraphQL `rateLimit` object) apart from termic's own spend, since the token is shared with agents and the user's terminal - background work gets a gate: held on a GitHub refusal, under 15% left on the account, or past termic's 20% GraphQL share - `forge::gh_api` / `gh_graphql` run `gh api --include` and feed the ledger; the older `gh pr` / `gh issue` calls are charged as estimates - new IPC `forge_rate_status` and event `termic://forge-rate-changed` - Settings > General shows the budget per host; a top-bar pill appears only while background polling is paused Signed-off-by: Alex Goodman <[email protected]>
The background poller ran one `gh pr view` per task, at most eight a
minute and one at a time, so with many PR tasks a merge could take
several minutes to show. GitHub tasks with a PR url now share one aliased
GraphQL query per host (up to 50 PRs, about 2 points), every tick.
- new IPC `task_pr_status_batch { ids, background }`
- a closed PR, a task whose branch no longer matches the PR head, or a PR
the query cannot see still goes through the by-branch lookup, so a
replacement PR on the same branch is found as before
- `background` skips hosts whose rate gate is closed; those tasks are left
out of the answer and stay due
- GitLab, Azure and multi-repo tasks keep the per-task path and its
three-minute cadence
Signed-off-by: Alex Goodman <[email protected]>
The Todos view ran one `gh issue list` / `gh pr list` per project per list, three at a time: 45 subprocesses for 15 projects on "For me". Every GitHub list on a host is now one GraphQL query: repo-wide lists as `repository` aliases, personal ones (assigned, mentions, mine, review) as `search` aliases with `repo:` qualifiers, split back out per project. - new IPC `project_forge_lists`; GitLab, Azure and anything the query cannot answer keep the per-project path, three at a time - the lists cache keys, TTL and rows are unchanged; a dialog asking for a list that is in the batch waits on it rather than fetching it again - an ignored live test runs both batched queries against a signed-in gh Signed-off-by: Alex Goodman <[email protected]>
The batched poll asks Rust's rate gate itself. The comment watcher and the per-task fallback in the background pass did not, so they now skip GitHub tasks while any host is paused. GitLab and Azure are unaffected. Signed-off-by: Alex Goodman <[email protected]>
Lets a spec seed the GitHub rate ledger's mirror: no fixture repo talks to GitHub, so nothing real would ever pause background polling. Signed-off-by: Alex Goodman <[email protected]>
Follow-ups from review of the rate budget and the batched reads. - a limit is `ForgeError::RateLimited`: a PR batch refused on one skips the host, any other batch failure answers each task with its `cli-unauthed` / `error` status instead of freezing it silently, and a Todos batch refused on a limit no longer re-asks project by project - background work asks Rust, per host: `task_pr_status` and `task_pr_comments` take `background` and answer null while the task's host is paused; `task_pr_status_batch` drops its param and is always gated. The webview mirror only draws the pill now - the rate event always goes out when a pause starts, ends or moves, so a budget or floor pause can no longer be throttled away - the PR card's minute tick skips tasks the batch covers - batch membership is tracked apart from `loading` (a forced refresh mid-batch is no longer dropped), a batch lands in one store write, and an urgent dialog no longer waits out a Todos batch - `gh api` only talks to github.com or a host `gh auth status` lists, is killed at 45s, and pause, reset and cost values are clamped; owner/repo outside GitHub's charset takes the CLI path - two projects on one remote both get their search list rows - docs no longer describe the unshipped REST cap or notifications feed Signed-off-by: Alex Goodman <[email protected]>
Covers the pill (absent, shown with its kind, gone once a pause has passed) and Settings > General's budget block opened from it. The rate store is held on the seed for the whole describe. The app inherits this machine's `gh` login, so a real probe or ledger event would otherwise replace the seed mid-case and could put a real hostname in the screenshot. Signed-off-by: Alex Goodman <[email protected]>
Follow-ups from review of the GitHub rate budget.
- every per-task `gh pr view` a batched pass starts (chunk fallback,
closed or missing PR, moved branch) spends from one budget of eight,
and each task gets one at most every three minutes. A PR in a deleted
repo no longer costs a subprocess every pass, and the webview stamps a
failure that lands over a good lookup instead of leaving it stalest
- a batch answer whose url is not the PR asked is not trusted or
persisted; PR urls and slugs are validated (32-bit number, GitHub's
charset and lengths) before they join a query
- a `gh` CLI call refused on a rate limit records the refusal, so the
CLI path stops too; the comments REST leg goes through
`gh api --include`, which makes the Core window and its cap real
- a task with no recorded forge is resolved from its remote before the
gate, so GitLab and Azure tasks no longer wait on github.com
- rate-limited lookups carry `retry_at`; the webview words them itself
(`lookupMessage`), and a pulled rate status no longer overwrites a
newer pushed one
- a Todos chunk past the output cap is split and asked again instead of
falling back to the uncapped CLI path
- a zero limit is ignored, resets are moved into the local clock by the
`Date` header, the ledger uses parking_lot locks, and the rate probe
runs at most once a minute per host
- `refresh(id, { force, background })` replaces the boolean pair; the
board, agent spawn and blocked-card retry poll as background
- a steady poll keeps the previous lookup object, and the batch runs
beside the per-task loop rather than ahead of it
- the pill is info-coloured and reads "GitHub polling paused"
`refresh` and `task_pr_comments` change shape (options object, a held
background call answers null), and lookups gain `retry_at`.
Signed-off-by: Alex Goodman <[email protected]>
Owner
|
No blocking bugs, the GraphQL batching and rate ledger hold up correctly across the aliasing, chunking, and backoff paths. One minor race: concurrent pollers can each pass the per-host budget check before their cost is recorded, letting termic briefly overspend its local share, though GitHub's own limit still catches real exhaustion. Thanks for the contribution! |
The background poller rechecks merged and closed PRs hourly, so a merged snapshot aged by 10 minutes was never due and the pass skipped it. Age it by two hours instead. Signed-off-by: Alex Goodman <[email protected]>
simion
added a commit
that referenced
this pull request
Nov 13, 2026
The case seeded the PR entry with loading:false, hiding a real lookup still in flight (leaving the Git tab starts one). On Windows its git spawn is slow enough to land inside the background pass: it landed as raced, kept the seed but stamped fetchedAt, and the batch then dropped its own answer as older than that landing, so the badge never moved. Failed on every Windows run since #455 batched the background poll. The seed now leaves loading as it is, and the case waits for no lookup in flight before aging the entry and running the pass. Refs #281 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
|
This is live in v1.23.0. Thanks for the contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Termic's background GitHub reads were one
ghsubprocess per task or per project, all spending from the token the user's terminal and agents also use, with no idea how much was left. With a dozen PR tasks a merge could take minutes to show, and the Todos view ran ~45 subprocesses for 15 projects.repositoryaliases for repo-wide lists,searchaliases for personal ones)forge_rate.rs) tracks GitHub's window apart from termic's own spend, from thex-ratelimit-*headers, the GraphQLrateLimitobject, and refusals seen on the plainghCLIgh apionly talks to github.com or a hostgh auth statusreports signed in, is killed at 45s, and refuses answers past 32 MiBInterface changes:
task_pr_status_batch,project_forge_lists,forge_rate_status, and eventtermic://forge-rate-changedtask_pr_status,task_member_pr_statusandtask_pr_commentstake a requiredbackgroundflag and answernullwhile the host is pausedretry_atrefresh(id, force, background)is nowrefresh(id, { force, background })