@arbidocs/blocks 0.4.67 → 0.4.68

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.
@@ -6,12 +6,12 @@ import { GridView, SelectionBar, SelectionBarAction } from '../chunk-BUHKUKKB.js
6
6
  import { FilterInput } from '../chunk-YU2KUMGE.js';
7
7
  export { DEFAULT_FILTER_INPUT_LABELS as DEFAULT_FACTS_FILTER_INPUT_LABELS, DEFAULT_FILTER_FIELDS as FACTS_SEARCH_FIELD_OPTIONS, FilterInput as FactsFilterInput } from '../chunk-YU2KUMGE.js';
8
8
  import { TabHeader } from '../chunk-4WWM3GQ5.js';
9
+ import '../chunk-76JDDMSP.js';
9
10
  import '../chunk-SLSBJRWW.js';
10
11
  import { observeResize } from '../chunk-NPLYHR2E.js';
11
- import '../chunk-76JDDMSP.js';
12
12
  import { initials } from '../chunk-OXF2IFXG.js';
13
13
  import { testIdOr } from '../chunk-7F6CBP3Z.js';
14
- import { PencilLine, Check, MoreVertical, Pencil, Trash2, CalendarDays, X, Columns3, ChevronDown, RotateCcw, Milestone, CalendarClock, Scale, Lightbulb, ArrowRight, Loader2, Info, PinOff, Pin, Tags, MoreHorizontal, FolderUp, BookMarked, Plus, Search, CheckCircle2, CornerDownLeft, Quote, ChevronLeft, ChevronRight, Table2, CalendarRange, GanttChartSquare } from 'lucide-react';
14
+ import { PencilLine, Check, MoreVertical, Pencil, Trash2, CalendarDays, X, Columns3, ChevronDown, RotateCcw, Milestone, CalendarClock, Scale, Lightbulb, ArrowRight, Loader2, Info, Paperclip, Tags, MoreHorizontal, FolderUp, BookMarked, Plus, Search, CheckCircle2, CornerDownLeft, Quote, ChevronLeft, ChevronRight, Table2, CalendarRange, GanttChartSquare } from 'lucide-react';
15
15
  import { Popover, PopoverTrigger, PopoverContent, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, cn, Input, Button, CommandSeparator, Tooltip, TooltipTrigger, TooltipContent } from '@arbidocs/react/ui';
16
16
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
17
17
  import { memo, useState, useMemo, useRef, useEffect } from 'react';
@@ -26,11 +26,11 @@ function decodeWhitespaceEntities(text) {
26
26
  });
27
27
  }
28
28
  var DEFAULT_FACT_COLUMN_LABELS = {
29
- pinnedHeaderTooltip: "Pinned facts are given to the assistant every turn",
30
- pinnedTitle: "Pinned \u2014 sent with every AI request. Click to unpin.",
31
- unpinnedTitle: "Pin \u2014 send with every AI request",
32
- unpin: "Unpin fact",
33
- pin: "Pin fact",
29
+ inChatHeaderTooltip: "Facts added to this chat are always in context for this chat",
30
+ inChatTitle: "In this chat \u2014 always in context for it. Click to remove from chat.",
31
+ notInChatTitle: "Add to chat \u2014 always in context for this chat",
32
+ removeFromChat: "Remove from chat",
33
+ addToChat: "Add to chat",
34
34
  fact: "Fact",
35
35
  dates: "Dates",
36
36
  dateTitle: "Date of the fact itself, not when this was saved",
@@ -65,7 +65,7 @@ function sourceDocCount(fact) {
65
65
  return fact?.citations?.length ?? 0;
66
66
  }
67
67
  var DEFAULT_FACT_COLUMN_ORDER = [
68
- "pinned",
68
+ "in_chat",
69
69
  "text",
70
70
  "sources",
71
71
  "tags",
@@ -81,49 +81,54 @@ function createFactColumns(slots) {
81
81
  const fieldOf = (name) => name;
82
82
  const l = { ...DEFAULT_FACT_COLUMN_LABELS, ...slots.labels };
83
83
  const ids = slots.testIds;
84
- const columns = [
84
+ const { isInChat, onToggleInChat } = slots;
85
+ const inChatColumn = isInChat && onToggleInChat ? [
85
86
  {
86
- colId: "pinned",
87
+ colId: "in_chat",
87
88
  headerName: "",
88
- headerComponent: () => /* @__PURE__ */ jsx("span", { className: "flex size-full items-center justify-center", children: /* @__PURE__ */ jsx(Pin, { className: "size-3.5 text-muted-foreground" }) }),
89
- field: fieldOf("pinned"),
89
+ headerComponent: () => /* @__PURE__ */ jsx("span", { className: "flex size-full items-center justify-center", children: /* @__PURE__ */ jsx(Paperclip, { className: "size-3.5 text-muted-foreground" }) }),
90
+ valueGetter: (params) => params.data ? isInChat(params.data) : false,
90
91
  width: 44,
91
92
  minWidth: 44,
92
93
  maxWidth: 44,
93
94
  sortable: true,
94
95
  resizable: false,
95
- headerTooltip: l.pinnedHeaderTooltip,
96
+ headerTooltip: l.inChatHeaderTooltip,
96
97
  cellClass: "cell-hcenter",
97
- // A toggle, not a readout: pinning is the row's most consequential switch (pinned facts
98
- // ride every AI request), so it flips in place.
98
+ // A toggle, not a readout: a fact in the chat rides every message of it, so it flips
99
+ // in place.
99
100
  cellRenderer: (params) => {
100
101
  if (!params.data) return null;
101
102
  const fact = params.data;
103
+ const inChat = isInChat(fact);
102
104
  return /* @__PURE__ */ jsx(
103
105
  "button",
104
106
  {
105
107
  type: "button",
106
- onClick: () => slots.onTogglePin(fact),
107
- title: fact.pinned ? l.pinnedTitle : l.unpinnedTitle,
108
- "aria-label": fact.pinned ? l.unpin : l.pin,
109
- "aria-pressed": fact.pinned,
110
- "data-testid": testIdOr(ids?.pinned?.(fact.external_id), {
111
- testId: `facts-grid-pinned-${fact.external_id}`
108
+ onClick: () => onToggleInChat(fact),
109
+ title: inChat ? l.inChatTitle : l.notInChatTitle,
110
+ "aria-label": inChat ? l.removeFromChat : l.addToChat,
111
+ "aria-pressed": inChat,
112
+ "data-testid": testIdOr(ids?.inChat?.(fact.external_id), {
113
+ testId: `facts-grid-in-chat-${fact.external_id}`
112
114
  }),
113
115
  className: "flex h-full items-center",
114
116
  children: /* @__PURE__ */ jsx(
115
- Pin,
117
+ Paperclip,
116
118
  {
117
119
  className: cn(
118
120
  "size-3.5",
119
- fact.pinned ? "fill-current text-yellow-text" : "text-muted-foreground/30 transition-colors hover:text-muted-foreground"
121
+ inChat ? "text-primary" : "text-muted-foreground/30 transition-colors hover:text-muted-foreground"
120
122
  )
121
123
  }
122
124
  )
123
125
  }
124
126
  );
125
127
  }
126
- },
128
+ }
129
+ ] : [];
130
+ const columns = [
131
+ ...inChatColumn,
127
132
  {
128
133
  colId: "text",
129
134
  suppressHeaderFilterButton: true,
@@ -435,7 +440,8 @@ var defaultFormatDate = (iso) => {
435
440
  var EMPTY_STATE = { title: "No facts yet" };
436
441
  function FactsTable({
437
442
  facts,
438
- onTogglePin,
443
+ isInChat,
444
+ onToggleInChat,
439
445
  onToggleConfirmed,
440
446
  onToggleShared,
441
447
  onEdit,
@@ -454,7 +460,8 @@ function FactsTable({
454
460
  const l = { ...DEFAULT_FACT_COLUMN_LABELS, ...columnLabels };
455
461
  const columnDefs = useMemo(
456
462
  () => createFactColumns({
457
- onTogglePin,
463
+ isInChat,
464
+ onToggleInChat,
458
465
  renderHeader: (params) => /* @__PURE__ */ jsx("span", { className: "text-[12.5px] font-medium", children: params.displayName }),
459
466
  renderRowActions: (fact) => onEdit && onDelete ? /* @__PURE__ */ jsx(FactRowActions, { onEdit: () => onEdit(fact), onDelete: () => onDelete(fact) }) : null,
460
467
  renderLabels: (fact) => /* @__PURE__ */ jsx("span", { className: "flex flex-wrap items-center gap-1", children: (fact.tags ?? []).map((tag) => /* @__PURE__ */ jsx(
@@ -499,7 +506,8 @@ function FactsTable({
499
506
  labels: columnLabels
500
507
  }),
501
508
  [
502
- onTogglePin,
509
+ isInChat,
510
+ onToggleInChat,
503
511
  onToggleConfirmed,
504
512
  onToggleShared,
505
513
  onEdit,
@@ -535,7 +543,6 @@ function toFactRow(record) {
535
543
  return {
536
544
  external_id: record.id,
537
545
  text: record.text,
538
- pinned: record.pinned ?? false,
539
546
  confirmed: record.confirmed ?? false,
540
547
  shared: record.shared ?? false,
541
548
  date_start: record.dateStart ?? null,
@@ -1326,7 +1333,7 @@ var DEFAULT_FACTS_FIELDS_BUTTON_LABELS = {
1326
1333
  fields: "Fields",
1327
1334
  defaultView: "Default view",
1328
1335
  columns: "Columns",
1329
- columnNames: { pinned: "Pinned" }
1336
+ columnNames: { in_chat: "In chat" }
1330
1337
  };
1331
1338
  function FactsFieldsButton({
1332
1339
  getGridApi,
@@ -1734,24 +1741,24 @@ function FactComposer({
1734
1741
  );
1735
1742
  }
1736
1743
  var DEFAULT_FACTS_BULK_BAR_LABELS = {
1737
- unpin: "Unpin Facts",
1738
- pin: "Pin to Chats",
1744
+ removeFromChat: "Remove from Chat",
1745
+ addToChat: "Add to Chat",
1739
1746
  label: "Label",
1740
1747
  shared: "Shared",
1741
1748
  more: "More",
1742
1749
  export: "Export",
1743
1750
  delete: "Delete",
1744
- budgetHint: "Pinned facts ride every AI request, so they are always in context and share one budget. This estimates the tokens they add (\u22484 characters per token), capped at ~2,000.",
1751
+ budgetHint: "Facts added to this chat are always in ARBI's context for this chat, so they share one budget. This estimates the tokens they add (\u22484 characters per token), capped at ~2,000.",
1745
1752
  budget: (tokens, cap) => `~${tokens}/${cap} tokens`,
1746
- unpinTooltip: (n) => `Unpin the selected ${n} so they no longer ride every chat`,
1747
- pinTooltip: (n) => `Pin the selected ${n} so they ride every chat with the assistant`,
1753
+ removeFromChatTooltip: (n) => `Remove the selected ${n} from this chat`,
1754
+ addToChatTooltip: (n) => `Add the selected ${n} to this chat, so they are always in its context`,
1748
1755
  labelTooltip: (n) => `Add or remove labels from selected ${n}`
1749
1756
  };
1750
1757
  function FactsBulkBar({
1751
1758
  count,
1752
1759
  onClear,
1753
- allSelectedPinned,
1754
- onTogglePin,
1760
+ allSelectedInChat,
1761
+ onToggleInChat,
1755
1762
  onLabel,
1756
1763
  sharedToggle,
1757
1764
  onExport,
@@ -1776,7 +1783,7 @@ function FactsBulkBar({
1776
1783
  budget.isOver ? "text-destructive" : "text-muted-foreground"
1777
1784
  ),
1778
1785
  title: l.budgetHint,
1779
- "data-testid": testIdOr(testIds?.budget, { testId: "facts-page-core-budget" }),
1786
+ "data-testid": testIdOr(testIds?.budget, { testId: "facts-page-chat-budget" }),
1780
1787
  children: l.budget(budget.tokens.toLocaleString(), budget.cap.toLocaleString())
1781
1788
  }
1782
1789
  ) : null,
@@ -1784,14 +1791,14 @@ function FactsBulkBar({
1784
1791
  /* @__PURE__ */ jsx(
1785
1792
  SelectionBarAction,
1786
1793
  {
1787
- icon: allSelectedPinned ? PinOff : Pin,
1788
- label: allSelectedPinned ? l.unpin : l.pin,
1789
- onClick: onTogglePin,
1794
+ icon: Paperclip,
1795
+ label: allSelectedInChat ? l.removeFromChat : l.addToChat,
1796
+ onClick: onToggleInChat,
1790
1797
  disabled: none,
1791
1798
  isCompact,
1792
- className: "border-yellow-border text-yellow-text hover:bg-yellow-bg hover:text-yellow-text",
1793
- tooltip: allSelectedPinned ? l.unpinTooltip(pluralNoun) : l.pinTooltip(pluralNoun),
1794
- testId: testIdOr(testIds?.pin, { testId: "bulk-pin-facts-button" })
1799
+ className: "border-blue-border text-blue-text hover:bg-blue-bg hover:text-blue-text",
1800
+ tooltip: allSelectedInChat ? l.removeFromChatTooltip(pluralNoun) : l.addToChatTooltip(pluralNoun),
1801
+ testId: testIdOr(testIds?.inChat, { testId: "bulk-in-chat-facts-button" })
1795
1802
  }
1796
1803
  ),
1797
1804
  /* @__PURE__ */ jsx(
@@ -2026,7 +2033,7 @@ var DEFAULT_FACT_SEARCH_BAR_LABELS = {
2026
2033
  submit: "Search"
2027
2034
  };
2028
2035
  var DEFAULT_FACT_SEARCH_RESULT_LABELS = {
2029
- core: "Core",
2036
+ inChat: "In this chat",
2030
2037
  verified: "Verified",
2031
2038
  open: "Open"
2032
2039
  };
@@ -2152,7 +2159,7 @@ function FactSearchResult({
2152
2159
  terms,
2153
2160
  renderSnippet,
2154
2161
  labels,
2155
- isPinned,
2162
+ isInChat,
2156
2163
  isVerified,
2157
2164
  isSelected,
2158
2165
  onOpen,
@@ -2189,11 +2196,18 @@ function FactSearchResult({
2189
2196
  testId: `facts-smart-search-hit-labels-${id}`
2190
2197
  }),
2191
2198
  children: [
2192
- isPinned && /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 pr-1", children: [
2193
- /* @__PURE__ */ jsx(Pin, { className: "size-3" }),
2194
- " ",
2195
- l.core
2196
- ] }),
2199
+ isInChat && /* @__PURE__ */ jsxs(
2200
+ "span",
2201
+ {
2202
+ className: "inline-flex items-center gap-1 pr-1",
2203
+ "data-testid": `facts-smart-search-hit-in-chat-${id}`,
2204
+ children: [
2205
+ /* @__PURE__ */ jsx(Paperclip, { className: "size-3" }),
2206
+ " ",
2207
+ l.inChat
2208
+ ]
2209
+ }
2210
+ ),
2197
2211
  labels.map((tag) => /* @__PURE__ */ jsxs(
2198
2212
  "span",
2199
2213
  {