@burtson-labs/bandit-engine 2.0.20 → 2.0.22

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.
Files changed (32) hide show
  1. package/dist/{chat-2Y72EFJ2.mjs → chat-VOVYLTMX.mjs} +4 -4
  2. package/dist/chat-provider.js +22 -1
  3. package/dist/chat-provider.js.map +1 -1
  4. package/dist/chat-provider.mjs +3 -3
  5. package/dist/{chunk-XEG45Q6V.mjs → chunk-GBANNFRD.mjs} +2 -2
  6. package/dist/{chunk-JECYIAWF.mjs → chunk-LB7QYC56.mjs} +6 -6
  7. package/dist/{chunk-L7UOQ2Y2.mjs → chunk-LG2JCTOE.mjs} +3 -3
  8. package/dist/{chunk-2ZNIQD26.mjs → chunk-N3G5XPCA.mjs} +2 -2
  9. package/dist/{chunk-UMPVXYVC.mjs → chunk-XD5VJCFN.mjs} +23 -2
  10. package/dist/chunk-XD5VJCFN.mjs.map +1 -0
  11. package/dist/{chunk-CY227I4F.mjs → chunk-XVWKFDTD.mjs} +3 -3
  12. package/dist/{chunk-6V2YMAX2.mjs → chunk-ZRTP2N7E.mjs} +74 -24
  13. package/dist/{chunk-6V2YMAX2.mjs.map → chunk-ZRTP2N7E.mjs.map} +1 -1
  14. package/dist/cli/cli.js +1 -1
  15. package/dist/cli/cli.js.map +1 -1
  16. package/dist/index.js +89 -19
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +7 -7
  19. package/dist/management/management.js +89 -19
  20. package/dist/management/management.js.map +1 -1
  21. package/dist/management/management.mjs +5 -5
  22. package/dist/modals/chat-modal/chat-modal.js +22 -1
  23. package/dist/modals/chat-modal/chat-modal.js.map +1 -1
  24. package/dist/modals/chat-modal/chat-modal.mjs +3 -3
  25. package/package.json +1 -1
  26. package/dist/chunk-UMPVXYVC.mjs.map +0 -1
  27. /package/dist/{chat-2Y72EFJ2.mjs.map → chat-VOVYLTMX.mjs.map} +0 -0
  28. /package/dist/{chunk-XEG45Q6V.mjs.map → chunk-GBANNFRD.mjs.map} +0 -0
  29. /package/dist/{chunk-JECYIAWF.mjs.map → chunk-LB7QYC56.mjs.map} +0 -0
  30. /package/dist/{chunk-L7UOQ2Y2.mjs.map → chunk-LG2JCTOE.mjs.map} +0 -0
  31. /package/dist/{chunk-2ZNIQD26.mjs.map → chunk-N3G5XPCA.mjs.map} +0 -0
  32. /package/dist/{chunk-CY227I4F.mjs.map → chunk-XVWKFDTD.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -1496,13 +1496,27 @@ var init_conversationStore = __esm({
1496
1496
  });
1497
1497
  },
1498
1498
  deleteConversation: (id) => {
1499
+ const runHydrate = async () => {
1500
+ try {
1501
+ await get().hydrate();
1502
+ } catch (error) {
1503
+ debugLogger.warn("conversationStore: rehydrate after delete failed", {
1504
+ error: error instanceof Error ? error.message : String(error)
1505
+ });
1506
+ }
1507
+ };
1499
1508
  set((state) => {
1500
1509
  const filtered = state.conversations.filter((c) => c.id !== id);
1501
1510
  const isDeletingCurrent = state.currentId === id;
1502
1511
  if (isDeletingCurrent) {
1503
1512
  useAIQueryStore.getState().reset();
1504
1513
  }
1505
- deleteConversationFromDB(id);
1514
+ deleteConversationFromDB(id).then(runHydrate).catch((error) => {
1515
+ debugLogger.error("Failed to delete conversation from DB", {
1516
+ error,
1517
+ conversationId: id
1518
+ });
1519
+ });
1506
1520
  emitConversationDelete(id);
1507
1521
  return {
1508
1522
  conversations: filtered,
@@ -1672,6 +1686,13 @@ var init_conversationStore = __esm({
1672
1686
  currentId: isCurrentDeleted ? null : state.currentId
1673
1687
  };
1674
1688
  });
1689
+ try {
1690
+ await get().hydrate();
1691
+ } catch (error) {
1692
+ debugLogger.warn("conversationStore: hydrate failed after remote delete", {
1693
+ error: error instanceof Error ? error.message : String(error)
1694
+ });
1695
+ }
1675
1696
  }
1676
1697
  }));
1677
1698
  }
@@ -22396,6 +22417,7 @@ var init_enhanced_mobile_conversations_modal = __esm({
22396
22417
  const [moveModalOpen, setMoveModalOpen] = (0, import_react29.useState)(false);
22397
22418
  const [conversationToMove, setConversationToMove] = (0, import_react29.useState)(null);
22398
22419
  const [renameProjectId, setRenameProjectId] = (0, import_react29.useState)(null);
22420
+ const [deletedConversationIds, setDeletedConversationIds] = (0, import_react29.useState)(/* @__PURE__ */ new Set());
22399
22421
  const [touchDragState, setTouchDragState] = (0, import_react29.useState)({ conversationId: null, originProjectId: null, hoverProjectId: null });
22400
22422
  const [avatarImage, setAvatarImage] = (0, import_react29.useState)(BANDIT_AVATAR2);
22401
22423
  const getCustomClaim = (0, import_react29.useCallback)((key) => {
@@ -22467,20 +22489,19 @@ var init_enhanced_mobile_conversations_modal = __esm({
22467
22489
  }
22468
22490
  }, [projectsHydrated, projects]);
22469
22491
  const projectGroups = (0, import_react29.useMemo)(() => {
22470
- const groups = [];
22471
- projects.forEach((project) => {
22472
- const projectConversations = getConversationsByProject(project.id).map((conversation) => ({
22492
+ const visibleConversations = conversations.filter(
22493
+ (conversation) => !deletedConversationIds.has(conversation.id)
22494
+ );
22495
+ const groups = projects.map((project) => ({
22496
+ id: project.id,
22497
+ name: project.name,
22498
+ color: project.color,
22499
+ conversations: visibleConversations.filter((conversation) => conversation.projectId === project.id).map((conversation) => ({
22473
22500
  ...conversation
22474
- }));
22475
- groups.push({
22476
- id: project.id,
22477
- name: project.name,
22478
- color: project.color,
22479
- conversations: projectConversations,
22480
- collapsed: collapsedProjects.has(project.id)
22481
- });
22482
- });
22483
- const ungroupedConversations = getConversationsByProject(null).map((conversation) => ({
22501
+ })),
22502
+ collapsed: collapsedProjects.has(project.id)
22503
+ }));
22504
+ const ungroupedConversations = visibleConversations.filter((conversation) => !conversation.projectId).map((conversation) => ({
22484
22505
  ...conversation
22485
22506
  }));
22486
22507
  if (ungroupedConversations.length > 0) {
@@ -22489,11 +22510,14 @@ var init_enhanced_mobile_conversations_modal = __esm({
22489
22510
  name: "Ungrouped",
22490
22511
  conversations: ungroupedConversations,
22491
22512
  collapsed: false
22492
- // Never collapsed for ungrouped
22493
22513
  });
22494
22514
  }
22495
22515
  return groups.filter((group) => group.conversations.length > 0 || group.id !== null);
22496
- }, [projects, getConversationsByProject, collapsedProjects]);
22516
+ }, [projects, conversations, collapsedProjects, deletedConversationIds]);
22517
+ const visibleConversationCount = (0, import_react29.useMemo)(
22518
+ () => projectGroups.reduce((total, group) => total + group.conversations.length, 0),
22519
+ [projectGroups]
22520
+ );
22497
22521
  const filteredProjectGroups = (0, import_react29.useMemo)(() => {
22498
22522
  if (!searchQuery.trim()) return projectGroups;
22499
22523
  const query = searchQuery.toLowerCase();
@@ -22604,6 +22628,7 @@ var init_enhanced_mobile_conversations_modal = __esm({
22604
22628
  };
22605
22629
  const handleClearAllConfirm = async () => {
22606
22630
  try {
22631
+ setDeletedConversationIds(new Set(conversations.map((conv) => conv.id)));
22607
22632
  await clearAllConversations();
22608
22633
  setClearConfirmOpen(false);
22609
22634
  handleMenuClose();
@@ -22622,6 +22647,21 @@ var init_enhanced_mobile_conversations_modal = __esm({
22622
22647
  setMoveModalOpen(false);
22623
22648
  setConversationToMove(null);
22624
22649
  };
22650
+ (0, import_react29.useEffect)(() => {
22651
+ setDeletedConversationIds((prev) => {
22652
+ let changed = false;
22653
+ const active = new Set(conversations.map((conv) => conv.id));
22654
+ const next = /* @__PURE__ */ new Set();
22655
+ prev.forEach((id) => {
22656
+ if (active.has(id)) {
22657
+ next.add(id);
22658
+ } else {
22659
+ changed = true;
22660
+ }
22661
+ });
22662
+ return changed ? next : prev;
22663
+ });
22664
+ }, [conversations]);
22625
22665
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
22626
22666
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22627
22667
  import_material20.Modal,
@@ -22658,6 +22698,19 @@ var init_enhanced_mobile_conversations_modal = __esm({
22658
22698
  },
22659
22699
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_material20.Toolbar, { children: [
22660
22700
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_material20.Typography, { variant: "h6", sx: { flex: 1, fontWeight: 600 }, children: "Conversations" }),
22701
+ visibleConversationCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22702
+ import_material20.Chip,
22703
+ {
22704
+ label: visibleConversationCount,
22705
+ size: "small",
22706
+ sx: {
22707
+ mr: 1,
22708
+ bgcolor: theme.palette.mode === "dark" ? "rgba(148, 163, 184, 0.16)" : "rgba(15, 23, 42, 0.08)",
22709
+ color: theme.palette.text.secondary,
22710
+ fontWeight: 600
22711
+ }
22712
+ }
22713
+ ),
22661
22714
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22662
22715
  import_material20.IconButton,
22663
22716
  {
@@ -22968,7 +23021,15 @@ var init_enhanced_mobile_conversations_modal = __esm({
22968
23021
  switchConversation(conversation.id);
22969
23022
  onClose();
22970
23023
  },
22971
- onDelete: () => deleteConversation(conversation.id),
23024
+ onDelete: () => {
23025
+ setDeletedConversationIds((prev) => {
23026
+ if (prev.has(conversation.id)) return prev;
23027
+ const next = new Set(prev);
23028
+ next.add(conversation.id);
23029
+ return next;
23030
+ });
23031
+ deleteConversation(conversation.id);
23032
+ },
22972
23033
  onRename: (newName) => renameConversation(conversation.id, newName),
22973
23034
  onMove: () => handleMoveConversation(conversation),
22974
23035
  projectColor: group.color,
@@ -23011,7 +23072,15 @@ var init_enhanced_mobile_conversations_modal = __esm({
23011
23072
  switchConversation(conversation.id);
23012
23073
  onClose();
23013
23074
  },
23014
- onDelete: () => deleteConversation(conversation.id),
23075
+ onDelete: () => {
23076
+ setDeletedConversationIds((prev) => {
23077
+ if (prev.has(conversation.id)) return prev;
23078
+ const next = new Set(prev);
23079
+ next.add(conversation.id);
23080
+ return next;
23081
+ });
23082
+ deleteConversation(conversation.id);
23083
+ },
23015
23084
  onRename: (newName) => renameConversation(conversation.id, newName),
23016
23085
  onMove: () => handleMoveConversation(conversation),
23017
23086
  projectColor: group.color,
@@ -23157,6 +23226,7 @@ var init_enhanced_mobile_conversations_modal = __esm({
23157
23226
  setClearConfirmOpen(true);
23158
23227
  handleMenuClose();
23159
23228
  },
23229
+ disabled: visibleConversationCount === 0,
23160
23230
  sx: { color: theme.palette.error.main },
23161
23231
  children: [
23162
23232
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_material20.ListItemIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_icons_material9.DeleteSweep, { fontSize: "small", sx: { color: theme.palette.error.main } }) }),
@@ -23175,7 +23245,7 @@ var init_enhanced_mobile_conversations_modal = __esm({
23175
23245
  fullWidth: true,
23176
23246
  children: [
23177
23247
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_material20.DialogTitle, { children: "Clear All Conversations?" }),
23178
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_material20.DialogContent, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_material20.Typography, { children: "This will permanently delete all conversations and cannot be undone. Are you sure you want to continue?" }) }),
23248
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_material20.DialogContent, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_material20.Typography, { children: visibleConversationCount === 0 ? "No conversations available to clear." : `This will permanently delete ${visibleConversationCount} conversation${visibleConversationCount === 1 ? "" : "s"} and cannot be undone.` }) }),
23179
23249
  /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_material20.DialogActions, { children: [
23180
23250
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_material20.Button, { onClick: () => setClearConfirmOpen(false), children: "Cancel" }),
23181
23251
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(