@iblai/web-utils 1.11.7 → 1.11.8

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
@@ -14499,6 +14499,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
14499
14499
  // `addUserMessage`) between the two `getChats` resolutions.
14500
14500
  const startNewChatInFlightRef = React.useRef(false);
14501
14501
  const startNewChat = React.useCallback(async () => {
14502
+ var _a, _b, _c;
14502
14503
  // Reset all chat state
14503
14504
  if (!showingSharedChat) {
14504
14505
  dispatch(chatActions.resetChats(undefined));
@@ -14531,6 +14532,10 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
14531
14532
  requestBody,
14532
14533
  }).unwrap();
14533
14534
  dispatch(chatActions.updateSessionIds(response.session_id));
14535
+ // The backend is the source of truth for which tools/artifacts are
14536
+ // enabled by default; seed the UI toggles from the create-session response.
14537
+ dispatch(chatActions.setTools((_b = (_a = response.tools) === null || _a === void 0 ? void 0 : _a.map((t) => t.slug).filter(Boolean)) !== null && _b !== void 0 ? _b : []));
14538
+ dispatch(chatActions.setArtifactsEnabled((_c = response.enable_artifacts) !== null && _c !== void 0 ? _c : false));
14534
14539
  onStartNewChat === null || onStartNewChat === void 0 ? void 0 : onStartNewChat(response.session_id);
14535
14540
  }
14536
14541
  catch (error) {
@@ -14650,7 +14655,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
14650
14655
  sendMessage,
14651
14656
  ]);
14652
14657
  async function changeTab(tab) {
14653
- var _a, _b, _c, _d;
14658
+ var _a, _b, _c, _d, _e, _f, _g;
14654
14659
  // while responding to a message, do not change the tab
14655
14660
  if (streaming) {
14656
14661
  errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler("Cannot change tab while streaming");
@@ -14679,14 +14684,18 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
14679
14684
  requestBody,
14680
14685
  }).unwrap();
14681
14686
  dispatch(chatActions.updateSessionIds(response.session_id));
14687
+ // The backend is the source of truth for which tools/artifacts are
14688
+ // enabled by default; seed the UI toggles from the create-session response.
14689
+ dispatch(chatActions.setTools((_b = (_a = response.tools) === null || _a === void 0 ? void 0 : _a.map((t) => t.slug).filter(Boolean)) !== null && _b !== void 0 ? _b : []));
14690
+ dispatch(chatActions.setArtifactsEnabled((_c = response.enable_artifacts) !== null && _c !== void 0 ? _c : false));
14682
14691
  // if the tab we are going to activate has no session Id (this is the first time we are creating the session for this tag)
14683
14692
  // we need to send a proactive prompt if the advanced tabs properties has no tag.
14684
14693
  // (presence of tag indicates an ACTIONABLE UI)
14685
- if (!((_a = advancedTabsProperties[tab]) === null || _a === void 0 ? void 0 : _a.tag)) {
14686
- for (const prompt of (_c = (_b = advancedTabsProperties[tab]) === null || _b === void 0 ? void 0 : _b.prompts) !== null && _c !== void 0 ? _c : []) {
14694
+ if (!((_d = advancedTabsProperties[tab]) === null || _d === void 0 ? void 0 : _d.tag)) {
14695
+ for (const prompt of (_f = (_e = advancedTabsProperties[tab]) === null || _e === void 0 ? void 0 : _e.prompts) !== null && _f !== void 0 ? _f : []) {
14687
14696
  // @ts-expect-error - Type mismatch
14688
14697
  if (prompt.type === "human" && (prompt === null || prompt === void 0 ? void 0 : prompt.proactive)) {
14689
- sendMessage(tab, (_d = prompt.content) !== null && _d !== void 0 ? _d : "", { visible: false });
14698
+ sendMessage(tab, (_g = prompt.content) !== null && _g !== void 0 ? _g : "", { visible: false });
14690
14699
  }
14691
14700
  }
14692
14701
  }