Repository navigation
feat(seer): Add useSeerCreditCheck hook - #129545
Merged
billyvg merged 4 commits intoNov 5, 2026
Merged
Conversation
This was referenced Nov 2, 2026
billyvg
commented
Nov 5, 2026
Comment on lines
+23
to
+25
| export function hasSeerCreditChecks(organization: Organization) { | ||
| return organization.features.includes('seer-credit-checks'); | ||
| } |
Member
Author
There was a problem hiding this comment.
@srest2021 should we also check token-billed-seer-enabled? https://sentry.slack.com/archives/C0CE9U55PK4/p1793827531081729
Member
There was a problem hiding this comment.
Yeah probably--I need to add the flag to the endpoint as well
billyvg
marked this pull request as ready for review
November 5, 2026 20:05
Asks /seer/credit-check/ whether the org can afford one Seer operation, such as the next autofix step or a chat message. It only calls the endpoint for orgs with seer-credit-checks and fails open otherwise, so gated UI keeps working while the backend lands. Fixes CW-2327 Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
force-pushed
the
billyvong/cw-2327-sentry-ui-seer-credit-check-hook
branch
from
November 5, 2026 20:08
d421b4d to
62bbc1e
Compare
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 62bbc1e. Configure here.
scttcper
approved these changes
Nov 5, 2026
scttcper
left a comment
Member
There was a problem hiding this comment.
knip might have something to say about this
natemoo-re
approved these changes
Nov 5, 2026
The app's query client turns off refetchOnWindowFocus, so staleTime: 0 alone never rechecked credits after a top-up in another tab. The check now sets it, with a test that fails without it. Orgs need token-billed-seer-enabled as well as seer-credit-checks before the hook calls the endpoint. Orgs without a Seer wallet always pass the check, so they make no billing lookup and no Seer trigger waits on one. hasSeerCreditChecks carries both flags for the usage meter. The PR step is autofix_open_pr, as in SeerOperation. The endpoint rejected autofix_create_pr, so that gate always failed open. seerCreditCheckOptions had no callers and is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
The backend's SeerOperation calls the PR step autofix_open_pr and rejects autofix_create_pr, so the create PR gate always failed open. Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests, stories and SeerCreditCheckStub that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Only the hook needs it. The flag check is inlined so the hook is the file's only export besides its operation type. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
useSeerCreditCheck no longer exports hasSeerCreditChecks as of #129545, so the meter checks seer-credit-checks and token-billed-seer-enabled directly. Only token-billed orgs have a wallet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Nothing in production imports useSeerCreditCheck until the gating PRs stacked on this one land, so knip --production reported the file as unused. It is a temporary entry point, like autofixChatContext, until #129563 and #129565 consume it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
deleted the
billyvong/cw-2327-sentry-ui-seer-credit-check-hook
branch
November 5, 2026 21:46
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
useSeerCreditCheck no longer exports hasSeerCreditChecks as of #129545, so the meter checks seer-credit-checks and token-billed-seer-enabled directly. Only token-billed orgs have a wallet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
The backend's SeerOperation calls the PR step autofix_open_pr and rejects autofix_create_pr, so the create PR gate always failed open. Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests, stories and SeerCreditCheckStub that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
useSeerCreditCheck no longer exports hasSeerCreditChecks as of #129545, so the meter checks seer-credit-checks and token-billed-seer-enabled directly. Only token-billed orgs have a wallet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
The backend's SeerOperation calls the PR step autofix_open_pr and rejects autofix_create_pr, so the create PR gate always failed open. Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 5, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests, stories and SeerCreditCheckStub that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 6, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 6, 2026
useSeerCreditCheck no longer exports hasSeerCreditChecks as of #129545, so the meter checks seer-credit-checks and token-billed-seer-enabled directly. Only token-billed orgs have a wallet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 6, 2026
Adds the shared out-of-credits CTA used by the Seer gating PRs stacked on this one: the chat gate, the autofix gate and the out-of-credits failures. Its copy and layout follow the "Seer Billing Gates Copy" spec in Notion. Product code renders `<SeerOutOfCreditsCta reason=… variant=… />`, an `OverrideOrDefault` slot in `static/app`. Open source registers nothing and renders nothing, since it has no credits. Everything else lives in gsApp next to the other billing UI: the copy, the escalation logic and the presentational `SeerOutOfCreditsNotice` with its story. - **`reason`** says what the org can't afford: - `agent-chat`: sending a message - `autofix-start`: starting a run - `autofix-continue`: the next step of a run that has results, or one that stopped part way Getsentry picks the spec copy from that, the viewer's billing access, and whether auto reload is already on. With auto reload on, the copy says the org has no auto top-ups remaining. - **`variant="muted"`** is for tight spots where the gated button stays on screen, disabled, under the notice, like the issue sidebar. - **Billing members** (`org:billing`) get "Configure auto reload" under the message. In this PR it links to the billing overview; #129552 makes it open the Seer credits modal in place. - **Other members of self-serve orgs** get "Request credits". It calls `seer-top-up-request` and shows "Request sent" until the billing period ends (from #130097). - **Members of orgs that can't self-serve** get the message and no button. Open for review: the spec only has billing-member copy. Members get the spec's first sentence plus who to ask. The spec also has no copy for Autofix when auto reload is already on, so those two strings follow the chat pattern. The spec's typos ("star an Autofix run", "Configure autoreload") are fixed, and its mix of "auto reload", "auto top-up" and "auto top up" is kept as written. Stacked on #129545. | Location | Screenshot | | --- | --- | | Scraps › gsApp › Seer Out of Credits › Agent chat |  | | Scraps › gsApp › Seer Out of Credits › Agent chat, auto reload already on |  | | Scraps › gsApp › Seer Out of Credits › Autofix, before a run |  | | Scraps › gsApp › Seer Out of Credits › Autofix, part way through a run |  | | Scraps › gsApp › Seer Out of Credits › Issue sidebar |  | | Scraps › gsApp › Seer Out of Credits › Members, request / sending / sent |  | | Scraps › gsApp › Seer Out of Credits › Orgs that can't self-serve |  | Fixes CW-2321 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Sofia Rest <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 6, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 6, 2026
useSeerCreditCheck no longer exports hasSeerCreditChecks as of #129545, so the meter checks seer-credit-checks and token-billed-seer-enabled directly. Only token-billed orgs have a wallet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 6, 2026
The backend's SeerOperation calls the PR step autofix_open_pr and rejects autofix_create_pr, so the create PR gate always failed open. Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 6, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests, stories and SeerCreditCheckStub that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 9, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 9, 2026
useSeerCreditCheck no longer exports hasSeerCreditChecks as of #129545, so the meter checks seer-credit-checks and token-billed-seer-enabled directly. Only token-billed orgs have a wallet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 9, 2026
When the org can't afford another Seer chat message, the Seer Explorer
chat (drawer, sidebar and popped-out window) shows the out-of-credits
alert (`SeerOutOfCreditsCta reason="agent-chat"`) directly above the
composer, and nothing in the panel can send a message. That covers the
send button, Enter, the suggested questions (hidden), Retry after a
timeout (disabled), `/investigate`, and the "Continue" / "Draft a pull
request" / "Try again" buttons in autofix embeds inside the chat. Those
buttons go disabled because the chat stops passing them its send
function, the same way it already does for read-only chats. Typing stays
enabled so a draft isn't lost. A question forwarded into the chat from
elsewhere (Ask Seer, the autofix hand-off, the command palette) waits
for the credit check, and if there are no credits it stays in the
composer unsent.
The composer now follows the Billing Gates designs: a toolbar row under
the text field holds the send button, which is the designs' small up
arrow, and the field and toolbar share one border and one focus ring.
This applies to every Seer Explorer chat, not only orgs with credit
checks.
Billing members also get a credit usage meter in that toolbar, next to
the send button: the percent of the org's Seer credits used and a small
bar. Hovering it shows how much is used and "{remaining}/{total} credits
remaining." With auto reload off, the tooltip counts the month's credits
and stops there, as in the designs. With auto reload on, it counts all
available credits and adds one line:
- with credits left: "Credits will reload automatically."
- when the chat's credit check says the org still can't afford a
message: "You do not have any more reloads available. Configure
auto-reload."
The bar turns warning-colored at 90% used, and whenever the org can't
afford a message. The meter is a new `component:seer-credit-usage-meter`
slot that renders nothing in open source. getsentry's implementation
reads the Seer wallet and the auto top-up settings, and renders nothing
until both load. Orgs without token-billed Seer get a 404 from the
wallet, so they see no meter.
Decisions the spec didn't settle:
- Members without `org:billing` don't see the meter. The spec only has
billing copy, and members can't act on its links.
- The warning starts at 90%. The designs show grey at 80% and yellow at
95% without naming a threshold. The check uses the rounded percent the
meter shows, so a meter that reads "90%" is never grey.
- The tooltip's "Configure auto-reload." link goes to the billing
overview, where the Seer wallet card configures auto reload. #129552
adds an in-place auto reload modal for the CTA's button.
- The meter stays while the send button turns into Interrupt, so the
toolbar doesn't shift while Seer answers.
- The designs' toolbar also has a "+" button on the left. It has no
action in the chat yet, so it's left out.
- The designs dim the composer when the org is out of credits and auto
reload is off. It stays at full strength here, because typing still
works.
- The meter loads the wallet when the composer mounts and on window
focus, like the credit check. It doesn't refresh after each message.
The credit check uses the `agent_chat_message` operation and only runs
while the composer is on screen. It does not run for someone else's
read-only chat, for a chat that failed to load, or while a question or
approval bar takes the composer's place. Without `seer-credit-checks`
nothing changes, including the meter. While the first check is still
loading, the user's own sends go through, because the hook fails open.
The exception is a forwarded question: it waits for the result, and
until it goes out the panel's other sends wait too, so it isn't dropped
or sent second.
Not gated here, for review:
- Answers to Seer's own questions, file-change approvals and write
approvals. These continue a message Seer already has.
- When the chat failed to load or a question bar is up, the check is
off. In those states a forwarded question or an embed button still
sends, and the backend has the final say.
- Other Seer inputs with their own composer: the dashboard Seer chat
(`dashboardEditSeerChat`, `createFromSeer`) and the Ask Seer search
combobox.
- The autofix embed buttons are gated by the chat-message check. CW-2331
may want its own autofix operations for them.
Builds on #129545 (credit-check hook) and #129551 (out-of-credits CTA),
which have both merged.
| Location | Screenshot |
| --- | --- |
| Seer Explorer › new chat, with credits | [](https://github.com/user-attachments/assets/2d71a364-8057-435b-ac03-dee9dc249c47)
|
| Seer Explorer › new chat, out of credits, auto reload off | [](https://github.com/user-attachments/assets/cd5c6ea2-ff6a-499b-bec1-09a5e3ae4c1d)
|
| Seer Explorer › conversation, out of credits, auto reload on | [](https://github.com/user-attachments/assets/ce7783df-0bf0-4da8-b276-5efb5baf1e96)
|
| Credit usage meter › auto reload off, tooltip | [](https://github.com/user-attachments/assets/fd59893e-d9d7-4eae-8ce9-672fdc9aed03)
|
| Credit usage meter › auto reload on, tooltip | [](https://github.com/user-attachments/assets/79a9ce8b-541b-4c5b-9fc9-d3798f762c2c)
|
| Credit usage meter › out of reloads, tooltip | [](https://github.com/user-attachments/assets/bcf17640-8c15-4ca7-95e4-d30f1ce051b2)
|
| Credit usage meter › out of credits, auto reload off, tooltip |
[](https://github.com/user-attachments/assets/1206d08e-d62d-4650-b621-78f3195fd620)
|
| Credit usage meter › colors | [](https://github.com/user-attachments/assets/78b0ebd4-7a5a-48c9-afbc-7114186cea0e)
|
Fixes CW-2332
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Sofia Rest <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 10, 2026
The backend's SeerOperation calls the PR step autofix_open_pr and rejects autofix_create_pr, so the create PR gate always failed open. Credit checks also need token-billed-seer-enabled as of #129545, so the tests and stories that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 10, 2026
When an org with `seer-credit-checks` can't afford the Autofix step a surface would start, that surface shows the out-of-credits CTA and keeps its billable buttons on screen, disabled. Whatever Seer already produced (root cause, plan, code changes, PRs) stays visible. Placement and copy follow the "Seer Billing Gates Copy" spec: one CTA per surface, with `reason` choosing start or continue copy. It builds on the out-of-credits CTA (#129551) and the credit-check hook (#129545), both merged. Orgs without the flag see no change and make no credit-check requests. Each surface checks only the operation for the step it offers, and only while that step is on offer. Billable buttons are also disabled until the surface's own check answers, so they never become clickable before it does, even when an earlier answer is cached. | Surface | CTA | Disabled | Operation | |---|---|---|---| | Seer drawer and Autofix tab, no run | Warning alert at the top, `autofix-start` | Start Analysis | `autofix_root_cause` | | Seer drawer and Autofix tab, run with results | Warning alert at the top, above the results, `autofix-continue` | Next-step prompt (Yes, Nevermind, No or Ask Seer, Rethink), PR feedback form, and the Code Changes card's PR feedback form | the step the prompt offers: `autofix_solution`, `autofix_code_changes`, `autofix_open_pr`, `autofix_pr_iteration` | | Issue sidebar, no run | Muted notice with a grey icon column, in place of the "Have Seer..." explainer, above the button, `autofix-start` | Start Analysis | `autofix_root_cause` | | Issue preview | Warning alert at the top of the body, since the header has no room for one. `autofix-start` to start or restart a run, `autofix-continue` for its next step | The header's Seer button: Find Root Cause, Make a Plan, Write a Code Fix, Create PR, Restart Autofix. PR links and the coding-agent menu stay enabled | whatever the header button would start | | Chat autofix card | In the Explorer chat, a warning alert above the composer, `autofix-continue`. Elsewhere, and while an approval or question bar stands in for the composer, a muted notice in the card, above the buttons | Continue: Plan, Continue: Code Changes, Draft a pull request | the matching step | Where to look: - `autofixCredits.tsx` holds the action-to-operation map, `getAutofixContinueAction` (the billable action a run with results would take next), and `AutofixOutOfCreditsAlert`. `SeerDrawerContent` renders that alert once, which covers both the drawer and the tab. The start card and next-step prompt only disable their buttons, so those views never show more than one CTA. - The drawer and tab alert also shows when the last step or PR create failed, because retrying it is the next billable action. That alert is the CTA for a run that stopped for credits. The retry buttons themselves are left to CW-2328. - Nothing is checked while a step is running. The exception is an open PR's feedback form, which takes feedback mid-run. - `autofixChatContext.tsx`: an autofix card in the Explorer chat reports that it can't afford its next step through `reportOutOfCredits` instead of showing a notice. `SeerExplorerContent` collects those reports and shows one notice in the composer's `notice` slot, the one the agent-chat notice uses. - Single runs offer no next step, so `getAutofixContinueAction` checks nothing for them and their chat cards offer no "Continue". - `issuePreviewSeer.tsx`: `getSeerButtonAction` follows the branches of the header's `SeerActionButton` to pick what to check. With two or more open PRs, the header lists them in place of a coding agent's result link and offers "Restart Autofix", so that case checks `autofix_root_cause`. Decisions the spec doesn't cover: - "No" and "Ask Seer" are disabled too. Every path behind them ends in Seer work: a re-run of the current step, or a Seer Agent message. The re-run is held on the next step's check, not on a second check for the current step. - The coding-agent dropdown stays enabled, since Cursor, Copilot and Claude Code hand-offs aren't paid for in Seer credits. "View GitHub permissions" also stays enabled, since it only checks repo access. - The PR feedback form disables its text box as well as Submit. - In the Explorer chat, the card's notice is a warning alert above the composer, with the chat's full-size button, so it stays in view as the chat scrolls. One notice covers every card in the chat. When the chat itself is out of credits, only the agent-chat notice shows, and the card's notice waits for the chat's check to answer so the two never swap. Outside the chat, as in an investigation, the card keeps a muted notice of its own. - The muted notice greys its icon column to match the Billing Gates design. The muted `Alert` leaves that column white, so `SeerOutOfCreditsNotice` paints it. - In the issue preview, "Restart Autofix" on an existing run uses `autofix-start`, since it starts a new run. - On the Autofix tab, the alert sits below any `AutofixWarnings`. These are deliberately left alone: retrying a failed step or PR (CW-2328), the per-card re-run buttons, the drawer toolbar's Restart, the command palette and the Autofix overview page. Also untouched are the auto-start for issues that ran legacy Autofix and the chat card's "Try again". The backend still rejects any of these that would overspend. The issue preview has no story, so it isn't shown here. | Location | Screenshot | | --- | --- | | Seer drawer, before a run, out of credits |  | | Seer drawer, before a run, with credits |  | | Seer drawer, after the root cause, out of credits |  | | Seer drawer, after the root cause, with credits |  | | Seer drawer, after the plan, out of credits |  | | Seer drawer, Create PR, out of credits |  | | Seer drawer, PR iteration, out of credits |  | | Seer drawer, a step that stopped, out of credits |  | | Issue details › sidebar › Seer Autofix, out of credits | [](https://github.com/user-attachments/assets/bee760ef-aaaa-4782-8d41-55d0f7c3a630) | | Issue details › sidebar › Seer Autofix, out of credits, billing member | [](https://github.com/user-attachments/assets/c5e82a23-0c66-4e40-b5e9-f1419a681891) | | Issue details › sidebar › Seer Autofix, with credits |  | | Seer Explorer › autofix card › Root Cause, out of credits | [](https://github.com/user-attachments/assets/b5c45ce2-649a-4224-a1cf-85bccd965ebf) | | Seer Explorer › autofix card › Root Cause, out of credits, billing member | [](https://github.com/user-attachments/assets/f214fef3-fade-4f0e-ad62-ea1be58f6ef3) | | Seer Explorer › autofix card › Plan, out of credits | [](https://github.com/user-attachments/assets/2e7d2b5d-5a54-476d-a19c-cfa7cd03df31) | | Seer Explorer › autofix card › Code Changes, out of credits | [](https://github.com/user-attachments/assets/08e43349-dd56-4659-9ab7-82009e145dc4) | | Seer Explorer › autofix card › Root Cause, with credits | [](https://github.com/user-attachments/assets/ec89c689-a71b-4c96-976c-23f243f6d5dc) | The sidebar and Explorer rows come from `autofixSection.stories.tsx` and `autofix.stories.tsx`. The embed stories' chat shell puts the notice above its composer, the way `SeerExplorerContent` does. Members see "Contact Admin" only when their org can self-serve, so those captures used a self-serve subscription. Fixes CW-2331 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
billyvg
added a commit
that referenced
this pull request
Nov 10, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests, stories and SeerCreditCheckStub that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 13, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests, stories and SeerCreditCheckStub that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 13, 2026
Credit checks also need token-billed-seer-enabled as of #129545, so the tests, stories and SeerCreditCheckStub that turn on seer-credit-checks turn it on too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
billyvg
added a commit
that referenced
this pull request
Nov 16, 2026
When an org runs out of Seer credits, Seer ends the run with `failure_reason=out_of_credits` (getsentry/seer#9242) or records `pr_creation_error_code=out_of_credits` on the repo's PR state (getsentry/seer#9268). Until now the UI showed those as generic failures ("This one is on us") next to a retry that fails the same way. This PR reads both fields, says the step stopped for credits, and makes its retry follow the credit check. It builds on #129545 (`useSeerCreditCheck`), #129551 (out-of-credits CTA), #129563 (agent chat gate), #129565 (autofix entry point gates) and #130463 (chat recheck), all merged. This PR renders no out-of-credits CTA. The credit gates already show one on each surface: the alert at the top of the Autofix tab and drawer (its `autofix-continue` copy covers a run that stopped part way), the alert above the chat composer, and the muted alert in the issue sidebar. A stopped step or failed PR only gets a one-line status here. **A step that stopped for credits** (root cause, plan, code changes, PR iteration): - The Seer drawer cards and the chat autofix card keep what the step wrote before it stopped: its reasoning, the root cause's evidence and, for code changes, the partial diff. Seer's own error block is left out. The drawer cards draw that work the way their running state does, like the Seer Agent chat. Below that, one line says which step stopped. It's muted in the drawer and danger in the chat card, which matches each card's existing failure text. Partial code changes can't be copied as Markdown or turned into a PR. - The issue sidebar previews say the step stopped for credits. A PR-iteration feedback item that stopped is marked failed, with out-of-credits copy. - In agent chat, the run's last response replaces Seer's plain-text error block with a muted "Seer stopped because your organization is out of credits." Earlier reasoning and tool calls stay in the thinking block. #130463 rechecks credits when a run stops for them, so the alert above the composer comes up as well. **A PR create or push that failed for credits:** - The drawer's Pull Requests card keeps "Retry PR" for that repo and adds a line under the PRs saying it failed for credits. The chat PR card says the same instead of "This one is on us". - The chat failure toast and the PR links bar tooltip use out-of-credits copy instead of the raw backend string. **A step or PR the backend refuses for credits.** The gates' credit checks fail open and can be out of date, so the Autofix endpoint has the final say: it answers 402 with `code: seer_out_of_credits`. `startStep` and `createPR` then recheck every Seer credit check, so the gates bring up their CTA and disable their buttons. They toast out-of-credits copy for the step, or for the repo's PR, instead of the backend's detail. A refused kickoff no longer paints a failed run that says "This one is on us", since the start card offers the CTA. | | Before | After | | --- | --- | --- | | Start Analysis, refused for credits | [](https://github.com/user-attachments/assets/02bdab75-3964-4544-8162-0f274e783723) | [](https://github.com/user-attachments/assets/46901430-d942-4272-ae2d-ad31b4efa924) | | Yes, draft a PR, refused for credits | [](https://github.com/user-attachments/assets/3f597c66-0996-43cd-8d52-53a5b7b7fe61) | [](https://github.com/user-attachments/assets/d584d5e9-0540-4e6e-a5fd-cad1ef705794) | These use the real drawer and `useExplorerAutofix`, with the Autofix endpoint stubbed in the browser: it refuses with a 402 and `code: seer_out_of_credits`, and the credit check says the organization can pay until that refusal. Before is this branch without the commit that handles the refusal. **Retries follow the credit check.** Each retry stays on screen. While the credit check says the org can't afford the operation, the retry is disabled, and its tooltip reads "Your organization does not have enough Seer credits for this." The check refetches on mount and window focus, so the retry turns back on once the org tops up. Until this mount's check answers, the retry stays disabled, even with an earlier answer cached, so it never flashes on. Only retries on screen for a credit failure run the check. Each retry checks its autofix action through #129565's `useAutofixCreditCheck`, so both gates read one action-to-operation map. | Retry | Where | Operation | |---|---|---| | Re-run, header Re-run step | Root cause card | `autofix_root_cause` | | Re-run, header Re-run step | Plan card | `autofix_solution` | | Re-run, header Re-run step | Code changes card | `autofix_code_changes` | | Add context & retry, header Re-run step | Code changes card, iteration stopped | `autofix_pr_iteration` | | Retry PR | Pull Requests card, inbox preview | `autofix_open_pr` | | Try again | Chat autofix card | the step that stopped | | Draft a pull request | Chat code changes card, after a PR failed for credits | `autofix_open_pr` | Decisions the spec doesn't cover, for review: - The spec has no failure copy. The status lines keep the earlier headlines, one sentence each, and the tooltip is new. - Without `seer-credit-checks` the hook reports enough credits, so a stopped step shows its retry enabled and the backend decides. - Only retries of something that stopped for credits are gated here. Retries after other failures, and re-runs of finished steps, don't call the credit check. The chat card's "Draft a pull request" is the exception: #129565 already holds it on `autofix_open_pr` for every run, so this PR only adds the tooltip when the earlier create failed for credits. - On a drawer card that stopped for credits, the header Re-run step does what it does on a finished card: it opens the context prompt, or Seer chat where the card offers chat. On cards that failed for other reasons, it still shows nothing. - A stopped PR iteration is retried through the PR feedback form. Since #129036 dropped the `autofix-pr-iteration-manual` gate, that retry is always there once the run has a PR. `hideErroredPrIteration` still hides CI-driven iterations that fail, whether or not they ran out of credits. - The chat card's "Try again" sends a chat message, so the composer's `agent_chat_message` gate also applies to it. On a code changes card whose iteration stopped, it still asks Seer to retry the Code Changes step, as it does for other failures, but it waits for the `autofix_pr_iteration` check. - The PR links bar has no retry and no status line. Its tooltip is the only status, and the composer's alert carries the CTA. | Location | Screenshot | | --- | --- | | Seer drawer › Code Changes, stopped for credits | [](https://github.com/user-attachments/assets/84d04adf-3768-4382-ad0d-73d8a5114675) | | Seer drawer › Code Changes, stopped for credits, after a top-up | [](https://github.com/user-attachments/assets/efdb02f1-fcac-41a7-a6bc-504d5fd19baa) | | Seer drawer › Code Changes, PR iteration stopped for credits | [](https://github.com/user-attachments/assets/0e9336ca-b6e7-4925-b73e-1afc483367fa) | | Seer drawer › Pull Requests, failed for credits | [](https://github.com/user-attachments/assets/9ec8a50d-fd8d-4f99-a0d7-a4673a36f95d) | | Seer Explorer › autofix card › Code Changes, stopped for credits | [](https://github.com/user-attachments/assets/0f4b9102-455a-4227-964d-42a258b74ca0) | | Seer Explorer › autofix card › Pull Request, failed for credits | [](https://github.com/user-attachments/assets/aa4eb9a6-6cc2-4c7e-b78b-13b026bc9bd1) | | Seer Explorer › conversation, run stopped for credits | [](https://github.com/user-attachments/assets/c22f2909-1946-4e1d-bb15-145e1bf9a239) | | Seer Explorer › PR links bar, failed for credits | [](https://github.com/user-attachments/assets/3ceb10e3-b9c1-47f9-a386-5a29d0ccbd76) | The screenshots come from the stories. Members see "Contact Admin" only when their org can self-serve, so the two captures with a CTA used a self-serve subscription. Fixes CW-2328 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Adds
useSeerCreditCheck(operation), which asksGET /organizations/{org}/seer/credit-check/?operation=…whether the org can afford one Seer operation (an autofix step or a chat message) and returnshasEnoughCredits. Nothing uses it yet; the gating PRs stacked on this one do.seer-credit-checks. Without the flag, when disabled, or when the request fails, it returnshasEnoughCredits: true, so a broken check never blocks Seer and the backend still has the final say.isPendingis only true while a check is in flight (a disabled TanStack query reports pending forever), so callers can show a placeholder instead of flashing the start button.useOrganizationSeerSetup: setup-check is mounted on many pages that should not make a billing call, so this one should only be mounted where a Seer trigger is about to show.staleTime: 0because credits change outside the page (a run elsewhere spends them, a billing member tops up in another tab), so the check reruns on mount and window focus.The endpoint landed in #129130.
Fixes CW-2327
🤖 Generated with Claude Code