feat: claude quotas
CI / verify (pull_request) Successful in 9s

This commit is contained in:
2026-10-07 14:49:00 +02:00
parent 0c7ac2b532
commit f6c69c7db0
6 changed files with 405 additions and 19 deletions
+31 -11
View File
@@ -61,24 +61,44 @@ export default Plugin.define({
});
const Slot = (props: { instance: string; centered?: boolean; visible?: () => boolean }) => {
const [status] = createResource(
const [statuses] = createResource(
() => (props.visible?.() === false ? false : `${props.instance}:${revision()}`),
() => loadQuotaStatus(() => quota.status({})),
async () => {
const [chatgpt, claude] = await Promise.all([
loadQuotaStatus(() => quota.status({})),
loadQuotaStatus(() => quota.claude({})),
]);
return chatgpt || claude ? { chatgpt, claude } : null;
},
);
const Section = (section: { title: string; status: QuotaStatus | null }) => (
<Show when={section.status}>
{(status: () => QuotaStatus) => (
<>
<text fg={context.theme.text.default}>
<b>
{section.title} quota ({status().plan})
</b>
</text>
<For each={status().windows}>
{(window) => (
<text fg={context.theme.text.muted}>
{formatQuotaWindow(window)}
</text>
)}
</For>
</>
)}
</Show>
);
const Content = () => (
<box flexDirection="column">
<text fg={context.theme.text.default}>
<b>ChatGPT quota ({status()!.plan})</b>
</text>
<For each={status()!.windows}>
{(window) => (
<text fg={context.theme.text.muted}>{formatQuotaWindow(window)}</text>
)}
</For>
<Section title="ChatGPT" status={statuses()!.chatgpt} />
<Section title="Claude" status={statuses()!.claude} />
</box>
);
return (
<Show when={status()}>
<Show when={statuses()}>
<Show when={props.centered} fallback={<Content />}>
<box position="absolute" top={2} left={0} width="100%" alignItems="center">
<Content />