AI credits: Warn at 80% usage in the sidebar and above the Classic composer - #4722
AI credits: Warn at 80% usage in the sidebar and above the Classic composer#4722gcsecsey wants to merge 5 commits into
Conversation
7e845fe to
cb27ce7
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The Classic warning has unresolved RTL alignment and screen-reader announcement defects.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds dismissible AI-credit usage warnings at 80%, coordinating Agentic UI sidebar and Classic composer behavior.
Changes:
- Adds shared threshold, dismissal, and localized-copy utilities.
- Adds Agentic sidebar and Classic composer warnings with purchase actions.
- Covers threshold transitions and dismissal behavior with tests.
File summaries
| File | Description |
|---|---|
packages/common/lib/studio-assistant-quota.ts |
Adds shared warning logic and copy. |
packages/common/lib/tests/studio-assistant-quota.test.ts |
Tests shared threshold behavior. |
apps/ui/src/ui-classic/components/session-view/composer/ai-credits-warning-strip.tsx |
Reuses shared warning title formatting. |
apps/ui/src/data/queries/use-app-messages.ts |
Adds the Agentic sidebar warning. |
apps/ui/src/data/queries/use-app-messages.test.tsx |
Tests sidebar warning behavior. |
apps/ui/src/data/ai-credits-notice.ts |
Stores session-only dismissal state. |
apps/ui/src/data/ai-credits-notice.test.ts |
Tests dismissal subscriptions. |
apps/ui/src/components/app-message-cards/index.tsx |
Renders the shared purchase action. |
apps/studio/src/stores/ui-slice.ts |
Stores Classic dismissal state. |
apps/studio/src/components/tests/ai-credits-threshold-notice.test.tsx |
Tests the Classic warning. |
apps/studio/src/components/studio-code-session/tests/session-not-found.test.tsx |
Updates store mocks. |
apps/studio/src/components/studio-code-session/tests/access-requirements.test.tsx |
Updates store mocks. |
apps/studio/src/components/studio-code-session/index.tsx |
Places the warning above the composer. |
apps/studio/src/components/ai-credits-threshold-notice.tsx |
Implements the Classic warning card. |
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Does it make sense to use the Notice component (https://wordpress.github.io/gutenberg/?path=/docs/design-system-components-notice--docs) for the Classic UI? -- Can we make the yellow background color a little more vibrant in dark mode? Its blending in a bit too much in the screenshots. |
Thanks @shaunandrews, I think you're right and adopting the Notice is the right direction here. I pushed these changes just now and updated the screenshots on the PR. I also updated the yellow color in dark mode on #4714. |
|
Thanks, looks good! |
Related issues
How AI was used in this PR
I used Opus 5 for implementation and tests.
Proposed Changes
This PR adds a dismissible warning at 80% to the sidebar, with a purchase CTA. It is also shown again at these points:
Classic has no sidebar cards, so its warning sits above the composer instead. It has no composer strip either, so that one slot covers the 90% step as well.
The copy is the approved wording from the exploration in #4446. Still I'd appreciate a final look @shaunandrews.
Testing Instructions
Use the balance setup steps in 236947-ghe-Automattic/wpcom.
At 83% usagewithAdd AI credits, and the composer shows no strip.At 92% usage, and the sidebar shows nothing. This is the duplication the issue is about.Check both color schemes, a narrow window, and an RTL locale such as Arabic.
Agentic UI:
Classic:
Pre-merge Checklist