Display error max token reached in Studio Code Desktop - #4077
Merged
Conversation
katinthehatsite
marked this pull request as draft
July 3, 2026 15:00
Collaborator
📊 Performance Test ResultsComparing 35633ec vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
added 2 commits
July 6, 2026 11:48
…-error-when-reaching-limits
katinthehatsite
marked this pull request as ready for review
July 6, 2026 13:44
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a dedicated “usage cap reached” error path for Studio Code Desktop so that HTTP 429 responses from the WordPress.com proxy are surfaced to users as a friendly, actionable message (and shown as a banner above the composer rather than as a generic run error).
Changes:
- Added a shared
isUsageCapError()helper inpackages/commonto detect usage-cap (429) errors by message pattern. - Updated Studio Code session run handling to translate detected 429 errors into a friendly message and expose
usageCapReachedstate to the UI. - Rendered a new usage-cap banner above the composer in the Studio renderer; updated CLI UI to reuse the shared helper.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/common/ai/json-events.ts | Adds isUsageCapError() helper used by CLI + Desktop to identify usage-cap errors. |
| apps/studio/src/components/studio-code-session/use-agent-run.tsx | Detects usage-cap errors, maps them to a friendly i18n string, and tracks usageCapReached in run state. |
| apps/studio/src/components/studio-code-session/index.tsx | Routes usage-cap messaging to the composer via a new usageCapMessage prop. |
| apps/studio/src/components/studio-code-session/composer/style.module.css | Adds styling for a usage-cap banner above the composer. |
| apps/studio/src/components/studio-code-session/composer/index.tsx | Renders an alert banner when usageCapMessage is set. |
| apps/cli/ai/ui.ts | Replaces inline 429 regex detection with the shared isUsageCapError() helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
435
to
+440
| <div className={ styles.root }> | ||
| { usageCapMessage ? ( | ||
| <div className={ styles.usageCapBanner } role="alert"> | ||
| { usageCapMessage } | ||
| </div> | ||
| ) : null } |
Contributor
Author
There was a problem hiding this comment.
Merged the suggestion 👍
nightnei
reviewed
Jul 7, 2026
…-error-when-reaching-limits
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Volodymyr Makukha <nei.css@gmail.com>
…utomattic/studio into fix/display-error-when-reaching-limits
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.

Related issues
Fixes STU-1825
How AI was used in this PR
It was used to implement the feature.
Proposed Changes
This PR ensures that we throw an error when the usage limit is reached in the Studio Code UI.
Testing Instructions
npm startCurrently, it looks like this:
I am not sure on the design so leaving it up for discussion.
I tried to use the
metafield below the input field but it was looking like this, which I think was looking even worse:Pre-merge Checklist