@burdenoff/fe-libs 2026.1028.5 → 2026.1028.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -301,33 +301,34 @@ async function Ee(e, t, n, r = 3e5) {
301
301
  throw Error("Sandbox startup timed out");
302
302
  }
303
303
  async function De(e, t, n, r, i = 9e4, a) {
304
- let s = Date.now(), l = (t) => (E.getState().setSandboxWriteCapabilities(e, X(t)), t);
305
- if (S("waitForAssistantReady") !== "unsupported") for (; Date.now() - s < i;) {
306
- let n = Date.now();
304
+ let s = Date.now(), l = (t) => (E.getState().setSandboxWriteCapabilities(e, X(t)), t), u = S("waitForAssistantReady") === "unsupported";
305
+ if (!u) for (; Date.now() - s < i;) {
306
+ let n = Date.now(), d = i - (n - s);
307
+ if (d < 1e3) break;
307
308
  try {
308
309
  let u = await c({
309
310
  query: ae,
310
311
  operationName: "WaitForAssistantReady",
311
312
  variables: {
312
313
  id: e,
313
- timeoutSeconds: Math.max(1, Math.min(25, Math.floor((i - (Date.now() - s)) / 1e3))),
314
+ timeoutSeconds: Math.min(25, Math.floor(d / 1e3)),
314
315
  context: o(t, r)
315
316
  },
316
317
  workspaceId: t,
317
318
  authContext: r
318
319
  });
319
320
  w("waitForAssistantReady");
320
- let d = u.waitForAssistantReady;
321
- if ((d.waited || !d.ready) && a?.(), d.ready && d.health) return l(d.health);
322
- let f = Date.now(), p = i - (f - s);
323
- f - n < 400 && p > 0 && await new Promise((e) => setTimeout(e, Math.min(400, p)));
321
+ let f = u.waitForAssistantReady;
322
+ if ((f.waited || !f.ready) && a?.(), f.ready && f.health) return l(f.health);
323
+ let p = Date.now(), m = i - (p - s);
324
+ p - n < 400 && m > 0 && await new Promise((e) => setTimeout(e, Math.min(400, m)));
324
325
  } catch (e) {
325
326
  if (!C(e, "waitForAssistantReady")) throw e;
326
- T("waitForAssistantReady");
327
+ T("waitForAssistantReady"), u = !0;
327
328
  break;
328
329
  }
329
330
  }
330
- for (; Date.now() - s < i;) {
331
+ for (; u && Date.now() - s < i;) {
331
332
  try {
332
333
  return l(await k(e, t, "/health", "GET", void 0, n, r, "transport"));
333
334
  } catch (e) {
@@ -134,6 +134,7 @@ export * from './ui/AssistantMessageAttachments';
134
134
  export * from './ui/AssistantPendingWriteCard';
135
135
  export * from './ui/AssistantWriteProposalCard';
136
136
  export * from './ui/AssistantAiDisclaimer';
137
+ export * from './ui/AiCreditBalance';
137
138
  export * from './ui/AssistantWriteConfirmDialog';
138
139
  export * from './ui/useWriteProposalConfirm';
139
140
  export * from './ui/writeProposalPresentation';
@@ -305,6 +306,7 @@ export * from './appControls/text';
305
306
  export * from './turnOutcomeCopy';
306
307
  export * from './aiCredits';
307
308
  export * from './productAiCredits';
309
+ export * from './useAiCreditStatus';
308
310
  export * from './usageReporting';
309
311
  export * from './writeProposals';
310
312
  export * from './writeReplyBinder';
@@ -0,0 +1,36 @@
1
+ import { FC } from 'react';
2
+ import { AiCreditStatus } from '../productAiCredits';
3
+ export interface AiCreditBalanceViewProps {
4
+ /** The workspace's standing; null renders nothing. */
5
+ status: AiCreditStatus | null;
6
+ /** Extra layout classes from the mount point. */
7
+ className?: string;
8
+ /** Distinguishes the mounts in tests and in Playwright checks. */
9
+ testId?: string;
10
+ /** Number formatting locale. Defaults to the browser's. */
11
+ locale?: string;
12
+ }
13
+ /**
14
+ * Pure presentation of a credit status: nothing for an unknown or unmetered
15
+ * workspace (never a guessed "0 left"), the remaining credits otherwise.
16
+ */
17
+ export declare const AiCreditBalanceView: FC<AiCreditBalanceViewProps>;
18
+ export interface AiCreditBalanceProps extends Omit<AiCreditBalanceViewProps, 'status'> {
19
+ /** Product registry key, for example `fluidgrids`. Reads `<productKey>.ai.credits`. */
20
+ productKey: string;
21
+ /** Workspace to read. Defaults to the shell's active workspace. */
22
+ workspaceId?: string;
23
+ /** False renders nothing and reads nothing (a product that does not meter AI). */
24
+ enabled?: boolean;
25
+ }
26
+ /**
27
+ * The remaining AI credits for a product, shown before an AI action
28
+ * (BOFF-3732): under the assistant composer and on a product's own AI surfaces.
29
+ *
30
+ * Re-reads after every charged turn and after a quota wall, so the number
31
+ * follows spend without a reload. Renders nothing while loading, when the read
32
+ * fails, or when the workspace is not metered for the product.
33
+ *
34
+ * Semantic tokens only (`text-text-muted`, `text-status-error-text`).
35
+ */
36
+ export declare const AiCreditBalance: FC<AiCreditBalanceProps>;
@@ -0,0 +1,32 @@
1
+ import { useAiCreditBalanceLabels as e } from "../../providers/shell/useAssistantShellLabels.js";
2
+ import { useAiCreditStatus as t } from "../useAiCreditStatus.js";
3
+ import { jsx as n } from "react/jsx-runtime";
4
+ //#region src/shared/assistant/ui/AiCreditBalance.tsx
5
+ var r = ({ status: t, className: r, testId: i = "ai-credit-balance", locale: a }) => {
6
+ let o = e();
7
+ if (!t?.provisioned) return null;
8
+ let s, c = "normal";
9
+ if (t.noLimit) s = o.unlimited;
10
+ else if (t.exhausted || t.remaining !== null && t.remaining <= 0) c = "exhausted", s = o.exhausted;
11
+ else if (t.remaining !== null) s = o.remaining(new Intl.NumberFormat(a, { maximumFractionDigits: 0 }).format(Math.floor(t.remaining)));
12
+ else return null;
13
+ return /* @__PURE__ */ n("p", {
14
+ className: `text-[11px] leading-snug ${c === "exhausted" ? "text-status-error-text" : "text-text-muted"}${r ? ` ${r}` : ""}`,
15
+ "data-testid": i,
16
+ "data-tone": c,
17
+ role: "status",
18
+ "aria-live": "polite",
19
+ children: s
20
+ });
21
+ }, i = ({ productKey: e, workspaceId: i, enabled: a = !0, ...o }) => {
22
+ let { status: s } = t(e, {
23
+ enabled: a,
24
+ ...i ? { workspaceId: i } : {}
25
+ });
26
+ return /* @__PURE__ */ n(r, {
27
+ status: a ? s : null,
28
+ ...o
29
+ });
30
+ };
31
+ //#endregion
32
+ export { i as AiCreditBalance, r as AiCreditBalanceView };