From d0c8e30f242462f1589ea3a11cb8b7f48ca3db29 Mon Sep 17 00:00:00 2001 From: huhn511 Date: Sat, 20 Jun 2026 17:25:40 +0200 Subject: [PATCH] feat(ai-settings): show remaining free MIND allotment + out-of-allotment prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the coder runs on the bridge's built-in key and the ledger is on, the "Your AI" panel now shows the remaining free MIND ("… N free MIND left") and, at zero, prompts the user to add their own key. Uses the new `freeBalance` from the bridge's GET /api/profile/ai; null (own key, or ledger off) renders the existing copy unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/components/AiSettings.tsx | 8 +++++++- src/lib/builder/bridge-client.ts | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/AiSettings.tsx b/src/components/AiSettings.tsx index ebd4af9..e304424 100644 --- a/src/components/AiSettings.tsx +++ b/src/components/AiSettings.tsx @@ -152,8 +152,14 @@ export function AiSettings({ webid }: { webid: string | null }) { if (!data) return null; if (data.summary.source === "user-pref") return `Right now your apps are built with ${data.summary.providerLabel} · ${data.summary.model}.`; - if (data.summary.source === "env-fallback") + if (data.summary.source === "env-fallback") { + const free = data.freeBalance; + if (typeof free === "number" && free <= 0) + return "You’ve used your free AI allotment. Add your own key below to keep building."; + if (typeof free === "number") + return `Right now your apps are built with the free built-in AI — ${free} free MIND left. Add your own key for a faster, smarter AI.`; return "Right now your apps are built with the free built-in AI."; + } return "No AI is set up yet — add a key below to start building."; })(); diff --git a/src/lib/builder/bridge-client.ts b/src/lib/builder/bridge-client.ts index 770ad34..a8eda94 100644 --- a/src/lib/builder/bridge-client.ts +++ b/src/lib/builder/bridge-client.ts @@ -298,6 +298,12 @@ export type AiSettings = { providers: AiConfiguredProvider[]; pref: AiPref; summary: AiSummary; + /** + * Remaining free MIND allotment, when the coder would run on the bridge's + * built-in key and the ledger is on. null when on the user's own key or the + * ledger is off — render the source-based copy unchanged. + */ + freeBalance?: number | null; catalog: AiCatalogEntry[]; };