@burdenoff/microfe-healthybowl 2026.725.7 → 2026.727.1
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/AssistantMarkdownImage.js +83 -48
- package/dist/components/assistant/AssistantMarkdownImage.js.map +1 -1
- package/dist/components/assistant/AssistantMessageAttachments.js +1 -0
- package/dist/components/assistant/AssistantMessageAttachments.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,87 +1,122 @@
|
|
|
1
1
|
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
2
|
import { useCallback as t, useEffect as n, useRef as r, useState as i } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { createPortal as
|
|
3
|
+
import { Eye as a, ImageOff as o, X as s } from "lucide-react";
|
|
4
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal as d } from "react-dom";
|
|
6
6
|
//#region src/components/assistant/AssistantMarkdownImage.tsx
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
function f(e) {
|
|
8
|
+
return !/^data:/i.test(e.trim());
|
|
9
|
+
}
|
|
10
|
+
function p(e) {
|
|
11
|
+
try {
|
|
12
|
+
let t = new URL(e.trim());
|
|
13
|
+
return t.protocol === "http:" || t.protocol === "https:" ? t.hostname : null;
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var m = ({ src: m, alt: h, title: g }) => {
|
|
19
|
+
let _ = e(), [v, y] = i(!1), [b, x] = i(!1), [S, C] = i(!1), w = r(null), T = r(null), E = h?.trim() ?? "";
|
|
9
20
|
n(() => {
|
|
10
|
-
if (!
|
|
11
|
-
let e = document.body.style.overflow, t =
|
|
12
|
-
return document.body.style.overflow = "hidden",
|
|
21
|
+
if (!b) return;
|
|
22
|
+
let e = document.body.style.overflow, t = w.current;
|
|
23
|
+
return document.body.style.overflow = "hidden", T.current?.focus(), () => {
|
|
13
24
|
document.body.style.overflow = e, t?.focus();
|
|
14
25
|
};
|
|
15
|
-
}, [
|
|
16
|
-
let
|
|
17
|
-
|
|
26
|
+
}, [b]);
|
|
27
|
+
let D = t(() => x(!1), []), O = (e) => {
|
|
28
|
+
if (e.key === "Escape") {
|
|
29
|
+
e.stopPropagation(), D();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
e.key === "Tab" && (e.preventDefault(), T.current?.focus());
|
|
33
|
+
}, k = (e) => {
|
|
34
|
+
e.target === e.currentTarget && D();
|
|
35
|
+
}, A = !!m && f(m) && !S;
|
|
36
|
+
if (m && A && !v) {
|
|
37
|
+
let e = p(m);
|
|
38
|
+
return /* @__PURE__ */ u("button", {
|
|
39
|
+
type: "button",
|
|
40
|
+
onClick: () => C(!0),
|
|
41
|
+
className: "my-2 flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-left text-[0.9em] text-text-secondary transition-colors hover:border-border-strong hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
|
|
42
|
+
"data-testid": "assistant-markdown-image-gated",
|
|
43
|
+
children: [/* @__PURE__ */ l(a, {
|
|
44
|
+
className: "size-4 flex-shrink-0",
|
|
45
|
+
"aria-hidden": "true"
|
|
46
|
+
}), /* @__PURE__ */ u("span", {
|
|
47
|
+
className: "min-w-0",
|
|
48
|
+
children: [/* @__PURE__ */ l("span", {
|
|
49
|
+
className: "block break-words",
|
|
50
|
+
children: e ? _("healthybowl.assistant.markdown.showRemoteImageNamed", "Show image from {{host}}", { host: e }) : _("healthybowl.assistant.markdown.showRemoteImage", "Show remote image")
|
|
51
|
+
}), E && /* @__PURE__ */ l("span", {
|
|
52
|
+
className: "block truncate text-[0.85em] text-text-muted",
|
|
53
|
+
children: E
|
|
54
|
+
})]
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return !m || v ? /* @__PURE__ */ u("span", {
|
|
18
59
|
className: "my-2 inline-flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-[0.9em] text-text-muted",
|
|
19
60
|
"data-testid": "assistant-markdown-image-fallback",
|
|
20
|
-
children: [/* @__PURE__ */
|
|
61
|
+
children: [/* @__PURE__ */ l(o, {
|
|
21
62
|
className: "size-4 flex-shrink-0",
|
|
22
63
|
"aria-hidden": "true"
|
|
23
|
-
}), /* @__PURE__ */
|
|
64
|
+
}), /* @__PURE__ */ l("span", {
|
|
24
65
|
className: "min-w-0 break-words",
|
|
25
|
-
children:
|
|
66
|
+
children: E || _("healthybowl.assistant.markdown.imageUnavailable", "Image unavailable")
|
|
26
67
|
})]
|
|
27
|
-
}) : /* @__PURE__ */
|
|
28
|
-
ref:
|
|
68
|
+
}) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
|
|
69
|
+
ref: w,
|
|
29
70
|
type: "button",
|
|
30
|
-
onClick: () =>
|
|
31
|
-
"aria-label":
|
|
71
|
+
onClick: () => x(!0),
|
|
72
|
+
"aria-label": E ? _("healthybowl.assistant.markdown.enlargeImageNamed", "Enlarge image: {{alt}}", { alt: E }) : _("healthybowl.assistant.markdown.enlargeImage", "Enlarge image"),
|
|
32
73
|
className: "my-2 block max-w-full cursor-zoom-in overflow-hidden rounded-lg border border-border-subtle bg-bg-sunken focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
|
|
33
74
|
"data-testid": "assistant-markdown-image",
|
|
34
|
-
children: /* @__PURE__ */
|
|
35
|
-
src:
|
|
36
|
-
alt:
|
|
37
|
-
title:
|
|
75
|
+
children: /* @__PURE__ */ l("img", {
|
|
76
|
+
src: m,
|
|
77
|
+
alt: E,
|
|
78
|
+
title: g,
|
|
38
79
|
loading: "lazy",
|
|
39
80
|
decoding: "async",
|
|
40
|
-
|
|
81
|
+
referrerPolicy: "no-referrer",
|
|
82
|
+
onError: () => y(!0),
|
|
41
83
|
className: "max-h-64 w-auto max-w-full object-contain"
|
|
42
84
|
})
|
|
43
|
-
}),
|
|
85
|
+
}), b && typeof document < "u" && d(/* @__PURE__ */ u("div", {
|
|
44
86
|
role: "dialog",
|
|
45
87
|
"aria-modal": "true",
|
|
46
|
-
"aria-label":
|
|
47
|
-
onClick:
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
onKeyDown: (e) => {
|
|
51
|
-
if (e.key === "Escape") {
|
|
52
|
-
e.stopPropagation(), S();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
e.key === "Tab" && (e.preventDefault(), b.current?.focus());
|
|
56
|
-
},
|
|
88
|
+
"aria-label": E ? _("healthybowl.assistant.markdown.imagePreviewNamed", "Image preview: {{alt}}", { alt: E }) : _("healthybowl.assistant.markdown.imagePreview", "Image preview"),
|
|
89
|
+
onClick: k,
|
|
90
|
+
onKeyDown: O,
|
|
57
91
|
className: "fixed inset-0 z-50 flex items-center justify-center bg-bg-canvas/95 p-6 backdrop-blur-sm motion-safe:transition-opacity",
|
|
58
92
|
"data-testid": "assistant-markdown-image-lightbox",
|
|
59
|
-
children: [/* @__PURE__ */
|
|
60
|
-
ref:
|
|
93
|
+
children: [/* @__PURE__ */ l("button", {
|
|
94
|
+
ref: T,
|
|
61
95
|
type: "button",
|
|
62
|
-
onClick:
|
|
63
|
-
"aria-label":
|
|
96
|
+
onClick: D,
|
|
97
|
+
"aria-label": _("healthybowl.assistant.markdown.closePreview", "Close image preview"),
|
|
64
98
|
className: "absolute right-4 top-4 flex size-9 items-center justify-center rounded-full border border-border-subtle bg-bg-surface text-text-secondary transition-colors hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
|
|
65
99
|
"data-testid": "assistant-markdown-image-close",
|
|
66
|
-
children: /* @__PURE__ */
|
|
67
|
-
}), /* @__PURE__ */
|
|
100
|
+
children: /* @__PURE__ */ l(s, { className: "size-4" })
|
|
101
|
+
}), /* @__PURE__ */ u("figure", {
|
|
68
102
|
className: "flex max-h-full min-w-0 flex-col items-center gap-2",
|
|
69
|
-
children: [/* @__PURE__ */
|
|
70
|
-
src:
|
|
71
|
-
alt:
|
|
103
|
+
children: [/* @__PURE__ */ l("img", {
|
|
104
|
+
src: m,
|
|
105
|
+
alt: E,
|
|
106
|
+
referrerPolicy: "no-referrer",
|
|
72
107
|
onError: () => {
|
|
73
|
-
|
|
108
|
+
y(!0), D();
|
|
74
109
|
},
|
|
75
110
|
className: "max-h-[80vh] max-w-full rounded-lg object-contain",
|
|
76
111
|
"data-testid": "assistant-markdown-image-full"
|
|
77
|
-
}),
|
|
112
|
+
}), E && /* @__PURE__ */ l("figcaption", {
|
|
78
113
|
className: "max-w-xl text-center text-xs text-text-secondary",
|
|
79
|
-
children:
|
|
114
|
+
children: E
|
|
80
115
|
})]
|
|
81
116
|
})]
|
|
82
117
|
}), document.body)] });
|
|
83
118
|
};
|
|
84
119
|
//#endregion
|
|
85
|
-
export {
|
|
120
|
+
export { m as AssistantMarkdownImage };
|
|
86
121
|
|
|
87
122
|
//# sourceMappingURL=AssistantMarkdownImage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantMarkdownImage.js","names":[],"sources":["../../../src/components/assistant/AssistantMarkdownImage.tsx"],"sourcesContent":["/**\n * Image rendered inside an assistant markdown reply (Workstream 5).\n *\n * The assistant can answer with a picture — a chart it generated in the sandbox,\n * or an annotated copy of a leaf photo the farmer just uploaded — either as a\n * URL or as an inline `data:image/*;base64` payload. Both arrive as a plain\n * markdown ``, so this component is what `AssistantMarkdownRenderer`\n * maps `img` to.\n *\n * Three things markdown does not give us for free, all of which matter in a\n * ~440px docked panel:\n *\n * 1. **Bounded height.** An unconstrained portrait photo pushes the whole\n * conversation off-screen. The thumbnail is capped and letterboxed\n * (`object-contain`), never cropped, so the farmer still sees the subject.\n * 2. **Click to enlarge.** Detail lost at thumbnail size (a lesion on a leaf,\n * an axis label) is recoverable in a full-viewport lightbox.\n * 3. **A graceful failure.** Presigned URLs expire and sandbox links die; the\n * browser's broken-image glyph tells the farmer nothing, so a dead image\n * degrades to its alt text in a bordered placeholder instead.\n */\n\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { ImageOff, X } from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface Props {\n /** Resolved `src` — already scheme-checked by the renderer's urlTransform. */\n src?: string;\n alt?: string;\n title?: string;\n}\n\nexport const AssistantMarkdownImage: FC<Props> = ({ src, alt, title }) => {\n const tr = useTr();\n const [failed, setFailed] = useState(false);\n const [open, setOpen] = useState(false);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const closeRef = useRef<HTMLButtonElement>(null);\n\n const label = alt?.trim() ?? '';\n\n // While the lightbox is up it owns focus and scrolling; the cleanup runs on\n // every close path (Escape, backdrop, close button, message unmount), so\n // focus is restored to the thumbnail in one place instead of three.\n useEffect(() => {\n if (!open) return;\n\n const previousOverflow = document.body.style.overflow;\n // Captured now, while the thumbnail is certainly still mounted, so the\n // cleanup restores focus to the element that actually opened this.\n const trigger = triggerRef.current;\n document.body.style.overflow = 'hidden';\n closeRef.current?.focus();\n\n return () => {\n document.body.style.overflow = previousOverflow;\n trigger?.focus();\n };\n }, [open]);\n\n const close = useCallback(() => setOpen(false), []);\n\n const handleOverlayKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n // The assistant panel closes on Escape too — swallow it here so one press\n // dismisses the image and leaves the conversation open.\n event.stopPropagation();\n close();\n return;\n }\n // The close button is the only focusable control in the overlay, so keeping\n // Tab on it is a complete focus trap.\n if (event.key === 'Tab') {\n event.preventDefault();\n closeRef.current?.focus();\n }\n };\n\n const handleOverlayClick = (event: ReactMouseEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget) close();\n };\n\n if (!src || failed) {\n return (\n <span\n className=\"my-2 inline-flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-[0.9em] text-text-muted\"\n data-testid=\"assistant-markdown-image-fallback\"\n >\n <ImageOff className=\"size-4 flex-shrink-0\" aria-hidden=\"true\" />\n <span className=\"min-w-0 break-words\">\n {label || tr('healthybowl.assistant.markdown.imageUnavailable', 'Image unavailable')}\n </span>\n </span>\n );\n }\n\n return (\n <>\n <button\n ref={triggerRef}\n type=\"button\"\n onClick={() => setOpen(true)}\n // A native button already answers \"click or Enter/Space opens it\" and\n // carries the right role — no key handling of our own needed.\n aria-label={\n label\n ? tr('healthybowl.assistant.markdown.enlargeImageNamed', 'Enlarge image: {{alt}}', { alt: label })\n : tr('healthybowl.assistant.markdown.enlargeImage', 'Enlarge image')\n }\n className=\"my-2 block max-w-full cursor-zoom-in overflow-hidden rounded-lg border border-border-subtle bg-bg-sunken focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image\"\n >\n <img\n src={src}\n alt={label}\n title={title}\n loading=\"lazy\"\n decoding=\"async\"\n onError={() => setFailed(true)}\n className=\"max-h-64 w-auto max-w-full object-contain\"\n />\n </button>\n\n {open &&\n typeof document !== 'undefined' &&\n createPortal(\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={\n label\n ? tr('healthybowl.assistant.markdown.imagePreviewNamed', 'Image preview: {{alt}}', { alt: label })\n : tr('healthybowl.assistant.markdown.imagePreview', 'Image preview')\n }\n onClick={handleOverlayClick}\n onKeyDown={handleOverlayKeyDown}\n // Scrim: a token tint of the app canvas rather than a literal black,\n // so it tracks the active theme instead of forking it.\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-canvas/95 p-6 backdrop-blur-sm motion-safe:transition-opacity\"\n data-testid=\"assistant-markdown-image-lightbox\"\n >\n <button\n ref={closeRef}\n type=\"button\"\n onClick={close}\n aria-label={tr('healthybowl.assistant.markdown.closePreview', 'Close image preview')}\n className=\"absolute right-4 top-4 flex size-9 items-center justify-center rounded-full border border-border-subtle bg-bg-surface text-text-secondary transition-colors hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image-close\"\n >\n <X className=\"size-4\" />\n </button>\n\n <figure className=\"flex max-h-full min-w-0 flex-col items-center gap-2\">\n <img\n src={src}\n alt={label}\n onError={() => {\n setFailed(true);\n close();\n }}\n className=\"max-h-[80vh] max-w-full rounded-lg object-contain\"\n data-testid=\"assistant-markdown-image-full\"\n />\n {label && <figcaption className=\"max-w-xl text-center text-xs text-text-secondary\">{label}</figcaption>}\n </figure>\n </div>,\n document.body\n )}\n </>\n );\n};\n"],"mappings":";;;;;;AA0CA,IAAa,KAAqC,EAAE,QAAK,QAAK,eAAY;CACxE,IAAM,IAAK,GAAO,EACZ,CAAC,GAAQ,KAAa,EAAS,GAAM,EACrC,CAAC,GAAM,KAAW,EAAS,GAAM,EACjC,IAAa,EAA0B,KAAK,EAC5C,IAAW,EAA0B,KAAK,EAE1C,IAAQ,GAAK,MAAM,IAAI;AAK7B,SAAgB;AACd,MAAI,CAAC,EAAM;EAEX,IAAM,IAAmB,SAAS,KAAK,MAAM,UAGvC,IAAU,EAAW;AAI3B,SAHA,SAAS,KAAK,MAAM,WAAW,UAC/B,EAAS,SAAS,OAAO,QAEZ;AAEX,GADA,SAAS,KAAK,MAAM,WAAW,GAC/B,GAAS,OAAO;;IAEjB,CAAC,EAAK,CAAC;CAEV,IAAM,IAAQ,QAAkB,EAAQ,GAAM,EAAE,EAAE,CAAC;AAoCnD,QAdI,CAAC,KAAO,IAER,kBAAC,QAAD;EACE,WAAU;EACV,eAAY;YAFd,CAIE,kBAAC,GAAD;GAAU,WAAU;GAAuB,eAAY;GAAS,CAAA,EAChE,kBAAC,QAAD;GAAM,WAAU;aACb,KAAS,EAAG,mDAAmD,oBAAoB;GAC/E,CAAA,CACF;MAKT,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,UAAD;EACE,KAAK;EACL,MAAK;EACL,eAAe,EAAQ,GAAK;EAG5B,cACE,IACI,EAAG,oDAAoD,0BAA0B,EAAE,KAAK,GAAO,CAAC,GAChG,EAAG,+CAA+C,gBAAgB;EAExE,WAAU;EACV,eAAY;YAEZ,kBAAC,OAAD;GACO;GACL,KAAK;GACE;GACP,SAAQ;GACR,UAAS;GACT,eAAe,EAAU,GAAK;GAC9B,WAAU;GACV,CAAA;EACK,CAAA,EAER,KACC,OAAO,WAAa,OACpB,EACE,kBAAC,OAAD;EACE,MAAK;EACL,cAAW;EACX,cACE,IACI,EAAG,oDAAoD,0BAA0B,EAAE,KAAK,GAAO,CAAC,GAChG,EAAG,+CAA+C,gBAAgB;EAExE,UAxDkB,MAA2C;AACrE,GAAI,EAAM,WAAW,EAAM,iBAAe,GAAO;;EAwDzC,YAzEoB,MAA8C;AAC1E,OAAI,EAAM,QAAQ,UAAU;AAI1B,IADA,EAAM,iBAAiB,EACvB,GAAO;AACP;;AAIF,GAAI,EAAM,QAAQ,UAChB,EAAM,gBAAgB,EACtB,EAAS,SAAS,OAAO;;EAgEnB,WAAU;EACV,eAAY;YAbd,CAeE,kBAAC,UAAD;GACE,KAAK;GACL,MAAK;GACL,SAAS;GACT,cAAY,EAAG,+CAA+C,sBAAsB;GACpF,WAAU;GACV,eAAY;aAEZ,kBAAC,GAAD,EAAG,WAAU,UAAW,CAAA;GACjB,CAAA,EAET,kBAAC,UAAD;GAAQ,WAAU;aAAlB,CACE,kBAAC,OAAD;IACO;IACL,KAAK;IACL,eAAe;AAEb,KADA,EAAU,GAAK,EACf,GAAO;;IAET,WAAU;IACV,eAAY;IACZ,CAAA,EACD,KAAS,kBAAC,cAAD;IAAY,WAAU;cAAoD;IAAmB,CAAA,CAChG;KACL;KACN,SAAS,KACV,CACF,EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"AssistantMarkdownImage.js","names":[],"sources":["../../../src/components/assistant/AssistantMarkdownImage.tsx"],"sourcesContent":["/**\n * Image rendered inside an assistant markdown reply (Workstream 5).\n *\n * The assistant can answer with a picture — a chart it generated in the sandbox,\n * or an annotated copy of a leaf photo the farmer just uploaded — either as a\n * URL or as an inline `data:image/*;base64` payload. Both arrive as a plain\n * markdown ``, so this component is what `AssistantMarkdownRenderer`\n * maps `img` to.\n *\n * Four things markdown does not give us for free, all of which matter in a\n * ~440px docked panel:\n *\n * 1. **Bounded height.** An unconstrained portrait photo pushes the whole\n * conversation off-screen. The thumbnail is capped and letterboxed\n * (`object-contain`), never cropped, so the farmer still sees the subject.\n * 2. **Click to enlarge.** Detail lost at thumbnail size (a lesion on a leaf,\n * an axis label) is recoverable in a full-viewport lightbox.\n * 3. **A graceful failure.** Presigned URLs expire and sandbox links die; the\n * browser's broken-image glyph tells the farmer nothing, so a dead image\n * degrades to its alt text in a bordered placeholder instead.\n * 4. **No silent third-party fetch.** See `isRemoteImageSrc` — a markdown image\n * in an assistant reply is untrusted content, and an `<img>` is a GET the\n * browser makes for us the instant it renders.\n */\n\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { Eye, ImageOff, X } from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\n\n/**\n * Would rendering this `src` immediately hit a server we do not control?\n *\n * An `<img>` is a GET the browser performs the moment it paints, and the markup\n * here is written by a model that has read tool output, fetched web pages and\n * user-uploaded files. So `` is a working exfiltration beacon that also\n * discloses that a HealthyBowl user opened the reply, when, and from which IP —\n * with no click required. `referrerPolicy` does not help: the payload is the URL\n * itself, not the Referer header.\n *\n * `data:` URLs carry their own bytes and reach no network, so those still render\n * straight away — and that is the shape the transport actually emits for inline\n * images (fe-libs `getAssistantMedia`). Anything else is held behind an explicit\n * click, the same bargain email clients have offered for remote images for\n * twenty years. Unparseable input fails CLOSED.\n */\nexport function isRemoteImageSrc(src: string): boolean {\n if (/^data:/i.test(src.trim())) return false;\n return true;\n}\n\n/**\n * Host to name in the \"show this?\" prompt, so the choice is an informed one.\n *\n * Parsed with NO base URL on purpose. Resolving against `location.href` would\n * make a relative or malformed src inherit OUR hostname, and the prompt would\n * then read \"Show image from app.gethealthybowl.com\" for something this app does\n * not serve — a prompt that lies is worse than an unnamed one. Absolute http(s)\n * only; everything else falls back to the generic wording.\n */\nexport function imageHostLabel(src: string): string | null {\n try {\n const url = new URL(src.trim());\n return url.protocol === 'http:' || url.protocol === 'https:' ? url.hostname : null;\n } catch {\n return null;\n }\n}\n\ninterface Props {\n /** Resolved `src` — already scheme-checked by the renderer's urlTransform. */\n src?: string;\n alt?: string;\n title?: string;\n}\n\nexport const AssistantMarkdownImage: FC<Props> = ({ src, alt, title }) => {\n const tr = useTr();\n const [failed, setFailed] = useState(false);\n const [open, setOpen] = useState(false);\n // Per-image consent for a third-party fetch. Deliberately NOT persisted: the\n // decision belongs to the reply the user is looking at, not to the origin.\n const [allowedRemote, setAllowedRemote] = useState(false);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const closeRef = useRef<HTMLButtonElement>(null);\n\n const label = alt?.trim() ?? '';\n\n // While the lightbox is up it owns focus and scrolling; the cleanup runs on\n // every close path (Escape, backdrop, close button, message unmount), so\n // focus is restored to the thumbnail in one place instead of three.\n useEffect(() => {\n if (!open) return;\n\n const previousOverflow = document.body.style.overflow;\n // Captured now, while the thumbnail is certainly still mounted, so the\n // cleanup restores focus to the element that actually opened this.\n const trigger = triggerRef.current;\n document.body.style.overflow = 'hidden';\n closeRef.current?.focus();\n\n return () => {\n document.body.style.overflow = previousOverflow;\n trigger?.focus();\n };\n }, [open]);\n\n const close = useCallback(() => setOpen(false), []);\n\n const handleOverlayKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n // The assistant panel closes on Escape too — swallow it here so one press\n // dismisses the image and leaves the conversation open.\n event.stopPropagation();\n close();\n return;\n }\n // The close button is the only focusable control in the overlay, so keeping\n // Tab on it is a complete focus trap.\n if (event.key === 'Tab') {\n event.preventDefault();\n closeRef.current?.focus();\n }\n };\n\n const handleOverlayClick = (event: ReactMouseEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget) close();\n };\n\n const isGated = Boolean(src) && isRemoteImageSrc(src!) && !allowedRemote;\n\n if (src && isGated && !failed) {\n const host = imageHostLabel(src);\n return (\n <button\n type=\"button\"\n onClick={() => setAllowedRemote(true)}\n className=\"my-2 flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-left text-[0.9em] text-text-secondary transition-colors hover:border-border-strong hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image-gated\"\n >\n <Eye className=\"size-4 flex-shrink-0\" aria-hidden=\"true\" />\n <span className=\"min-w-0\">\n <span className=\"block break-words\">\n {host\n ? tr('healthybowl.assistant.markdown.showRemoteImageNamed', 'Show image from {{host}}', { host })\n : tr('healthybowl.assistant.markdown.showRemoteImage', 'Show remote image')}\n </span>\n {label && <span className=\"block truncate text-[0.85em] text-text-muted\">{label}</span>}\n </span>\n </button>\n );\n }\n\n if (!src || failed) {\n return (\n <span\n className=\"my-2 inline-flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-[0.9em] text-text-muted\"\n data-testid=\"assistant-markdown-image-fallback\"\n >\n <ImageOff className=\"size-4 flex-shrink-0\" aria-hidden=\"true\" />\n <span className=\"min-w-0 break-words\">\n {label || tr('healthybowl.assistant.markdown.imageUnavailable', 'Image unavailable')}\n </span>\n </span>\n );\n }\n\n return (\n <>\n <button\n ref={triggerRef}\n type=\"button\"\n onClick={() => setOpen(true)}\n // A native button already answers \"click or Enter/Space opens it\" and\n // carries the right role — no key handling of our own needed.\n aria-label={\n label\n ? tr('healthybowl.assistant.markdown.enlargeImageNamed', 'Enlarge image: {{alt}}', { alt: label })\n : tr('healthybowl.assistant.markdown.enlargeImage', 'Enlarge image')\n }\n className=\"my-2 block max-w-full cursor-zoom-in overflow-hidden rounded-lg border border-border-subtle bg-bg-sunken focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image\"\n >\n <img\n src={src}\n alt={label}\n title={title}\n loading=\"lazy\"\n decoding=\"async\"\n // Belt to the gate's braces: once the user does opt in, do not also\n // hand the third party our URL — HealthyBowl paths carry ?workspace=\n // and ?org= identifiers.\n referrerPolicy=\"no-referrer\"\n onError={() => setFailed(true)}\n className=\"max-h-64 w-auto max-w-full object-contain\"\n />\n </button>\n\n {open &&\n typeof document !== 'undefined' &&\n createPortal(\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={\n label\n ? tr('healthybowl.assistant.markdown.imagePreviewNamed', 'Image preview: {{alt}}', { alt: label })\n : tr('healthybowl.assistant.markdown.imagePreview', 'Image preview')\n }\n onClick={handleOverlayClick}\n onKeyDown={handleOverlayKeyDown}\n // Scrim: a token tint of the app canvas rather than a literal black,\n // so it tracks the active theme instead of forking it.\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-canvas/95 p-6 backdrop-blur-sm motion-safe:transition-opacity\"\n data-testid=\"assistant-markdown-image-lightbox\"\n >\n <button\n ref={closeRef}\n type=\"button\"\n onClick={close}\n aria-label={tr('healthybowl.assistant.markdown.closePreview', 'Close image preview')}\n className=\"absolute right-4 top-4 flex size-9 items-center justify-center rounded-full border border-border-subtle bg-bg-surface text-text-secondary transition-colors hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image-close\"\n >\n <X className=\"size-4\" />\n </button>\n\n <figure className=\"flex max-h-full min-w-0 flex-col items-center gap-2\">\n <img\n src={src}\n alt={label}\n referrerPolicy=\"no-referrer\"\n onError={() => {\n setFailed(true);\n close();\n }}\n className=\"max-h-[80vh] max-w-full rounded-lg object-contain\"\n data-testid=\"assistant-markdown-image-full\"\n />\n {label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T,cAAY,EAAG,+CAA+C,sBAAsB;GACpF,WAAU;GACV,eAAY;aAEZ,kBAAC,GAAD,EAAG,WAAU,UAAW,CAAA;GACjB,CAAA,EAET,kBAAC,UAAD;GAAQ,WAAU;aAAlB,CACE,kBAAC,OAAD;IACO;IACL,KAAK;IACL,gBAAe;IACf,eAAe;AAEb,KADA,EAAU,GAAK,EACf,GAAO;;IAET,WAAU;IACV,eAAY;IACZ,CAAA,EACD,KAAS,kBAAC,cAAD;IAAY,WAAU;cAAoD;IAAmB,CAAA,CAChG;KACL;KACN,SAAS,KACV,CACF,EAAA,CAAA"}
|
|
@@ -33,6 +33,7 @@ var f = ({ attachment: t }) => {
|
|
|
33
33
|
alt: t.filename,
|
|
34
34
|
className: "size-full object-cover",
|
|
35
35
|
loading: "lazy",
|
|
36
|
+
referrerPolicy: "no-referrer",
|
|
36
37
|
"data-testid": "assistant-message-attachment-image"
|
|
37
38
|
}) : /* @__PURE__ */ s("span", {
|
|
38
39
|
className: "flex size-full items-center justify-center text-text-muted",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantMessageAttachments.js","names":[],"sources":["../../../src/components/assistant/AssistantMessageAttachments.tsx"],"sourcesContent":["import { useEffect, useState, type FC } from 'react';\nimport { FileText, Paperclip } from 'lucide-react';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { getWorkspaceId } from '@/utils/assistantContext';\nimport { formatBytes, type AssistantMessageAttachment } from '@/utils/assistantAttachments';\n\nconst DOWNLOAD_URL_QUERY = `\n query HealthyBowlAssistantMessageAttachmentUrl($id: ID!) {\n getFileDownloadUrl(id: $id)\n }\n`;\n\n/**\n * Resolve an opaque files-svc id to a short-lived presigned URL.\n *\n * The sent message only stores the file id (persisted conversations must stay\n * small), and presigned URLs expire — so the URL is re-fetched per render of a\n * visible attachment rather than being kept on the message.\n */\nfunction useAttachmentUrl(fileId: string | undefined): string | null {\n const [url, setUrl] = useState<string | null>(null);\n\n useEffect(() => {\n let active = true;\n const workspaceId = getWorkspaceId();\n if (!fileId || !workspaceId) return;\n\n void graphqlFetch<{ getFileDownloadUrl?: string | null }>({\n gateway: 'workspace',\n query: DOWNLOAD_URL_QUERY,\n variables: { id: fileId },\n workspaceToken: true,\n workspaceId,\n suppressGlobalErrorEvent: true,\n })\n .then((res) => {\n if (active) setUrl(res.data?.getFileDownloadUrl ?? null);\n })\n .catch(() => undefined);\n\n return () => {\n active = false;\n };\n }, [fileId]);\n\n return url;\n}\n\nconst AttachmentTile: FC<{ attachment: AssistantMessageAttachment }> = ({ attachment }) => {\n const tr = useTr();\n const url = useAttachmentUrl(attachment.fileId);\n const isImage = attachment.kind === 'image';\n\n const body = isImage ? (\n <span className=\"block size-full overflow-hidden rounded-lg bg-bg-sunken\">\n {url ? (\n <img\n src={url}\n alt={attachment.filename}\n className=\"size-full object-cover\"\n loading=\"lazy\"\n data-testid=\"assistant-message-attachment-image\"\n />\n ) : (\n <span className=\"flex size-full items-center justify-center text-text-muted\">\n <Paperclip className=\"size-4\" />\n </span>\n )}\n </span>\n ) : (\n <span className=\"flex items-center gap-1.5 rounded-lg border border-border-subtle bg-bg-surface px-2 py-1.5\">\n <span className=\"flex size-6 flex-shrink-0 items-center justify-center rounded-md bg-bg-sunken text-text-muted\">\n {attachment.kind === 'text' ? <FileText className=\"size-3.5\" /> : <Paperclip className=\"size-3.5\" />}\n </span>\n <span className=\"min-w-0\">\n <span className=\"block truncate text-[11px] font-medium leading-tight text-text-primary\">\n {attachment.filename}\n </span>\n <span className=\"block text-[10px] leading-tight text-text-muted\">{formatBytes(attachment.size)}</span>\n </span>\n </span>\n );\n\n const className = isImage ? 'block size-16 overflow-hidden rounded-lg' : 'block max-w-[200px]';\n\n // Only linkable once the presigned URL resolves; without it the tile is still\n // a faithful record of what was sent, just not clickable.\n return url ? (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={`${className} focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`}\n title={tr('healthybowl.assistant.attachments.open', 'Open {{name}}', { name: attachment.filename })}\n >\n {body}\n </a>\n ) : (\n <span className={className}>{body}</span>\n );\n};\n\n/**\n * Attachments rendered under a user message bubble — a durable record of what\n * the farmer actually sent with the question, thumbnails included.\n */\nexport const AssistantMessageAttachments: FC<{ attachments: AssistantMessageAttachment[] }> = ({ attachments }) => {\n const tr = useTr();\n if (attachments.length === 0) return null;\n\n return (\n <ul\n className=\"mt-1.5 flex flex-wrap justify-end gap-1.5\"\n aria-label={tr('healthybowl.assistant.attachments.messageLabel', 'Files sent with this message')}\n data-testid=\"assistant-message-attachments\"\n >\n {attachments.map((attachment) => (\n <li key={attachment.id}>\n <AttachmentTile attachment={attachment} />\n </li>\n ))}\n </ul>\n );\n};\n"],"mappings":";;;;;;;;AAOA,IAAM,IAAqB;AAa3B,SAAS,EAAiB,GAA2C;CACnE,IAAM,CAAC,GAAK,KAAU,EAAwB,KAAK;AAyBnD,QAvBA,QAAgB;EACd,IAAI,IAAS,IACP,IAAc,GAAgB;AAChC,SAAC,KAAU,CAAC,GAehB,QAbK,EAAqD;GACxD,SAAS;GACT,OAAO;GACP,WAAW,EAAE,IAAI,GAAQ;GACzB,gBAAgB;GAChB;GACA,0BAA0B;GAC3B,CAAC,CACC,MAAM,MAAQ;AACb,GAAI,KAAQ,EAAO,EAAI,MAAM,sBAAsB,KAAK;IACxD,CACD,YAAY,KAAA,EAAU,QAEZ;AACX,OAAS;;IAEV,CAAC,EAAO,CAAC,EAEL;;AAGT,IAAM,KAAkE,EAAE,oBAAiB;CACzF,IAAM,IAAK,GAAO,EACZ,IAAM,EAAiB,EAAW,OAAO,EACzC,IAAU,EAAW,SAAS,SAE9B,IAAO,IACX,kBAAC,QAAD;EAAM,WAAU;YACb,IACC,kBAAC,OAAD;GACE,KAAK;GACL,KAAK,EAAW;GAChB,WAAU;GACV,SAAQ;GACR,eAAY;GACZ,CAAA,GAEF,kBAAC,QAAD;GAAM,WAAU;aACd,kBAAC,GAAD,EAAW,WAAU,UAAW,CAAA;GAC3B,CAAA;EAEJ,CAAA,GAEP,kBAAC,QAAD;EAAM,WAAU;YAAhB,CACE,kBAAC,QAAD;GAAM,WAAU;aACb,EAAW,SAAS,SAAS,kBAAC,GAAD,EAAU,WAAU,YAAa,CAAA,GAAG,kBAAC,GAAD,EAAW,WAAU,YAAa,CAAA;GAC/F,CAAA,EACP,kBAAC,QAAD;GAAM,WAAU;aAAhB,CACE,kBAAC,QAAD;IAAM,WAAU;cACb,EAAW;IACP,CAAA,EACP,kBAAC,QAAD;IAAM,WAAU;cAAmD,EAAY,EAAW,KAAK;IAAQ,CAAA,CAClG;KACF;KAGH,IAAY,IAAU,6CAA6C;AAIzE,QAAO,IACL,kBAAC,KAAD;EACE,MAAM;EACN,QAAO;EACP,KAAI;EACJ,WAAW,GAAG,EAAU;EACxB,OAAO,EAAG,0CAA0C,iBAAiB,EAAE,MAAM,EAAW,UAAU,CAAC;YAElG;EACC,CAAA,GAEJ,kBAAC,QAAD;EAAiB;YAAY;EAAY,CAAA;GAQhC,KAAkF,EAAE,qBAAkB;CACjH,IAAM,IAAK,GAAO;AAGlB,QAFI,EAAY,WAAW,IAAU,OAGnC,kBAAC,MAAD;EACE,WAAU;EACV,cAAY,EAAG,kDAAkD,+BAA+B;EAChG,eAAY;YAEX,EAAY,KAAK,MAChB,kBAAC,MAAD,EAAA,UACE,kBAAC,GAAD,EAA4B,eAAc,CAAA,EACvC,EAFI,EAAW,GAEf,CACL;EACC,CAAA"}
|
|
1
|
+
{"version":3,"file":"AssistantMessageAttachments.js","names":[],"sources":["../../../src/components/assistant/AssistantMessageAttachments.tsx"],"sourcesContent":["import { useEffect, useState, type FC } from 'react';\nimport { FileText, Paperclip } from 'lucide-react';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { getWorkspaceId } from '@/utils/assistantContext';\nimport { formatBytes, type AssistantMessageAttachment } from '@/utils/assistantAttachments';\n\nconst DOWNLOAD_URL_QUERY = `\n query HealthyBowlAssistantMessageAttachmentUrl($id: ID!) {\n getFileDownloadUrl(id: $id)\n }\n`;\n\n/**\n * Resolve an opaque files-svc id to a short-lived presigned URL.\n *\n * The sent message only stores the file id (persisted conversations must stay\n * small), and presigned URLs expire — so the URL is re-fetched per render of a\n * visible attachment rather than being kept on the message.\n */\nfunction useAttachmentUrl(fileId: string | undefined): string | null {\n const [url, setUrl] = useState<string | null>(null);\n\n useEffect(() => {\n let active = true;\n const workspaceId = getWorkspaceId();\n if (!fileId || !workspaceId) return;\n\n void graphqlFetch<{ getFileDownloadUrl?: string | null }>({\n gateway: 'workspace',\n query: DOWNLOAD_URL_QUERY,\n variables: { id: fileId },\n workspaceToken: true,\n workspaceId,\n suppressGlobalErrorEvent: true,\n })\n .then((res) => {\n if (active) setUrl(res.data?.getFileDownloadUrl ?? null);\n })\n .catch(() => undefined);\n\n return () => {\n active = false;\n };\n }, [fileId]);\n\n return url;\n}\n\nconst AttachmentTile: FC<{ attachment: AssistantMessageAttachment }> = ({ attachment }) => {\n const tr = useTr();\n const url = useAttachmentUrl(attachment.fileId);\n const isImage = attachment.kind === 'image';\n\n const body = isImage ? (\n <span className=\"block size-full overflow-hidden rounded-lg bg-bg-sunken\">\n {url ? (\n <img\n src={url}\n alt={attachment.filename}\n className=\"size-full object-cover\"\n loading=\"lazy\"\n referrerPolicy=\"no-referrer\"\n data-testid=\"assistant-message-attachment-image\"\n />\n ) : (\n <span className=\"flex size-full items-center justify-center text-text-muted\">\n <Paperclip className=\"size-4\" />\n </span>\n )}\n </span>\n ) : (\n <span className=\"flex items-center gap-1.5 rounded-lg border border-border-subtle bg-bg-surface px-2 py-1.5\">\n <span className=\"flex size-6 flex-shrink-0 items-center justify-center rounded-md bg-bg-sunken text-text-muted\">\n {attachment.kind === 'text' ? <FileText className=\"size-3.5\" /> : <Paperclip className=\"size-3.5\" />}\n </span>\n <span className=\"min-w-0\">\n <span className=\"block truncate text-[11px] font-medium leading-tight text-text-primary\">\n {attachment.filename}\n </span>\n <span className=\"block text-[10px] leading-tight text-text-muted\">{formatBytes(attachment.size)}</span>\n </span>\n </span>\n );\n\n const className = isImage ? 'block size-16 overflow-hidden rounded-lg' : 'block max-w-[200px]';\n\n // Only linkable once the presigned URL resolves; without it the tile is still\n // a faithful record of what was sent, just not clickable.\n return url ? (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={`${className} focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`}\n title={tr('healthybowl.assistant.attachments.open', 'Open {{name}}', { name: attachment.filename })}\n >\n {body}\n </a>\n ) : (\n <span className={className}>{body}</span>\n );\n};\n\n/**\n * Attachments rendered under a user message bubble — a durable record of what\n * the farmer actually sent with the question, thumbnails included.\n */\nexport const AssistantMessageAttachments: FC<{ attachments: AssistantMessageAttachment[] }> = ({ attachments }) => {\n const tr = useTr();\n if (attachments.length === 0) return null;\n\n return (\n <ul\n className=\"mt-1.5 flex flex-wrap justify-end gap-1.5\"\n aria-label={tr('healthybowl.assistant.attachments.messageLabel', 'Files sent with this message')}\n data-testid=\"assistant-message-attachments\"\n >\n {attachments.map((attachment) => (\n <li key={attachment.id}>\n <AttachmentTile attachment={attachment} />\n </li>\n ))}\n </ul>\n );\n};\n"],"mappings":";;;;;;;;AAOA,IAAM,IAAqB;AAa3B,SAAS,EAAiB,GAA2C;CACnE,IAAM,CAAC,GAAK,KAAU,EAAwB,KAAK;AAyBnD,QAvBA,QAAgB;EACd,IAAI,IAAS,IACP,IAAc,GAAgB;AAChC,SAAC,KAAU,CAAC,GAehB,QAbK,EAAqD;GACxD,SAAS;GACT,OAAO;GACP,WAAW,EAAE,IAAI,GAAQ;GACzB,gBAAgB;GAChB;GACA,0BAA0B;GAC3B,CAAC,CACC,MAAM,MAAQ;AACb,GAAI,KAAQ,EAAO,EAAI,MAAM,sBAAsB,KAAK;IACxD,CACD,YAAY,KAAA,EAA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