@burdenoff/microfe-healthybowl 2026.813.18 → 2026.813.20
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.
- package/dist/components/assistant/AIAssistantPanel.js +19 -18
- package/dist/components/assistant/AIAssistantPanel.js.map +1 -1
- package/dist/components/assistant/composer/AssistantAttachmentChips.js +1 -1
- package/dist/components/assistant/composer/AssistantAttachmentChips.js.map +1 -1
- package/dist/healthybowl/pages/tasks/TasksPage.js +24 -2
- package/dist/healthybowl/pages/tasks/TasksPage.js.map +1 -1
- package/dist/hooks/useAssistantAttachments.js +140 -117
- package/dist/hooks/useAssistantAttachments.js.map +1 -1
- package/dist/node_modules/@burdenoff/planmagnet-fe-sdk/dist/index.js +505 -502
- package/dist/node_modules/@burdenoff/planmagnet-fe-sdk/dist/index.js.map +1 -1
- package/dist/utils/assistantAttachments.js.map +1 -1
- package/package.json +3 -3
|
@@ -9,40 +9,41 @@ import { AssistantChatArea as s } from "./AssistantChatArea.js";
|
|
|
9
9
|
import { AssistantConversationList as c } from "./AssistantConversationList.js";
|
|
10
10
|
import { useMemo as l, useRef as u } from "react";
|
|
11
11
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
12
|
+
import { useFilesServiceWarmup as p } from "@burdenoff/fe-libs/storage";
|
|
12
13
|
//#region src/components/assistant/AIAssistantPanel.tsx
|
|
13
|
-
var
|
|
14
|
-
let
|
|
15
|
-
r(
|
|
16
|
-
let
|
|
14
|
+
var m = ({ onClose: m, visible: h, docked: g, onToggleDock: _ }) => {
|
|
15
|
+
let v = t(), y = u(null), { conversations: b, activeConversationId: x, conversationListOpen: S, toggleConversationList: C, createConversation: w } = e(), T = b.find((e) => e.id === x);
|
|
16
|
+
r(T?.backendSessionId ?? null, T?.mode ?? null, h ?? !0), p(h ?? !0);
|
|
17
|
+
let E = l(() => i(), []);
|
|
17
18
|
return n({
|
|
18
|
-
panelRef:
|
|
19
|
-
onClose:
|
|
19
|
+
panelRef: y,
|
|
20
|
+
onClose: m
|
|
20
21
|
}), /* @__PURE__ */ d(a, {
|
|
21
|
-
visible:
|
|
22
|
+
visible: h ?? !0,
|
|
22
23
|
children: /* @__PURE__ */ f("div", {
|
|
23
|
-
ref:
|
|
24
|
+
ref: y,
|
|
24
25
|
className: "relative flex h-full w-full flex-col bg-bg-surface",
|
|
25
26
|
role: "complementary",
|
|
26
|
-
"aria-label":
|
|
27
|
+
"aria-label": v("healthybowl.assistant.panel.ariaLabel", "AI Assistant"),
|
|
27
28
|
"data-testid": "ai-assistant-panel",
|
|
28
29
|
tabIndex: -1,
|
|
29
30
|
children: [
|
|
30
31
|
/* @__PURE__ */ d(o, {
|
|
31
|
-
contextLabel:
|
|
32
|
-
onNewConversation: () =>
|
|
33
|
-
onOpenHistory:
|
|
34
|
-
historyOpen:
|
|
35
|
-
onClose:
|
|
36
|
-
docked:
|
|
37
|
-
onToggleDock:
|
|
32
|
+
contextLabel: E,
|
|
33
|
+
onNewConversation: () => w(),
|
|
34
|
+
onOpenHistory: C,
|
|
35
|
+
historyOpen: S,
|
|
36
|
+
onClose: m,
|
|
37
|
+
docked: g,
|
|
38
|
+
onToggleDock: _
|
|
38
39
|
}),
|
|
39
|
-
|
|
40
|
+
S && /* @__PURE__ */ d(c, {}),
|
|
40
41
|
/* @__PURE__ */ d(s, {})
|
|
41
42
|
]
|
|
42
43
|
})
|
|
43
44
|
});
|
|
44
45
|
};
|
|
45
46
|
//#endregion
|
|
46
|
-
export {
|
|
47
|
+
export { m as AIAssistantPanel };
|
|
47
48
|
|
|
48
49
|
//# sourceMappingURL=AIAssistantPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIAssistantPanel.js","names":[],"sources":["../../../src/components/assistant/AIAssistantPanel.tsx"],"sourcesContent":["/**\n * AI Assistant Panel — top-level component for the in-page assistant.\n *\n * Layout (v2): a fixed identity header (AssistantHeader) with the brand mark,\n * an availability/context subtitle and icon actions (new conversation, history,\n * export, dock, close), an always-visible transcript, and the composer pinned\n * to the bottom. Conversation history opens as an overlay drawer over the panel\n * — never as an accordion over the transcript.\n *\n * The external prop contract ({ onClose, visible, docked, onToggleDock }) is\n * unchanged; the sandbox/session/transport logic lives in AssistantChatArea.\n */\n\nimport { useMemo, useRef, type FC } from 'react';\nimport type { PanelProps } from '@burdenoff/fe-libs/shared/plugins';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { useAssistantKeyboardShortcuts } from '@/hooks/useAssistantKeyboardShortcuts';\nimport { useAssistantHeartbeat } from '@/hooks/useAssistantHeartbeat';\nimport { describeCurrentPage } from '@/utils/pageContext';\nimport { AssistantHeader } from './AssistantHeader';\nimport { AssistantChatArea } from './AssistantChatArea';\nimport { AssistantConversationList } from './AssistantConversationList';\nimport { AssistantSpeechProvider } from './AssistantSpeechProvider';\nimport { useTr } from '../../shared/hooks/useTr';\n\nexport type AIAssistantPanelProps = PanelProps & {\n /** When provided, renders a dock/float toggle in the header. */\n docked?: boolean;\n onToggleDock?: () => void;\n};\n\nexport const AIAssistantPanel: FC<AIAssistantPanelProps> = ({ onClose, visible, docked, onToggleDock }) => {\n const tr = useTr();\n const panelRef = useRef<HTMLDivElement>(null);\n\n const { conversations, activeConversationId, conversationListOpen, toggleConversationList, createConversation } =\n useAssistantStore();\n\n const activeConversation = conversations.find((c) => c.id === activeConversationId);\n const activeSessionId = activeConversation?.backendSessionId ?? null;\n\n // Keep sandbox alive while panel is open\n useAssistantHeartbeat(activeSessionId, activeConversation?.mode ?? null, visible ?? true);\n\n const contextLabel = useMemo(() => describeCurrentPage(), []);\n\n useAssistantKeyboardShortcuts({\n panelRef,\n onClose,\n });\n\n return (\n // Speech output (BOFF-6290) is provided at the panel root so that hiding the\n // panel — not only unmounting it — stops the voice, and so the header toggle\n // and every message's speak button share one playback state.\n <AssistantSpeechProvider visible={visible ?? true}>\n <div\n ref={panelRef}\n className=\"relative flex h-full w-full flex-col bg-bg-surface\"\n role=\"complementary\"\n aria-label={tr('healthybowl.assistant.panel.ariaLabel', 'AI Assistant')}\n data-testid=\"ai-assistant-panel\"\n tabIndex={-1}\n >\n <AssistantHeader\n contextLabel={contextLabel}\n onNewConversation={() => createConversation()}\n onOpenHistory={toggleConversationList}\n historyOpen={conversationListOpen}\n onClose={onClose}\n docked={docked}\n onToggleDock={onToggleDock}\n />\n\n {/* Conversation history overlay drawer (switch between chats) */}\n {conversationListOpen && <AssistantConversationList />}\n\n <AssistantChatArea />\n </div>\n </AssistantSpeechProvider>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AIAssistantPanel.js","names":[],"sources":["../../../src/components/assistant/AIAssistantPanel.tsx"],"sourcesContent":["/**\n * AI Assistant Panel — top-level component for the in-page assistant.\n *\n * Layout (v2): a fixed identity header (AssistantHeader) with the brand mark,\n * an availability/context subtitle and icon actions (new conversation, history,\n * export, dock, close), an always-visible transcript, and the composer pinned\n * to the bottom. Conversation history opens as an overlay drawer over the panel\n * — never as an accordion over the transcript.\n *\n * The external prop contract ({ onClose, visible, docked, onToggleDock }) is\n * unchanged; the sandbox/session/transport logic lives in AssistantChatArea.\n */\n\nimport { useMemo, useRef, type FC } from 'react';\nimport type { PanelProps } from '@burdenoff/fe-libs/shared/plugins';\nimport { useFilesServiceWarmup } from '@burdenoff/fe-libs/storage';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { useAssistantKeyboardShortcuts } from '@/hooks/useAssistantKeyboardShortcuts';\nimport { useAssistantHeartbeat } from '@/hooks/useAssistantHeartbeat';\nimport { describeCurrentPage } from '@/utils/pageContext';\nimport { AssistantHeader } from './AssistantHeader';\nimport { AssistantChatArea } from './AssistantChatArea';\nimport { AssistantConversationList } from './AssistantConversationList';\nimport { AssistantSpeechProvider } from './AssistantSpeechProvider';\nimport { useTr } from '../../shared/hooks/useTr';\n\nexport type AIAssistantPanelProps = PanelProps & {\n /** When provided, renders a dock/float toggle in the header. */\n docked?: boolean;\n onToggleDock?: () => void;\n};\n\nexport const AIAssistantPanel: FC<AIAssistantPanelProps> = ({ onClose, visible, docked, onToggleDock }) => {\n const tr = useTr();\n const panelRef = useRef<HTMLDivElement>(null);\n\n const { conversations, activeConversationId, conversationListOpen, toggleConversationList, createConversation } =\n useAssistantStore();\n\n const activeConversation = conversations.find((c) => c.id === activeConversationId);\n const activeSessionId = activeConversation?.backendSessionId ?? null;\n\n // Keep sandbox alive while panel is open\n useAssistantHeartbeat(activeSessionId, activeConversation?.mode ?? null, visible ?? true);\n\n // Wake wspace-files-svc the moment the panel opens. It runs at minReplicas 0 and\n // needs >=51s to bind its port (prisma migrate deploy 26.0s + boot ~25.5s) against\n // the gateway's 15s budget, so the first attachment after any quiet period would\n // otherwise fail outright. Firing here means the container boots while the user is\n // still typing. Best-effort by construction: single-flighted, rate-limited, and it\n // never surfaces an error — see fe-libs `warmFilesService`.\n useFilesServiceWarmup(visible ?? true);\n\n const contextLabel = useMemo(() => describeCurrentPage(), []);\n\n useAssistantKeyboardShortcuts({\n panelRef,\n onClose,\n });\n\n return (\n // Speech output (BOFF-6290) is provided at the panel root so that hiding the\n // panel — not only unmounting it — stops the voice, and so the header toggle\n // and every message's speak button share one playback state.\n <AssistantSpeechProvider visible={visible ?? true}>\n <div\n ref={panelRef}\n className=\"relative flex h-full w-full flex-col bg-bg-surface\"\n role=\"complementary\"\n aria-label={tr('healthybowl.assistant.panel.ariaLabel', 'AI Assistant')}\n data-testid=\"ai-assistant-panel\"\n tabIndex={-1}\n >\n <AssistantHeader\n contextLabel={contextLabel}\n onNewConversation={() => createConversation()}\n onOpenHistory={toggleConversationList}\n historyOpen={conversationListOpen}\n onClose={onClose}\n docked={docked}\n onToggleDock={onToggleDock}\n />\n\n {/* Conversation history overlay drawer (switch between chats) */}\n {conversationListOpen && <AssistantConversationList />}\n\n <AssistantChatArea />\n </div>\n </AssistantSpeechProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAgCA,IAAa,KAA+C,EAAE,YAAS,YAAS,WAAQ,sBAAmB;CACzG,IAAM,IAAK,GAAO,EACZ,IAAW,EAAuB,KAAK,EAEvC,EAAE,kBAAe,yBAAsB,yBAAsB,2BAAwB,0BACzF,GAAmB,EAEf,IAAqB,EAAc,MAAM,MAAM,EAAE,OAAO,EAAqB;AAYnF,CARA,EAHwB,GAAoB,oBAAoB,MAGzB,GAAoB,QAAQ,MAAM,KAAW,GAAK,EAQzF,EAAsB,KAAW,GAAK;CAEtC,IAAM,IAAe,QAAc,GAAqB,EAAE,EAAE,CAAC;AAO7D,QALA,EAA8B;EAC5B;EACA;EACD,CAAC,EAMA,kBAAC,GAAD;EAAyB,SAAS,KAAW;YAC3C,kBAAC,OAAD;GACE,KAAK;GACL,WAAU;GACV,MAAK;GACL,cAAY,EAAG,yCAAyC,eAAe;GACvE,eAAY;GACZ,UAAU;aANZ;IAQE,kBAAC,GAAD;KACgB;KACd,yBAAyB,GAAoB;KAC7C,eAAe;KACf,aAAa;KACJ;KACD;KACM;KACd,CAAA;IAGD,KAAwB,kBAAC,GAAD,EAA6B,CAAA;IAEtD,kBAAC,GAAD,EAAqB,CAAA;IACjB;;EACkB,CAAA"}
|
|
@@ -30,7 +30,7 @@ var u = ({ attachments: u, onRemove: d, onRetry: f, disabled: p = !1 }) => {
|
|
|
30
30
|
children: e.filename
|
|
31
31
|
}), /* @__PURE__ */ c("span", {
|
|
32
32
|
className: "block truncate text-[10px] leading-tight text-text-muted",
|
|
33
|
-
children: h ? e.error ?? m("healthybowl.assistant.attachments.failed", "Upload failed") : u ? m("healthybowl.assistant.attachments.uploading", "Uploading…") : t(e.size)
|
|
33
|
+
children: h ? e.error ?? m("healthybowl.assistant.attachments.failed", "Upload failed") : u ? e.progressNote ?? m("healthybowl.assistant.attachments.uploading", "Uploading…") : t(e.size)
|
|
34
34
|
})]
|
|
35
35
|
}),
|
|
36
36
|
h && /* @__PURE__ */ c("button", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantAttachmentChips.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantAttachmentChips.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { AlertCircle, FileText, Loader2, Paperclip, RotateCcw, X } from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { formatBytes, type AssistantAttachment } from '@/utils/assistantAttachments';\n\ninterface Props {\n attachments: AssistantAttachment[];\n onRemove: (id: string) => void;\n /** Re-upload a failed attachment from the bytes already prepared. */\n onRetry: (id: string) => void;\n disabled?: boolean;\n}\n\n/**\n * Pending-attachment strip above the composer input (Workstream 3).\n *\n * Images get a thumbnail, everything else a typed icon chip. Upload state is\n * shown on the chip itself — a spinner while it is in flight, a red outline plus\n * the reason when it fails — so a farmer on a weak connection can see which\n * photo is still going up instead of guessing why send is disabled.\n */\nexport const AssistantAttachmentChips: FC<Props> = ({ attachments, onRemove, onRetry, disabled = false }) => {\n const tr = useTr();\n if (attachments.length === 0) return null;\n\n return (\n <ul\n className=\"mb-1.5 flex flex-wrap gap-1.5 px-0.5\"\n aria-label={tr('healthybowl.assistant.attachments.listLabel', 'Attached files')}\n data-testid=\"assistant-attachment-chips\"\n >\n {attachments.map((attachment) => {\n const isBusy = attachment.status === 'pending' || attachment.status === 'uploading';\n const isError = attachment.status === 'error';\n\n return (\n <li\n key={attachment.id}\n className={`flex max-w-[220px] items-center gap-1.5 rounded-lg border py-1 pl-1 pr-1.5 ${\n isError ? 'border-status-error-text/40 bg-status-error-bg/10' : 'border-border-subtle bg-bg-surface'\n }`}\n data-testid=\"assistant-attachment-chip\"\n >\n <span className=\"flex size-7 flex-shrink-0 items-center justify-center overflow-hidden rounded-md bg-bg-sunken text-text-muted\">\n {attachment.previewUrl ? (\n <img src={attachment.previewUrl} alt=\"\" className=\"size-full object-cover\" />\n ) : isError ? (\n <AlertCircle className=\"size-3.5 text-status-error-text\" />\n ) : attachment.kind === 'text' ? (\n <FileText className=\"size-3.5\" />\n ) : (\n <Paperclip className=\"size-3.5\" />\n )}\n </span>\n\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[11px] font-medium leading-tight text-text-primary\">\n {attachment.filename}\n </span>\n <span className=\"block truncate text-[10px] leading-tight text-text-muted\">\n {isError\n ? (attachment.error ?? tr('healthybowl.assistant.attachments.failed', 'Upload failed'))\n : isBusy\n ? tr('healthybowl.assistant.attachments.uploading', 'Uploading…')\n : formatBytes(attachment.size)}\n </span>\n </span>\n\n {isError && (\n <button\n type=\"button\"\n onClick={() => onRetry(attachment.id)}\n disabled={disabled}\n className=\"flex size-5 flex-shrink-0 items-center justify-center rounded-full text-status-error-text transition-colors hover:bg-bg-sunken focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed\"\n aria-label={tr('healthybowl.assistant.attachments.retry', 'Retry uploading {{name}}', {\n name: attachment.filename,\n })}\n data-testid=\"assistant-attachment-retry\"\n >\n <RotateCcw className=\"size-3\" />\n </button>\n )}\n\n {isBusy ? (\n <Loader2\n className=\"size-3.5 flex-shrink-0 animate-spin text-text-muted\"\n aria-label={tr('healthybowl.assistant.attachments.uploading', 'Uploading…')}\n />\n ) : (\n <button\n type=\"button\"\n onClick={() => onRemove(attachment.id)}\n disabled={disabled}\n className=\"flex size-5 flex-shrink-0 items-center justify-center rounded-full text-text-muted transition-colors hover:bg-bg-sunken hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed\"\n aria-label={tr('healthybowl.assistant.attachments.remove', 'Remove {{name}}', {\n name: attachment.filename,\n })}\n data-testid=\"assistant-attachment-remove\"\n >\n <X className=\"size-3\" />\n </button>\n )}\n </li>\n );\n })}\n </ul>\n );\n};\n"],"mappings":";;;;;AAqBA,IAAa,KAAuC,EAAE,gBAAa,aAAU,YAAS,cAAW,SAAY;CAC3G,IAAM,IAAK,GAAO;AAGlB,QAFI,EAAY,WAAW,IAAU,OAGnC,kBAAC,MAAD;EACE,WAAU;EACV,cAAY,EAAG,+CAA+C,iBAAiB;EAC/E,eAAY;YAEX,EAAY,KAAK,MAAe;GAC/B,IAAM,IAAS,EAAW,WAAW,aAAa,EAAW,WAAW,aAClE,IAAU,EAAW,WAAW;AAEtC,UACE,kBAAC,MAAD;IAEE,WAAW,8EACT,IAAU,sDAAsD;IAElE,eAAY;cALd;KAOE,kBAAC,QAAD;MAAM,WAAU;gBACb,EAAW,aACV,kBAAC,OAAD;OAAK,KAAK,EAAW;OAAY,KAAI;OAAG,WAAU;OAA2B,CAAA,GAC3E,IACF,kBAAC,GAAD,EAAa,WAAU,mCAAoC,CAAA,GACzD,EAAW,SAAS,SACtB,kBAAC,GAAD,EAAU,WAAU,YAAa,CAAA,GAEjC,kBAAC,GAAD,EAAW,WAAU,YAAa,CAAA;MAE/B,CAAA;KAEP,kBAAC,QAAD;MAAM,WAAU;gBAAhB,CACE,kBAAC,QAAD;OAAM,WAAU;iBACb,EAAW;OACP,CAAA,EACP,kBAAC,QAAD;OAAM,WAAU;iBACb,IACI,EAAW,SAAS,EAAG,4CAA4C,gBAAgB,GACpF,
|
|
1
|
+
{"version":3,"file":"AssistantAttachmentChips.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantAttachmentChips.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { AlertCircle, FileText, Loader2, Paperclip, RotateCcw, X } from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { formatBytes, type AssistantAttachment } from '@/utils/assistantAttachments';\n\ninterface Props {\n attachments: AssistantAttachment[];\n onRemove: (id: string) => void;\n /** Re-upload a failed attachment from the bytes already prepared. */\n onRetry: (id: string) => void;\n disabled?: boolean;\n}\n\n/**\n * Pending-attachment strip above the composer input (Workstream 3).\n *\n * Images get a thumbnail, everything else a typed icon chip. Upload state is\n * shown on the chip itself — a spinner while it is in flight, a red outline plus\n * the reason when it fails — so a farmer on a weak connection can see which\n * photo is still going up instead of guessing why send is disabled.\n */\nexport const AssistantAttachmentChips: FC<Props> = ({ attachments, onRemove, onRetry, disabled = false }) => {\n const tr = useTr();\n if (attachments.length === 0) return null;\n\n return (\n <ul\n className=\"mb-1.5 flex flex-wrap gap-1.5 px-0.5\"\n aria-label={tr('healthybowl.assistant.attachments.listLabel', 'Attached files')}\n data-testid=\"assistant-attachment-chips\"\n >\n {attachments.map((attachment) => {\n const isBusy = attachment.status === 'pending' || attachment.status === 'uploading';\n const isError = attachment.status === 'error';\n\n return (\n <li\n key={attachment.id}\n className={`flex max-w-[220px] items-center gap-1.5 rounded-lg border py-1 pl-1 pr-1.5 ${\n isError ? 'border-status-error-text/40 bg-status-error-bg/10' : 'border-border-subtle bg-bg-surface'\n }`}\n data-testid=\"assistant-attachment-chip\"\n >\n <span className=\"flex size-7 flex-shrink-0 items-center justify-center overflow-hidden rounded-md bg-bg-sunken text-text-muted\">\n {attachment.previewUrl ? (\n <img src={attachment.previewUrl} alt=\"\" className=\"size-full object-cover\" />\n ) : isError ? (\n <AlertCircle className=\"size-3.5 text-status-error-text\" />\n ) : attachment.kind === 'text' ? (\n <FileText className=\"size-3.5\" />\n ) : (\n <Paperclip className=\"size-3.5\" />\n )}\n </span>\n\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[11px] font-medium leading-tight text-text-primary\">\n {attachment.filename}\n </span>\n <span className=\"block truncate text-[10px] leading-tight text-text-muted\">\n {isError\n ? (attachment.error ?? tr('healthybowl.assistant.attachments.failed', 'Upload failed'))\n : isBusy\n ? // `progressNote` explains a long wait (a scale-to-zero files-svc\n // container needs ~51s to boot, so fe-libs retries for about a\n // minute). Still an upload in progress, never an error.\n (attachment.progressNote ?? tr('healthybowl.assistant.attachments.uploading', 'Uploading…'))\n : formatBytes(attachment.size)}\n </span>\n </span>\n\n {isError && (\n <button\n type=\"button\"\n onClick={() => onRetry(attachment.id)}\n disabled={disabled}\n className=\"flex size-5 flex-shrink-0 items-center justify-center rounded-full text-status-error-text transition-colors hover:bg-bg-sunken focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed\"\n aria-label={tr('healthybowl.assistant.attachments.retry', 'Retry uploading {{name}}', {\n name: attachment.filename,\n })}\n data-testid=\"assistant-attachment-retry\"\n >\n <RotateCcw className=\"size-3\" />\n </button>\n )}\n\n {isBusy ? (\n <Loader2\n className=\"size-3.5 flex-shrink-0 animate-spin text-text-muted\"\n aria-label={tr('healthybowl.assistant.attachments.uploading', 'Uploading…')}\n />\n ) : (\n <button\n type=\"button\"\n onClick={() => onRemove(attachment.id)}\n disabled={disabled}\n className=\"flex size-5 flex-shrink-0 items-center justify-center rounded-full text-text-muted transition-colors hover:bg-bg-sunken hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed\"\n aria-label={tr('healthybowl.assistant.attachments.remove', 'Remove {{name}}', {\n name: attachment.filename,\n })}\n data-testid=\"assistant-attachment-remove\"\n >\n <X className=\"size-3\" />\n </button>\n )}\n </li>\n );\n })}\n </ul>\n );\n};\n"],"mappings":";;;;;AAqBA,IAAa,KAAuC,EAAE,gBAAa,aAAU,YAAS,cAAW,SAAY;CAC3G,IAAM,IAAK,GAAO;AAGlB,QAFI,EAAY,WAAW,IAAU,OAGnC,kBAAC,MAAD;EACE,WAAU;EACV,cAAY,EAAG,+CAA+C,iBAAiB;EAC/E,eAAY;YAEX,EAAY,KAAK,MAAe;GAC/B,IAAM,IAAS,EAAW,WAAW,aAAa,EAAW,WAAW,aAClE,IAAU,EAAW,WAAW;AAEtC,UACE,kBAAC,MAAD;IAEE,WAAW,8EACT,IAAU,sDAAsD;IAElE,eAAY;cALd;KAOE,kBAAC,QAAD;MAAM,WAAU;gBACb,EAAW,aACV,kBAAC,OAAD;OAAK,KAAK,EAAW;OAAY,KAAI;OAAG,WAAU;OAA2B,CAAA,GAC3E,IACF,kBAAC,GAAD,EAAa,WAAU,mCAAoC,CAAA,GACzD,EAAW,SAAS,SACtB,kBAAC,GAAD,EAAU,WAAU,YAAa,CAAA,GAEjC,kBAAC,GAAD,EAAW,WAAU,YAAa,CAAA;MAE/B,CAAA;KAEP,kBAAC,QAAD;MAAM,WAAU;gBAAhB,CACE,kBAAC,QAAD;OAAM,WAAU;iBACb,EAAW;OACP,CAAA,EACP,kBAAC,QAAD;OAAM,WAAU;iBACb,IACI,EAAW,SAAS,EAAG,4CAA4C,gBAAgB,GACpF,IAIG,EAAW,gBAAgB,EAAG,+CAA+C,aAAa,GAC3F,EAAY,EAAW,KAAK;OAC7B,CAAA,CACF;;KAEN,KACC,kBAAC,UAAD;MACE,MAAK;MACL,eAAe,EAAQ,EAAW,GAAG;MAC3B;MACV,WAAU;MACV,cAAY,EAAG,2CAA2C,4BAA4B,EACpF,MAAM,EAAW,UAClB,CAAC;MACF,eAAY;gBAEZ,kBAAC,GAAD,EAAW,WAAU,UAAW,CAAA;MACzB,CAAA;KAGV,IACC,kBAAC,GAAD;MACE,WAAU;MACV,cAAY,EAAG,+CAA+C,aAAa;MAC3E,CAAA,GAEF,kBAAC,UAAD;MACE,MAAK;MACL,eAAe,EAAS,EAAW,GAAG;MAC5B;MACV,WAAU;MACV,cAAY,EAAG,4CAA4C,mBAAmB,EAC5E,MAAM,EAAW,UAClB,CAAC;MACF,eAAY;gBAEZ,kBAAC,GAAD,EAAG,WAAU,UAAW,CAAA;MACjB,CAAA;KAER;MApEE,EAAW,GAoEb;IAEP;EACC,CAAA"}
|
|
@@ -71,9 +71,31 @@ var O = (e) => {
|
|
|
71
71
|
mentionedUserIds: e.mentionedIds
|
|
72
72
|
} }
|
|
73
73
|
}).catch(() => {});
|
|
74
|
-
}, [w]), J =
|
|
74
|
+
}, [w]), J = [
|
|
75
|
+
{
|
|
76
|
+
status: "BACKLOG",
|
|
77
|
+
label: "Backlog"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
status: "TODO",
|
|
81
|
+
label: "To Do"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
status: "IN_PROGRESS",
|
|
85
|
+
label: "In Progress"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
status: "IN_REVIEW",
|
|
89
|
+
label: "In Review"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
status: "DONE",
|
|
93
|
+
label: "Done"
|
|
94
|
+
}
|
|
95
|
+
], Y = d(() => w ? /* @__PURE__ */ x(T, {
|
|
75
96
|
client: w,
|
|
76
97
|
children: /* @__PURE__ */ x(a, {
|
|
98
|
+
columns: J,
|
|
77
99
|
workspaceId: p,
|
|
78
100
|
projectId: I ?? void 0,
|
|
79
101
|
readonly: !K,
|
|
@@ -126,7 +148,7 @@ var O = (e) => {
|
|
|
126
148
|
title: "Couldn't open Farm Tasks",
|
|
127
149
|
description: R.message,
|
|
128
150
|
onRetry: z
|
|
129
|
-
}) : L || !I ? /* @__PURE__ */ x(i, {}) :
|
|
151
|
+
}) : L || !I ? /* @__PURE__ */ x(i, {}) : Y : /* @__PURE__ */ x(r, {
|
|
130
152
|
title: "Tasks unavailable",
|
|
131
153
|
description: "The workspace connection isn't ready. Reload the page or reselect your workspace."
|
|
132
154
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TasksPage.js","names":[],"sources":["../../../../src/healthybowl/pages/tasks/TasksPage.tsx"],"sourcesContent":["/**\n * TasksPage — HealthyBowl \"Farm Tasks\".\n *\n * Embeds the composed `<TasksPageCore/>` from `@burdenoff/planmagnet-fe-sdk`\n * (kanban board + create flow + click-to-open detail with inline edit) so farm\n * teams can plan and track work items backed by `wspace-planmagnet-svc`.\n *\n * Wiring:\n * - workspaceId — from the HealthyBowl workspace context (`useHealthyBowl`).\n * - Apollo — the app shell's WORKSPACE gateway client (`useSafeGatewayClient\n * ('workspace')`), the same authed client every other HB page uses. The SDK\n * core is BYO-Apollo, so we wrap it in an `<ApolloProvider>` bound to that\n * client (rather than relying on the ambient default) to be explicit.\n * - projectId — a per-workspace \"Farm Tasks\" project, get-or-created via\n * `useDefaultTaskProject`. Farmers never see PlanMagnet's project concept.\n *\n * Theming: the SDK renders with semantic tokens (`bg-primary`, `text-foreground`,\n * `text-destructive`, `border-border`, …) which resolve against fe-libs' shipped\n * tokens, so the forest theme is inherited — no SDK stylesheet import and no raw\n * colors.\n *\n * Host wiring beyond Apollo + project:\n * - labels — HB's i18n catalog via `useFarmTaskLabels` (6 languages).\n * - assignee picker — the real workspace member directory\n * (`useWorkspaceDirectory`), so tasks show names/avatars and the create/edit\n * forms offer a member dropdown instead of a raw actor-id field.\n * - readonly — Viewers/Members (read-only on `planmagnet-workitem`) get\n * a read-only board via `useCanManageTasks` (fails open; server enforces).\n * - currentActorId — enables the toolbar \"My tasks\" filter.\n * - entity-linked create — shipped as `CreateFarmTaskButton` on Field/Crop/\n * Animal detail pages and Pest Issue rows (WorkItemLink); no longer a TODO.\n *\n * @module healthybowl\n */\n\nimport { useCallback, useMemo, type FC, type ReactNode } from 'react';\nimport { useNavigate, useSearchParams } from 'react-router';\nimport { gql } from '@apollo/client';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { useSafeGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspaceDirectory } from '@burdenoff/fe-libs/sharing';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { TasksPageCore, type AssigneeOption } from '@burdenoff/planmagnet-fe-sdk';\nimport { Bug, ListChecks, MapPin, PawPrint, Printer, Sprout } from 'lucide-react';\nimport { PageLayout, ErrorState, PageLoader } from '../../components';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useDefaultTaskProject } from './useDefaultTaskProject';\nimport { useFarmTaskLabels } from './useFarmTaskLabels';\nimport { useCanManageTasks } from './useCanManageTasks';\nimport { todayDateParam } from './useJobCardTasks';\n\n/**\n * Farm icon per linked-entity type, so a task's linked-record chip shows a\n * leaf / field / animal / pest issue glyph (the SDK falls back to a generic link\n * glyph for anything unmapped). Module-level so it's referentially stable.\n */\nconst renderFarmLinkIcon = (entityType: string): ReactNode => {\n switch (entityType) {\n case 'FIELD':\n return <MapPin className=\"h-3 w-3\" aria-hidden=\"true\" />;\n case 'CROP':\n return <Sprout className=\"h-3 w-3\" aria-hidden=\"true\" />;\n case 'ANIMAL':\n return <PawPrint className=\"h-3 w-3\" aria-hidden=\"true\" />;\n case 'PEST_ISSUE':\n case 'PEST':\n return <Bug className=\"h-3 w-3\" aria-hidden=\"true\" />;\n default:\n return null;\n }\n};\n\n/**\n * IN_APP-notify @-mentioned members of a task comment. The comment lives in the\n * shared conversations service (which can't carry the workspace member ids), so\n * the SDK hands us the mentioned ids via `onMention` and wspace-healthybowl-svc\n * dispatches the notifications with its own service identity.\n */\nconst NOTIFY_MENTION = gql`\n mutation HealthyBowlNotifyMention($input: HealthyBowlNotifyMentionInput!) {\n healthybowlNotifyMention(input: $input)\n }\n`;\n\nexport const TasksPage: FC = () => {\n const { workspaceId, currentUser, authToken, apiGatewayUrl } = useHealthyBowl();\n // The workspace gateway client the whole app already uses (dual-token auth +\n // x-workspace-id). Null only if the shell's GatewayProvider isn't mounted.\n const workspaceClient = useSafeGatewayClient('workspace');\n const ownerId = currentUser?.id;\n // Deep-link from the calendar: `/healthybowl/tasks?item=<id>` opens that task.\n const [searchParams] = useSearchParams();\n const openItemId = searchParams.get('item') ?? undefined;\n\n // \"Print job card\" entry point (BOFF-6120): today's run-sheet for the current\n // user, deep-linked via buildPath — never a bare relative path.\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const openJobCard = useCallback(() => {\n const params = new URLSearchParams({ date: todayDateParam() });\n if (ownerId) params.set('assignee', ownerId);\n navigate(`${buildPath('tasks/job-card')}?${params.toString()}`);\n }, [navigate, buildPath, ownerId]);\n\n const {\n projectId,\n loading: projectLoading,\n error: projectError,\n retry,\n } = useDefaultTaskProject(workspaceClient, workspaceId, ownerId);\n\n // Farm-team member directory → real assignee names/avatars + a picker.\n const { members } = useWorkspaceDirectory({ workspaceId, authToken, apiGatewayUrl });\n const assigneeOptions = useMemo<AssigneeOption[]>(() => members.map((m) => ({ id: m.id, name: m.name })), [members]);\n const memberNameById = useMemo(() => new Map(members.map((m) => [m.id, m.name])), [members]);\n const resolveAssignee = useCallback(\n (id: string) => {\n const name = memberNameById.get(id);\n return name ? { name } : null;\n },\n [memberNameById]\n );\n\n // HB i18n → SDK label contract (6 languages, English fallback).\n const labels = useFarmTaskLabels();\n // Active language → localizes the Timeline's weekday/month names in the SDK.\n const { locale } = useI18n();\n // Read-only for Viewers/Members (fails open; server still enforces RBAC).\n const { canManage } = useCanManageTasks(workspaceId);\n\n // @mention notifications: the SDK fires this after a comment @-mentions\n // members; dispatch IN_APP notifications via wspace-healthybowl-svc (which\n // notifies with its service identity). Fire-and-forget — never blocks the UI.\n const handleMention = useCallback(\n (payload: { mentionedIds: string[]; entityId: string }) => {\n if (!workspaceClient || payload.mentionedIds.length === 0) return;\n void workspaceClient\n .mutate({\n mutation: NOTIFY_MENTION,\n variables: {\n input: { taskId: payload.entityId, mentionedUserIds: payload.mentionedIds },\n },\n })\n .catch(() => {\n // Best-effort: a notification failure must never disrupt commenting.\n });\n },\n [workspaceClient]\n );\n\n // The SDK core is BYO-Apollo: give it an ApolloProvider explicitly bound to\n // the workspace client so it never depends on the ambient default gateway.\n const board = useMemo(() => {\n if (!workspaceClient) return null;\n return (\n <ApolloProvider client={workspaceClient}>\n <TasksPageCore\n workspaceId={workspaceId}\n projectId={projectId ?? undefined}\n readonly={!canManage}\n currentActorId={ownerId}\n commentsEntityType=\"planmagnet_workitem\"\n onMention={handleMention}\n openItemId={openItemId}\n labels={labels}\n locale={locale}\n assigneeOptions={assigneeOptions}\n resolveAssignee={resolveAssignee}\n linkSourceProduct=\"healthybowl\"\n renderLinkIcon={renderFarmLinkIcon}\n enableSavedViews\n enableShortcuts\n onTaskSaved={() => {\n // The SDK already refetches its own board list after a save; nothing\n // else in HB depends on this data yet, so this is a deliberate no-op.\n }}\n />\n </ApolloProvider>\n );\n }, [\n workspaceClient,\n workspaceId,\n projectId,\n canManage,\n ownerId,\n openItemId,\n labels,\n locale,\n assigneeOptions,\n resolveAssignee,\n handleMention,\n ]);\n\n return (\n <PageLayout\n title=\"Farm Tasks\"\n titleAccent=\"Tasks\"\n description=\"Plan and track farm work — planting, harvesting, maintenance, and more — on a shared board.\"\n helpPrompt=\"How do I use Farm Tasks to plan and track work on my farm?\"\n purpose=\"Farm Tasks is your team's shared to-do board. Create tasks, set priority and due dates, drag them across columns as work progresses, and open any task for details.\"\n purposeIcon={<ListChecks className=\"size-5\" aria-hidden=\"true\" />}\n actions={\n <Button variant=\"outline\" onClick={openJobCard}>\n <Printer className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" /> Print job card\n </Button>\n }\n >\n {!workspaceClient ? (\n <ErrorState\n title=\"Tasks unavailable\"\n description=\"The workspace connection isn't ready. Reload the page or reselect your workspace.\"\n />\n ) : projectError ? (\n <ErrorState title=\"Couldn't open Farm Tasks\" description={projectError.message} onRetry={retry} />\n ) : projectLoading || !projectId ? (\n <PageLoader />\n ) : (\n board\n )}\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0DA,IAAM,KAAsB,MAAkC;AAC5D,SAAQ,GAAR;EACE,KAAK,QACH,QAAO,kBAAC,GAAD;GAAQ,WAAU;GAAU,eAAY;GAAS,CAAA;EAC1D,KAAK,OACH,QAAO,kBAAC,GAAD;GAAQ,WAAU;GAAU,eAAY;GAAS,CAAA;EAC1D,KAAK,SACH,QAAO,kBAAC,GAAD;GAAU,WAAU;GAAU,eAAY;GAAS,CAAA;EAC5D,KAAK;EACL,KAAK,OACH,QAAO,kBAAC,GAAD;GAAK,WAAU;GAAU,eAAY;GAAS,CAAA;EACvD,QACE,QAAO;;GAUP,IAAiB,CAAG;;;;GAMb,UAAsB;CACjC,IAAM,EAAE,gBAAa,gBAAa,cAAW,qBAAkB,GAAgB,EAGzE,IAAkB,EAAqB,YAAY,EACnD,IAAU,GAAa,IAEvB,CAAC,KAAgB,GAAiB,EAClC,IAAa,EAAa,IAAI,OAAO,IAAI,KAAA,GAIzC,IAAW,GAAa,EACxB,EAAE,iBAAc,GAAa,EAC7B,IAAc,QAAkB;EACpC,IAAM,IAAS,IAAI,gBAAgB,EAAE,MAAM,GAAgB,EAAE,CAAC;AAE9D,EADI,KAAS,EAAO,IAAI,YAAY,EAAQ,EAC5C,EAAS,GAAG,EAAU,iBAAiB,CAAC,GAAG,EAAO,UAAU,GAAG;IAC9D;EAAC;EAAU;EAAW;EAAQ,CAAC,EAE5B,EACJ,cACA,SAAS,GACT,OAAO,GACP,aACE,EAAsB,GAAiB,GAAa,EAAQ,EAG1D,EAAE,eAAY,EAAsB;EAAE;EAAa;EAAW;EAAe,CAAC,EAC9E,IAAkB,QAAgC,EAAQ,KAAK,OAAO;EAAE,IAAI,EAAE;EAAI,MAAM,EAAE;EAAM,EAAE,EAAE,CAAC,EAAQ,CAAC,EAC9G,IAAiB,QAAc,IAAI,IAAI,EAAQ,KAAK,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAQ,CAAC,EACtF,IAAkB,GACrB,MAAe;EACd,IAAM,IAAO,EAAe,IAAI,EAAG;AACnC,SAAO,IAAO,EAAE,SAAM,GAAG;IAE3B,CAAC,EAAe,CACjB,EAGK,IAAS,GAAmB,EAE5B,EAAE,cAAW,GAAS,EAEtB,EAAE,iBAAc,EAAkB,EAAY,EAK9C,IAAgB,GACnB,MAA0D;AACrD,GAAC,KAAmB,EAAQ,aAAa,WAAW,KACnD,EACF,OAAO;GACN,UAAU;GACV,WAAW,EACT,OAAO;IAAE,QAAQ,EAAQ;IAAU,kBAAkB,EAAQ;IAAc,EAC5E;GACF,CAAC,CACD,YAAY,GAEX;IAEN,CAAC,EAAgB,CAClB,EAIK,IAAQ,QACP,IAEH,kBAAC,GAAD;EAAgB,QAAQ;YACtB,kBAAC,GAAD;GACe;GACb,WAAW,KAAa,KAAA;GACxB,UAAU,CAAC;GACX,gBAAgB;GAChB,oBAAmB;GACnB,WAAW;GACC;GACJ;GACA;GACS;GACA;GACjB,mBAAkB;GAClB,gBAAgB;GAChB,kBAAA;GACA,iBAAA;GACA,mBAAmB;GAInB,CAAA;EACa,CAAA,GAxBU,MA0B5B;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QACE,kBAAC,GAAD;EACE,OAAM;EACN,aAAY;EACZ,aAAY;EACZ,YAAW;EACX,SAAQ;EACR,aAAa,kBAAC,GAAD;GAAY,WAAU;GAAS,eAAY;GAAS,CAAA;EACjE,SACE,kBAAC,GAAD;GAAQ,SAAQ;GAAU,SAAS;aAAnC,CACE,kBAAC,GAAD;IAAS,WAAU;IAAiB,eAAY;IAAS,CAAA,EAAA,kBAClD;;YAGT,IAKE,IACF,kBAAC,GAAD;GAAY,OAAM;GAA2B,aAAa,EAAa;GAAS,SAAS;GAAS,CAAA,GAChG,KAAkB,CAAC,IACrB,kBAAC,GAAD,EAAc,CAAA,GAEd,IATA,kBAAC,GAAD;GACE,OAAM;GACN,aAAY;GACZ,CAAA;EAQO,CAAA"}
|
|
1
|
+
{"version":3,"file":"TasksPage.js","names":[],"sources":["../../../../src/healthybowl/pages/tasks/TasksPage.tsx"],"sourcesContent":["/**\n * TasksPage — HealthyBowl \"Farm Tasks\".\n *\n * Embeds the composed `<TasksPageCore/>` from `@burdenoff/planmagnet-fe-sdk`\n * (kanban board + create flow + click-to-open detail with inline edit) so farm\n * teams can plan and track work items backed by `wspace-planmagnet-svc`.\n *\n * Wiring:\n * - workspaceId — from the HealthyBowl workspace context (`useHealthyBowl`).\n * - Apollo — the app shell's WORKSPACE gateway client (`useSafeGatewayClient\n * ('workspace')`), the same authed client every other HB page uses. The SDK\n * core is BYO-Apollo, so we wrap it in an `<ApolloProvider>` bound to that\n * client (rather than relying on the ambient default) to be explicit.\n * - projectId — a per-workspace \"Farm Tasks\" project, get-or-created via\n * `useDefaultTaskProject`. Farmers never see PlanMagnet's project concept.\n *\n * Theming: the SDK renders with semantic tokens (`bg-primary`, `text-foreground`,\n * `text-destructive`, `border-border`, …) which resolve against fe-libs' shipped\n * tokens, so the forest theme is inherited — no SDK stylesheet import and no raw\n * colors.\n *\n * Host wiring beyond Apollo + project:\n * - labels — HB's i18n catalog via `useFarmTaskLabels` (6 languages).\n * - assignee picker — the real workspace member directory\n * (`useWorkspaceDirectory`), so tasks show names/avatars and the create/edit\n * forms offer a member dropdown instead of a raw actor-id field.\n * - readonly — Viewers/Members (read-only on `planmagnet-workitem`) get\n * a read-only board via `useCanManageTasks` (fails open; server enforces).\n * - currentActorId — enables the toolbar \"My tasks\" filter.\n * - entity-linked create — shipped as `CreateFarmTaskButton` on Field/Crop/\n * Animal detail pages and Pest Issue rows (WorkItemLink); no longer a TODO.\n *\n * @module healthybowl\n */\n\nimport { useCallback, useMemo, type FC, type ReactNode } from 'react';\nimport { useNavigate, useSearchParams } from 'react-router';\nimport { gql } from '@apollo/client';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { useSafeGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspaceDirectory } from '@burdenoff/fe-libs/sharing';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { TasksPageCore, type AssigneeOption, type BoardColumn } from '@burdenoff/planmagnet-fe-sdk';\nimport { Bug, ListChecks, MapPin, PawPrint, Printer, Sprout } from 'lucide-react';\nimport { PageLayout, ErrorState, PageLoader } from '../../components';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useDefaultTaskProject } from './useDefaultTaskProject';\nimport { useFarmTaskLabels } from './useFarmTaskLabels';\nimport { useCanManageTasks } from './useCanManageTasks';\nimport { todayDateParam } from './useJobCardTasks';\n\n/**\n * Farm icon per linked-entity type, so a task's linked-record chip shows a\n * leaf / field / animal / pest issue glyph (the SDK falls back to a generic link\n * glyph for anything unmapped). Module-level so it's referentially stable.\n */\nconst renderFarmLinkIcon = (entityType: string): ReactNode => {\n switch (entityType) {\n case 'FIELD':\n return <MapPin className=\"h-3 w-3\" aria-hidden=\"true\" />;\n case 'CROP':\n return <Sprout className=\"h-3 w-3\" aria-hidden=\"true\" />;\n case 'ANIMAL':\n return <PawPrint className=\"h-3 w-3\" aria-hidden=\"true\" />;\n case 'PEST_ISSUE':\n case 'PEST':\n return <Bug className=\"h-3 w-3\" aria-hidden=\"true\" />;\n default:\n return null;\n }\n};\n\n/**\n * IN_APP-notify @-mentioned members of a task comment. The comment lives in the\n * shared conversations service (which can't carry the workspace member ids), so\n * the SDK hands us the mentioned ids via `onMention` and wspace-healthybowl-svc\n * dispatches the notifications with its own service identity.\n */\nconst NOTIFY_MENTION = gql`\n mutation HealthyBowlNotifyMention($input: HealthyBowlNotifyMentionInput!) {\n healthybowlNotifyMention(input: $input)\n }\n`;\n\nexport const TasksPage: FC = () => {\n const { workspaceId, currentUser, authToken, apiGatewayUrl } = useHealthyBowl();\n // The workspace gateway client the whole app already uses (dual-token auth +\n // x-workspace-id). Null only if the shell's GatewayProvider isn't mounted.\n const workspaceClient = useSafeGatewayClient('workspace');\n const ownerId = currentUser?.id;\n // Deep-link from the calendar: `/healthybowl/tasks?item=<id>` opens that task.\n const [searchParams] = useSearchParams();\n const openItemId = searchParams.get('item') ?? undefined;\n\n // \"Print job card\" entry point (BOFF-6120): today's run-sheet for the current\n // user, deep-linked via buildPath — never a bare relative path.\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const openJobCard = useCallback(() => {\n const params = new URLSearchParams({ date: todayDateParam() });\n if (ownerId) params.set('assignee', ownerId);\n navigate(`${buildPath('tasks/job-card')}?${params.toString()}`);\n }, [navigate, buildPath, ownerId]);\n\n const {\n projectId,\n loading: projectLoading,\n error: projectError,\n retry,\n } = useDefaultTaskProject(workspaceClient, workspaceId, ownerId);\n\n // Farm-team member directory → real assignee names/avatars + a picker.\n const { members } = useWorkspaceDirectory({ workspaceId, authToken, apiGatewayUrl });\n const assigneeOptions = useMemo<AssigneeOption[]>(() => members.map((m) => ({ id: m.id, name: m.name })), [members]);\n const memberNameById = useMemo(() => new Map(members.map((m) => [m.id, m.name])), [members]);\n const resolveAssignee = useCallback(\n (id: string) => {\n const name = memberNameById.get(id);\n return name ? { name } : null;\n },\n [memberNameById]\n );\n\n // HB i18n → SDK label contract (6 languages, English fallback).\n const labels = useFarmTaskLabels();\n // Active language → localizes the Timeline's weekday/month names in the SDK.\n const { locale } = useI18n();\n // Read-only for Viewers/Members (fails open; server still enforces RBAC).\n const { canManage } = useCanManageTasks(workspaceId);\n\n // @mention notifications: the SDK fires this after a comment @-mentions\n // members; dispatch IN_APP notifications via wspace-healthybowl-svc (which\n // notifies with its service identity). Fire-and-forget — never blocks the UI.\n const handleMention = useCallback(\n (payload: { mentionedIds: string[]; entityId: string }) => {\n if (!workspaceClient || payload.mentionedIds.length === 0) return;\n void workspaceClient\n .mutate({\n mutation: NOTIFY_MENTION,\n variables: {\n input: { taskId: payload.entityId, mentionedUserIds: payload.mentionedIds },\n },\n })\n .catch(() => {\n // Best-effort: a notification failure must never disrupt commenting.\n });\n },\n [workspaceClient]\n );\n\n // The SDK core is BYO-Apollo: give it an ApolloProvider explicitly bound to\n // the workspace client so it never depends on the ambient default gateway.\n /**\n * The five columns the published use case promises (BOFF-6309).\n *\n * The SDK default adds Testing and Cancelled — engineering workflow states with no\n * farm meaning. A farmer moving \"spray Tomato Block A\" has no use for a Testing\n * column, and each extra column is horizontal scroll on a phone in a field.\n *\n * ★ Narrowing this also narrows what a user can SET: since planmagnet-fe-sdk\n * 2026.813.1, TasksPageCore derives the create / detail / bulk status options from\n * these columns. Before that it did not, and a task set to Testing rendered in no\n * column at all. Do not pin back below that version while this override is here.\n */\n const FARM_BOARD_COLUMNS: BoardColumn[] = [\n { status: 'BACKLOG', label: 'Backlog' },\n { status: 'TODO', label: 'To Do' },\n { status: 'IN_PROGRESS', label: 'In Progress' },\n { status: 'IN_REVIEW', label: 'In Review' },\n { status: 'DONE', label: 'Done' },\n ];\n\n const board = useMemo(() => {\n if (!workspaceClient) return null;\n return (\n <ApolloProvider client={workspaceClient}>\n <TasksPageCore\n columns={FARM_BOARD_COLUMNS}\n workspaceId={workspaceId}\n projectId={projectId ?? undefined}\n readonly={!canManage}\n currentActorId={ownerId}\n commentsEntityType=\"planmagnet_workitem\"\n onMention={handleMention}\n openItemId={openItemId}\n labels={labels}\n locale={locale}\n assigneeOptions={assigneeOptions}\n resolveAssignee={resolveAssignee}\n linkSourceProduct=\"healthybowl\"\n renderLinkIcon={renderFarmLinkIcon}\n enableSavedViews\n enableShortcuts\n onTaskSaved={() => {\n // The SDK already refetches its own board list after a save; nothing\n // else in HB depends on this data yet, so this is a deliberate no-op.\n }}\n />\n </ApolloProvider>\n );\n }, [\n workspaceClient,\n workspaceId,\n projectId,\n canManage,\n ownerId,\n openItemId,\n labels,\n locale,\n assigneeOptions,\n resolveAssignee,\n handleMention,\n ]);\n\n return (\n <PageLayout\n title=\"Farm Tasks\"\n titleAccent=\"Tasks\"\n description=\"Plan and track farm work — planting, harvesting, maintenance, and more — on a shared board.\"\n helpPrompt=\"How do I use Farm Tasks to plan and track work on my farm?\"\n purpose=\"Farm Tasks is your team's shared to-do board. Create tasks, set priority and due dates, drag them across columns as work progresses, and open any task for details.\"\n purposeIcon={<ListChecks className=\"size-5\" aria-hidden=\"true\" />}\n actions={\n <Button variant=\"outline\" onClick={openJobCard}>\n <Printer className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" /> Print job card\n </Button>\n }\n >\n {!workspaceClient ? (\n <ErrorState\n title=\"Tasks unavailable\"\n description=\"The workspace connection isn't ready. Reload the page or reselect your workspace.\"\n />\n ) : projectError ? (\n <ErrorState title=\"Couldn't open Farm Tasks\" description={projectError.message} onRetry={retry} />\n ) : projectLoading || !projectId ? (\n <PageLoader />\n ) : (\n board\n )}\n </PageLayout>\n );\n};\n"],"mappings":"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"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { useTr as e } from "../shared/hooks/useTr.js";
|
|
2
|
+
import { getWorkspaceId as t } from "../utils/assistantContext.js";
|
|
3
|
+
import { AttachmentRejectedError as n, INLINE_IMAGE_QUALITY as r, MAX_INLINE_CHARS_PER_FILE as i, classifyAttachment as a, detectDocumentFormat as o, getAttachmentSendBlocker as s, truncateForInline as c, validateFile as l } from "../utils/assistantAttachments.js";
|
|
4
|
+
import { downscaleImage as u } from "../healthybowl/utils/imageDownscale.js";
|
|
5
|
+
import { extractDocumentText as d } from "../utils/documentExtract.js";
|
|
6
|
+
import { useCallback as f, useEffect as p, useRef as m, useState as h } from "react";
|
|
7
|
+
import { useSaveToFiles as g } from "@burdenoff/fe-libs/storage";
|
|
8
|
+
import { graphqlFetch as _ } from "@burdenoff/fe-libs/shared/graphql";
|
|
8
9
|
//#region src/hooks/useAssistantAttachments.ts
|
|
9
|
-
var
|
|
10
|
-
async function
|
|
10
|
+
var v = "/HealthyBowl/AI Assistant/Attachments", y = "\n query HealthyBowlAssistantAttachmentUrl($id: ID!) {\n getFileDownloadUrl(id: $id)\n }\n";
|
|
11
|
+
async function b(e, t) {
|
|
11
12
|
if (!e || !t) return null;
|
|
12
13
|
try {
|
|
13
|
-
return (await
|
|
14
|
+
return (await _({
|
|
14
15
|
gateway: "workspace",
|
|
15
|
-
query:
|
|
16
|
+
query: y,
|
|
16
17
|
variables: { id: e },
|
|
17
18
|
workspaceToken: !0,
|
|
18
19
|
workspaceId: t,
|
|
@@ -22,175 +23,197 @@ async function y(e, t) {
|
|
|
22
23
|
return null;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
var
|
|
26
|
-
function
|
|
27
|
-
return
|
|
26
|
+
var x = 0;
|
|
27
|
+
function S() {
|
|
28
|
+
return x += 1, `att-${Date.now()}-${x}`;
|
|
28
29
|
}
|
|
29
|
-
async function
|
|
30
|
-
let
|
|
31
|
-
id:
|
|
30
|
+
async function C(e) {
|
|
31
|
+
let t = a(e.type, e.name), s = {
|
|
32
|
+
id: S(),
|
|
32
33
|
status: "pending"
|
|
33
34
|
};
|
|
34
|
-
if (
|
|
35
|
-
let
|
|
35
|
+
if (t === "image") {
|
|
36
|
+
let i = await u(e, {
|
|
36
37
|
encodeFallback: !1,
|
|
37
38
|
inline: {
|
|
38
39
|
maxDim: 768,
|
|
39
|
-
quality:
|
|
40
|
+
quality: r
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
|
-
if (!
|
|
43
|
+
if (!i.downscaled && i.blob.size > 10485760) throw new n("unsupported-image");
|
|
43
44
|
return {
|
|
44
45
|
attachment: {
|
|
45
|
-
...
|
|
46
|
-
filename:
|
|
47
|
-
mimeType:
|
|
48
|
-
size:
|
|
49
|
-
kind:
|
|
50
|
-
previewUrl:
|
|
51
|
-
inlineDataUrl:
|
|
46
|
+
...s,
|
|
47
|
+
filename: i.filename,
|
|
48
|
+
mimeType: i.mimeType,
|
|
49
|
+
size: i.blob.size,
|
|
50
|
+
kind: t,
|
|
51
|
+
previewUrl: i.dataUrl || void 0,
|
|
52
|
+
inlineDataUrl: i.inlineDataUrl
|
|
52
53
|
},
|
|
53
|
-
blob:
|
|
54
|
+
blob: i.blob
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
|
-
if (
|
|
57
|
-
let { text:
|
|
57
|
+
if (t === "text") {
|
|
58
|
+
let { text: n, truncated: r } = c(await e.text(), i);
|
|
58
59
|
return {
|
|
59
60
|
attachment: {
|
|
60
|
-
...
|
|
61
|
+
...s,
|
|
61
62
|
filename: e.name,
|
|
62
63
|
mimeType: e.type || "text/plain",
|
|
63
64
|
size: e.size,
|
|
64
|
-
kind:
|
|
65
|
-
textContent:
|
|
66
|
-
textTruncated:
|
|
65
|
+
kind: t,
|
|
66
|
+
textContent: n,
|
|
67
|
+
textTruncated: r
|
|
67
68
|
},
|
|
68
69
|
blob: e
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
|
-
let
|
|
72
|
-
if (
|
|
73
|
-
let
|
|
72
|
+
let l = o(e.type, e.name);
|
|
73
|
+
if (l) {
|
|
74
|
+
let n = await d(e, l);
|
|
74
75
|
return {
|
|
75
76
|
attachment: {
|
|
76
|
-
...
|
|
77
|
+
...s,
|
|
77
78
|
filename: e.name,
|
|
78
79
|
mimeType: e.type || "application/octet-stream",
|
|
79
80
|
size: e.size,
|
|
80
|
-
kind:
|
|
81
|
-
extraction:
|
|
82
|
-
textContent:
|
|
83
|
-
textTruncated:
|
|
84
|
-
documentPages:
|
|
81
|
+
kind: t,
|
|
82
|
+
extraction: n.extraction,
|
|
83
|
+
textContent: n.textContent,
|
|
84
|
+
textTruncated: n.textTruncated,
|
|
85
|
+
documentPages: n.documentPages
|
|
85
86
|
},
|
|
86
87
|
blob: e
|
|
87
88
|
};
|
|
88
89
|
}
|
|
89
90
|
return {
|
|
90
91
|
attachment: {
|
|
91
|
-
...
|
|
92
|
+
...s,
|
|
92
93
|
filename: e.name,
|
|
93
94
|
mimeType: e.type || "application/octet-stream",
|
|
94
95
|
size: e.size,
|
|
95
|
-
kind:
|
|
96
|
+
kind: t
|
|
96
97
|
},
|
|
97
98
|
blob: e
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
-
let { save:
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
function w() {
|
|
102
|
+
let r = e(), { save: i } = g(), [a, o] = h([]), [c, u] = h(null), d = m(Promise.resolve()), [_, y] = h(0), x = m(0), S = m(/* @__PURE__ */ new Map()), w = m(/* @__PURE__ */ new Set()), T = m(0), E = m(!0);
|
|
103
|
+
p(() => () => {
|
|
104
|
+
E.current = !1;
|
|
104
105
|
}, []);
|
|
105
|
-
let
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}, [
|
|
109
|
-
let
|
|
110
|
-
|
|
106
|
+
let D = m([]);
|
|
107
|
+
p(() => {
|
|
108
|
+
D.current = a;
|
|
109
|
+
}, [a]);
|
|
110
|
+
let O = f((e, t) => {
|
|
111
|
+
E.current && o((n) => n.map((n) => n.id === e ? {
|
|
111
112
|
...n,
|
|
112
113
|
...t
|
|
113
114
|
} : n));
|
|
114
|
-
}, []),
|
|
115
|
-
if (!
|
|
116
|
-
|
|
115
|
+
}, []), k = f(async ({ attachment: e, blob: n }) => {
|
|
116
|
+
if (!w.current.has(e.id)) {
|
|
117
|
+
O(e.id, {
|
|
118
|
+
status: "uploading",
|
|
119
|
+
progressNote: void 0
|
|
120
|
+
});
|
|
117
121
|
try {
|
|
118
|
-
let
|
|
122
|
+
let a = await i({
|
|
119
123
|
source: {
|
|
120
124
|
kind: "blob",
|
|
121
|
-
filename:
|
|
122
|
-
mimeType:
|
|
125
|
+
filename: e.filename,
|
|
126
|
+
mimeType: e.mimeType,
|
|
123
127
|
getBlob: async () => ({
|
|
124
|
-
blob:
|
|
125
|
-
filename:
|
|
126
|
-
mimeType:
|
|
128
|
+
blob: n,
|
|
129
|
+
filename: e.filename,
|
|
130
|
+
mimeType: e.mimeType
|
|
127
131
|
})
|
|
128
132
|
},
|
|
129
|
-
folderPath:
|
|
133
|
+
folderPath: v,
|
|
134
|
+
onRetry: (t) => {
|
|
135
|
+
w.current.has(e.id) || O(e.id, { progressNote: t.kind === "cold-start" ? r("healthybowl.assistant.attachments.waking", "File service is starting up — retry {{attempt}} of {{max}}", {
|
|
136
|
+
attempt: String(t.attempt),
|
|
137
|
+
max: String(t.maxAttempts)
|
|
138
|
+
}) : r("healthybowl.assistant.attachments.retrying", "Retrying {{attempt}} of {{max}}", {
|
|
139
|
+
attempt: String(t.attempt),
|
|
140
|
+
max: String(t.maxAttempts)
|
|
141
|
+
}) });
|
|
142
|
+
}
|
|
130
143
|
});
|
|
131
|
-
if (
|
|
132
|
-
let
|
|
133
|
-
if (
|
|
134
|
-
|
|
144
|
+
if (w.current.has(e.id)) return;
|
|
145
|
+
let o = a?.id ? await b(a.id, t()) : null;
|
|
146
|
+
if (w.current.has(e.id)) return;
|
|
147
|
+
O(e.id, {
|
|
135
148
|
status: "ready",
|
|
136
|
-
fileId:
|
|
137
|
-
downloadUrl:
|
|
149
|
+
fileId: a?.id,
|
|
150
|
+
downloadUrl: o ?? void 0,
|
|
151
|
+
progressNote: void 0
|
|
138
152
|
});
|
|
139
|
-
} catch (
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
142
|
-
|
|
153
|
+
} catch (t) {
|
|
154
|
+
if (w.current.has(e.id)) return;
|
|
155
|
+
if (e.kind === "text" || e.textContent) {
|
|
156
|
+
O(e.id, {
|
|
157
|
+
status: "ready",
|
|
158
|
+
progressNote: void 0
|
|
159
|
+
});
|
|
143
160
|
return;
|
|
144
161
|
}
|
|
145
|
-
|
|
162
|
+
O(e.id, {
|
|
146
163
|
status: "error",
|
|
147
|
-
error:
|
|
164
|
+
error: t instanceof Error ? t.message : "Upload failed",
|
|
165
|
+
progressNote: void 0
|
|
148
166
|
});
|
|
149
167
|
}
|
|
150
168
|
}
|
|
151
|
-
}, [
|
|
169
|
+
}, [
|
|
170
|
+
O,
|
|
171
|
+
i,
|
|
172
|
+
r
|
|
173
|
+
]), A = f((e) => {
|
|
152
174
|
if (!e) return;
|
|
153
|
-
let
|
|
154
|
-
if (
|
|
155
|
-
|
|
175
|
+
let t = Array.from(e);
|
|
176
|
+
if (t.length === 0) return;
|
|
177
|
+
u(null);
|
|
156
178
|
let r = [];
|
|
157
|
-
for (let e of
|
|
158
|
-
let t =
|
|
179
|
+
for (let e of t) {
|
|
180
|
+
let t = l(e, T.current);
|
|
159
181
|
if (t) {
|
|
160
|
-
|
|
182
|
+
u(t);
|
|
161
183
|
continue;
|
|
162
184
|
}
|
|
163
|
-
r.push(e),
|
|
185
|
+
r.push(e), T.current += 1;
|
|
164
186
|
}
|
|
165
187
|
if (r.length !== 0) {
|
|
166
|
-
|
|
188
|
+
y((e) => e + r.length);
|
|
167
189
|
for (let e of r) {
|
|
168
|
-
let
|
|
169
|
-
|
|
190
|
+
let t = x.current;
|
|
191
|
+
d.current = d.current.then(async () => {
|
|
170
192
|
let r = null;
|
|
171
193
|
try {
|
|
172
|
-
r = await
|
|
194
|
+
r = await C(e);
|
|
173
195
|
} catch (e) {
|
|
174
|
-
|
|
196
|
+
T.current = Math.max(0, T.current - 1), E.current && u(e instanceof n ? e.reason : "unreadable");
|
|
175
197
|
}
|
|
176
|
-
if (!
|
|
177
|
-
if (
|
|
178
|
-
|
|
198
|
+
if (!E.current || (y((e) => Math.max(0, e - 1)), !r)) return;
|
|
199
|
+
if (t !== x.current) {
|
|
200
|
+
T.current = Math.max(0, T.current - 1);
|
|
179
201
|
return;
|
|
180
202
|
}
|
|
181
|
-
let
|
|
182
|
-
|
|
203
|
+
let i = r;
|
|
204
|
+
S.current.set(i.attachment.id, i.blob), o((e) => [...e, i.attachment]), await k(i);
|
|
183
205
|
});
|
|
184
206
|
}
|
|
185
207
|
}
|
|
186
|
-
}, [
|
|
187
|
-
|
|
188
|
-
}, []),
|
|
189
|
-
let t =
|
|
190
|
-
!t || t.status !== "error" || !n || (
|
|
208
|
+
}, [k]), j = f((e) => {
|
|
209
|
+
w.current.add(e), S.current.delete(e), T.current = Math.max(0, T.current - 1), o((t) => t.filter((t) => t.id !== e));
|
|
210
|
+
}, []), M = f((e) => {
|
|
211
|
+
let t = D.current.find((t) => t.id === e), n = S.current.get(e);
|
|
212
|
+
!t || t.status !== "error" || !n || (w.current.delete(e), O(e, {
|
|
191
213
|
status: "pending",
|
|
192
|
-
error: void 0
|
|
193
|
-
|
|
214
|
+
error: void 0,
|
|
215
|
+
progressNote: void 0
|
|
216
|
+
}), d.current = d.current.then(() => k({
|
|
194
217
|
attachment: {
|
|
195
218
|
...t,
|
|
196
219
|
status: "pending",
|
|
@@ -198,23 +221,23 @@ function C() {
|
|
|
198
221
|
},
|
|
199
222
|
blob: n
|
|
200
223
|
})));
|
|
201
|
-
}, [
|
|
202
|
-
|
|
203
|
-
}, []),
|
|
224
|
+
}, [O, k]), N = f(() => {
|
|
225
|
+
x.current += 1, T.current = 0, D.current.forEach((e) => w.current.add(e.id)), S.current.clear(), o([]);
|
|
226
|
+
}, []), P = s(_, a);
|
|
204
227
|
return {
|
|
205
|
-
attachments:
|
|
206
|
-
isBusy:
|
|
207
|
-
sendBlocker:
|
|
208
|
-
rejection:
|
|
209
|
-
addFiles:
|
|
210
|
-
remove:
|
|
211
|
-
retry:
|
|
212
|
-
clear:
|
|
213
|
-
clearRejection:
|
|
214
|
-
canAddMore:
|
|
228
|
+
attachments: a,
|
|
229
|
+
isBusy: P === "in-flight",
|
|
230
|
+
sendBlocker: P,
|
|
231
|
+
rejection: c,
|
|
232
|
+
addFiles: A,
|
|
233
|
+
remove: j,
|
|
234
|
+
retry: M,
|
|
235
|
+
clear: N,
|
|
236
|
+
clearRejection: f(() => u(null), []),
|
|
237
|
+
canAddMore: T.current < 5
|
|
215
238
|
};
|
|
216
239
|
}
|
|
217
240
|
//#endregion
|
|
218
|
-
export {
|
|
241
|
+
export { w as useAssistantAttachments };
|
|
219
242
|
|
|
220
243
|
//# sourceMappingURL=useAssistantAttachments.js.map
|