Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(chat): de-emphasize expired usage limit errors
DiogoTS116e0457b98de6
diff --git a/src/components/ChatView.controls.test.ts b/src/components/ChatView.controls.test.tsindex cf5f14c269..3d5625d2d4 100644--- a/src/components/ChatView.controls.test.ts+++ b/src/components/ChatView.controls.test.ts@@ -424,6 +424,36 @@ describe("thread control placement", () => {expect(markup).toContain("Manage usage");expect(markup).not.toContain("<button");});+ it("turns an expired usage-limit error into history without hiding a new refusal", () => {+ const codex = { instanceId: "codex", driverKind: "codex", displayName: "Codex",+ snapshot: { state: "available", authenticated: true } } as unknown as InstanceInfo;+ const reset = Date.now() - 60_000;+ const limit = failedTurnTool(CODEX_USAGE_LIMIT_REACHED, { limitResetsAt: reset });+ const historical = renderToStaticMarkup(createElement(FailedTurnRow, {+ tool: limit, engine: codex, messageAt: reset - 10_000,+ }));+ expect(historical).toContain("Past usage-limit notice");+ expect(historical).toContain(CODEX_USAGE_LIMIT_REACHED.replaceAll("'", "'"));+ expect(historical).not.toContain("Manage usage");++ const recent = renderToStaticMarkup(createElement(FailedTurnRow, {+ tool: limit, engine: codex, messageAt: reset + 1_000,+ }));+ expect(recent).not.toContain("Past usage-limit notice");+ expect(recent).toContain("Manage usage");++ const pending = renderToStaticMarkup(createElement(FailedTurnRow, {+ tool: failedTurnTool(CODEX_USAGE_LIMIT_REACHED, { limitResetsAt: Date.now() + 60_000 }),+ engine: codex, messageAt: Date.now() - 1_000,+ }));+ expect(pending).not.toContain("Past usage-limit notice");+ expect(pending).toContain("Manage usage");++ const unknown = renderToStaticMarkup(createElement(FailedTurnRow, {+ tool: failedTurnTool(CODEX_USAGE_LIMIT_REACHED), engine: codex, messageAt: reset - 10_000,+ }));+ expect(unknown).toContain("Manage usage");+ });it("opens a signed-out engine's failed turn with one sentence and the sign-in, the CLI's words under Details", () => {const claude = {instanceId: "claude", driverKind: "claudeAgent", displayName: "Claude",diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsxindex 60bc869e25..70c16dfbca 100644--- a/src/components/ChatView.tsx+++ b/src/components/ChatView.tsx@@ -273,19 +273,47 @@ function TrialCreditFailedRow({ kind, onRetry }: { kind: TrialCreditRefusal; onRreturn <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 }: {+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;+ const delay = at - Date.now();+ if (delay <= 0) {+ setClock(Date.now());+ return;+ }+ const timer = setTimeout(() => setClock(Date.now()), Math.min(delay + 1_000, 2_147_483_647));+ return () => clearTimeout(timer);+ }, [tool.limitResetsAt]);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 = 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">Past usage-limit notice (reset time passed; check current usage)</summary>+ <p className="mt-2 break-words">{notice ?? cause}</p>+ </details>+ );+ }const signedOut = signedOutEngine(tool, engine);return (<ErrorRow@@ -754,6 +782,7 @@ const MessagesList = memo(function MessagesList({return (<FailedTurnRowtool={m.tool}+ messageAt={m.at}engine={engine}botId={botId}threadId={threadId}diff --git a/src/components/GroupView.tsx b/src/components/GroupView.tsxindex b2ae592cc9..cc143ebef1 100644--- a/src/components/GroupView.tsx+++ b/src/components/GroupView.tsx@@ -107,7 +107,7 @@ export function RoomToolChip({ message, roomId, threadId, live = false }: { messif (!tool) return null;if (message.threadRef) return <ThreadChip message={message} />; if (message.relay) return <TeammateChip message={message} />;if (failedTurnCause(tool.name) !== null) {- return <FailedTurnRow tool={tool} engine={botEngine(state.bots.find((b) => b.id === message.from?.botId), state.instances)} botId={message.from?.botId} />;+ return <FailedTurnRow tool={tool} engine={botEngine(state.bots.find((b) => b.id === message.from?.botId), state.instances)} botId={message.from?.botId} messageAt={message.at} />;}const comm = message.comm;if (comm && comm.groupId !== roomId) {