Skip to content

feat(seer): Gate agent chat on Seer credits - #129563

Merged
billyvg merged 11 commits into
masterfrom
billyvong/cw-2332-sentry-ui-gate-agent-chat-before-sending
Nov 9, 2026
Merged

billyvg merged 11 commits into
masterfrom
billyvong/cw-2332-sentry-ui-gate-agent-chat-before-sending

Conversation

@billyvg

@billyvg billyvg commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

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. feat(seer): Configure auto reload in a modal from the out-of-credits CTA #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 Seer Explorer › new chat, with credits
Seer Explorer › new chat, out of credits, auto reload off Seer Explorer › new chat, out of credits, auto reload off
Seer Explorer › conversation, out of credits, auto reload on Seer Explorer › conversation, out of credits, auto reload on
Credit usage meter › auto reload off, tooltip Credit usage meter › auto reload off, tooltip
Credit usage meter › auto reload on, tooltip Credit usage meter › auto reload on, tooltip
Credit usage meter › out of reloads, tooltip Credit usage meter › out of reloads, tooltip
Credit usage meter › out of credits, auto reload off, tooltip Credit usage meter › out of credits, auto reload off, tooltip
Credit usage meter › colors Credit usage meter › colors

Fixes CW-2332

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Nov 2, 2026

Copy link
Copy Markdown

CW-2332

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 2, 2026
@billyvg
billyvg force-pushed the billyvong/cw-2332-sentry-ui-gate-agent-chat-before-sending branch from a781f45 to b549aa9 Compare November 5, 2026 20:08
@billyvg
billyvg force-pushed the billyvong/cw-2321-sentry-ui-out-of-credits-cta-with-escalation branch from b2159ac to 53361ad Compare November 5, 2026 20:08
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Story previews

Preview the stories changed in this PR on the Vercel deployment:

Preview deployment: https://sentry-cynav3bo0.sentry.dev

@billyvg
billyvg force-pushed the billyvong/cw-2332-sentry-ui-gate-agent-chat-before-sending branch from b549aa9 to 60f9222 Compare November 5, 2026 20:33
@sentry

sentry Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 804 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

billyvg added a commit that referenced this pull request Nov 5, 2026
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 <noreply@anthropic.com>
@billyvg
billyvg force-pushed the billyvong/cw-2321-sentry-ui-out-of-credits-cta-with-escalation branch from d009d44 to dba69c6 Compare November 5, 2026 21:38
billyvg added a commit that referenced this pull request Nov 5, 2026
…s CTA

The story manifest loads MDX stories from gsApp, but knip only took gsApp's .stories.tsx files as
entry points, so it reported seerOutOfCreditsNotice.stories.mdx as unused. SeerOutOfCreditsCta
gets a temporary entry point until the credit gates in #129563 and #129565 render it, and
getSeerOutOfCreditsMessage is only used in its own file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@billyvg
billyvg force-pushed the billyvong/cw-2332-sentry-ui-gate-agent-chat-before-sending branch from 6c3d73b to 5e11518 Compare November 5, 2026 21:49
@billyvg
billyvg force-pushed the billyvong/cw-2321-sentry-ui-out-of-credits-cta-with-escalation branch from dba69c6 to a43272f Compare November 5, 2026 22:03
billyvg added a commit that referenced this pull request Nov 5, 2026
…s CTA

The story manifest loads MDX stories from gsApp, but knip only took gsApp's .stories.tsx files as
entry points, so it reported seerOutOfCreditsNotice.stories.mdx as unused. SeerOutOfCreditsCta
gets a temporary entry point until the credit gates in #129563 and #129565 render it, and
getSeerOutOfCreditsMessage is only used in its own file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@billyvg
billyvg force-pushed the billyvong/cw-2332-sentry-ui-gate-agent-chat-before-sending branch from 5e11518 to 0b82f19 Compare November 5, 2026 22:06
@billyvg
billyvg force-pushed the billyvong/cw-2332-sentry-ui-gate-agent-chat-before-sending branch from 5c07c7a to 61f0c8d Compare November 6, 2026 17:14
@billyvg
billyvg marked this pull request as ready for review November 6, 2026 17:26
@billyvg
billyvg requested review from a team as code owners November 6, 2026 17:26
@billyvg billyvg self-assigned this Nov 6, 2026
@billyvg
billyvg requested a review from srest2021 November 6, 2026 17:26

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@srest2021 srest2021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote #130463 to address running out of credits mid-run as well

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

billyvg and others added 10 commits November 9, 2026 13:46
When the org can't afford another chat message, the Seer chat shows the out-of-credits CTA
right above the composer and nothing sends: the send button and Enter, suggested questions,
timeout retry, /investigate, the autofix embeds' chat actions, and questions forwarded from
elsewhere, which wait in the composer instead. Typing stays enabled so the draft survives a
top-up.

The check only runs while the composer is on screen, and does nothing for orgs without
seer-credit-checks.

Fixes CW-2332

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Billing members of orgs with seer-credit-checks now see how much of the
org's Seer credits is used, next to the chat's send button. Hovering shows
the balance and the auto reload state, using the billing gates copy. The
meter is a getsentry override slot. It renders nothing in open source, or
when the wallet doesn't load.

The out-of-credits alert above the composer now passes reason="agent-chat"
to the reworked CTA.

Refs CW-2332

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…ates designs

The Seer chat composer gets the designs' toolbar row under the editor, and the
credit usage meter and send button move into it. The send button is the
designs' small up arrow. The editor and toolbar share one border and one focus
ring.

The meter's bar is the designs' 50x10 pill on a bordered track, and its tooltip
is 250px wide with a line's space between paragraphs. With auto reload off, the
tooltip only counts the month's credits, as in the designs; the out-of-credits
alert is where billing members turn auto reload on.

Refs CW-2332

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A question forwarded into the chat waits for the first credit check, but the
user's own sends went through in the meantime. One landing first left the
session non-empty, so the forwarded question was dropped, sent after it, or
replayed into the next new chat. While a forwarded question waits, the panel's
other sends wait too: the composer, suggestions, retry, /investigate, and the
autofix embeds.

Refs CW-2332

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app's query client turns refetch on window focus off by default, so after a
top-up or spend in another tab the meter kept its old numbers while the chat's
credit check updated. Its wallet and auto reload queries now refetch on focus
too.

Refs CW-2332

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Sofia Rest <68917129+srest2021@users.noreply.github.com>
InputSection's usageMeter prop renders whatever it gets in the toolbar under the
editor, before the send button. toolbarItems says where it shows rather than
what the chat happens to put there today.

Refs CW-2332

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The out-of-reloads tooltip link now reads "Configure auto-reload.", so the test
finds it by that name and the story describes where it goes.

Refs CW-2332

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@billyvg
billyvg force-pushed the billyvong/cw-2332-sentry-ui-gate-agent-chat-before-sending branch from deb6206 to 1eb7886 Compare November 9, 2026 18:48

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1eb7886. Configure here.

…rward

Each forwarded question remounts the chat, but React Query keeps the previous
panel's credit-check answer. The check isn't pending while that cached answer
exists, so a forwarded question acted on it. If it said the org was out of
credits but someone had topped up since, the question was parked in the
composer and never sent.

useSeerCreditCheck now also returns hasCheckedSinceMount, which only turns true
once the check answers or fails after the caller mounted. The chat waits on it
instead of isPending. Later window-focus refetches don't hold sends again.

Refs CW-2332

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@billyvg
billyvg requested a review from a team as a code owner November 9, 2026 19:01
@billyvg
billyvg merged commit 85412ae into master Nov 9, 2026
77 checks passed
@billyvg
billyvg deleted the billyvong/cw-2332-sentry-ui-gate-agent-chat-before-sending branch November 9, 2026 19:32
srest2021 added a commit that referenced this pull request Nov 9, 2026
…tion (#130463)

relates to CW-2332

depends on #129563, #130283,
#130284

The chat's credit check only runs when the panel opens or the window
regains focus. If credits run out partway through a conversation, the
message box stays enabled and the next send fails with a generic error.

This rechecks credits when:
- Seer stops a reply for credits (`failure_reason: out_of_credits`)
- a send comes back 402

so the out-of-credits notice and disabled message box show right away. A
402 no longer shows "There was an error sending your message"; the
recheck brings up the notice instead.

The recheck invalidates the credit check query, like
`useExplorerAutofix` does. That needed `useSeerCreditCheck` to turn off
with `enabled` instead of `skipToken`, so the key is the same either
way.

Example (it would show any intermediate thinking as well):
<img width="402" height="615" alt="× Seer Agent I"
src="https://github.com/user-attachments/assets/c7e056e8-73a7-4a5a-be32-62bcb80e1609"
/>

---------

Co-authored-by: Billy Vong <billy@sentry.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
srest2021 added a commit that referenced this pull request Nov 11, 2026
…ling access (#130803)

Problem: The credit usage meter next to the send button in the Seer chat
only rendered for members with `org:billing` (#129563). The designs show
it to every member, and every member can already read the wallet (`GET
/customers/{org}/seer-wallet/` uses `RelaxedBillingPermission`).

This PR: Show the meter to all members of orgs that have
`seer-credit-checks` and `token-billed-seer-enabled`.

Members without billing access see:
- the percent bar, with the same warning color rules
- "Your organization has used X% of your available credits." (no
"monthly" since we don't have permission to know if autoload is on or
not)
- "{remaining}/{total} credits remaining."
- no auto reload line and no "Configure auto-reload." link.

No UI change for members with billing access.

Before:
<img width="419" height="300" alt="image"
src="https://github.com/user-attachments/assets/91817863-2c7e-4714-b9cd-4278b6238d9f"
/>

After:
<img width="419" height="300" alt="image"
src="https://github.com/user-attachments/assets/b9492b99-aab8-411e-ab87-7bafc5c3ee6f"
/>

<!-- junior-request-attribution:start -->
via **sofia**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AD0B1UK2PQKS%3A1794419917.134109 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AD0B1UK2PQKS%3A1794419917.134109)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0B1UK2PQKS%3A1794419917.134109/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Sofia Rest <sofia.rest@sentry.io>

This branch was successfully deployed

1 active deployment
Preview — 76d19a5c Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants