@webless/agent 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -7272,6 +7272,9 @@ function AgentWidget({
7272
7272
  ] });
7273
7273
  }
7274
7274
 
7275
+ // src/react/components/AgentTranscript/AgentTranscript.tsx
7276
+ var import_react16 = require("react");
7277
+
7275
7278
  // src/react/components/AgentTranscript/TranscriptActivity.tsx
7276
7279
  var import_jsx_runtime20 = require("react/jsx-runtime");
7277
7280
  var statusLabels = {
@@ -7299,16 +7302,12 @@ function RecordedResult({
7299
7302
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(VisitorToolResultView, { disabled: true, result });
7300
7303
  }
7301
7304
  function TranscriptActivity({
7302
- activity,
7303
- formatTimestamp
7305
+ activity
7304
7306
  }) {
7305
- const date = new Date(activity.createdAt);
7306
- const validTimestamp = Number.isFinite(date.getTime());
7307
7307
  const result = activity.result?.kind === "hidden" ? void 0 : activity.result;
7308
7308
  const heading = /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
7309
7309
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: activity.category === "specialist" ? `Specialist \xB7 ${activity.label}` : activity.label }),
7310
- activity.status !== "completed" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "agent-transcript__activity-status", children: statusLabels[activity.status] }) : null,
7311
- validTimestamp ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("time", { dateTime: date.toISOString(), children: formatTimestamp(activity.createdAt) }) : null
7310
+ activity.status !== "completed" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "agent-transcript__activity-status", children: statusLabels[activity.status] }) : null
7312
7311
  ] });
7313
7312
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("li", { className: "agent-transcript__activity", "data-status": activity.status, children: result ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("details", { children: [
7314
7313
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("summary", { className: "agent-transcript__activity-heading", children: heading }),
@@ -7370,7 +7369,8 @@ function AgentTranscript({
7370
7369
  agentLabel = "Agent",
7371
7370
  visitorLabel = "Visitor",
7372
7371
  label = "Conversation transcript",
7373
- formatTimestamp = defaultTimestamp
7372
+ formatTimestamp = defaultTimestamp,
7373
+ showInitialTimestamp = true
7374
7374
  }) {
7375
7375
  const scheme = useAgentColorScheme(colorScheme);
7376
7376
  const entries = [
@@ -7388,41 +7388,31 @@ function AgentTranscript({
7388
7388
  "data-color-scheme": scheme,
7389
7389
  "aria-label": label,
7390
7390
  style: agentThemeStyle(theme, scheme),
7391
- children: entries.map((message) => {
7392
- if (message.kind === "activity")
7393
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
7394
- TranscriptActivity,
7395
- {
7396
- activity: message,
7397
- formatTimestamp
7398
- },
7399
- message.id
7400
- );
7401
- if (message.role === "visitor" && !message.text.trim()) return null;
7402
- const date = new Date(message.createdAt);
7391
+ children: entries.map((entry, index) => {
7392
+ const date = new Date(entry.createdAt);
7393
+ const previous = entries[index - 1];
7403
7394
  const validTimestamp = Number.isFinite(date.getTime());
7404
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
7405
- "li",
7406
- {
7407
- className: `agent-transcript__message agent-transcript__message--${message.role}`,
7408
- children: [
7409
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "agent-transcript__meta", children: [
7410
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: message.role === "visitor" ? visitorLabel : agentLabel }),
7411
- validTimestamp ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("time", { dateTime: date.toISOString(), children: formatTimestamp(message.createdAt) }) : null
7412
- ] }),
7413
- message.role === "agent" ? message.toolResults?.map((result) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(VisitorToolResultView, { result }, result.id)) : null,
7414
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
7415
- MessageBubble,
7416
- {
7417
- message: message.role === "agent" ? { ...message, streaming: false } : message,
7418
- bookingReadOnly: true,
7419
- bookingDisabled: true
7420
- }
7421
- )
7422
- ]
7423
- },
7424
- message.id
7425
- );
7395
+ const showTimestamp = validTimestamp && (previous ? entry.createdAt - previous.createdAt >= 5 * 60 * 1e3 || date.toISOString().slice(0, 10) !== new Date(previous.createdAt).toJSON()?.slice(0, 10) : showInitialTimestamp);
7396
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react16.Fragment, { children: [
7397
+ showTimestamp ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("li", { className: "agent-transcript__time-marker", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("time", { dateTime: date.toISOString(), children: formatTimestamp(entry.createdAt) }) }) : null,
7398
+ entry.kind === "activity" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TranscriptActivity, { activity: entry }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
7399
+ "li",
7400
+ {
7401
+ className: `agent-transcript__message agent-transcript__message--${entry.role}`,
7402
+ children: [
7403
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "agent-transcript__meta", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: entry.role === "visitor" ? visitorLabel : agentLabel }) }),
7404
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
7405
+ MessageBubble,
7406
+ {
7407
+ message: entry.role === "agent" ? { ...entry, streaming: false } : entry,
7408
+ bookingReadOnly: true,
7409
+ bookingDisabled: true
7410
+ }
7411
+ )
7412
+ ]
7413
+ }
7414
+ )
7415
+ ] }, `${entry.kind}:${entry.id}`);
7426
7416
  })
7427
7417
  }
7428
7418
  );