llmasaservice-ui 0.16.13 → 0.16.15

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.css CHANGED
@@ -877,6 +877,29 @@
877
877
  line-height: 1.4;
878
878
  white-space: pre-wrap;
879
879
  }
880
+ .thinking-content-collapsed {
881
+ display: -webkit-box;
882
+ -webkit-line-clamp: 2;
883
+ -webkit-box-orient: vertical;
884
+ overflow: hidden;
885
+ text-overflow: ellipsis;
886
+ }
887
+ .thinking-content-expanded {
888
+ }
889
+ .thinking-expand-btn {
890
+ background: none;
891
+ border: none;
892
+ cursor: pointer;
893
+ color: var(--title-text-color);
894
+ font-size: 0.75rem;
895
+ padding: 2px 4px;
896
+ margin-top: 2px;
897
+ opacity: 0.7;
898
+ align-self: flex-start;
899
+ }
900
+ .thinking-expand-btn:hover {
901
+ opacity: 1;
902
+ }
880
903
  button[data-pending=true] {
881
904
  opacity: 0.55;
882
905
  pointer-events: none;
package/dist/index.js CHANGED
@@ -261,6 +261,7 @@ var ChatPanel = ({
261
261
  const [alwaysApprovedTools, setAlwaysApprovedTools] = (0, import_react3.useState)([]);
262
262
  const [thinkingBlocks, setThinkingBlocks] = (0, import_react3.useState)([]);
263
263
  const [currentThinkingIndex, setCurrentThinkingIndex] = (0, import_react3.useState)(0);
264
+ const [thinkingExpanded, setThinkingExpanded] = (0, import_react3.useState)(false);
264
265
  const [userResizedHeight, setUserResizedHeight] = (0, import_react3.useState)(null);
265
266
  const [pendingButtonAttachments, setPendingButtonAttachments] = (0, import_react3.useState)([]);
266
267
  const actionMatchRegistry = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
@@ -438,8 +439,16 @@ var ChatPanel = ({
438
439
  className: "thinking-nav-btn"
439
440
  },
440
441
  "\u2192"
441
- ))), /* @__PURE__ */ import_react3.default.createElement("div", { className: "thinking-content" }, content)));
442
- }, [thinkingBlocks, currentThinkingIndex]);
442
+ ))), /* @__PURE__ */ import_react3.default.createElement("div", { className: `thinking-content ${thinkingExpanded ? "thinking-content-expanded" : "thinking-content-collapsed"}` }, content), /* @__PURE__ */ import_react3.default.createElement(
443
+ "button",
444
+ {
445
+ className: "thinking-expand-btn",
446
+ onClick: () => setThinkingExpanded((prev) => !prev),
447
+ title: thinkingExpanded ? "Collapse" : "Expand"
448
+ },
449
+ thinkingExpanded ? "\u25B2" : "\u25BC"
450
+ )));
451
+ }, [thinkingBlocks, currentThinkingIndex, thinkingExpanded]);
443
452
  const getBrowserInfo = () => {
444
453
  try {
445
454
  return {
@@ -952,8 +961,21 @@ var ChatPanel = ({
952
961
  callbackType: typeof action.callback,
953
962
  pattern: action.pattern
954
963
  });
964
+ if (typeof action.callback === "string") {
965
+ const parsed = parseCallbackString(action.callback);
966
+ if (parsed && parsed.name && callbackMapping[parsed.name]) {
967
+ const mappedCallback = callbackMapping[parsed.name];
968
+ if (mappedCallback) {
969
+ return __spreadProps(__spreadValues({}, action), {
970
+ callback: (match, groups) => mappedCallback(match, groups, ...parsed.args)
971
+ });
972
+ }
973
+ }
974
+ const _a2 = action, { callback } = _a2, rest = __objRest(_a2, ["callback"]);
975
+ return rest;
976
+ }
955
977
  return action;
956
- });
978
+ }).filter(Boolean);
957
979
  } else if (actions) {
958
980
  const actionsString = JSON.stringify(actions);
959
981
  processedActions = getActionsArraySafely(actionsString);
package/dist/index.mjs CHANGED
@@ -233,6 +233,7 @@ var ChatPanel = ({
233
233
  const [alwaysApprovedTools, setAlwaysApprovedTools] = useState2([]);
234
234
  const [thinkingBlocks, setThinkingBlocks] = useState2([]);
235
235
  const [currentThinkingIndex, setCurrentThinkingIndex] = useState2(0);
236
+ const [thinkingExpanded, setThinkingExpanded] = useState2(false);
236
237
  const [userResizedHeight, setUserResizedHeight] = useState2(null);
237
238
  const [pendingButtonAttachments, setPendingButtonAttachments] = useState2([]);
238
239
  const actionMatchRegistry = useRef(/* @__PURE__ */ new Map());
@@ -410,8 +411,16 @@ var ChatPanel = ({
410
411
  className: "thinking-nav-btn"
411
412
  },
412
413
  "\u2192"
413
- ))), /* @__PURE__ */ React3.createElement("div", { className: "thinking-content" }, content)));
414
- }, [thinkingBlocks, currentThinkingIndex]);
414
+ ))), /* @__PURE__ */ React3.createElement("div", { className: `thinking-content ${thinkingExpanded ? "thinking-content-expanded" : "thinking-content-collapsed"}` }, content), /* @__PURE__ */ React3.createElement(
415
+ "button",
416
+ {
417
+ className: "thinking-expand-btn",
418
+ onClick: () => setThinkingExpanded((prev) => !prev),
419
+ title: thinkingExpanded ? "Collapse" : "Expand"
420
+ },
421
+ thinkingExpanded ? "\u25B2" : "\u25BC"
422
+ )));
423
+ }, [thinkingBlocks, currentThinkingIndex, thinkingExpanded]);
415
424
  const getBrowserInfo = () => {
416
425
  try {
417
426
  return {
@@ -924,8 +933,21 @@ var ChatPanel = ({
924
933
  callbackType: typeof action.callback,
925
934
  pattern: action.pattern
926
935
  });
936
+ if (typeof action.callback === "string") {
937
+ const parsed = parseCallbackString(action.callback);
938
+ if (parsed && parsed.name && callbackMapping[parsed.name]) {
939
+ const mappedCallback = callbackMapping[parsed.name];
940
+ if (mappedCallback) {
941
+ return __spreadProps(__spreadValues({}, action), {
942
+ callback: (match, groups) => mappedCallback(match, groups, ...parsed.args)
943
+ });
944
+ }
945
+ }
946
+ const _a2 = action, { callback } = _a2, rest = __objRest(_a2, ["callback"]);
947
+ return rest;
948
+ }
927
949
  return action;
928
- });
950
+ }).filter(Boolean);
929
951
  } else if (actions) {
930
952
  const actionsString = JSON.stringify(actions);
931
953
  processedActions = getActionsArraySafely(actionsString);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmasaservice-ui",
3
- "version": "0.16.13",
3
+ "version": "0.16.15",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/ChatPanel.css CHANGED
@@ -1068,6 +1068,34 @@
1068
1068
  white-space: pre-wrap;
1069
1069
  }
1070
1070
 
1071
+ .thinking-content-collapsed {
1072
+ display: -webkit-box;
1073
+ -webkit-line-clamp: 2;
1074
+ -webkit-box-orient: vertical;
1075
+ overflow: hidden;
1076
+ text-overflow: ellipsis;
1077
+ }
1078
+
1079
+ .thinking-content-expanded {
1080
+ /* show all content */
1081
+ }
1082
+
1083
+ .thinking-expand-btn {
1084
+ background: none;
1085
+ border: none;
1086
+ cursor: pointer;
1087
+ color: var(--title-text-color);
1088
+ font-size: 0.75rem;
1089
+ padding: 2px 4px;
1090
+ margin-top: 2px;
1091
+ opacity: 0.7;
1092
+ align-self: flex-start;
1093
+ }
1094
+
1095
+ .thinking-expand-btn:hover {
1096
+ opacity: 1;
1097
+ }
1098
+
1071
1099
  /* Progressive action placeholder buttons */
1072
1100
  button[data-pending="true"] {
1073
1101
  opacity: 0.55;
package/src/ChatPanel.tsx CHANGED
@@ -220,6 +220,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
220
220
  Array<{ type: "reasoning" | "searching"; content: string; index: number }>
221
221
  >([]);
222
222
  const [currentThinkingIndex, setCurrentThinkingIndex] = useState(0);
223
+ const [thinkingExpanded, setThinkingExpanded] = useState(false);
223
224
 
224
225
  // State for tracking user-resized textarea height
225
226
  const [userResizedHeight, setUserResizedHeight] = useState<number | null>(null);
@@ -510,11 +511,20 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
510
511
  </div>
511
512
  )}
512
513
  </div>
513
- <div className="thinking-content">{content}</div>
514
+ <div className={`thinking-content ${thinkingExpanded ? 'thinking-content-expanded' : 'thinking-content-collapsed'}`}>
515
+ {content}
516
+ </div>
517
+ <button
518
+ className="thinking-expand-btn"
519
+ onClick={() => setThinkingExpanded((prev) => !prev)}
520
+ title={thinkingExpanded ? "Collapse" : "Expand"}
521
+ >
522
+ {thinkingExpanded ? "▲" : "▼"}
523
+ </button>
514
524
  </div>
515
525
  </div>
516
526
  );
517
- }, [thinkingBlocks, currentThinkingIndex]);
527
+ }, [thinkingBlocks, currentThinkingIndex, thinkingExpanded]);
518
528
 
519
529
  const getBrowserInfo = () => {
520
530
  try {
@@ -1192,8 +1202,25 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
1192
1202
  callbackType: typeof action.callback,
1193
1203
  pattern: action.pattern
1194
1204
  });
1195
- return action; // Keep the action as-is, including function callbacks
1196
- });
1205
+ // If callback is a string, resolve it via callbackMapping (same as getActionsArraySafely)
1206
+ if (typeof action.callback === "string") {
1207
+ const parsed = parseCallbackString(action.callback);
1208
+ if (parsed && parsed.name && callbackMapping[parsed.name]) {
1209
+ const mappedCallback = callbackMapping[parsed.name];
1210
+ if (mappedCallback) {
1211
+ return {
1212
+ ...action,
1213
+ callback: (match: string, groups: any[]) =>
1214
+ mappedCallback(match, groups, ...parsed.args),
1215
+ };
1216
+ }
1217
+ }
1218
+ // Unknown string callback — remove it so it doesn't crash
1219
+ const { callback, ...rest } = action;
1220
+ return rest;
1221
+ }
1222
+ return action; // Keep the action as-is (function callbacks, no callback, etc.)
1223
+ }).filter(Boolean);
1197
1224
  } else if (actions) {
1198
1225
  // Handle object actions by converting to string and parsing
1199
1226
  const actionsString = JSON.stringify(actions);