@tangle-network/agent-app 0.45.45 → 0.45.46

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ChatComposer,
3
3
  ChatMessages
4
- } from "../chunk-G7BVJ3IH.js";
4
+ } from "../chunk-UM6ODCLN.js";
5
5
  import "../chunk-FBVLEGEG.js";
6
6
  import "../chunk-54FYYXAX.js";
7
7
  import "../chunk-GEYACSFW.js";
@@ -20,7 +20,7 @@ import "../chunk-CCVG2TL6.js";
20
20
  import "../chunk-5ZTFZBS6.js";
21
21
  import "../chunk-ZVEEWGDK.js";
22
22
  import "../chunk-KWXUBMXU.js";
23
- import "../chunk-XZ27ENOZ.js";
23
+ import "../chunk-XF7ZKISQ.js";
24
24
  import "../chunk-M3K2HVQD.js";
25
25
  import "../chunk-YJMCRXQQ.js";
26
26
  import "../chunk-TH7L265V.js";
@@ -72,7 +72,7 @@ import {
72
72
  normalizePersistedPart,
73
73
  normalizeToolEvent,
74
74
  terminalizeDanglingAssistantToolUpdates
75
- } from "../chunk-XZ27ENOZ.js";
75
+ } from "../chunk-XF7ZKISQ.js";
76
76
  import {
77
77
  cancelStatusFor,
78
78
  interactionPartKey,
@@ -24,7 +24,7 @@ import "../chunk-ZVEEWGDK.js";
24
24
  import "../chunk-KWXUBMXU.js";
25
25
  import {
26
26
  attachmentPartKey
27
- } from "../chunk-XZ27ENOZ.js";
27
+ } from "../chunk-XF7ZKISQ.js";
28
28
  import "../chunk-M3K2HVQD.js";
29
29
  import "../chunk-YJMCRXQQ.js";
30
30
 
@@ -938,6 +938,12 @@ function WarningGlyph({ className }) {
938
938
  function iconForMediaType(mediaType) {
939
939
  return mediaType?.startsWith("image/") ? ImageGlyph : FileGlyph;
940
940
  }
941
+ function attachmentDisplayName(part) {
942
+ if (typeof part.name === "string" && part.name.trim().length > 0) return part.name;
943
+ const base = part.path.split("/").pop() ?? "";
944
+ const trimmed = base.trim();
945
+ return trimmed.length > 0 ? trimmed : null;
946
+ }
941
947
  var attachmentFileCache = /* @__PURE__ */ new Map();
942
948
  function __resetAttachmentFileCacheForTests() {
943
949
  attachmentFileCache.clear();
@@ -998,10 +1004,38 @@ function AttachmentThumbnailError({ name }) {
998
1004
  /* @__PURE__ */ jsx6("span", { className: "line-clamp-2 text-[10px] leading-tight", children: name })
999
1005
  ] });
1000
1006
  }
1007
+ function AttachmentUnavailable({ shape }) {
1008
+ if (shape === "thumbnail") {
1009
+ return /* @__PURE__ */ jsxs4(
1010
+ "span",
1011
+ {
1012
+ "aria-disabled": "true",
1013
+ className: "inline-flex h-16 w-16 shrink-0 flex-col items-center justify-center gap-1 rounded-md border border-border bg-muted px-1 text-center text-muted-foreground",
1014
+ children: [
1015
+ /* @__PURE__ */ jsx6(WarningGlyph, { className: "h-4 w-4 shrink-0" }),
1016
+ /* @__PURE__ */ jsx6("span", { className: "line-clamp-2 text-[10px] leading-tight", children: "Attachment unavailable" })
1017
+ ]
1018
+ }
1019
+ );
1020
+ }
1021
+ return /* @__PURE__ */ jsxs4(
1022
+ "span",
1023
+ {
1024
+ "aria-disabled": "true",
1025
+ className: "inline-flex items-center gap-1 rounded-md border border-border bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",
1026
+ children: [
1027
+ /* @__PURE__ */ jsx6(WarningGlyph, { className: "h-3 w-3 shrink-0" }),
1028
+ "Attachment unavailable"
1029
+ ]
1030
+ }
1031
+ );
1032
+ }
1001
1033
  function AttachmentThumbnail({ part, resolveFileUrl, fetchFile }) {
1002
1034
  const url = resolveFileUrl(part);
1035
+ const displayName = attachmentDisplayName(part);
1003
1036
  const [result, setResult] = useState5(null);
1004
1037
  useEffect4(() => {
1038
+ if (!displayName) return;
1005
1039
  let cancelled = false;
1006
1040
  setResult(null);
1007
1041
  loadAttachmentFile(url, fetchFile).then((next) => {
@@ -1010,34 +1044,38 @@ function AttachmentThumbnail({ part, resolveFileUrl, fetchFile }) {
1010
1044
  return () => {
1011
1045
  cancelled = true;
1012
1046
  };
1013
- }, [url, fetchFile]);
1047
+ }, [url, fetchFile, displayName]);
1014
1048
  const objectUrl = useAttachmentObjectUrl(result?.ok ? result.blob : void 0);
1015
1049
  const handleClick = useCallback(() => {
1016
1050
  if (!objectUrl) return;
1017
1051
  window.open(objectUrl, "_blank", "noopener");
1018
1052
  }, [objectUrl]);
1053
+ if (!displayName) {
1054
+ return /* @__PURE__ */ jsx6(AttachmentUnavailable, { shape: "thumbnail" });
1055
+ }
1019
1056
  if (!result) {
1020
1057
  return /* @__PURE__ */ jsx6("span", { "aria-hidden": "true", className: "inline-block h-16 w-16 shrink-0 animate-pulse rounded-md bg-muted" });
1021
1058
  }
1022
1059
  if (!result.ok || !objectUrl) {
1023
- return /* @__PURE__ */ jsx6(AttachmentThumbnailError, { name: part.name });
1060
+ return /* @__PURE__ */ jsx6(AttachmentThumbnailError, { name: displayName });
1024
1061
  }
1025
1062
  return /* @__PURE__ */ jsx6(
1026
1063
  "button",
1027
1064
  {
1028
1065
  type: "button",
1029
1066
  onClick: handleClick,
1030
- "aria-label": `Open ${part.name}`,
1067
+ "aria-label": `Open ${displayName}`,
1031
1068
  className: "h-16 w-16 shrink-0 overflow-hidden rounded-md border border-border",
1032
- children: /* @__PURE__ */ jsx6("img", { src: objectUrl, alt: part.name, className: "h-16 w-16 object-cover" })
1069
+ children: /* @__PURE__ */ jsx6("img", { src: objectUrl, alt: displayName, className: "h-16 w-16 object-cover" })
1033
1070
  }
1034
1071
  );
1035
1072
  }
1036
1073
  function AttachmentChip({ part, resolveFileUrl, fetchFile }) {
1074
+ const displayName = attachmentDisplayName(part);
1037
1075
  const [status, setStatus] = useState5("idle");
1038
1076
  const [errorMessage, setErrorMessage] = useState5(null);
1039
1077
  const handleClick = useCallback(() => {
1040
- if (status === "loading") return;
1078
+ if (!displayName || status === "loading") return;
1041
1079
  setStatus("loading");
1042
1080
  setErrorMessage(null);
1043
1081
  const url = resolveFileUrl(part);
@@ -1047,7 +1085,7 @@ function AttachmentChip({ part, resolveFileUrl, fetchFile }) {
1047
1085
  setErrorMessage(result.message);
1048
1086
  return;
1049
1087
  }
1050
- const download = triggerAttachmentDownload(part.name, result.blob);
1088
+ const download = triggerAttachmentDownload(displayName, result.blob);
1051
1089
  if (!download.ok) {
1052
1090
  setStatus("error");
1053
1091
  setErrorMessage(download.message);
@@ -1055,7 +1093,10 @@ function AttachmentChip({ part, resolveFileUrl, fetchFile }) {
1055
1093
  }
1056
1094
  setStatus("idle");
1057
1095
  });
1058
- }, [status, resolveFileUrl, part, fetchFile]);
1096
+ }, [displayName, status, resolveFileUrl, part, fetchFile]);
1097
+ if (!displayName) {
1098
+ return /* @__PURE__ */ jsx6(AttachmentUnavailable, { shape: "chip" });
1099
+ }
1059
1100
  const Icon = status === "error" ? WarningGlyph : iconForMediaType(part.mediaType);
1060
1101
  const className = [
1061
1102
  "inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-[11px]",
@@ -1070,7 +1111,7 @@ function AttachmentChip({ part, resolveFileUrl, fetchFile }) {
1070
1111
  className,
1071
1112
  children: [
1072
1113
  /* @__PURE__ */ jsx6(Icon, { className: "h-3 w-3 shrink-0" }),
1073
- part.name,
1114
+ displayName,
1074
1115
  typeof part.size === "number" && /* @__PURE__ */ jsxs4("span", { className: "text-muted-foreground/70", children: [
1075
1116
  "\xB7 ",
1076
1117
  formatBytes(part.size)
@@ -5990,4 +6031,4 @@ export {
5990
6031
  useThinkingSeconds,
5991
6032
  ChatMessages
5992
6033
  };
5993
- //# sourceMappingURL=chunk-G7BVJ3IH.js.map
6034
+ //# sourceMappingURL=chunk-UM6ODCLN.js.map