@trops/dash-core 0.1.381 → 0.1.383

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.js CHANGED
@@ -56558,7 +56558,13 @@ var MessageBubble = function MessageBubble(_ref2) {
56558
56558
  isLast = _ref2$isLast === void 0 ? false : _ref2$isLast;
56559
56559
  var role = message.role,
56560
56560
  content = message.content,
56561
- toolCalls = message.toolCalls;
56561
+ toolCalls = message.toolCalls,
56562
+ hidden = message.hidden;
56563
+
56564
+ // App-injected priming messages (e.g. widget-builder "Hello…" seed)
56565
+ // are kept in state for conversation continuity but suppressed from
56566
+ // the rendered timeline — the user sees only the agent's reply.
56567
+ if (hidden) return null;
56562
56568
  if (role === "user") {
56563
56569
  var text = typeof content === "string" ? content : Array.isArray(content) ? content.filter(function (c) {
56564
56570
  return c.type === "text";
@@ -56912,6 +56918,8 @@ function ChatCore(_ref) {
56912
56918
  uuid = _ref$uuid === void 0 ? null : _ref$uuid,
56913
56919
  _ref$persistKey = _ref.persistKey,
56914
56920
  persistKey = _ref$persistKey === void 0 ? null : _ref$persistKey,
56921
+ _ref$sessionKey = _ref.sessionKey,
56922
+ sessionKey = _ref$sessionKey === void 0 ? null : _ref$sessionKey,
56915
56923
  _ref$backend = _ref.backend,
56916
56924
  backend = _ref$backend === void 0 ? "anthropic" : _ref$backend,
56917
56925
  _ref$onPublishEvent = _ref.onPublishEvent,
@@ -56919,7 +56927,9 @@ function ChatCore(_ref) {
56919
56927
  _ref$hideToolsBanner = _ref.hideToolsBanner,
56920
56928
  hideToolsBanner = _ref$hideToolsBanner === void 0 ? false : _ref$hideToolsBanner,
56921
56929
  _ref$cwd = _ref.cwd,
56922
- cwd = _ref$cwd === void 0 ? null : _ref$cwd;
56930
+ cwd = _ref$cwd === void 0 ? null : _ref$cwd,
56931
+ _ref$initialMessage = _ref.initialMessage,
56932
+ initialMessage = _ref$initialMessage === void 0 ? null : _ref$initialMessage;
56923
56933
  var mainApi = window.mainApi;
56924
56934
 
56925
56935
  // Conversation state
@@ -57011,8 +57021,14 @@ function ChatCore(_ref) {
57011
57021
  } catch (e) {
57012
57022
  /* ignore quota errors */
57013
57023
  }
57024
+ } else if (sessionKey) {
57025
+ try {
57026
+ sessionStorage.setItem(sessionKey, JSON.stringify(data));
57027
+ } catch (e) {
57028
+ /* ignore quota errors */
57029
+ }
57014
57030
  }
57015
- }, [api, uuid, persistKey, enabledTools]);
57031
+ }, [api, uuid, persistKey, sessionKey, enabledTools]);
57016
57032
 
57017
57033
  // Load saved conversation on mount
57018
57034
  React.useEffect(function () {
@@ -57044,8 +57060,23 @@ function ChatCore(_ref) {
57044
57060
  } catch (e) {
57045
57061
  /* ignore */
57046
57062
  }
57063
+ } else if (sessionKey) {
57064
+ try {
57065
+ var _raw = sessionStorage.getItem(sessionKey);
57066
+ if (_raw) {
57067
+ var _data = JSON.parse(_raw);
57068
+ if (_data !== null && _data !== void 0 && _data.messages && Array.isArray(_data.messages)) {
57069
+ setMessages(_data.messages);
57070
+ }
57071
+ if (_data !== null && _data !== void 0 && _data.enabledTools) {
57072
+ setEnabledTools(_data.enabledTools);
57073
+ }
57074
+ }
57075
+ } catch (e) {
57076
+ /* ignore */
57077
+ }
57047
57078
  }
57048
- }, [api, uuid, persistKey]);
57079
+ }, [api, uuid, persistKey, sessionKey]);
57049
57080
 
57050
57081
  // Discover connected MCP tools (only for anthropic backend)
57051
57082
  var refreshTools = React.useCallback(function () {
@@ -57161,14 +57192,19 @@ function ChatCore(_ref) {
57161
57192
  };
57162
57193
  }, [mainApi, onPublishEvent, saveConversation]);
57163
57194
 
57164
- // Send message
57195
+ // Send message. `options.hidden` marks the user message so
57196
+ // MessageBubble skips rendering it — useful for app-injected
57197
+ // priming prompts where the agent's reply should appear first,
57198
+ // but the prompt still needs to be in conversation history.
57165
57199
  var handleSend = React.useCallback(function (text) {
57200
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
57166
57201
  if (!(mainApi !== null && mainApi !== void 0 && mainApi.llm) || isLoading) return;
57167
57202
  setError(null);
57168
57203
  var userMessage = {
57169
57204
  id: "msg-".concat(Date.now()),
57170
57205
  role: "user",
57171
- content: text
57206
+ content: text,
57207
+ hidden: options.hidden === true
57172
57208
  };
57173
57209
  var updatedMessages = [].concat(_toConsumableArray(messages), [userMessage]);
57174
57210
  setMessages(updatedMessages);
@@ -57213,7 +57249,7 @@ function ChatCore(_ref) {
57213
57249
  _iterator2.f();
57214
57250
  }
57215
57251
  }
57216
- var requestId = generateRequestId(uuid || persistKey);
57252
+ var requestId = generateRequestId(uuid || persistKey || sessionKey);
57217
57253
  activeRequestId.current = requestId;
57218
57254
  toolCallsRef.current = [];
57219
57255
  setIsLoading(true);
@@ -57235,7 +57271,7 @@ function ChatCore(_ref) {
57235
57271
  toolServerMap: toolServerMap,
57236
57272
  systemPrompt: systemPrompt,
57237
57273
  maxToolRounds: parseInt(maxToolRounds, 10) || 10,
57238
- widgetUuid: uuid || persistKey,
57274
+ widgetUuid: uuid || persistKey || sessionKey,
57239
57275
  cwd: cwd || undefined
57240
57276
  });
57241
57277
  }, [mainApi, isLoading, messages, servers, enabledTools, apiKey, model, systemPrompt, maxToolRounds, uuid, persistKey, onPublishEvent, backend, isAnthropicBackend]);
@@ -57278,6 +57314,27 @@ function ChatCore(_ref) {
57278
57314
  }
57279
57315
  }, [mainApi, streamingText, saveConversation]);
57280
57316
 
57317
+ // Auto-send an initial message once the chat is ready and empty.
57318
+ // Runs at most once per mount. Skipped if the conversation was
57319
+ // restored from persistence (messages already populated) or the
57320
+ // backend isn't ready yet.
57321
+ var initialMessageFiredRef = React.useRef(false);
57322
+ React.useEffect(function () {
57323
+ if (initialMessageFiredRef.current) return;
57324
+ if (!initialMessage) return;
57325
+ if (!(mainApi !== null && mainApi !== void 0 && mainApi.llm)) return;
57326
+ if (isLoading) return;
57327
+ if (messages.length !== 0) return;
57328
+ // CLI backend: wait for availability check to resolve.
57329
+ if (isCliBackend && cliAvailable === null) return;
57330
+ if (isCliBackend && !cliAvailable) return;
57331
+ initialMessageFiredRef.current = true;
57332
+ handleSend(initialMessage, {
57333
+ hidden: true
57334
+ });
57335
+ // eslint-disable-next-line react-hooks/exhaustive-deps
57336
+ }, [initialMessage, mainApi, messages, isCliBackend, cliAvailable, isLoading]);
57337
+
57281
57338
  // New chat
57282
57339
  var handleNewChat = function handleNewChat() {
57283
57340
  var _mainApi$llm3;
@@ -57288,7 +57345,7 @@ function ChatCore(_ref) {
57288
57345
  setSessionActive(false);
57289
57346
  saveConversation([]);
57290
57347
  if (isCliBackend && mainApi !== null && mainApi !== void 0 && (_mainApi$llm3 = mainApi.llm) !== null && _mainApi$llm3 !== void 0 && _mainApi$llm3.clearCliSession) {
57291
- mainApi.llm.clearCliSession(uuid || persistKey);
57348
+ mainApi.llm.clearCliSession(uuid || persistKey || sessionKey);
57292
57349
  }
57293
57350
  };
57294
57351
 
@@ -57297,7 +57354,7 @@ function ChatCore(_ref) {
57297
57354
  var _mainApi$llm4;
57298
57355
  if (!isCliBackend || !(mainApi !== null && mainApi !== void 0 && (_mainApi$llm4 = mainApi.llm) !== null && _mainApi$llm4 !== void 0 && _mainApi$llm4.endCliSession)) return;
57299
57356
  if (isLoading) handleStop();
57300
- mainApi.llm.endCliSession(uuid || persistKey);
57357
+ mainApi.llm.endCliSession(uuid || persistKey || sessionKey);
57301
57358
  setSessionActive(false);
57302
57359
  };
57303
57360