@burdenoff/microfe-healthybowl 2026.720.2 → 2026.725.2

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.
Files changed (43) hide show
  1. package/dist/components/assistant/AIAssistantPanel.js +27 -99
  2. package/dist/components/assistant/AIAssistantPanel.js.map +1 -1
  3. package/dist/components/assistant/AssistantApiCallsConsentDialog.js +4 -4
  4. package/dist/components/assistant/AssistantApiCallsConsentDialog.js.map +1 -1
  5. package/dist/components/assistant/AssistantChatArea.js +147 -163
  6. package/dist/components/assistant/AssistantChatArea.js.map +1 -1
  7. package/dist/components/assistant/AssistantEmptyState.js +41 -0
  8. package/dist/components/assistant/AssistantEmptyState.js.map +1 -0
  9. package/dist/components/assistant/AssistantHeader.js +77 -0
  10. package/dist/components/assistant/AssistantHeader.js.map +1 -0
  11. package/dist/components/assistant/AssistantMessageItem.js +93 -51
  12. package/dist/components/assistant/AssistantMessageItem.js.map +1 -1
  13. package/dist/components/assistant/AssistantMessageList.js +12 -15
  14. package/dist/components/assistant/AssistantMessageList.js.map +1 -1
  15. package/dist/components/assistant/AssistantToolActivity.js +110 -0
  16. package/dist/components/assistant/AssistantToolActivity.js.map +1 -0
  17. package/dist/components/assistant/composer/AssistantAttachmentButton.js +20 -0
  18. package/dist/components/assistant/composer/AssistantAttachmentButton.js.map +1 -0
  19. package/dist/components/assistant/composer/AssistantComposer.js +74 -0
  20. package/dist/components/assistant/composer/AssistantComposer.js.map +1 -0
  21. package/dist/components/assistant/composer/AssistantModeSelector.js +46 -0
  22. package/dist/components/assistant/composer/AssistantModeSelector.js.map +1 -0
  23. package/dist/components/assistant/composer/AssistantVoiceButton.js +20 -0
  24. package/dist/components/assistant/composer/AssistantVoiceButton.js.map +1 -0
  25. package/dist/components/assistant/index.js +6 -4
  26. package/dist/config/assistantUsecases.js +2 -2
  27. package/dist/config/assistantUsecases.js.map +1 -1
  28. package/dist/healthybowl/components/index.js +2 -1
  29. package/dist/healthybowl/index.js +2 -1
  30. package/dist/healthybowl/pages/HomePage.js +450 -368
  31. package/dist/healthybowl/pages/HomePage.js.map +1 -1
  32. package/dist/index.js +7 -7
  33. package/dist/utils/pageContext.js +20 -2
  34. package/dist/utils/pageContext.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/components/assistant/AssistantChatInput.js +0 -65
  37. package/dist/components/assistant/AssistantChatInput.js.map +0 -1
  38. package/dist/components/assistant/AssistantModeSelector.js +0 -61
  39. package/dist/components/assistant/AssistantModeSelector.js.map +0 -1
  40. package/dist/components/assistant/AssistantWelcome.js +0 -45
  41. package/dist/components/assistant/AssistantWelcome.js.map +0 -1
  42. package/dist/healthybowl/components/assistant/AIAssistantPanel.js +0 -3
  43. package/dist/healthybowl/components/assistant/index.js +0 -1
@@ -1,32 +1,30 @@
1
1
  import { useAssistantStore as e } from "../../store/assistantStore.js";
2
2
  import { useTr as t } from "../../shared/hooks/useTr.js";
3
3
  import { checkAssistantAiCredits as n, createAssistantSandbox as r, createAssistantSession as i, extendAssistantSandboxTTL as a, findExistingSandbox as o, getAssistantArtifacts as s, getAssistantMessages as c, getAssistantSession as l, reportAssistantAiTokenUsage as u, sendAssistantPromptAsync as d, waitForAssistantServiceReady as f, waitForSandboxReady as p } from "../../services/assistantApi.js";
4
- import { AssistantChatInput as m } from "./AssistantChatInput.js";
4
+ import { gatherPageContext as m } from "../../utils/pageContext.js";
5
5
  import { AssistantMessageList as h } from "./AssistantMessageList.js";
6
- import { ASSISTANT_MODES as g } from "../../types/assistant.js";
7
- import { AssistantModeSelector as _ } from "./AssistantModeSelector.js";
8
- import { AssistantApiCallsConsentDialog as v } from "./AssistantApiCallsConsentDialog.js";
9
- import { AssistantWelcome as ee } from "./AssistantWelcome.js";
6
+ import { AssistantApiCallsConsentDialog as g } from "./AssistantApiCallsConsentDialog.js";
7
+ import { ASSISTANT_MODES as _ } from "../../types/assistant.js";
8
+ import { AssistantEmptyState as v } from "./AssistantEmptyState.js";
9
+ import { AssistantComposer as ee } from "./composer/AssistantComposer.js";
10
10
  import { useAssistantApiAccess as te } from "../../hooks/useAssistantApiAccess.js";
11
- import { gatherPageContext as ne } from "../../utils/pageContext.js";
12
- import { isQuotaExhaustedError as re } from "../../utils/quotaUtils.js";
13
- import { dispatchAssistantQuotaExhausted as ie, notifyAiCreditsUpdated as ae } from "../../utils/aiCredits.js";
14
- import { buildPromptForMode as oe } from "../../utils/assistantPrompt.js";
15
- import { useCallback as y, useEffect as b, useMemo as se, useRef as ce, useState as le } from "react";
16
- import { Plus as ue } from "lucide-react";
17
- import { Fragment as de, jsx as x, jsxs as S } from "react/jsx-runtime";
18
- import { useGatewayClient as fe } from "@burdenoff/fe-libs/shared/graphql";
19
- import { useAuthToken as pe } from "@burdenoff/fe-libs/shared/providers/shell";
11
+ import { isQuotaExhaustedError as y } from "../../utils/quotaUtils.js";
12
+ import { dispatchAssistantQuotaExhausted as b, notifyAiCreditsUpdated as ne } from "../../utils/aiCredits.js";
13
+ import { buildPromptForMode as re } from "../../utils/assistantPrompt.js";
14
+ import { useCallback as x, useEffect as S, useMemo as ie, useRef as ae, useState as oe } from "react";
15
+ import { jsx as C, jsxs as se } from "react/jsx-runtime";
16
+ import { useGatewayClient as ce } from "@burdenoff/fe-libs/shared/graphql";
17
+ import { useAuthToken as le } from "@burdenoff/fe-libs/shared/providers/shell";
20
18
  //#region src/components/assistant/AssistantChatArea.tsx
21
- var me = {
19
+ var ue = {
22
20
  general: 18e4,
23
21
  "api-calls": 18e4,
24
22
  "vibe-plugins": 6e5
25
- }, he = 18e4;
26
- function ge() {
23
+ }, de = 18e4;
24
+ function fe() {
27
25
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
28
26
  }
29
- function C(e) {
27
+ function w(e) {
30
28
  try {
31
29
  let t = e === "workspaceId" ? "burdenoff-active-context-workspace" : "burdenoff-active-context-organization", n = sessionStorage.getItem(t);
32
30
  if (n) return n;
@@ -40,13 +38,13 @@ function C(e) {
40
38
  return "";
41
39
  }
42
40
  }
43
- function _e() {
44
- return new URLSearchParams(window.location.search).get("workspace") ?? C("workspaceId");
41
+ function pe() {
42
+ return new URLSearchParams(window.location.search).get("workspace") ?? w("workspaceId");
45
43
  }
46
- function ve() {
47
- return new URLSearchParams(window.location.search).get("org") ?? C("organizationId");
44
+ function me() {
45
+ return new URLSearchParams(window.location.search).get("org") ?? w("organizationId");
48
46
  }
49
- function ye(e) {
47
+ function he(e) {
50
48
  let t = e instanceof Error ? e.message.toLowerCase() : String(e).toLowerCase();
51
49
  return t.includes("rate limit exceeded") || t.includes("unauthorized") || t.includes("k8s api error 401") ? !1 : [
52
50
  "sandbox not found",
@@ -61,35 +59,35 @@ function ye(e) {
61
59
  "session mode mismatch"
62
60
  ].some((e) => t.includes(e));
63
61
  }
64
- function be(e) {
62
+ function T(e) {
65
63
  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]");
66
64
  }
67
- function w(e) {
65
+ function E(e) {
68
66
  return e.info?.time?.created ?? 0;
69
67
  }
70
- function T(e) {
68
+ function D(e) {
71
69
  return (e ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n");
72
70
  }
73
- function E(e) {
71
+ function O(e) {
74
72
  return (e ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
75
73
  let t = e.state?.status ?? "running", n = e.tool ?? "tool";
76
74
  return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
77
75
  });
78
76
  }
79
- function xe(e, t) {
80
- let n = e.filter((e) => e.info?.role === "assistant" && w(e) > t).sort((e, t) => w(e) - w(t));
77
+ function k(e, t) {
78
+ let n = e.filter((e) => e.info?.role === "assistant" && E(e) > t).sort((e, t) => E(e) - E(t));
81
79
  if (n.length === 0) return {
82
80
  content: "Thinking...",
83
81
  done: !1
84
82
  };
85
- let r = n[n.length - 1], i = T(r.parts), a = E(r.parts);
83
+ let r = n[n.length - 1], i = D(r.parts), a = O(r.parts);
86
84
  return {
87
85
  content: [i, ...a].filter(Boolean).join("\n\n") || "Thinking...",
88
86
  done: !!r.info?.time?.completed && (!!i || a.length > 0),
89
87
  tokens: r.info?.tokens
90
88
  };
91
89
  }
92
- function Se(e) {
90
+ function ge(e) {
93
91
  switch (e) {
94
92
  case "provisioning": return "Starting assistant environment...";
95
93
  case "connecting": return "Connecting to assistant...";
@@ -97,85 +95,85 @@ function Se(e) {
97
95
  default: return "";
98
96
  }
99
97
  }
100
- var D = ({ messagesExpanded: C = !1 }) => {
101
- let T = t(), E = fe("workspace"), { getAccessToken: D, getWorkspaceToken: O, userId: k } = pe(), { conversations: A, activeConversationId: j, mode: M, processingByConversationId: N, setMode: P, setConversationMode: F, setActiveConversation: I, createConversation: L, addMessage: R, updateMessage: z, patchMessage: B, setConversationProcessing: V, clearConversationProcessing: Ce, setBackendSessionId: H, clearBackendSessionId: U, setSandbox: W, clearSandbox: we, acknowledgeApiCalls: Te } = e(), Ee = A.find((e) => e.id === j)?.messages ?? [], G = j ? N[j] : void 0, De = G?.messageId ?? null, Oe = G?.status === "provisioning" || G?.status === "connecting" || G?.status === "streaming", { canUseApiCalls: K, loading: ke } = te(ve()), Ae = se(() => g.filter((e) => !e.requiresAdmin || K), [K]), [q, J] = le(null);
102
- b(() => {
103
- if (ke) return;
104
- let e = g.find((e) => e.id === M);
105
- (!e || e.requiresAdmin && !K) && M !== "general" && P("general");
98
+ var A = () => {
99
+ let w = t(), D = ce("workspace"), { getAccessToken: O, getWorkspaceToken: A, userId: j } = le(), { conversations: _e, activeConversationId: M, mode: N, processingByConversationId: P, setMode: F, setConversationMode: I, setActiveConversation: ve, createConversation: L, addMessage: R, updateMessage: z, patchMessage: B, setConversationProcessing: V, clearConversationProcessing: ye, setBackendSessionId: H, clearBackendSessionId: U, setSandbox: W, clearSandbox: be, acknowledgeApiCalls: xe } = e(), G = _e.find((e) => e.id === M)?.messages ?? [], K = M ? P[M] : void 0, Se = K?.messageId ?? null, Ce = K?.status === "provisioning" || K?.status === "connecting" || K?.status === "streaming", we = K?.status === "error" ? K.messageId : null, { canUseApiCalls: q, loading: Te } = te(me()), Ee = ie(() => _.filter((e) => !e.requiresAdmin || q), [q]), [J, Y] = oe(null);
100
+ S(() => {
101
+ if (Te) return;
102
+ let e = _.find((e) => e.id === N);
103
+ (!e || e.requiresAdmin && !q) && N !== "general" && F("general");
106
104
  }, [
107
- M,
108
- K,
109
- ke,
110
- P
105
+ N,
106
+ q,
107
+ Te,
108
+ F
111
109
  ]);
112
- let Y = y((e, t, n, r) => {
113
- V(e, n, t, null), r ? z(e, t, r) : z(e, t, Se(n));
114
- }, [V, z]), X = y(async (t, n, a, s, c) => {
110
+ let X = x((e, t, n, r) => {
111
+ V(e, n, t, null), r ? z(e, t, r) : z(e, t, ge(n));
112
+ }, [V, z]), De = x(async (t, n, a, s, c) => {
115
113
  let u = e.getState().sandboxesByMode[a]?.sandboxId ?? null, d = async (e) => {
116
114
  try {
117
- return await p(E, e, s, c, 3e5, (e) => Y(t, n, "provisioning", e)), await f(E, e, s, c, 9e4, (e) => Y(t, n, "connecting", e)), !0;
115
+ return await p(D, e, s, c, 3e5, (e) => X(t, n, "provisioning", e)), await f(D, e, s, c, 9e4, (e) => X(t, n, "connecting", e)), !0;
118
116
  } catch {
119
117
  return !1;
120
118
  }
121
119
  };
122
- if (u && (W(a, u, "provisioning"), Y(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (W(a, null, "provisioning"), u = null)), !u) {
123
- Y(t, n, "provisioning", "Looking for existing environment...");
124
- let e = await o(E, s, a, c);
125
- e && (W(a, e, "provisioning"), Y(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : W(a, null, "provisioning"));
120
+ if (u && (W(a, u, "provisioning"), X(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (W(a, null, "provisioning"), u = null)), !u) {
121
+ X(t, n, "provisioning", "Looking for existing environment...");
122
+ let e = await o(D, s, a, c);
123
+ e && (W(a, e, "provisioning"), X(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : W(a, null, "provisioning"));
126
124
  }
127
125
  if (!u) {
128
- if (a === "api-calls" && !D()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
129
- Y(t, n, "provisioning", "Starting assistant environment..."), W(a, null, "provisioning"), u = await r(E, a, s, c), W(a, u, "provisioning"), await p(E, u, s, c, 3e5, (e) => Y(t, n, "provisioning", e)), await f(E, u, s, c, 9e4, (e) => Y(t, n, "connecting", e));
126
+ if (a === "api-calls" && !O()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
127
+ X(t, n, "provisioning", "Starting assistant environment..."), W(a, null, "provisioning"), u = await r(D, a, s, c), W(a, u, "provisioning"), await p(D, u, s, c, 3e5, (e) => X(t, n, "provisioning", e)), await f(D, u, s, c, 9e4, (e) => X(t, n, "connecting", e));
130
128
  }
131
129
  W(a, u, "running");
132
130
  let m = e.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null;
133
131
  if (m) try {
134
- let e = await l(E, u, s, m, c);
132
+ let e = await l(D, u, s, m, c);
135
133
  if (e.mode !== a) throw Error(`Session mode mismatch: expected ${a}, received ${e.mode}`);
136
134
  } catch {
137
135
  U(t), m = null;
138
136
  }
139
- return m || (Y(t, n, "connecting", "Preparing session..."), m = (await i(E, u, s, a, c)).sessionId, H(t, m)), {
137
+ return m || (X(t, n, "connecting", "Preparing session..."), m = (await i(D, u, s, a, c)).sessionId, H(t, m)), {
140
138
  sandboxId: u,
141
139
  sessionId: m
142
140
  };
143
141
  }, [
144
- E,
145
- U,
146
142
  D,
143
+ U,
144
+ O,
147
145
  H,
148
146
  W,
149
- Y
150
- ]), Z = y(async (t) => {
151
- if (j) {
152
- let e = N[j]?.status;
147
+ X
148
+ ]), Z = x(async (t) => {
149
+ if (M) {
150
+ let e = P[M]?.status;
153
151
  if (e === "provisioning" || e === "connecting" || e === "streaming") return;
154
152
  }
155
- let r = e.getState().mode, i = j, o = i ? e.getState().conversations.find((e) => e.id === i) : void 0;
156
- if (i ? o && o.mode !== r && (o.messages.length > 0 || o.backendSessionId) ? i = L(void 0, r) : o && o.mode !== r && F(i, r) : i = L(void 0, r), !i) return;
157
- let l = _e(), f = {
158
- accessToken: D(),
159
- workspaceToken: O(),
160
- userId: k,
161
- organizationId: ve()
153
+ let r = e.getState().mode, i = M, o = i ? e.getState().conversations.find((e) => e.id === i) : void 0;
154
+ if (i ? o && o.mode !== r && (o.messages.length > 0 || o.backendSessionId) ? i = L(void 0, r) : o && o.mode !== r && I(i, r) : i = L(void 0, r), !i) return;
155
+ let l = pe(), f = {
156
+ accessToken: O(),
157
+ workspaceToken: A(),
158
+ userId: j,
159
+ organizationId: me()
162
160
  }, p = {
163
- id: ge(),
161
+ id: fe(),
164
162
  role: "user",
165
163
  content: t,
166
164
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
167
165
  };
168
166
  R(i, p);
169
- let m = ge();
167
+ let h = fe();
170
168
  R(i, {
171
- id: m,
169
+ id: h,
172
170
  role: "assistant",
173
171
  content: "",
174
172
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
175
173
  });
176
- let h = (e, t, n, a) => {
177
- B(i, m, {
178
- content: be(e),
174
+ let g = (e, t, n, a) => {
175
+ B(i, h, {
176
+ content: T(e),
179
177
  metadata: t?.length || n || a ? {
180
178
  artifacts: t,
181
179
  mode: r,
@@ -183,74 +181,77 @@ var D = ({ messagesExpanded: C = !1 }) => {
183
181
  sandboxId: a
184
182
  } : void 0
185
183
  });
186
- }, g = async (e = 1) => {
184
+ }, _ = async (e = 1) => {
187
185
  try {
188
- await n(E, l, f);
186
+ await n(D, l, f);
189
187
  } catch (e) {
190
- if (re(e)) {
191
- ie("ai-credits"), h("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting."), V(i, "error", m, null);
188
+ if (y(e)) {
189
+ b("ai-credits"), g("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting."), V(i, "error", h, null);
192
190
  return;
193
191
  }
194
192
  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);
195
193
  }
196
194
  try {
197
- let { sandboxId: e, sessionId: n } = await X(i, m, r, l, f), o = (await c(E, e, l, n, f, 50).catch(() => [])).reduce((e, t) => Math.max(e, w(t)), 0);
198
- Y(i, m, "streaming", "Thinking..."), await d(E, e, l, n, oe(r, t), r, ne(), f);
199
- let p = xe([], o), g = Date.now() + (me[r] ?? he), _ = Date.now();
200
- for (; Date.now() < g && (p = xe(await c(E, e, l, n, f, 50), o), B(i, m, { content: be(p.content) }), !p.done);) Date.now() - _ > 3e4 && (await a(E, e, l, 600, f).catch(() => void 0), _ = Date.now()), await new Promise((e) => setTimeout(e, 1500));
195
+ let { sandboxId: e, sessionId: n } = await De(i, h, r, l, f), o = (await c(D, e, l, n, f, 50).catch(() => [])).reduce((e, t) => Math.max(e, E(t)), 0);
196
+ X(i, h, "streaming", "Thinking..."), await d(D, e, l, n, re(r, t), r, m(), f);
197
+ let p = k([], o), _ = Date.now() + (ue[r] ?? de), v = Date.now();
198
+ for (; Date.now() < _ && (p = k(await c(D, e, l, n, f, 50), o), B(i, h, { content: T(p.content) }), !p.done);) Date.now() - v > 3e4 && (await a(D, e, l, 600, f).catch(() => void 0), v = Date.now()), await new Promise((e) => setTimeout(e, 1500));
201
199
  if (!p.done && r !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
202
- let v = r === "vibe-plugins" ? await s(E, e, l, n, f).catch(() => []) : void 0;
200
+ let ee = r === "vibe-plugins" ? await s(D, e, l, n, f).catch(() => []) : void 0;
203
201
  if (p.done || (p = {
204
202
  ...p,
205
203
  content: `${p.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
206
- }), h(p.content, v, n, e), p.tokens) {
207
- B(i, m, { tokens: p.tokens });
204
+ }), g(p.content, ee, n, e), p.tokens) {
205
+ B(i, h, { tokens: p.tokens });
208
206
  try {
209
- await u(E, l, n, p.tokens, f), ae();
207
+ await u(D, l, n, p.tokens, f), ne();
210
208
  } catch {}
211
209
  }
212
- V(i, "complete", m, null);
210
+ V(i, "complete", h, null);
213
211
  } catch (t) {
214
- if (e === 1 && ye(t)) return U(i), we(r), g(2);
212
+ if (e === 1 && he(t)) return U(i), be(r), _(2);
215
213
  throw t;
216
214
  }
217
215
  };
218
216
  try {
219
217
  if (!l) throw Error("Assistant backend is unavailable without an active workspace context.");
220
- await g();
218
+ await _();
221
219
  } catch (e) {
222
- if (re(e)) {
223
- ie("sandbox"), h("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant."), V(i, "error", m, null);
220
+ if (y(e)) {
221
+ b("sandbox"), g("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant."), V(i, "error", h, null);
224
222
  return;
225
223
  }
226
224
  let t = e instanceof Error ? e.message : "Something went wrong";
227
- V(i, "error", m, t), z(i, m, `Sorry, an error occurred: ${t}. Please try again.`);
225
+ V(i, "error", h, t), z(i, h, `Sorry, an error occurred: ${t}. Please try again.`);
228
226
  }
229
227
  }, [
230
- j,
228
+ M,
231
229
  R,
232
- E,
230
+ D,
233
231
  U,
234
- we,
235
- A,
232
+ be,
233
+ _e,
236
234
  L,
237
- X,
238
- D,
235
+ De,
239
236
  O,
237
+ A,
240
238
  B,
241
- N,
239
+ P,
242
240
  H,
243
- F,
241
+ I,
244
242
  V,
245
- Y,
243
+ X,
246
244
  z,
247
- k
248
- ]), je = y((e) => {
245
+ j
246
+ ]), Oe = x((e) => {
249
247
  Z(e);
250
- }, [Z]), Q = ce(Z);
251
- b(() => {
248
+ }, [Z]), ke = x(() => {
249
+ let e = [...G].reverse().find((e) => e.role === "user");
250
+ e && Z(e.content);
251
+ }, [G, Z]), Q = ae(Z);
252
+ S(() => {
252
253
  Q.current = Z;
253
- }, [Z]), b(() => {
254
+ }, [Z]), S(() => {
254
255
  let t = e.getState().consumePendingPrompt();
255
256
  return t && Q.current(t), e.subscribe((t, n) => {
256
257
  if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
@@ -259,86 +260,69 @@ var D = ({ messagesExpanded: C = !1 }) => {
259
260
  }
260
261
  });
261
262
  }, []);
262
- let $ = y((t) => {
263
- let n = j ? e.getState().conversations.find((e) => e.id === j) : void 0;
263
+ let $ = x((t) => {
264
+ let n = M ? e.getState().conversations.find((e) => e.id === M) : void 0;
264
265
  if (n && (n.messages.length > 0 || n.backendSessionId)) {
265
266
  if (n.mode !== t) {
266
267
  let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
267
- n ? I(n.id) : L(void 0, t);
268
+ n ? ve(n.id) : L(void 0, t);
268
269
  }
269
- } else j && F(j, t);
270
- P(t);
270
+ } else M && I(M, t);
271
+ F(t);
271
272
  }, [
272
- j,
273
+ M,
273
274
  L,
275
+ ve,
274
276
  I,
275
- F,
276
- P
277
- ]), Me = y((t) => {
278
- if (g.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
279
- J(t);
277
+ F
278
+ ]), Ae = x((t) => {
279
+ if (_.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
280
+ Y(t);
280
281
  return;
281
282
  }
282
283
  $(t);
283
- }, [$]), Ne = y(() => {
284
- let e = q;
285
- J(null), Te(), e && $(e);
284
+ }, [$]), je = x(() => {
285
+ let e = J;
286
+ Y(null), xe(), e && $(e);
286
287
  }, [
287
- q,
288
- Te,
288
+ J,
289
+ xe,
289
290
  $
290
- ]), Pe = y(() => {
291
- J(null);
291
+ ]), Me = x(() => {
292
+ Y(null);
292
293
  }, []);
293
- return /* @__PURE__ */ S("div", {
294
- className: "flex flex-col flex-1 overflow-hidden",
294
+ return /* @__PURE__ */ se("div", {
295
+ className: "flex flex-1 flex-col overflow-hidden",
295
296
  children: [
296
- Ee.length === 0 ? /* @__PURE__ */ x(ee, {
297
- mode: M,
298
- onSuggestionClick: je
299
- }) : /* @__PURE__ */ S(de, { children: [/* @__PURE__ */ x("div", {
300
- className: `grid min-h-0 transition-[grid-template-rows] duration-300 ease-out ${C ? "flex-1" : "flex-shrink-0"}`,
301
- style: { gridTemplateRows: C ? "1fr" : "0fr" },
302
- inert: !C || void 0,
303
- "data-testid": "message-transcript",
304
- children: /* @__PURE__ */ x("div", {
305
- className: `min-h-0 overflow-hidden transition-opacity duration-300 ${C ? "opacity-100" : "opacity-0"}`,
306
- children: /* @__PURE__ */ x("div", {
307
- className: "flex h-full flex-col",
308
- children: /* @__PURE__ */ x(h, {
309
- messages: Ee,
310
- streamingMessageId: De,
311
- expanded: C
312
- })
313
- })
297
+ G.length === 0 ? /* @__PURE__ */ C(v, {
298
+ mode: N,
299
+ onSuggestionClick: Oe
300
+ }) : /* @__PURE__ */ C("div", {
301
+ className: "flex min-h-0 flex-1 flex-col",
302
+ children: /* @__PURE__ */ C(h, {
303
+ messages: G,
304
+ streamingMessageId: Se,
305
+ failedMessageId: we,
306
+ onRetry: ke
314
307
  })
315
- }), !C && /* @__PURE__ */ x("div", { className: "flex-1" })] }),
316
- /* @__PURE__ */ x(m, {
308
+ }),
309
+ /* @__PURE__ */ C(ee, {
317
310
  onSend: (e) => void Z(e),
318
- disabled: Oe,
319
- placeholder: M === "api-calls" ? T("healthybowl.assistant.chatArea.placeholderActions", "What would you like to change or create?") : T("healthybowl.assistant.chatArea.placeholderGeneral", "Ask anything about your farm…"),
320
- toolbarStart: /* @__PURE__ */ S(de, { children: [/* @__PURE__ */ x("button", {
321
- type: "button",
322
- onClick: () => L(),
323
- className: "flex size-7 flex-shrink-0 items-center justify-center rounded-full text-text-secondary transition-colors hover:bg-bg-elevated hover:text-text-primary",
324
- "aria-label": T("healthybowl.assistant.chatArea.newConversation", "New conversation"),
325
- "data-testid": "composer-new-conversation",
326
- children: /* @__PURE__ */ x(ue, { className: "size-4" })
327
- }), /* @__PURE__ */ x(_, {
328
- mode: M,
329
- availableModes: Ae,
330
- onModeChange: Me
331
- })] })
311
+ disabled: Ce,
312
+ placeholder: N === "api-calls" ? w("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : w("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
313
+ mode: N,
314
+ availableModes: Ee,
315
+ onModeChange: Ae
332
316
  }),
333
- /* @__PURE__ */ x(v, {
334
- open: q !== null,
335
- onConfirm: Ne,
336
- onCancel: Pe
317
+ /* @__PURE__ */ C(g, {
318
+ open: J !== null,
319
+ onConfirm: je,
320
+ onCancel: Me
337
321
  })
338
322
  ]
339
323
  });
340
324
  };
341
325
  //#endregion
342
- export { D as AssistantChatArea };
326
+ export { A as AssistantChatArea };
343
327
 
344
328
  //# sourceMappingURL=AssistantChatArea.js.map