@trops/dash-core 0.1.381 → 0.1.382

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
@@ -56540,7 +56540,13 @@ var MessageBubble = function MessageBubble(_ref2) {
56540
56540
  isLast = _ref2$isLast === void 0 ? false : _ref2$isLast;
56541
56541
  var role = message.role,
56542
56542
  content = message.content,
56543
- toolCalls = message.toolCalls;
56543
+ toolCalls = message.toolCalls,
56544
+ hidden = message.hidden;
56545
+
56546
+ // App-injected priming messages (e.g. widget-builder "Hello…" seed)
56547
+ // are kept in state for conversation continuity but suppressed from
56548
+ // the rendered timeline — the user sees only the agent's reply.
56549
+ if (hidden) return null;
56544
56550
  if (role === "user") {
56545
56551
  var text = typeof content === "string" ? content : Array.isArray(content) ? content.filter(function (c) {
56546
56552
  return c.type === "text";
@@ -56894,6 +56900,8 @@ function ChatCore(_ref) {
56894
56900
  uuid = _ref$uuid === void 0 ? null : _ref$uuid,
56895
56901
  _ref$persistKey = _ref.persistKey,
56896
56902
  persistKey = _ref$persistKey === void 0 ? null : _ref$persistKey,
56903
+ _ref$sessionKey = _ref.sessionKey,
56904
+ sessionKey = _ref$sessionKey === void 0 ? null : _ref$sessionKey,
56897
56905
  _ref$backend = _ref.backend,
56898
56906
  backend = _ref$backend === void 0 ? "anthropic" : _ref$backend,
56899
56907
  _ref$onPublishEvent = _ref.onPublishEvent,
@@ -56901,7 +56909,9 @@ function ChatCore(_ref) {
56901
56909
  _ref$hideToolsBanner = _ref.hideToolsBanner,
56902
56910
  hideToolsBanner = _ref$hideToolsBanner === void 0 ? false : _ref$hideToolsBanner,
56903
56911
  _ref$cwd = _ref.cwd,
56904
- cwd = _ref$cwd === void 0 ? null : _ref$cwd;
56912
+ cwd = _ref$cwd === void 0 ? null : _ref$cwd,
56913
+ _ref$initialMessage = _ref.initialMessage,
56914
+ initialMessage = _ref$initialMessage === void 0 ? null : _ref$initialMessage;
56905
56915
  var mainApi = window.mainApi;
56906
56916
 
56907
56917
  // Conversation state
@@ -56993,8 +57003,14 @@ function ChatCore(_ref) {
56993
57003
  } catch (e) {
56994
57004
  /* ignore quota errors */
56995
57005
  }
57006
+ } else if (sessionKey) {
57007
+ try {
57008
+ sessionStorage.setItem(sessionKey, JSON.stringify(data));
57009
+ } catch (e) {
57010
+ /* ignore quota errors */
57011
+ }
56996
57012
  }
56997
- }, [api, uuid, persistKey, enabledTools]);
57013
+ }, [api, uuid, persistKey, sessionKey, enabledTools]);
56998
57014
 
56999
57015
  // Load saved conversation on mount
57000
57016
  useEffect(function () {
@@ -57026,8 +57042,23 @@ function ChatCore(_ref) {
57026
57042
  } catch (e) {
57027
57043
  /* ignore */
57028
57044
  }
57045
+ } else if (sessionKey) {
57046
+ try {
57047
+ var _raw = sessionStorage.getItem(sessionKey);
57048
+ if (_raw) {
57049
+ var _data = JSON.parse(_raw);
57050
+ if (_data !== null && _data !== void 0 && _data.messages && Array.isArray(_data.messages)) {
57051
+ setMessages(_data.messages);
57052
+ }
57053
+ if (_data !== null && _data !== void 0 && _data.enabledTools) {
57054
+ setEnabledTools(_data.enabledTools);
57055
+ }
57056
+ }
57057
+ } catch (e) {
57058
+ /* ignore */
57059
+ }
57029
57060
  }
57030
- }, [api, uuid, persistKey]);
57061
+ }, [api, uuid, persistKey, sessionKey]);
57031
57062
 
57032
57063
  // Discover connected MCP tools (only for anthropic backend)
57033
57064
  var refreshTools = useCallback(function () {
@@ -57143,14 +57174,19 @@ function ChatCore(_ref) {
57143
57174
  };
57144
57175
  }, [mainApi, onPublishEvent, saveConversation]);
57145
57176
 
57146
- // Send message
57177
+ // Send message. `options.hidden` marks the user message so
57178
+ // MessageBubble skips rendering it — useful for app-injected
57179
+ // priming prompts where the agent's reply should appear first,
57180
+ // but the prompt still needs to be in conversation history.
57147
57181
  var handleSend = useCallback(function (text) {
57182
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
57148
57183
  if (!(mainApi !== null && mainApi !== void 0 && mainApi.llm) || isLoading) return;
57149
57184
  setError(null);
57150
57185
  var userMessage = {
57151
57186
  id: "msg-".concat(Date.now()),
57152
57187
  role: "user",
57153
- content: text
57188
+ content: text,
57189
+ hidden: options.hidden === true
57154
57190
  };
57155
57191
  var updatedMessages = [].concat(_toConsumableArray(messages), [userMessage]);
57156
57192
  setMessages(updatedMessages);
@@ -57195,7 +57231,7 @@ function ChatCore(_ref) {
57195
57231
  _iterator2.f();
57196
57232
  }
57197
57233
  }
57198
- var requestId = generateRequestId(uuid || persistKey);
57234
+ var requestId = generateRequestId(uuid || persistKey || sessionKey);
57199
57235
  activeRequestId.current = requestId;
57200
57236
  toolCallsRef.current = [];
57201
57237
  setIsLoading(true);
@@ -57217,7 +57253,7 @@ function ChatCore(_ref) {
57217
57253
  toolServerMap: toolServerMap,
57218
57254
  systemPrompt: systemPrompt,
57219
57255
  maxToolRounds: parseInt(maxToolRounds, 10) || 10,
57220
- widgetUuid: uuid || persistKey,
57256
+ widgetUuid: uuid || persistKey || sessionKey,
57221
57257
  cwd: cwd || undefined
57222
57258
  });
57223
57259
  }, [mainApi, isLoading, messages, servers, enabledTools, apiKey, model, systemPrompt, maxToolRounds, uuid, persistKey, onPublishEvent, backend, isAnthropicBackend]);
@@ -57260,6 +57296,27 @@ function ChatCore(_ref) {
57260
57296
  }
57261
57297
  }, [mainApi, streamingText, saveConversation]);
57262
57298
 
57299
+ // Auto-send an initial message once the chat is ready and empty.
57300
+ // Runs at most once per mount. Skipped if the conversation was
57301
+ // restored from persistence (messages already populated) or the
57302
+ // backend isn't ready yet.
57303
+ var initialMessageFiredRef = useRef(false);
57304
+ useEffect(function () {
57305
+ if (initialMessageFiredRef.current) return;
57306
+ if (!initialMessage) return;
57307
+ if (!(mainApi !== null && mainApi !== void 0 && mainApi.llm)) return;
57308
+ if (isLoading) return;
57309
+ if (messages.length !== 0) return;
57310
+ // CLI backend: wait for availability check to resolve.
57311
+ if (isCliBackend && cliAvailable === null) return;
57312
+ if (isCliBackend && !cliAvailable) return;
57313
+ initialMessageFiredRef.current = true;
57314
+ handleSend(initialMessage, {
57315
+ hidden: true
57316
+ });
57317
+ // eslint-disable-next-line react-hooks/exhaustive-deps
57318
+ }, [initialMessage, mainApi, messages, isCliBackend, cliAvailable, isLoading]);
57319
+
57263
57320
  // New chat
57264
57321
  var handleNewChat = function handleNewChat() {
57265
57322
  var _mainApi$llm3;
@@ -57270,7 +57327,7 @@ function ChatCore(_ref) {
57270
57327
  setSessionActive(false);
57271
57328
  saveConversation([]);
57272
57329
  if (isCliBackend && mainApi !== null && mainApi !== void 0 && (_mainApi$llm3 = mainApi.llm) !== null && _mainApi$llm3 !== void 0 && _mainApi$llm3.clearCliSession) {
57273
- mainApi.llm.clearCliSession(uuid || persistKey);
57330
+ mainApi.llm.clearCliSession(uuid || persistKey || sessionKey);
57274
57331
  }
57275
57332
  };
57276
57333
 
@@ -57279,7 +57336,7 @@ function ChatCore(_ref) {
57279
57336
  var _mainApi$llm4;
57280
57337
  if (!isCliBackend || !(mainApi !== null && mainApi !== void 0 && (_mainApi$llm4 = mainApi.llm) !== null && _mainApi$llm4 !== void 0 && _mainApi$llm4.endCliSession)) return;
57281
57338
  if (isLoading) handleStop();
57282
- mainApi.llm.endCliSession(uuid || persistKey);
57339
+ mainApi.llm.endCliSession(uuid || persistKey || sessionKey);
57283
57340
  setSessionActive(false);
57284
57341
  };
57285
57342