Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Usage rings: go back to the bot's own AI when the picked one stops reporting

enixmomo-git1544eaa0cc5d
diff --git a/src/components/EngineUsage.tsx b/src/components/EngineUsage.tsx
index 49d36b6db0..2f756d722e 100644
--- a/src/components/EngineUsage.tsx
+++ b/src/components/EngineUsage.tsx
@@ -178,7 +178,7 @@ export function UsageRows({ limit }: { limit: EngineLimit }) {
function UsageOverview({ engine }: { engine: string | undefined }) {
const limits = useEngineLimits().filter(reportsUsage);
const [picked, setPicked] = useState<string>();
- const shown = limits.find((limit) => limit.engine === (picked ?? engine));
+ const shown = limits.find((limit) => limit.engine === picked) ?? limits.find((limit) => limit.engine === engine);
const now = Date.now();
return (
<div className="flex flex-col gap-2.5">
diff --git a/src/components/ModelPicker.usage.test.ts b/src/components/ModelPicker.usage.test.ts
index 075d420be0..419e97c0f3 100644
--- a/src/components/ModelPicker.usage.test.ts
+++ b/src/components/ModelPicker.usage.test.ts
@@ -187,6 +187,19 @@ describe("the model menu's usage rings", () => {
expect(document.querySelector("[data-model-picker-content]")).not.toBeNull();
});
+ it("go back to the bot's own AI when the pressed AI stops reporting usage", async () => {
+ remember([usage(38), other("codex", "Codex", 91)]);
+ const menu = await openMenu();
+ flushSync(() => rings(menu)[1]!.click());
+ expect(shownRows(menu)).toEqual(["weekly"]);
+ remember([usage(38)]);
+ expect(menu.querySelector("[data-usage-rings]")).toBeNull();
+ expect(shownRows(menu)).toEqual(["5-hour", "weekly"]);
+ remember([usage(38), other("gemini", "Gemini", 50)]);
+ expect(rings(menu).map((ring) => ring.getAttribute("aria-pressed"))).toEqual(["true", "false"]);
+ expect(shownRows(menu)).toEqual(["5-hour", "weekly"]);
+ });
+
it("draw less of the ring as the usage runs down, and none at the limit", async () => {
remember([usage(25), other("codex", "Codex", 75), other("gemini", "Gemini", 100, true)]);
const menu = await openMenu();