@burdenoff/microfe-healthybowl 2026.830.3 → 2026.830.5

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.
@@ -5,58 +5,58 @@ import { gatherPageContext as m } from "../../utils/pageContext.js";
5
5
  import { findAssistantLanguage as h, resolveAssistantLanguage as g } from "../../config/assistantLanguages.js";
6
6
  import { isTurnInFlight as _ } from "../../utils/assistantTurnState.js";
7
7
  import { parseToolActivity as v } from "./AssistantToolActivity.js";
8
- import { getOrganizationId as ee, getWorkspaceId as y } from "../../utils/assistantContext.js";
9
- import { buildPromptParts as te, buildPromptWithAttachments as ne, countInlineImageCandidates as re, countInlinedImageParts as ie, toMessageAttachment as b } from "../../utils/assistantAttachments.js";
10
- import { AssistantMessageList as x } from "./AssistantMessageList.js";
11
- import { AssistantApiCallsConsentDialog as S } from "./AssistantApiCallsConsentDialog.js";
12
- import { ASSISTANT_MODES as C } from "../../types/assistant.js";
13
- import { AssistantEmptyState as w } from "./AssistantEmptyState.js";
14
- import { AssistantComposer as ae } from "./composer/AssistantComposer.js";
15
- import { AssistantVoiceSession as oe } from "./voice/AssistantVoiceSession.js";
16
- import { useVoiceSession as se } from "../../hooks/useVoiceSession.js";
17
- import { useAssistantApiAccess as ce } from "../../hooks/useAssistantApiAccess.js";
18
- import { isQuotaExhaustedError as le } from "../../utils/quotaUtils.js";
19
- import { dispatchAssistantQuotaExhausted as ue, notifyAiCreditsUpdated as de } from "../../utils/aiCredits.js";
20
- import { buildPromptForMode as fe } from "../../utils/assistantPrompt.js";
21
- import { isMultimodalBodyRejection as pe, isRecoverableAssistantError as me } from "../../utils/assistantTransportErrors.js";
22
- import { useCallback as T, useEffect as E, useMemo as D, useRef as he, useState as ge } from "react";
8
+ import { getOrganizationId as ee, getWorkspaceId as te } from "../../utils/assistantContext.js";
9
+ import { buildPromptParts as ne, buildPromptWithAttachments as re, countInlineImageCandidates as ie, countInlinedImageParts as ae, toMessageAttachment as y } from "../../utils/assistantAttachments.js";
10
+ import { AssistantMessageList as b } from "./AssistantMessageList.js";
11
+ import { AssistantApiCallsConsentDialog as x } from "./AssistantApiCallsConsentDialog.js";
12
+ import { ASSISTANT_MODES as S } from "../../types/assistant.js";
13
+ import { AssistantEmptyState as C } from "./AssistantEmptyState.js";
14
+ import { AssistantComposer as oe } from "./composer/AssistantComposer.js";
15
+ import { AssistantVoiceSession as se } from "./voice/AssistantVoiceSession.js";
16
+ import { useVoiceSession as ce } from "../../hooks/useVoiceSession.js";
17
+ import { useAssistantApiAccess as le } from "../../hooks/useAssistantApiAccess.js";
18
+ import { isQuotaExhaustedError as ue } from "../../utils/quotaUtils.js";
19
+ import { dispatchAssistantQuotaExhausted as de, notifyAiCreditsUpdated as fe } from "../../utils/aiCredits.js";
20
+ import { buildPromptForMode as pe } from "../../utils/assistantPrompt.js";
21
+ import { isMultimodalBodyRejection as me, isRecoverableAssistantError as he } from "../../utils/assistantTransportErrors.js";
22
+ import { useCallback as w, useEffect as T, useMemo as E, useRef as D, useState as ge } from "react";
23
23
  import { useI18n as _e } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
24
24
  import { jsx as O, jsxs as ve } from "react/jsx-runtime";
25
25
  import { useGatewayClient as ye } from "@burdenoff/fe-libs/shared/graphql";
26
26
  import { useAuthToken as be } from "@burdenoff/fe-libs/shared/providers/shell";
27
- import { getAssistantMedia as xe } from "@burdenoff/fe-libs/shared/assistant";
27
+ import { getAssistantMedia as k } from "@burdenoff/fe-libs/shared/assistant";
28
28
  //#region src/components/assistant/AssistantChatArea.tsx
29
- var Se = {
29
+ var xe = {
30
30
  general: 18e4,
31
31
  assistant: 18e4,
32
32
  "api-calls": 18e4,
33
33
  "vibe-plugins": 6e5
34
- }, Ce = 18e4;
35
- function we() {
34
+ }, Se = 18e4;
35
+ function Ce() {
36
36
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
37
37
  }
38
- function Te(e) {
38
+ function we(e) {
39
39
  return e.replace(/(Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/(X-Workspace-Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+\b/g, "[REDACTED_JWT]").replace(/\bsk-ant-[A-Za-z0-9-]+\b/g, "[REDACTED_API_KEY]");
40
40
  }
41
- function k(e) {
41
+ function A(e) {
42
42
  return e.info?.time?.created ?? 0;
43
43
  }
44
- function A(e) {
44
+ function j(e) {
45
45
  return (e ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n");
46
46
  }
47
- function j(e) {
47
+ function M(e) {
48
48
  return (e ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
49
49
  let t = e.state?.status ?? "running", n = e.tool ?? "tool";
50
50
  return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
51
51
  });
52
52
  }
53
- function Ee(e, t) {
54
- let n = e.filter((e) => e.info?.role === "assistant" && k(e) > t).sort((e, t) => k(e) - k(t));
53
+ function Te(e, t) {
54
+ let n = e.filter((e) => e.info?.role === "assistant" && A(e) > t).sort((e, t) => A(e) - A(t));
55
55
  if (n.length === 0) return {
56
56
  content: "Thinking...",
57
57
  done: !1
58
58
  };
59
- let r = n[n.length - 1], i = A(r.parts), a = xe(r.parts), o = j(r.parts);
59
+ let r = n[n.length - 1], i = j(r.parts), a = k(r.parts), o = M(r.parts);
60
60
  return {
61
61
  content: [
62
62
  i,
@@ -67,7 +67,7 @@ function Ee(e, t) {
67
67
  tokens: r.info?.tokens
68
68
  };
69
69
  }
70
- function De(e) {
70
+ function Ee(e) {
71
71
  switch (e) {
72
72
  case "provisioning": return "Starting assistant environment...";
73
73
  case "connecting": return "Connecting to assistant...";
@@ -75,11 +75,11 @@ function De(e) {
75
75
  default: return "";
76
76
  }
77
77
  }
78
- var M = ({ visible: xe = !0 }) => {
79
- let A = t(), j = ye("workspace"), { getAccessToken: M, getWorkspaceToken: Oe, userId: ke } = be(), { locale: N } = _e(), P = e((e) => e.assistantLanguage), Ae = D(() => g(P, N).english, [P, N]), je = h(P) !== null, F = D(() => g(P, N).code, [P, N]), { conversations: Me, activeConversationId: I, mode: L, processingByConversationId: Ne, setMode: R, setConversationMode: z, setActiveConversation: Pe, createConversation: B, addMessage: Fe, updateMessage: Ie, patchMessage: V, setConversationProcessing: H, clearConversationProcessing: Le, setBackendSessionId: Re, clearBackendSessionId: U, setSandbox: W, clearSandbox: ze, acknowledgeApiCalls: Be } = e(), G = Me.find((e) => e.id === I)?.messages ?? [], K = I ? Ne[I] : void 0, q = _(K?.status), Ve = q ? K?.messageId ?? null : null, He = K?.status === "error" ? K.messageId : null, { canUseApiCalls: J, loading: Ue } = ce(ee()), We = D(() => C.filter((e) => !e.requiresAdmin || J), [J]), [Ge, Ke] = ge(null), qe = he({}), Je = he(/* @__PURE__ */ new Set());
80
- E(() => {
78
+ var N = ({ visible: k = !0 }) => {
79
+ let j = t(), M = ye("workspace"), { getAccessToken: N, getWorkspaceToken: De, userId: Oe } = be(), { locale: P } = _e(), F = e((e) => e.assistantLanguage), ke = E(() => g(F, P).english, [F, P]), Ae = h(F) !== null, je = E(() => g(F, P).code, [F, P]), { conversations: Me, activeConversationId: I, mode: L, processingByConversationId: Ne, setMode: R, setConversationMode: z, setActiveConversation: Pe, createConversation: B, addMessage: Fe, updateMessage: Ie, patchMessage: V, setConversationProcessing: H, clearConversationProcessing: Le, setBackendSessionId: Re, clearBackendSessionId: U, setSandbox: W, clearSandbox: ze, acknowledgeApiCalls: Be } = e(), G = Me.find((e) => e.id === I)?.messages ?? [], K = I ? Ne[I] : void 0, q = _(K?.status), Ve = q ? K?.messageId ?? null : null, He = K?.status === "error" ? K.messageId : null, { canUseApiCalls: J, loading: Ue } = le(ee()), We = E(() => S.filter((e) => !e.requiresAdmin || J), [J]), [Ge, Ke] = ge(null), qe = D({}), Je = D(/* @__PURE__ */ new Set());
80
+ T(() => {
81
81
  if (Ue) return;
82
- let e = C.find((e) => e.id === L);
82
+ let e = S.find((e) => e.id === L);
83
83
  (!e || e.requiresAdmin && !J) && L !== "assistant" && R("assistant");
84
84
  }, [
85
85
  L,
@@ -87,74 +87,74 @@ var M = ({ visible: xe = !0 }) => {
87
87
  Ue,
88
88
  R
89
89
  ]);
90
- let Y = T((e, t, n, r) => {
91
- H(e, n, t, null), r ? Ie(e, t, r) : Ie(e, t, De(n));
92
- }, [H, Ie]), Ye = T(async (t, n, a, s, c) => {
90
+ let Y = w((e, t, n, r) => {
91
+ H(e, n, t, null), r ? Ie(e, t, r) : Ie(e, t, Ee(n));
92
+ }, [H, Ie]), Ye = w(async (t, n, a, s, c) => {
93
93
  let u = e.getState().sandboxesByMode[a]?.sandboxId ?? null, d = async (e) => {
94
94
  try {
95
- return await p(j, e, s, c, 3e5, (e) => Y(t, n, "provisioning", e)), await f(j, e, s, c, 9e4, (e) => Y(t, n, "connecting", e)), !0;
95
+ return await p(M, e, s, c, 3e5, (e) => Y(t, n, "provisioning", e)), await f(M, e, s, c, 9e4, (e) => Y(t, n, "connecting", e)), !0;
96
96
  } catch {
97
97
  return !1;
98
98
  }
99
99
  };
100
100
  if (u && (W(a, u, "provisioning"), Y(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (W(a, null, "provisioning"), u = null)), !u) {
101
101
  Y(t, n, "provisioning", "Looking for existing environment...");
102
- let e = await o(j, s, a, c);
102
+ let e = await o(M, s, a, c);
103
103
  e && (W(a, e, "provisioning"), Y(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : W(a, null, "provisioning"));
104
104
  }
105
105
  if (!u) {
106
- if (a === "api-calls" && !M()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
107
- Y(t, n, "provisioning", "Starting assistant environment..."), W(a, null, "provisioning"), u = await r(j, a, s, c), W(a, u, "provisioning"), await p(j, u, s, c, 3e5, (e) => Y(t, n, "provisioning", e)), await f(j, u, s, c, 9e4, (e) => Y(t, n, "connecting", e));
106
+ if (a === "api-calls" && !N()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
107
+ Y(t, n, "provisioning", "Starting assistant environment..."), W(a, null, "provisioning"), u = await r(M, a, s, c), W(a, u, "provisioning"), await p(M, u, s, c, 3e5, (e) => Y(t, n, "provisioning", e)), await f(M, u, s, c, 9e4, (e) => Y(t, n, "connecting", e));
108
108
  }
109
109
  W(a, u, "running");
110
110
  let m = e.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null;
111
111
  if (m) try {
112
- let e = await l(j, u, s, m, c);
112
+ let e = await l(M, u, s, m, c);
113
113
  if (e.mode !== a) throw Error(`Session mode mismatch: expected ${a}, received ${e.mode}`);
114
114
  } catch {
115
115
  U(t), m = null;
116
116
  }
117
- return m || (Y(t, n, "connecting", "Preparing session..."), m = (await i(j, u, s, a, c)).sessionId, Re(t, m)), {
117
+ return m || (Y(t, n, "connecting", "Preparing session..."), m = (await i(M, u, s, a, c)).sessionId, Re(t, m)), {
118
118
  sandboxId: u,
119
119
  sessionId: m
120
120
  };
121
121
  }, [
122
- j,
123
- U,
124
122
  M,
123
+ U,
124
+ N,
125
125
  Re,
126
126
  W,
127
127
  Y
128
- ]), X = T(async (t, r = []) => {
128
+ ]), X = w(async (t, r = []) => {
129
129
  let i = e.getState(), o = i.activeConversationId ?? I;
130
130
  if (o && (_(i.processingByConversationId[o]?.status) || Je.current.has(o))) return;
131
131
  let l = i.mode, f = I, p = f ? e.getState().conversations.find((e) => e.id === f) : void 0;
132
132
  if (f ? p && p.mode !== l && (p.messages.length > 0 || p.backendSessionId) ? f = B(void 0, l) : p && p.mode !== l && z(f, l) : f = B(void 0, l), !f) return;
133
133
  qe.current[f] = r;
134
- let h = y(), g = {
135
- accessToken: M(),
136
- workspaceToken: Oe(),
137
- userId: ke,
134
+ let h = te(), g = {
135
+ accessToken: N(),
136
+ workspaceToken: De(),
137
+ userId: Oe,
138
138
  organizationId: ee()
139
139
  }, v = {
140
- id: we(),
140
+ id: Ce(),
141
141
  role: "user",
142
142
  content: t,
143
143
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
144
- metadata: r.length ? { attachments: r.map(b) } : void 0
144
+ metadata: r.length ? { attachments: r.map(y) } : void 0
145
145
  };
146
146
  Fe(f, v);
147
- let x = we();
147
+ let b = Ce();
148
148
  Fe(f, {
149
- id: x,
149
+ id: b,
150
150
  role: "assistant",
151
151
  content: "",
152
152
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
153
- metadata: { lang: F }
154
- }), H(f, "provisioning", x, null);
155
- let S = (e, t, n, r, i = F) => {
156
- V(f, x, {
157
- content: Te(e),
153
+ metadata: { lang: je }
154
+ }), H(f, "provisioning", b, null);
155
+ let x = (e, t, n, r, i = je) => {
156
+ V(f, b, {
157
+ content: we(e),
158
158
  metadata: {
159
159
  lang: i,
160
160
  ...t?.length ? { artifacts: t } : {},
@@ -163,102 +163,102 @@ var M = ({ visible: xe = !0 }) => {
163
163
  ...r ? { sandboxId: r } : {}
164
164
  }
165
165
  });
166
- }, C = async (e = 1) => {
166
+ }, S = async (e = 1) => {
167
167
  let i = !1;
168
168
  try {
169
- await n(j, h, g);
169
+ await n(M, h, g);
170
170
  } catch (e) {
171
- if (le(e)) {
172
- ue("ai-credits"), S("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting.", void 0, void 0, void 0, "en"), H(f, "error", x, null);
171
+ if (ue(e)) {
172
+ de("ai-credits"), x("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting.", void 0, void 0, void 0, "en"), H(f, "error", b, null);
173
173
  return;
174
174
  }
175
175
  console.warn("[assistant] AI-credit pre-flight check failed with a non-quota error; proceeding — gateway @usage(checkQuota) still enforces the real budget downstream", e);
176
176
  }
177
177
  try {
178
- let { sandboxId: e, sessionId: n } = await Ye(f, x, l, h, g), o = (await c(j, e, h, n, g, 50).catch(() => [])).reduce((e, t) => Math.max(e, k(t)), 0);
179
- Y(f, x, "streaming", "Thinking...");
180
- let p = fe(l, ne(t, r), Ae, je), _ = te(p, r), v = ie(_), ee = v > 0, y = m();
181
- i = re(r) > v;
178
+ let { sandboxId: e, sessionId: n } = await Ye(f, b, l, h, g), o = (await c(M, e, h, n, g, 50).catch(() => [])).reduce((e, t) => Math.max(e, A(t)), 0);
179
+ Y(f, b, "streaming", "Thinking...");
180
+ let p = pe(l, re(t, r), ke, Ae), _ = ne(p, r), v = ae(_), ee = v > 0, te = m();
181
+ i = ie(r) > v;
182
182
  try {
183
- await d(j, e, h, n, p, l, y, g, _);
183
+ await d(M, e, h, n, p, l, te, g, _);
184
184
  } catch (t) {
185
- if (!_ || !pe(t)) throw t;
186
- await d(j, e, h, n, p, l, y, g, void 0), i ||= ee;
185
+ if (!_ || !me(t)) throw t;
186
+ await d(M, e, h, n, p, l, te, g, void 0), i ||= ee;
187
187
  }
188
- let b = Ee([], o), C = Date.now() + (Se[l] ?? Ce), w = Date.now();
189
- for (; Date.now() < C && (b = Ee(await c(j, e, h, n, g, 50), o), V(f, x, { content: Te(b.content) }), !b.done);) Date.now() - w > 3e4 && (await a(j, e, h, 600, g).catch(() => void 0), w = Date.now()), await new Promise((e) => setTimeout(e, 1500));
190
- if (!b.done && l !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
191
- let ae = l === "vibe-plugins" ? await s(j, e, h, n, g).catch(() => []) : void 0;
192
- if (b.done || (b = {
193
- ...b,
194
- content: `${b.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
195
- }), i && (b = {
196
- ...b,
197
- content: `${b.content}\n\n${A("healthybowl.assistant.attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
198
- }), S(b.content, ae, n, e), b.tokens) {
199
- V(f, x, { tokens: b.tokens });
188
+ let y = Te([], o), S = Date.now() + (xe[l] ?? Se), C = Date.now();
189
+ for (; Date.now() < S && (y = Te(await c(M, e, h, n, g, 50), o), V(f, b, { content: we(y.content) }), !y.done);) Date.now() - C > 3e4 && (await a(M, e, h, 600, g).catch(() => void 0), C = Date.now()), await new Promise((e) => setTimeout(e, 1500));
190
+ if (!y.done && l !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
191
+ let oe = l === "vibe-plugins" ? await s(M, e, h, n, g).catch(() => []) : void 0;
192
+ if (y.done || (y = {
193
+ ...y,
194
+ content: `${y.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
195
+ }), i && (y = {
196
+ ...y,
197
+ content: `${y.content}\n\n${j("healthybowl.assistant.attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
198
+ }), x(y.content, oe, n, e), y.tokens) {
199
+ V(f, b, { tokens: y.tokens });
200
200
  try {
201
- await u(j, h, n, b.tokens, g), de();
201
+ await u(M, h, n, y.tokens, g), fe();
202
202
  } catch {}
203
203
  }
204
- H(f, "complete", x, null);
204
+ H(f, "complete", b, null);
205
205
  } catch (t) {
206
- if (e === 1 && me(t)) return U(f), ze(l), C(2);
206
+ if (e === 1 && he(t)) return U(f), ze(l), S(2);
207
207
  throw t;
208
208
  }
209
- }, w = f;
210
- Je.current.add(w);
209
+ }, C = f;
210
+ Je.current.add(C);
211
211
  try {
212
212
  if (!h) throw Error("Assistant backend is unavailable without an active workspace context.");
213
- await C();
213
+ await S();
214
214
  } catch (e) {
215
- if (le(e)) {
216
- ue("sandbox"), S("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant.", void 0, void 0, void 0, "en"), H(f, "error", x, null);
215
+ if (ue(e)) {
216
+ de("sandbox"), x("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant.", void 0, void 0, void 0, "en"), H(f, "error", b, null);
217
217
  return;
218
218
  }
219
219
  let t = e instanceof Error ? e.message : "Something went wrong";
220
- H(f, "error", x, t), V(f, x, {
220
+ H(f, "error", b, t), V(f, b, {
221
221
  content: `Sorry, an error occurred: ${t}. Please try again.`,
222
222
  metadata: { lang: "en" }
223
223
  });
224
224
  } finally {
225
- Je.current.delete(w);
225
+ Je.current.delete(C);
226
226
  }
227
227
  }, [
228
228
  I,
229
229
  Fe,
230
- j,
230
+ M,
231
231
  U,
232
232
  ze,
233
233
  Me,
234
234
  B,
235
235
  Ye,
236
- M,
237
- Oe,
236
+ N,
237
+ De,
238
238
  V,
239
- je,
240
- F,
241
239
  Ae,
240
+ je,
241
+ ke,
242
242
  Re,
243
243
  z,
244
244
  H,
245
- A,
245
+ j,
246
246
  Y,
247
- ke
248
- ]), Xe = T((e) => {
247
+ Oe
248
+ ]), Xe = w((e) => {
249
249
  X(e);
250
- }, [X]), Ze = T(() => {
250
+ }, [X]), Ze = w(() => {
251
251
  let e = [...G].reverse().find((e) => e.role === "user"), t = I ? qe.current[I] ?? [] : [];
252
252
  e && X(e.content, t);
253
253
  }, [
254
254
  G,
255
255
  X,
256
256
  I
257
- ]), Z = he(X);
258
- E(() => {
257
+ ]), Z = D(X);
258
+ T(() => {
259
259
  Z.current = X;
260
260
  }, [X]);
261
- let Qe = D(() => {
261
+ let Qe = E(() => {
262
262
  if (q) return null;
263
263
  for (let e = G.length - 1; e >= 0; --e) {
264
264
  let t = G[e];
@@ -270,16 +270,20 @@ var M = ({ visible: xe = !0 }) => {
270
270
  } : null;
271
271
  }
272
272
  return null;
273
- }, [G, q]), Q = se({
274
- onSubmit: T((e) => {
273
+ }, [G, q]), $e = E(() => G.filter((e) => e.role === "user" || e.role === "assistant").slice(-6).map((e) => ({
274
+ id: e.id,
275
+ role: e.role,
276
+ text: v(e.content).text.trim()
277
+ })).filter((e) => e.text.length > 0), [G]), Q = ce({
278
+ onSubmit: w((e) => {
275
279
  Z.current(e);
276
280
  }, []),
277
281
  latestReply: Qe,
278
- language: g(P, N).tag
282
+ language: g(F, P).tag
279
283
  });
280
- E(() => {
281
- !xe && Q.active && Q.end();
282
- }, [xe, Q]), E(() => {
284
+ T(() => {
285
+ !k && Q.active && Q.end();
286
+ }, [k, Q]), T(() => {
283
287
  let t = e.getState().consumePendingPrompt();
284
288
  return t && Z.current(t), e.subscribe((t, n) => {
285
289
  if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
@@ -288,7 +292,7 @@ var M = ({ visible: xe = !0 }) => {
288
292
  }
289
293
  });
290
294
  }, []);
291
- let $ = T((t) => {
295
+ let $ = w((t) => {
292
296
  let n = I ? e.getState().conversations.find((e) => e.id === I) : void 0;
293
297
  if (n && (n.messages.length > 0 || n.backendSessionId)) {
294
298
  if (n.mode !== t) {
@@ -303,20 +307,20 @@ var M = ({ visible: xe = !0 }) => {
303
307
  Pe,
304
308
  z,
305
309
  R
306
- ]), $e = T((t) => {
307
- if (C.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
310
+ ]), et = w((t) => {
311
+ if (S.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
308
312
  Ke(t);
309
313
  return;
310
314
  }
311
315
  $(t);
312
- }, [$]), et = T(() => {
316
+ }, [$]), tt = w(() => {
313
317
  let e = Ge;
314
318
  Ke(null), Be(), e && $(e);
315
319
  }, [
316
320
  Ge,
317
321
  Be,
318
322
  $
319
- ]), tt = T(() => {
323
+ ]), nt = w(() => {
320
324
  Ke(null);
321
325
  }, []);
322
326
  return /* @__PURE__ */ ve("div", {
@@ -325,42 +329,45 @@ var M = ({ visible: xe = !0 }) => {
325
329
  /* @__PURE__ */ ve("div", {
326
330
  className: "contents",
327
331
  inert: Q.active || void 0,
328
- children: [G.length === 0 ? /* @__PURE__ */ O(w, {
332
+ children: [G.length === 0 ? /* @__PURE__ */ O(C, {
329
333
  mode: L,
330
334
  onSuggestionClick: Xe
331
335
  }) : /* @__PURE__ */ O("div", {
332
336
  className: "flex min-h-0 flex-1 flex-col",
333
- children: /* @__PURE__ */ O(x, {
337
+ children: /* @__PURE__ */ O(b, {
334
338
  messages: G,
335
339
  streamingMessageId: Ve,
336
340
  failedMessageId: He,
337
341
  onRetry: Ze
338
342
  })
339
- }), /* @__PURE__ */ O(ae, {
343
+ }), /* @__PURE__ */ O(oe, {
340
344
  onStartVoiceSession: Q.available && L !== "api-calls" ? Q.start : void 0,
341
345
  onSend: (e, t) => void X(e, t),
342
346
  disabled: q,
343
- placeholder: L === "api-calls" ? A("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : A("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
347
+ placeholder: L === "api-calls" ? j("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : j("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
344
348
  mode: L,
345
349
  availableModes: We,
346
- onModeChange: $e
350
+ onModeChange: et
347
351
  })]
348
352
  }),
349
- Q.active && /* @__PURE__ */ O(oe, {
353
+ Q.active && /* @__PURE__ */ O(se, {
350
354
  session: Q.session,
355
+ notice: Q.notice,
356
+ turns: $e,
357
+ onInterrupt: Q.interrupt,
351
358
  spoken: Qe?.text ?? null,
352
359
  onToggleMute: Q.toggleMute,
353
360
  onEnd: Q.end
354
361
  }),
355
- /* @__PURE__ */ O(S, {
362
+ /* @__PURE__ */ O(x, {
356
363
  open: Ge !== null,
357
- onConfirm: et,
358
- onCancel: tt
364
+ onConfirm: tt,
365
+ onCancel: nt
359
366
  })
360
367
  ]
361
368
  });
362
369
  };
363
370
  //#endregion
364
- export { M as AssistantChatArea };
371
+ export { N as AssistantChatArea };
365
372
 
366
373
  //# sourceMappingURL=AssistantChatArea.js.map