Uh oh!
There was an error while loading. Please reload this page.
feat(app-shell): proactive AI usage indicator in the ChatDock (ADR-0057 #8) - #2498
Merged
Conversation
…the ChatDock (ADR-0057 #8) Surfaces remaining AI headroom BEFORE a send hits the 429 wall, instead of only learning the limit reactively. Consumes the cloud `GET /api/v1/ai/usage` endpoint. - AiUsageIndicator (app-shell): two meters (build + dataChat) as small progress rings in the ChatDock header (desktop rail + mobile sheet). Near-full → amber "running low" + a popover with "resets tonight/next cycle" and the upgrade / top-up CTA, reusing the 429 deep-link (cloudPricingDeepLink). D5-safe: renders fractions/qualitative words only, never a token number. Hides itself when the endpoint is absent (older backend / OSS / no seat) — fail-soft, never broken. - useAiUsage (app-shell): fetches the D5-safe per-meter fractions; refetches on the chat engine's post-turn / 429 nudge and on tab re-focus; inert without an apiBase; fails soft to null on any error. - useObjectChat (plugin-chatbot): emits AI_USAGE_REFRESH_EVENT on a rejected send (429) and on the loading→ready turn-finish edge, so the ring moves right after the user's action. Decoupled window event — no callback threaded through ChatPane. - i18n: console.ai.usage.* in en + zh-CN. Depends on cloud PR #824 (the read endpoint) being deployed; until then the indicator stays hidden. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
❌ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Why
Today a user only learns they've hit an AI quota reactively — the send returns a 429. This adds a proactive indicator in the ChatDock header so remaining headroom is visible before the wall. It's the objectui half of ADR-0057 #8; the cloud read endpoint is objectstack-ai/cloud#824.
What
AiUsageIndicator(packages/app-shell/src/layout/AiUsageIndicator.tsx) — two independent meters (build+dataChat) as small progress rings, mounted in both the desktop ChatDock rail header and the mobile sheet header.cloudPricingDeepLink).useAiUsage(packages/app-shell/src/hooks/useAiUsage.ts) — fetches the D5-safe per-meter fractions; refetches on the chat engine's post-turn / 429 nudge and on tab re-focus; inert without anapiBase; fails soft tonull.useObjectChat(packages/plugin-chatbot) — emits a decoupledAI_USAGE_REFRESH_EVENTon a rejected send (429) and on the loading→ready turn-finish edge, so the ring updates right after the user's action. No callback threaded throughChatPane.console.ai.usage.*in en and zh-CN.Tests
useAiUsage.test.ts— fetch/parse, credentials, fail-soft on 404, inert w/o apiBase, refetch on the event.AiUsageIndicator.test.tsx— hides on null/unmetered, renders on numeric fraction, "running low" hint, D5 (no token numbers in output), and the CTA opening the upgrade deep-link.ChatDock.test.tsxupdated to stub the indicator so its chrome tests stay focused.17 app-shell tests + the plugin-chatbot send-failure/handoff suites pass;
tsc --noEmitclean on app-shell, plugin-chatbot, and i18n.Dependency / sequencing
Runtime-only dependency on cloud#824 (no compile-time import across repos). Merge cloud#824 first; until the endpoint is deployed the indicator stays hidden (fail-soft), so this is safe to merge independently. Live browser verification awaits the endpoint deploy.
🤖 Generated with Claude Code