Skip to content

Commit 600a972

Browse files
feat(web): a ring around the sidebar account icon shows the allowance left
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9cd7e51 commit 600a972

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ import { ProjectFavicon, type ProjectFaviconProject } from "./ProjectFavicon";
265265
import { PROJECT_ICON_COLORS } from "../projectIconColors";
266266
import { ThreadSearchMatchExcerpt } from "./ThreadSearchMatch";
267267
import { makeWorkspaceFileDropHandlers } from "./chat/workspaceFileDrop";
268+
import { usageHeadroomPercent } from "@t3tools/shared/usageLimitSwitch";
268269
import { ProviderInstanceIcon } from "./chat/ProviderInstanceIcon";
269270
import { getTriggerDisplayModelLabel } from "./chat/providerIconUtils";
270271
import {
@@ -442,6 +443,7 @@ function SidebarProviderStack(props: {
442443
acpRegistryAgentId={currentEntry.acpRegistryAgentId}
443444
acpRegistryIconUrl={currentEntry.acpRegistryIconUrl}
444445
showBadge={showInstanceBadge}
446+
remainingPercent={usageHeadroomPercent(currentEntry.snapshot)}
445447
// Glyph dims, badge stays saturated; offset matches the composer trigger.
446448
iconClassName="size-3.5 opacity-60"
447449
badgeClassName="right-[-0.1875rem] bottom-[-0.1875rem] h-3 min-w-3 px-0.5 text-5xs"

‎apps/web/src/components/chat/ProviderInstanceIcon.tsx‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ export const ProviderInstanceIcon = memo(function ProviderInstanceIcon(props: {
6767
badgeClassName?: string;
6868
statusDotClassName?: string;
6969
indicatorBackground?: string;
70+
/**
71+
* Allowance left in the account's tightest usage window, 0 to 100. Draws a
72+
* ring around the icon that empties with it; omit for accounts that report
73+
* no usage.
74+
*/
75+
remainingPercent?: number | null | undefined;
7076
}) {
7177
const Icon = PROVIDER_ICON_BY_PROVIDER[props.driverKind] ?? null;
7278
const packageIcon = providerClients.get(props.driverKind)?.icon;
@@ -112,6 +118,35 @@ export const ProviderInstanceIcon = memo(function ProviderInstanceIcon(props: {
112118
{providerInstanceInitials(props.displayName)}
113119
</span>
114120
)}
121+
{props.remainingPercent != null ? (
122+
<svg
123+
viewBox="0 0 36 36"
124+
className="pointer-events-none absolute -inset-1 -z-10 -rotate-90"
125+
aria-hidden
126+
>
127+
<circle
128+
cx="18"
129+
cy="18"
130+
r="16"
131+
fill="none"
132+
strokeWidth="2.5"
133+
className="stroke-muted-foreground/20"
134+
/>
135+
<circle
136+
cx="18"
137+
cy="18"
138+
r="16"
139+
fill="none"
140+
strokeWidth="2.5"
141+
strokeLinecap="round"
142+
pathLength={100}
143+
strokeDasharray={`${Math.max(0, Math.min(100, props.remainingPercent))} 100`}
144+
className={
145+
props.remainingPercent < 10 ? "stroke-destructive" : "stroke-muted-foreground/70"
146+
}
147+
/>
148+
</svg>
149+
) : null}
115150
{props.statusDotClassName ? (
116151
<span
117152
className={cn(

0 commit comments

Comments
 (0)