@trops/dash-core 0.1.756 → 0.1.758

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/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
2
  import _typeof from '@babel/runtime/helpers/typeof';
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import * as DashReact from '@trops/dash-react';
5
- import { isObject, ThemeContext, FontAwesomeIcon, Modal, deepCopy, MainSection, getUUID, getStylesForItem, themeObjects, Heading, SearchInput, ButtonIcon, SubHeading3, InputText, Button, Tag, Button3, Button2, Paragraph, Sidebar, Panel, Stepper, Tag3, Card2, Card3, Heading3, MenuItem3, FormLabel, SelectMenu, Switch, SelectInput, CodeEditorVS, SettingsModal, SubHeading2, tailwindHeightFractions, Menu3, Panel3, ButtonIcon2, DropdownPanel, MenuItem2, useStatusTokens, Caption2, ConfirmationModal, DropComponent, DragComponent, getStyleName, capitalizeFirstLetter, isHexColor as isHexColor$1, deriveShades, colorTypes, TAILWIND_PALETTE, Toggle, normalizeHex as normalizeHex$1, contrastRatio, Caption, getColorFamilies, getCuratedColorGrid, DashPanel, hexToRgb as hexToRgb$1, themeVariants, SubHeading, Heading2, Paragraph2, Paragraph3, ButtonIcon3, Tag2, Alert, Alert2, Alert3, Toast, Toast2, Toast3, ProgressBar, ProgressBar2, ProgressBar3, MenuItem, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Caption3, Code, Code2, Code3, Divider, Divider2, Divider3, DashPanel2, DashPanel3, Tabs, Tabs2, Tabs3, Accordion, Accordion2, Accordion3, Toggle2, Toggle3, TextArea, Checkbox, Slider, RadioGroup, AlertBanner, StatusBadge as StatusBadge$1, Skeleton, StatCard, DataList, EmptyState, Card, Panel2, ThemeFromUrlPane, AlgoliaSearchBox, CodeEditorInline, Icon2, SectionLabel, SegmentedControl, useResizableWidth, ResizeHandle, ChoiceMenu, CommandPalette, useSidebar, FilterMenu, Navbar, withRouter, Menu as Menu$1 } from '@trops/dash-react';
5
+ import { isObject, ThemeContext, FontAwesomeIcon, Modal, deepCopy, MainSection, getUUID, getStylesForItem, themeObjects, Heading, SearchInput, ButtonIcon, SubHeading3, InputText, Button, Tag, Button3, Button2, Paragraph, Sidebar, Panel, Stepper, Tag3, Card2, Card3, Heading3, MenuItem3, FormLabel, SelectMenu, Switch, SelectInput, CodeEditorVS, SettingsModal, SubHeading2, tailwindHeightFractions, Menu3, Panel3, ButtonIcon2, DropdownPanel, MenuItem2, useStatusTokens, Caption2, ConfirmationModal, DropComponent, DragComponent, getStyleName, capitalizeFirstLetter, isHexColor as isHexColor$1, deriveShades, colorTypes, TAILWIND_PALETTE, Toggle, normalizeHex as normalizeHex$1, contrastRatio, Caption, getColorFamilies, getCuratedColorGrid, DashPanel, hexToRgb as hexToRgb$1, themeVariants, SubHeading, Heading2, Paragraph2, Paragraph3, ButtonIcon3, Tag2, Alert, Alert2, Alert3, Toast, Toast2, Toast3, ProgressBar, ProgressBar2, ProgressBar3, MenuItem, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Caption3, Code, Code2, Code3, Divider, Divider2, Divider3, DashPanel2, DashPanel3, Tabs, Tabs2, Tabs3, Accordion, Accordion2, Accordion3, Toggle2, Toggle3, TextArea, Checkbox, Slider, RadioGroup, AlertBanner, StatusBadge as StatusBadge$1, Skeleton, StatCard, DataList, EmptyState, Card, Panel2, ThemeFromUrlPane, AlgoliaSearchBox, CodeEditorInline, Icon2, SectionLabel, SegmentedControl, ChatMessage, ChatComposer, useResizableWidth, ResizeHandle, ChoiceMenu, CommandPalette, useSidebar, FilterMenu, Navbar, withRouter, Menu as Menu$1, ChatToolCall } from '@trops/dash-react';
6
6
  export * from '@trops/dash-react';
7
7
  export { FontAwesomeIcon, ThemeContext } from '@trops/dash-react';
8
8
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
@@ -56751,70 +56751,6 @@ var PlanSketch = function PlanSketch(_ref) {
56751
56751
  });
56752
56752
  };
56753
56753
 
56754
- function useBubbleTokens() {
56755
- var _ref = useContext(ThemeContext) || {},
56756
- currentTheme = _ref.currentTheme;
56757
- return {
56758
- reply: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme["bg-secondary-dark"]) || (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme["bg-primary-dark"]) || "",
56759
- you: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme["bg-primary-medium"]) || "",
56760
- text: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme["text-primary-medium"]) || ""
56761
- };
56762
- }
56763
-
56764
- /** What the user said, right-aligned. */
56765
- var YouBubble = function YouBubble(_ref2) {
56766
- var children = _ref2.children;
56767
- var t = useBubbleTokens();
56768
- return /*#__PURE__*/jsx("div", {
56769
- className: "flex justify-end",
56770
- children: /*#__PURE__*/jsxs("div", {
56771
- className: "max-w-xl",
56772
- children: [/*#__PURE__*/jsx(Caption2, {
56773
- block: true,
56774
- className: "font-semibold uppercase tracking-wider mb-1 text-right",
56775
- children: "You"
56776
- }), /*#__PURE__*/jsx("div", {
56777
- className: "px-3 py-2 rounded-lg text-sm whitespace-pre-wrap break-words leading-relaxed ".concat(t.you, " ").concat(t.text),
56778
- children: children
56779
- })]
56780
- })
56781
- });
56782
- };
56783
-
56784
- /**
56785
- * A team member's reply: its label ("Planner"), an optional meta line
56786
- * (model · tokens), the text, and anything below it (a button).
56787
- */
56788
- var TeamBubble = function TeamBubble(_ref3) {
56789
- var _ref3$label = _ref3.label,
56790
- label = _ref3$label === void 0 ? "Planner" : _ref3$label,
56791
- _ref3$meta = _ref3.meta,
56792
- meta = _ref3$meta === void 0 ? null : _ref3$meta,
56793
- _ref3$muted = _ref3.muted,
56794
- muted = _ref3$muted === void 0 ? false : _ref3$muted,
56795
- testId = _ref3.testId,
56796
- children = _ref3.children,
56797
- _ref3$footer = _ref3.footer,
56798
- footer = _ref3$footer === void 0 ? null : _ref3$footer;
56799
- var t = useBubbleTokens();
56800
- return /*#__PURE__*/jsxs("div", {
56801
- className: "flex flex-col gap-1",
56802
- "data-testid": testId,
56803
- children: [/*#__PURE__*/jsxs("div", {
56804
- className: "flex flex-row items-center gap-2",
56805
- children: [/*#__PURE__*/jsx(Caption2, {
56806
- className: "font-semibold uppercase tracking-wider",
56807
- children: label
56808
- }), meta ? /*#__PURE__*/jsx(Caption2, {
56809
- children: meta
56810
- }) : null]
56811
- }), /*#__PURE__*/jsx("div", {
56812
- className: "px-3 py-2 rounded-lg text-sm whitespace-pre-wrap break-words leading-relaxed ".concat(t.reply, " ").concat(t.text, " ").concat(muted ? "opacity-70 italic" : ""),
56813
- children: children
56814
- }), footer]
56815
- });
56816
- };
56817
-
56818
56754
  function ownKeys$J(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
56819
56755
  function _objectSpread$J(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$J(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$J(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
56820
56756
  function reopenedRequest(original, plan, text) {
@@ -57388,19 +57324,30 @@ var CreatePlanStep = function CreatePlanStep(_ref2) {
57388
57324
  children: /*#__PURE__*/jsxs("div", {
57389
57325
  className: "mx-auto w-full max-w-3xl flex flex-col ".concat(compact ? "gap-3 px-3 py-3" : "gap-4 px-6 py-8"),
57390
57326
  children: [messages.map(function (m, i) {
57391
- return m.who === "you" ? /*#__PURE__*/jsx(YouBubble, {
57327
+ return m.who === "you" ? /*#__PURE__*/jsx(ChatMessage, {
57328
+ role: "you",
57392
57329
  children: m.text
57393
- }, i) : m.who === "note" ? /*#__PURE__*/jsx("span", {
57394
- className: "text-xs ".concat(muted),
57330
+ }, i) : m.who === "note" ? /*#__PURE__*/jsx(ChatMessage, {
57331
+ role: "note",
57395
57332
  children: m.text
57396
- }, i) : /*#__PURE__*/jsx(TeamBubble, {
57333
+ }, i) : /*#__PURE__*/jsx(ChatMessage, {
57334
+ role: "reply",
57335
+ label: "Planner",
57397
57336
  meta: m.meta,
57398
57337
  testId: "planner-message",
57399
- children: m.text
57338
+ children: /*#__PURE__*/jsx("span", {
57339
+ className: "whitespace-pre-wrap",
57340
+ children: m.text
57341
+ })
57400
57342
  }, i);
57401
- }), busy ? /*#__PURE__*/jsx(TeamBubble, {
57402
- muted: true,
57403
- children: withoutPlan(soFar) || "Thinking…"
57343
+ }), busy ? /*#__PURE__*/jsx(ChatMessage, {
57344
+ role: "reply",
57345
+ label: "Planner",
57346
+ streaming: true,
57347
+ children: /*#__PURE__*/jsx("span", {
57348
+ className: "whitespace-pre-wrap",
57349
+ children: withoutPlan(soFar) || "Thinking…"
57350
+ })
57404
57351
  }) : null, !busy && questions.length ? /*#__PURE__*/jsxs("div", {
57405
57352
  className: "flex flex-col gap-3",
57406
57353
  "data-testid": "plan-questions",
@@ -57664,33 +57611,22 @@ var CreatePlanStep = function CreatePlanStep(_ref2) {
57664
57611
  setWalking(false);
57665
57612
  }
57666
57613
  }) : null, /*#__PURE__*/jsx("div", {
57667
- className: "flex-shrink-0 border-t ".concat(hairline),
57668
- children: /*#__PURE__*/jsxs("div", {
57669
- className: "mx-auto w-full max-w-3xl flex flex-row items-end gap-2 ".concat(compact ? "px-3 py-2" : "px-6 py-3"),
57670
- children: [/*#__PURE__*/jsx("div", {
57671
- className: "flex-1",
57672
- children: /*#__PURE__*/jsx(TextArea, {
57673
- "aria-label": "Reply to the Planner",
57674
- value: reply,
57675
- onChange: function onChange(v) {
57676
- return setReply(v);
57677
- },
57678
- placeholder: busy ? "The Planner is working…" : "Answer, or ask for changes…",
57679
- rows: 2,
57680
- onKeyDown: function onKeyDown(e) {
57681
- if (e.key === "Enter" && !e.shiftKey) {
57682
- e.preventDefault();
57683
- answer(reply);
57684
- }
57685
- }
57686
- })
57687
- }), /*#__PURE__*/jsx(Button, {
57688
- title: "Send",
57689
- onClick: function onClick() {
57614
+ className: "flex-shrink-0",
57615
+ children: /*#__PURE__*/jsx("div", {
57616
+ className: "mx-auto w-full max-w-3xl",
57617
+ children: /*#__PURE__*/jsx(ChatComposer, {
57618
+ ariaLabel: "Reply to the Planner",
57619
+ value: reply,
57620
+ onChange: function onChange(v) {
57621
+ return setReply(v);
57622
+ },
57623
+ onSend: function onSend() {
57690
57624
  return answer(reply);
57691
57625
  },
57692
- disabled: busy || !reply.trim()
57693
- })]
57626
+ busy: busy,
57627
+ placeholder: busy ? "The Planner is working…" : "Answer, or ask for changes…",
57628
+ className: compact ? "" : "px-6 py-3"
57629
+ })
57694
57630
  })
57695
57631
  })]
57696
57632
  });
@@ -58572,9 +58508,6 @@ var AskStep = function AskStep(_ref) {
58572
58508
  recentId = _ref$recentId === void 0 ? null : _ref$recentId,
58573
58509
  _ref$onOpenPlan = _ref.onOpenPlan,
58574
58510
  onOpenPlan = _ref$onOpenPlan === void 0 ? null : _ref$onOpenPlan;
58575
- var _useConfigTokens = useConfigTokens(),
58576
- muted = _useConfigTokens.muted,
58577
- hairline = _useConfigTokens.hairline;
58578
58511
  // [{ who: "you" | "planner" | "note", text, meta?, plan? }]
58579
58512
  var _useState = useState(recentId ? [] : [{
58580
58513
  who: "you",
@@ -58758,56 +58691,51 @@ var AskStep = function AskStep(_ref) {
58758
58691
  children: /*#__PURE__*/jsxs("div", {
58759
58692
  className: "flex flex-col gap-3 px-3 py-3",
58760
58693
  children: [messages.map(function (m, i) {
58761
- return m.who === "you" ? /*#__PURE__*/jsx(YouBubble, {
58694
+ return m.who === "you" ? /*#__PURE__*/jsx(ChatMessage, {
58695
+ role: "you",
58762
58696
  children: m.text
58763
- }, i) : m.who === "note" ? /*#__PURE__*/jsx("span", {
58764
- className: "text-xs ".concat(muted),
58697
+ }, i) : m.who === "note" ? /*#__PURE__*/jsx(ChatMessage, {
58698
+ role: "note",
58765
58699
  children: m.text
58766
- }, i) : /*#__PURE__*/jsx(TeamBubble, {
58700
+ }, i) : /*#__PURE__*/jsx(ChatMessage, {
58701
+ role: "reply",
58702
+ label: "Planner",
58767
58703
  meta: m.meta,
58768
58704
  testId: "ask-answer",
58769
- footer: m.plan && onOpenPlan ? /*#__PURE__*/jsx("div", {
58770
- children: /*#__PURE__*/jsx(Button3, {
58771
- size: "sm",
58772
- title: "Open as a plan",
58773
- onClick: function onClick() {
58774
- return onOpenPlan(planSeed(m.asked, m.plan));
58775
- }
58776
- })
58705
+ footer: m.plan && onOpenPlan ? /*#__PURE__*/jsx(Button3, {
58706
+ size: "sm",
58707
+ title: "Open as a plan",
58708
+ onClick: function onClick() {
58709
+ return onOpenPlan(planSeed(m.asked, m.plan));
58710
+ }
58777
58711
  }) : null,
58778
- children: m.text
58712
+ children: /*#__PURE__*/jsx("span", {
58713
+ className: "whitespace-pre-wrap",
58714
+ children: m.text
58715
+ })
58779
58716
  }, i);
58780
- }), busy ? /*#__PURE__*/jsx(TeamBubble, {
58781
- muted: true,
58782
- children: withoutPlan(soFar) || "Looking…"
58717
+ }), busy ? /*#__PURE__*/jsx(ChatMessage, {
58718
+ role: "reply",
58719
+ label: "Planner",
58720
+ streaming: true,
58721
+ children: /*#__PURE__*/jsx("span", {
58722
+ className: "whitespace-pre-wrap",
58723
+ children: withoutPlan(soFar) || "Looking…"
58724
+ })
58783
58725
  }) : null]
58784
58726
  })
58785
- }), /*#__PURE__*/jsxs("div", {
58786
- className: "flex-shrink-0 flex flex-row items-end gap-2 px-3 py-2 border-t ".concat(hairline),
58787
- children: [/*#__PURE__*/jsx("div", {
58788
- className: "flex-1",
58789
- children: /*#__PURE__*/jsx(TextArea, {
58790
- "aria-label": "Ask a follow-up",
58791
- value: reply,
58792
- onChange: function onChange(v) {
58793
- return setReply(v);
58794
- },
58795
- placeholder: busy ? "The Planner is looking…" : "Ask a follow-up…",
58796
- rows: 2,
58797
- onKeyDown: function onKeyDown(e) {
58798
- if (e.key === "Enter" && !e.shiftKey) {
58799
- e.preventDefault();
58800
- send(reply);
58801
- }
58802
- }
58803
- })
58804
- }), /*#__PURE__*/jsx(Button, {
58805
- title: "Send",
58806
- onClick: function onClick() {
58807
- return send(reply);
58808
- },
58809
- disabled: busy || !reply.trim()
58810
- })]
58727
+ }), /*#__PURE__*/jsx(ChatComposer, {
58728
+ ariaLabel: "Ask a follow-up",
58729
+ value: reply,
58730
+ onChange: function onChange(v) {
58731
+ return setReply(v);
58732
+ },
58733
+ onSend: function onSend() {
58734
+ return send(reply);
58735
+ },
58736
+ busy: busy,
58737
+ placeholder: busy ? "The Planner is looking…" : "Ask a follow-up…",
58738
+ className: "flex-shrink-0"
58811
58739
  })]
58812
58740
  });
58813
58741
  };
@@ -81531,6 +81459,7 @@ var ThemesPage = function ThemesPage(_ref2) {
81531
81459
  children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
81532
81460
  icon: "sun"
81533
81461
  }), /*#__PURE__*/jsx(Switch, {
81462
+ ariaLabel: "Dark mode",
81534
81463
  checked: themeVariant === "dark",
81535
81464
  onChange: function onChange(isDark) {
81536
81465
  return changeThemeVariant && changeThemeVariant(isDark ? "dark" : "light");
@@ -87804,6 +87733,15 @@ var StreamingText = function StreamingText(_ref) {
87804
87733
  });
87805
87734
  };
87806
87735
 
87736
+ /**
87737
+ * ToolCallBlock
87738
+ *
87739
+ * One MCP tool call in a chat, drawn with dash-react's ChatToolCall: status
87740
+ * dot, tool name, where it ran, and a disclosure with the input and result.
87741
+ */
87742
+ var pretty = function pretty(v) {
87743
+ return typeof v === "string" ? v : JSON.stringify(v, null, 2);
87744
+ };
87807
87745
  var ToolCallBlock = function ToolCallBlock(_ref) {
87808
87746
  var toolName = _ref.toolName,
87809
87747
  serverName = _ref.serverName,
@@ -87811,62 +87749,36 @@ var ToolCallBlock = function ToolCallBlock(_ref) {
87811
87749
  result = _ref.result,
87812
87750
  isError = _ref.isError,
87813
87751
  isLoading = _ref.isLoading;
87814
- var _useState = useState(false),
87815
- _useState2 = _slicedToArray(_useState, 2),
87816
- expanded = _useState2[0],
87817
- setExpanded = _useState2[1];
87818
- var _ref2 = useContext(ThemeContext) || {},
87819
- currentTheme = _ref2.currentTheme;
87820
87752
  var statusTokens = useStatusTokens();
87821
- var t = function t(key) {
87822
- return (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme[key]) || "";
87823
- };
87824
- var dotColor = isLoading ? "".concat(statusTokens.warning.solidBg, " animate-pulse") : isError ? statusTokens.error.solidBg : statusTokens.success.solidBg;
87825
- var preBase = "p-1.5 rounded overflow-x-auto overflow-y-auto font-mono";
87826
- var preNeutral = "".concat(t("bg-primary-very-dark"), " ").concat(t("text-primary-medium"));
87827
- return /*#__PURE__*/jsxs("div", {
87828
- className: "my-1.5 border rounded-md overflow-hidden text-xs ".concat(t("border-primary-dark")),
87829
- children: [/*#__PURE__*/jsxs("button", {
87830
- onClick: function onClick() {
87831
- return setExpanded(!expanded);
87832
- },
87833
- className: "w-full flex items-center gap-2 px-2.5 py-1.5 transition-colors text-left ".concat(t("bg-primary-dark"), " ").concat(t("hover-bg-primary-dark")),
87834
- children: [/*#__PURE__*/jsx("span", {
87835
- className: "inline-block w-2 h-2 rounded-full ".concat(dotColor)
87836
- }), /*#__PURE__*/jsx("span", {
87837
- className: "font-mono ".concat(t("text-secondary-medium")),
87838
- children: toolName
87839
- }), serverName && /*#__PURE__*/jsxs(Caption2, {
87840
- children: ["via ", serverName]
87841
- }), /*#__PURE__*/jsx(Caption2, {
87842
- className: "ml-auto",
87843
- children: expanded ? "▲" : "▼"
87844
- })]
87845
- }), expanded && /*#__PURE__*/jsxs("div", {
87846
- className: "px-2.5 py-2 space-y-2 ".concat(t("bg-primary-dark")),
87847
- children: [input && /*#__PURE__*/jsxs("div", {
87753
+ var status = isLoading ? "running" : isError ? "error" : "done";
87754
+ var hasDetails = input !== undefined || result !== undefined;
87755
+ var pre = "p-1.5 rounded overflow-auto font-mono text-xs";
87756
+ return /*#__PURE__*/jsx(ChatToolCall, {
87757
+ name: toolName,
87758
+ source: serverName ? "via ".concat(serverName) : null,
87759
+ status: status,
87760
+ children: hasDetails ? /*#__PURE__*/jsxs("div", {
87761
+ className: "space-y-2",
87762
+ children: [input !== undefined && input !== null && input !== "" ? /*#__PURE__*/jsxs("div", {
87848
87763
  children: [/*#__PURE__*/jsx(Caption2, {
87849
87764
  block: true,
87850
87765
  className: "mb-0.5",
87851
87766
  children: "Input:"
87852
87767
  }), /*#__PURE__*/jsx("pre", {
87853
- className: "".concat(preBase, " max-h-32 ").concat(preNeutral),
87854
- children: typeof input === "string" ? input : JSON.stringify(input, null, 2)
87768
+ className: "".concat(pre, " max-h-32"),
87769
+ children: pretty(input)
87855
87770
  })]
87856
- }), result !== undefined && /*#__PURE__*/jsxs("div", {
87771
+ }) : null, result !== undefined ? /*#__PURE__*/jsxs("div", {
87857
87772
  children: [/*#__PURE__*/jsx(Caption2, {
87858
87773
  block: true,
87859
87774
  className: "mb-0.5",
87860
87775
  children: "Result:"
87861
87776
  }), /*#__PURE__*/jsx("pre", {
87862
- className: "".concat(preBase, " max-h-48 ").concat(isError ? "".concat(statusTokens.error.bg, " ").concat(statusTokens.error.text) : preNeutral),
87863
- children: typeof result === "string" ? result : JSON.stringify(result, null, 2)
87777
+ className: "".concat(pre, " max-h-48 ").concat(isError ? "".concat(statusTokens.error.bg, " ").concat(statusTokens.error.text) : ""),
87778
+ children: pretty(result)
87864
87779
  })]
87865
- }), isLoading && /*#__PURE__*/jsx("div", {
87866
- className: "italic ".concat(statusTokens.warning.icon),
87867
- children: "Running..."
87868
- })]
87869
- })]
87780
+ }) : null]
87781
+ }) : null
87870
87782
  });
87871
87783
  };
87872
87784
 
@@ -87988,18 +87900,7 @@ var MessageBubble = function MessageBubble(_ref2) {
87988
87900
  content = message.content,
87989
87901
  toolCalls = message.toolCalls,
87990
87902
  hidden = message.hidden;
87991
- var _ref3 = useContext(ThemeContext) || {},
87992
- currentTheme = _ref3.currentTheme;
87993
87903
  var statusTokens = useStatusTokens();
87994
- // Theme-provided colors so the chat follows the active light/dark
87995
- // theme. No hardcoded fallbacks — they only read correctly on dark.
87996
- var bubbleBg = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme["bg-secondary-dark"]) || (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme["bg-primary-dark"]) || "";
87997
- // The user's bubble uses the primary surface so it stands apart from the
87998
- // Assistant/lead bubbles (secondary). "bg-primary-medium" is a real
87999
- // ThemeModel key; the old "bg-primary-bright"/"bg-primary" don't exist,
88000
- // which left the user's text with no bubble at all.
88001
- var userBubbleBg = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme["bg-primary-medium"]) || "";
88002
- var bubbleText = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme["text-primary-medium"]) || "";
88003
87904
 
88004
87905
  // App-injected priming messages (e.g. widget-builder "Hello…" seed)
88005
87906
  // are kept in state for conversation continuity but suppressed from
@@ -88011,19 +87912,13 @@ var MessageBubble = function MessageBubble(_ref2) {
88011
87912
  }).map(function (c) {
88012
87913
  return c.text;
88013
87914
  }).join("") : "";
88014
- return /*#__PURE__*/jsx("div", {
88015
- className: "flex justify-end mb-4",
88016
- children: /*#__PURE__*/jsxs("div", {
88017
- className: "max-w-md",
88018
- children: [/*#__PURE__*/jsx(Caption2, {
88019
- block: true,
88020
- className: "font-semibold uppercase tracking-wider mb-1 text-right",
88021
- children: message.to ? "You \u2192 ".concat(leadLabel(message.to)) : "You"
88022
- }), /*#__PURE__*/jsx("div", {
88023
- className: "px-3 py-2 rounded-lg text-sm whitespace-pre-wrap break-words leading-relaxed ".concat(userBubbleBg, " ").concat(bubbleText),
88024
- children: text
88025
- })]
88026
- })
87915
+ return /*#__PURE__*/jsxs(ChatMessage, {
87916
+ role: "you",
87917
+ testId: "user-bubble",
87918
+ children: [message.to ? /*#__PURE__*/jsxs("span", {
87919
+ className: "block text-xs opacity-70 mb-0.5",
87920
+ children: ["To ", leadLabel(message.to)]
87921
+ }) : null, text]
88027
87922
  });
88028
87923
  }
88029
87924
  if (role === "assistant") {
@@ -88094,51 +87989,39 @@ var MessageBubble = function MessageBubble(_ref2) {
88094
87989
  // indicator so the user knows the AI is working.
88095
87990
  if (!isStreaming && !_text && toolBlocks.length === 0) {
88096
87991
  if (isLast) {
88097
- return /*#__PURE__*/jsxs("div", {
88098
- className: "mb-4",
88099
- children: [/*#__PURE__*/jsx(Caption2, {
88100
- block: true,
88101
- className: "font-semibold uppercase tracking-wider mb-1",
88102
- children: "Assistant"
88103
- }), /*#__PURE__*/jsx("div", {
88104
- className: "text-sm leading-relaxed px-3 py-2 rounded-lg ".concat(bubbleBg),
88105
- children: /*#__PURE__*/jsx(Caption2, {
88106
- className: "italic",
88107
- children: "Thinking..."
88108
- })
88109
- })]
87992
+ return /*#__PURE__*/jsx(ChatMessage, {
87993
+ role: "reply",
87994
+ label: "Assistant",
87995
+ streaming: true,
87996
+ children: "Thinking..."
88110
87997
  });
88111
87998
  }
88112
87999
  return null;
88113
88000
  }
88114
88001
  return /*#__PURE__*/jsxs("div", {
88115
- className: "mb-4",
88116
- children: [/*#__PURE__*/jsx(Caption2, {
88117
- block: true,
88118
- className: "font-semibold uppercase tracking-wider mb-1",
88119
- children: "Assistant"
88120
- }), /*#__PURE__*/jsxs("div", {
88121
- className: "text-sm leading-relaxed px-3 py-2 rounded-lg ".concat(bubbleBg, " ").concat(bubbleText),
88122
- children: [isStreaming && /*#__PURE__*/jsx("div", {
88123
- children: /*#__PURE__*/jsx(StreamingText, {
88124
- text: codeNote ? collapseCodeBlocks(streamingText, codeNote, {
88125
- plain: true
88126
- }) : streamingText,
88127
- isStreaming: true
88128
- })
88129
- }), !isStreaming && _text && /*#__PURE__*/jsx(AssistantTextContent, {
88002
+ className: "flex flex-col gap-2",
88003
+ children: [toolBlocks.map(function (block) {
88004
+ return /*#__PURE__*/jsx(ToolCallBlock, {
88005
+ toolName: block.name,
88006
+ serverName: block.serverName,
88007
+ input: block.input,
88008
+ result: block.result,
88009
+ isError: block.isError,
88010
+ isLoading: block.isLoading
88011
+ }, block.id);
88012
+ }), isStreaming || _text ? /*#__PURE__*/jsx(ChatMessage, {
88013
+ role: "reply",
88014
+ label: "Assistant",
88015
+ streaming: isStreaming && !streamingText,
88016
+ children: isStreaming ? /*#__PURE__*/jsx(StreamingText, {
88017
+ text: codeNote ? collapseCodeBlocks(streamingText, codeNote, {
88018
+ plain: true
88019
+ }) : streamingText,
88020
+ isStreaming: true
88021
+ }) : /*#__PURE__*/jsx(AssistantTextContent, {
88130
88022
  text: codeNote ? collapseCodeBlocks(_text, codeNote) : _text
88131
- }), toolBlocks.map(function (block) {
88132
- return /*#__PURE__*/jsx(ToolCallBlock, {
88133
- toolName: block.name,
88134
- serverName: block.serverName,
88135
- input: block.input,
88136
- result: block.result,
88137
- isError: block.isError,
88138
- isLoading: block.isLoading
88139
- }, block.id);
88140
- })]
88141
- })]
88023
+ })
88024
+ }) : null]
88142
88025
  });
88143
88026
  }
88144
88027
 
@@ -88146,25 +88029,20 @@ var MessageBubble = function MessageBubble(_ref2) {
88146
88029
  // lead and its dashboard.
88147
88030
  if (role === "lead") {
88148
88031
  var _text2 = typeof content === "string" ? content : textOfContent(content);
88149
- return /*#__PURE__*/jsxs("div", {
88150
- className: "mb-4",
88151
- "data-testid": "lead-bubble",
88152
- children: [/*#__PURE__*/jsx(Caption2, {
88153
- block: true,
88154
- className: "font-semibold uppercase tracking-wider mb-1",
88155
- children: leadLabel(message.from)
88156
- }), /*#__PURE__*/jsx("div", {
88157
- className: "text-sm leading-relaxed px-3 py-2 rounded-lg ".concat(bubbleBg, " ").concat(bubbleText),
88158
- children: message.error ? /*#__PURE__*/jsx("span", {
88159
- className: statusTokens.error.icon,
88160
- children: message.error
88161
- }) : _text2 ? /*#__PURE__*/jsx(AssistantTextContent, {
88162
- text: _text2
88163
- }) : /*#__PURE__*/jsx(Caption2, {
88164
- className: "italic",
88165
- children: message.streaming ? "Working…" : "No answer."
88166
- })
88167
- })]
88032
+ return /*#__PURE__*/jsx(ChatMessage, {
88033
+ role: "reply",
88034
+ label: leadLabel(message.from),
88035
+ streaming: !!message.streaming && !_text2,
88036
+ testId: "lead-bubble",
88037
+ children: message.error ? /*#__PURE__*/jsx("span", {
88038
+ className: statusTokens.error.icon,
88039
+ children: message.error
88040
+ }) : _text2 ? /*#__PURE__*/jsx(AssistantTextContent, {
88041
+ text: _text2
88042
+ }) : /*#__PURE__*/jsx("span", {
88043
+ className: "italic",
88044
+ children: message.streaming ? "Working…" : "No answer."
88045
+ })
88168
88046
  });
88169
88047
  }
88170
88048
  return null;
@@ -88192,11 +88070,6 @@ var ChatMessages = function ChatMessages(_ref) {
88192
88070
  _ref$codeNote = _ref.codeNote,
88193
88071
  codeNote = _ref$codeNote === void 0 ? null : _ref$codeNote;
88194
88072
  var scrollRef = useRef(null);
88195
- var _ref2 = useContext(ThemeContext) || {},
88196
- currentTheme = _ref2.currentTheme;
88197
- var t = function t(key) {
88198
- return (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme[key]) || "";
88199
- };
88200
88073
  useEffect(function () {
88201
88074
  if (scrollRef.current) {
88202
88075
  scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
@@ -88204,23 +88077,17 @@ var ChatMessages = function ChatMessages(_ref) {
88204
88077
  }, [messages, streamingText]);
88205
88078
  if (messages.length === 0) {
88206
88079
  return /*#__PURE__*/jsx("div", {
88207
- className: "flex-1 flex items-center justify-center",
88208
- children: /*#__PURE__*/jsxs("div", {
88209
- className: "text-center space-y-1",
88210
- children: [/*#__PURE__*/jsx("div", {
88211
- className: "text-2xl",
88212
- children: "\uD83D\uDCAC"
88213
- }), /*#__PURE__*/jsx(Caption2, {
88214
- block: true,
88215
- className: "text-sm",
88216
- children: "Send a message to start chatting"
88217
- })]
88080
+ className: "flex-1 flex items-center justify-center px-4",
88081
+ children: /*#__PURE__*/jsx(Caption2, {
88082
+ block: true,
88083
+ className: "text-sm text-center",
88084
+ children: "Send a message to start chatting"
88218
88085
  })
88219
88086
  });
88220
88087
  }
88221
88088
  return /*#__PURE__*/jsxs("div", {
88222
88089
  ref: scrollRef,
88223
- className: "flex-1 overflow-y-auto px-4 py-3 scroll-smooth",
88090
+ className: "flex-1 overflow-y-auto px-4 py-3 scroll-smooth flex flex-col gap-3",
88224
88091
  children: [messages.map(function (message, index) {
88225
88092
  var isLastAssistant = message.role === "assistant" && index === messages.length - 1;
88226
88093
  var isStreaming = isLastAssistant && streamingRequestId !== null;
@@ -88231,34 +88098,11 @@ var ChatMessages = function ChatMessages(_ref) {
88231
88098
  isLast: index === messages.length - 1,
88232
88099
  codeNote: codeNote
88233
88100
  }, message.id || index);
88234
- }), isLoading && !streamingRequestId && ((_messages = messages[messages.length - 1]) === null || _messages === void 0 ? void 0 : _messages.role) === "user" && /*#__PURE__*/jsxs("div", {
88235
- className: "mb-4",
88236
- children: [/*#__PURE__*/jsx(Caption2, {
88237
- block: true,
88238
- className: "font-semibold uppercase tracking-wider mb-1",
88239
- children: "Assistant"
88240
- }), /*#__PURE__*/jsxs("div", {
88241
- className: "text-sm leading-relaxed px-3 py-2 rounded-lg italic flex items-center gap-2 opacity-70 ".concat(t("bg-primary-dark"), " ").concat(t("text-primary-medium")),
88242
- children: [/*#__PURE__*/jsxs("span", {
88243
- className: "inline-flex gap-0.5",
88244
- children: [/*#__PURE__*/jsx("span", {
88245
- className: "w-1.5 h-1.5 rounded-full animate-bounce ".concat(t("bg-primary-medium")),
88246
- style: {
88247
- animationDelay: "0ms"
88248
- }
88249
- }), /*#__PURE__*/jsx("span", {
88250
- className: "w-1.5 h-1.5 rounded-full animate-bounce ".concat(t("bg-primary-medium")),
88251
- style: {
88252
- animationDelay: "150ms"
88253
- }
88254
- }), /*#__PURE__*/jsx("span", {
88255
- className: "w-1.5 h-1.5 rounded-full animate-bounce ".concat(t("bg-primary-medium")),
88256
- style: {
88257
- animationDelay: "300ms"
88258
- }
88259
- })]
88260
- }), "Thinking..."]
88261
- })]
88101
+ }), isLoading && !streamingRequestId && ((_messages = messages[messages.length - 1]) === null || _messages === void 0 ? void 0 : _messages.role) === "user" && /*#__PURE__*/jsx(ChatMessage, {
88102
+ role: "reply",
88103
+ label: "Assistant",
88104
+ streaming: true,
88105
+ children: "Thinking..."
88262
88106
  })]
88263
88107
  });
88264
88108
  };
@@ -88322,11 +88166,6 @@ var ChatInput = function ChatInput(_ref) {
88322
88166
  leads = _ref$leads === void 0 ? null : _ref$leads,
88323
88167
  _ref$onPickRecipient = _ref.onPickRecipient,
88324
88168
  onPickRecipient = _ref$onPickRecipient === void 0 ? null : _ref$onPickRecipient;
88325
- var _ref2 = useContext(ThemeContext) || {},
88326
- currentTheme = _ref2.currentTheme;
88327
- var t = function t(key) {
88328
- return (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme[key]) || "";
88329
- };
88330
88169
  var _useState = useState(""),
88331
88170
  _useState2 = _slicedToArray(_useState, 2),
88332
88171
  input = _useState2[0],
@@ -88441,37 +88280,25 @@ var ChatInput = function ChatInput(_ref) {
88441
88280
  handleSend();
88442
88281
  }
88443
88282
  };
88444
- return /*#__PURE__*/jsxs("div", {
88445
- className: "flex flex-col gap-1 px-3 py-2 border-t ".concat(t("border-primary-dark")),
88446
- children: [mentionOpen && /*#__PURE__*/jsx(LeadMentionMenu, {
88283
+ return /*#__PURE__*/jsx(ChatComposer, {
88284
+ ref: textareaRef,
88285
+ value: input,
88286
+ onChange: function onChange(_value, e) {
88287
+ return handleChange(e);
88288
+ },
88289
+ onKeyDown: handleKeyDown,
88290
+ onSend: handleSend,
88291
+ onStop: onStop,
88292
+ busy: !!isLoading,
88293
+ disabled: disabled,
88294
+ rows: 1,
88295
+ placeholder: "Type a message...",
88296
+ hint: queued ? "Sends when the current reply finishes" : "Enter to send · Shift+Enter for a new line",
88297
+ above: mentionOpen ? /*#__PURE__*/jsx(LeadMentionMenu, {
88447
88298
  options: mentionOptions,
88448
88299
  activeIndex: mentionIndex,
88449
88300
  onPick: pickMention
88450
- }), /*#__PURE__*/jsxs("div", {
88451
- className: "flex items-end gap-2",
88452
- children: [/*#__PURE__*/jsx("textarea", {
88453
- ref: textareaRef,
88454
- value: input,
88455
- onChange: handleChange,
88456
- onKeyDown: handleKeyDown,
88457
- placeholder: "Type a message...",
88458
- disabled: disabled,
88459
- rows: 1,
88460
- className: "flex-1 px-3 py-2 border rounded-lg text-sm focus:outline-none resize-none disabled:opacity-50 ".concat(t("bg-primary-dark"), " ").concat(t("border-primary-dark"), " ").concat(t("text-primary-medium"))
88461
- }), isLoading ? /*#__PURE__*/jsx(Button, {
88462
- title: "Stop",
88463
- danger: true,
88464
- onClick: onStop,
88465
- className: "shrink-0"
88466
- }) : /*#__PURE__*/jsx(Button, {
88467
- title: "Send",
88468
- onClick: handleSend,
88469
- disabled: !input.trim() || disabled,
88470
- className: "shrink-0"
88471
- })]
88472
- }), queued && /*#__PURE__*/jsx(Caption2, {
88473
- children: "Sends when the current reply finishes"
88474
- })]
88301
+ }) : null
88475
88302
  });
88476
88303
  };
88477
88304