Skip to content

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

fix(chat): move past usage-limit notice into EngineUsage, record locale hashes

milind-sonifa8f2555d7dc
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index 3083db1d2c..99b81ca8fc 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -80,7 +80,7 @@ import { RichMessageRow, UserLineNote, richRowKind } from "./RichMessageRow"; im
import { Composer } from "./Composer";
import { ChatErrorBanner, ChatNotice } from "./ChatErrorBanner";
import { ThreadContextWarning } from "./ContextWarning";
-import { UsageAlert, useLimitResetContinue } from "./EngineUsage";
+import { UsageAlert, useLimitResetContinue, usePastLimitNotice } from "./EngineUsage";
import { ChatFindBar } from "./ChatFindBar";
import { ReplyQuote } from "./ReplyQuote";
import { ConnectorCard } from "./ConnectorCard";
@@ -273,51 +273,15 @@ function TrialCreditFailedRow({ kind, onRetry }: { kind: TrialCreditRefusal; onR
return <ErrorRow message={t(TRIAL_CREDIT_LINE[kind])} action={{ label: t("chat.error.connectOwnAi"), onClick: () => dispatch({ type: "toggleAppSettings", open: true, section: "engines" }) }} />;
}
-export function FailedTurnRow({ tool, engine, onRetry, botId, threadId, messageAt }: {
- tool: NonNullable<Message["tool"]>;
- engine: InstanceInfo | undefined;
- onRetry?: () => void;
- botId?: string;
- threadId?: string;
- messageAt?: number;
-}) {
+export function FailedTurnRow({ tool, engine, onRetry, botId, threadId, messageAt }: { tool: NonNullable<Message["tool"]>; engine: InstanceInfo | undefined; onRetry?: () => void; botId?: string; threadId?: string; messageAt?: number }) {
const resume = useLimitResetContinue(botId, threadId, tool.limitResetsAt);
- const [clock, setClock] = useState(Date.now);
- useEffect(() => {
- const at = tool.limitResetsAt;
- if (typeof at !== "number" || !Number.isFinite(at)) return;
- let timer: ReturnType<typeof setTimeout> | undefined;
- const arm = () => {
- const remaining = at - Date.now();
- if (remaining <= 0) {
- setClock(Date.now());
- return;
- }
- timer = setTimeout(arm, Math.min(remaining + 1_000, 2_147_483_647));
- };
- arm();
- return () => { if (timer) clearTimeout(timer); };
- }, [tool.limitResetsAt]);
+ const past = usePastLimitNotice(tool, messageAt);
if (tool.place && botId) return <PlaceFailedRow place={tool.place} botId={botId} threadId={threadId} onRetry={onRetry} />;
const credit = trialCreditKind(failedTurnCause(tool.name) ?? "");
if (credit) return <TrialCreditFailedRow kind={credit} onRetry={onRetry} />;
const { cause, notice } = failedTurnNotice(tool);
if (tool.partial) return <PartlyDoneRow cause={notice ?? cause} onRetry={onRetry} />;
- // A past refusal remains in the transcript for evidence, not as a current blocker.
- // The reset time passing does not prove today's quota is available again.
- const expired = codexUsageLimitReached(cause) && typeof tool.limitResetsAt === "number" &&
- Number.isFinite(tool.limitResetsAt) &&
- typeof messageAt === "number" &&
- messageAt <= tool.limitResetsAt &&
- clock >= tool.limitResetsAt;
- if (expired) {
- return (
- <details className="my-1 w-fit max-w-[min(var(--chat-bubble-max),var(--chat-bubble-pct))] rounded-lg border border-hairline/40 bg-raised px-3 py-2 text-[12px] text-ink-secondary">
- <summary className="cursor-pointer">{t("chat.error.pastUsageLimit")}</summary>
- <p className="mt-2 break-words">{notice ?? cause}</p>
- </details>
- );
- }
+ if (past) return past;
const signedOut = signedOutEngine(tool, engine);
return (
<ErrorRow
@@ -785,8 +749,7 @@ const MessagesList = memo(function MessagesList({
if (m.tool && failedTurnCause(m.tool.name) !== null) {
return (
<FailedTurnRow
- tool={m.tool}
- messageAt={m.at}
+ tool={m.tool} messageAt={m.at}
engine={engine}
botId={botId}
threadId={threadId}
diff --git a/src/components/EngineUsage.tsx b/src/components/EngineUsage.tsx
index de1385da14..94bb0277a4 100644
--- a/src/components/EngineUsage.tsx
+++ b/src/components/EngineUsage.tsx
@@ -8,7 +8,9 @@ import {
type EngineLimit, type UsageTone,
} from "@/lib/limit-resets";
import type { Routine } from "@/lib/routines";
-import { api, useStore } from "@/state/store";
+import { api, useStore, type Message } from "@/state/store";
+import { failedTurnNotice } from "@/lib/failed-turn";
+import { codexUsageLimitReached } from "../../shared/codex-usage-limit";
import { openBotSettings } from "./bot-panel/panel-link";
import { threadUpdatedLabel } from "./SidebarThreadRow";
@@ -36,6 +38,36 @@ export function useLimitResetContinue(botId: string | undefined, threadId: strin
};
}
+/** A usage-limit refusal whose reset time has passed stays in the transcript as evidence, collapsed, not as a current
+ * blocker: the reset passing does not prove today's quota is available again. Null while the refusal is still current. */
+export function usePastLimitNotice(tool: NonNullable<Message["tool"]>, messageAt: number | undefined) {
+ const at = tool.limitResetsAt;
+ const [clock, setClock] = useState(Date.now);
+ useEffect(() => {
+ if (typeof at !== "number" || !Number.isFinite(at)) return;
+ let timer: ReturnType<typeof setTimeout> | undefined;
+ const arm = () => {
+ const remaining = at - Date.now();
+ if (remaining <= 0) {
+ setClock(Date.now());
+ return;
+ }
+ timer = setTimeout(arm, Math.min(remaining + 1_000, 2_147_483_647));
+ };
+ arm();
+ return () => { if (timer) clearTimeout(timer); };
+ }, [at]);
+ if (typeof at !== "number" || !Number.isFinite(at) || typeof messageAt !== "number" || messageAt > at || clock < at) return null;
+ const { cause, notice } = failedTurnNotice(tool);
+ if (!codexUsageLimitReached(cause)) return null;
+ return (
+ <details className="my-1 w-fit max-w-[min(var(--chat-bubble-max),var(--chat-bubble-pct))] rounded-lg border border-hairline/40 bg-raised px-3 py-2 text-[12px] text-ink-secondary">
+ <summary className="cursor-pointer">{t("chat.error.pastUsageLimit")}</summary>
+ <p className="mt-2 break-words">{notice ?? cause}</p>
+ </details>
+ );
+}
+
function useEngineUsage(engine: string | undefined): EngineLimit | undefined {
const limit = useEngineLimits().find((candidate) => candidate.engine === engine);
return reportsUsage(limit) ? limit : undefined;
diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.json
index a1106b3a7f..01012cd2d2 100644
--- a/src/locales/source-hashes.json
+++ b/src/locales/source-hashes.json
@@ -3394,7 +3394,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"es": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
@@ -9439,7 +9440,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"fr": {
"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",
@@ -12700,7 +12702,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"hi": {
"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",
@@ -15813,7 +15816,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"ja": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
@@ -23535,7 +23539,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"pt-br": {
"voice.gemini.keyPlaceholder": "8c87ba2043a4a89d63c90cae8a6dafd5cbd193652e923b97988e381a74773e10",
@@ -33308,7 +33313,10 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381",
+ "chat.notice.acpMcpAppsFailed": "d4e7b2a8d9464e8365bf1842d5e0eea17f602dc29834f58cd2d4d8b258387fba",
+ "chat.notice.acpMcpServerFailed": "0691e7f2e00e744d7a8092a5ff69a6be41fc3d998c0cd996bdf4ff6e31560bdd"
},
"zh": {
"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",
@@ -40916,7 +40924,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"zh-tw": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
@@ -50686,7 +50695,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"uk": {
"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",
@@ -54240,7 +54250,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"vi": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
@@ -59784,7 +59795,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"tr": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
@@ -65328,7 +65340,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"pl": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
@@ -72135,7 +72148,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"ru": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
@@ -79004,7 +79018,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"it": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
@@ -85673,7 +85688,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
},
"ko": {
"connectedWorkspaces.localTitle": "7d6deafeab011d734c3fdd1bfd6f69544fbb746a004019269bdb48544b01164b",
@@ -93064,7 +93080,8 @@
"remote.client.endsDec7": "5d9f8b310cc70fd59233acccd00c4fd201e3b33ef2ed79e4fc3aa491c95f8f35",
"phone.code.pairingCode": "1c5ea2f7ed52a91c82993d40cf16581ac6ccff5283e1840cad1a1857311d1121",
"phone.code.typeIntro": "eefcfc11ed512a8866f3764a972fa5a7c7bdd01bcbe4cb1681c37ae697f69fe1",
- "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128"
+ "phone.signIn.emailCode": "81c2e322abeb89f738de06ccdbefa7893c976a129b89c194299c75bd490fe128",
+ "chat.error.pastUsageLimit": "7c63a440471f4d20b5ce89b6e9c83547db02d840c79cbe7a4913b06e5a57c381"
}
}
}