Skip to content

Commit 3e6727c

Browse files
fix(usage): keep the environment picker when the default target is read-only
Gating the whole header on the target's operate access hid the picker along with the button, so a read-only default left no way to choose an operable environment. The picker now stays whenever several are connected; only the button follows the picked target, disabled with a reason when that target cannot be written. Co-Authored-By: Claude Code <[email protected]>
1 parent f790a41 commit 3e6727c

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

‎apps/web/src/components/usage/UsageLimits.tsx‎

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,10 @@ export function UsageLimitsSection() {
590590
Quota from a CLIProxyAPI hub shows beside the providers signed in on this machine.
591591
</p>
592592
</div>
593-
{targetEnvironment && canOperateTarget ? (
593+
{/* The picker stays whenever several environments are connected, so
594+
a read-only default target does not hide the way to an operable
595+
one; only the button follows the picked target's access. */}
596+
{targetEnvironment ? (
594597
<div className="flex items-center gap-2">
595598
{connected.length > 1 ? (
596599
<Select
@@ -616,10 +619,33 @@ export function UsageLimitsSection() {
616619
</SelectPopup>
617620
</Select>
618621
) : null}
619-
<Button size="xs" variant="outline" onClick={() => setAdding(true)}>
620-
<PlusIcon className="size-3" aria-hidden />
621-
Add hub
622-
</Button>
622+
{canOperateTarget ? (
623+
<Button size="xs" variant="outline" onClick={() => setAdding(true)}>
624+
<PlusIcon className="size-3" aria-hidden />
625+
Add hub
626+
</Button>
627+
) : (
628+
<Tooltip>
629+
<TooltipTrigger
630+
render={
631+
<span
632+
tabIndex={0}
633+
className="rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring"
634+
/>
635+
}
636+
>
637+
<span className="inline-flex" inert>
638+
<Button size="xs" variant="outline" disabled>
639+
<PlusIcon className="size-3" aria-hidden />
640+
Add hub
641+
</Button>
642+
</span>
643+
</TooltipTrigger>
644+
<TooltipPopup side="top" className="max-w-72">
645+
Your session cannot change settings on {targetEnvironment.label}.
646+
</TooltipPopup>
647+
</Tooltip>
648+
)}
623649
</div>
624650
) : null}
625651
</div>

0 commit comments

Comments
 (0)