@locusgraph/loop 0.1.0 → 0.2.0

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 (115) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/pulse/gradient-label.js +86 -15
  3. package/dist/agent/pulse/marks/bars-mark.js +46 -10
  4. package/dist/agent/pulse/marks/glyph-mark.js +56 -11
  5. package/dist/agent/pulse/marks/locus-mark.js +63 -28
  6. package/dist/agent/pulse/marks/orb-mark.js +31 -8
  7. package/dist/agent/pulse/marks/spinner-mark.js +29 -1
  8. package/dist/agent/pulse/pulse.js +150 -35
  9. package/dist/agent/pulse/use-loop-animation.js +36 -17
  10. package/dist/agent/steps/step-icon.js +110 -24
  11. package/dist/agent/steps/steps.js +235 -25
  12. package/dist/agent/thinking/thinking.js +203 -23
  13. package/dist/agent/thinking/thought-duration.js +7 -9
  14. package/dist/agent/tool/json-block.js +38 -11
  15. package/dist/agent/tool/tool-status.js +51 -18
  16. package/dist/agent/tool/tool.js +184 -6
  17. package/dist/approval/inbox/inbox-row.d.ts +3 -2
  18. package/dist/approval/inbox/inbox-row.js +321 -7
  19. package/dist/approval/inbox/inbox-selection.js +7 -13
  20. package/dist/approval/inbox/inbox.d.ts +2 -1
  21. package/dist/approval/inbox/inbox.js +250 -18
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  23. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  24. package/dist/approval/memory/memory-choices.js +27 -22
  25. package/dist/approval/memory/memory-review.js +242 -17
  26. package/dist/approval/memory/memory-row.js +215 -19
  27. package/dist/approval/plan/plan-review.js +279 -28
  28. package/dist/approval/plan/plan-step-row.js +194 -43
  29. package/dist/approval/plan/plan-steps.js +24 -23
  30. package/dist/approval/plan/question-choices.js +158 -39
  31. package/dist/approval/plan/question.d.ts +1 -1
  32. package/dist/approval/plan/question.js +223 -26
  33. package/dist/approval/run/run-bar.js +178 -22
  34. package/dist/approval/shared/decision-line.js +1 -1
  35. package/dist/approval/shared/risk-badge.js +47 -16
  36. package/dist/approval/shared/time.js +5 -8
  37. package/dist/approval/shared/use-focus-on-mount.js +23 -6
  38. package/dist/approval/spend/raise-cap-form.js +235 -17
  39. package/dist/approval/spend/spend-gate.js +239 -21
  40. package/dist/approval/spend/spend-math.js +7 -8
  41. package/dist/approval/spend/spend-meter.js +362 -34
  42. package/dist/approval/tool/approval.js +272 -27
  43. package/dist/approval/tool/args/args-editor.js +262 -26
  44. package/dist/approval/tool/args/args-field.js +259 -19
  45. package/dist/approval/tool/args/args-validation.js +38 -47
  46. package/dist/approval/tool/deny-form.js +130 -10
  47. package/dist/approval/tool/tool-inputs.js +127 -38
  48. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  49. package/dist/chat/chat/chat-item-spacing.js +19 -0
  50. package/dist/chat/chat/chat.d.ts +2 -1
  51. package/dist/chat/chat/chat.js +181 -5
  52. package/dist/chat/chat/use-stick-to-bottom.js +123 -47
  53. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  54. package/dist/chat/chat/virtual-chat-items.js +153 -0
  55. package/dist/chat/composer/composer-actions.js +151 -16
  56. package/dist/chat/composer/composer.js +330 -32
  57. package/dist/chat/composer/use-auto-grow.js +24 -9
  58. package/dist/chat/files/file-meta.js +19 -19
  59. package/dist/chat/files/files.js +316 -28
  60. package/dist/chat/reply/fenced-code.js +45 -21
  61. package/dist/chat/reply/markdown-components.js +137 -17
  62. package/dist/chat/reply/reply.js +105 -10
  63. package/dist/chat/turn/group-parts.js +43 -29
  64. package/dist/chat/turn/turn.js +238 -30
  65. package/dist/cost/context.js +321 -23
  66. package/dist/cost/cost-steps.js +220 -14
  67. package/dist/cost/cost.js +521 -27
  68. package/dist/cost/model-picker.js +181 -6
  69. package/dist/cost/shared/context-breakdown.js +299 -10
  70. package/dist/cost/shared/meter-marks.js +107 -9
  71. package/dist/cost/shared/model-option-row.js +178 -21
  72. package/dist/cost/shared/step-cost-row.js +248 -20
  73. package/dist/cost/shared/usage-totals.js +22 -18
  74. package/dist/memory/cite.js +182 -11
  75. package/dist/memory/memorized.js +217 -11
  76. package/dist/memory/recall.js +296 -17
  77. package/dist/memory/shared/host-label.js +19 -22
  78. package/dist/memory/shared/source-mark.js +39 -3
  79. package/dist/memory/sources.js +255 -13
  80. package/dist/shared/decision-summary.js +133 -14
  81. package/dist/shared/panel-empty.js +78 -3
  82. package/dist/shared/panel.js +243 -13
  83. package/dist/shared/status-dot.js +38 -8
  84. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  85. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  86. package/dist/thread/actions/action-button.js +65 -3
  87. package/dist/thread/actions/actions.js +184 -13
  88. package/dist/thread/actions/branch-switcher.js +102 -5
  89. package/dist/thread/canvas/canvas.js +205 -5
  90. package/dist/thread/canvas/version-switcher.js +149 -8
  91. package/dist/thread/code/code.js +186 -24
  92. package/dist/thread/code/copy-code-button.js +61 -13
  93. package/dist/thread/code/highlight.js +30 -29
  94. package/dist/thread/history/history-rows.d.ts +16 -0
  95. package/dist/thread/history/history-rows.js +23 -0
  96. package/dist/thread/history/history.d.ts +3 -2
  97. package/dist/thread/history/history.js +174 -5
  98. package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
  99. package/dist/thread/history/row/history-row.js +137 -0
  100. package/dist/thread/history/row/thread-item-menu.js +84 -0
  101. package/dist/thread/history/row/thread-title-editor.js +81 -0
  102. package/dist/thread/history/thread-groups.d.ts +1 -1
  103. package/dist/thread/history/thread-groups.js +40 -34
  104. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  105. package/dist/thread/history/virtual-history-list.js +107 -0
  106. package/dist/thread/index.d.ts +1 -1
  107. package/dist/thread/starters/starters.js +92 -7
  108. package/dist/thread/use-copied.js +45 -15
  109. package/dist/types.js +1 -1
  110. package/package.json +6 -4
  111. package/dist/thread/history/history-row.js +0 -17
  112. package/dist/thread/history/thread-item-menu.js +0 -6
  113. package/dist/thread/history/thread-title-editor.js +0 -25
  114. /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
  115. /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
@@ -1,10 +1,179 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
3
4
  import { Add as PlusIcon } from "@carbon/icons-react";
4
5
  import { Button, cn, ScrollArea } from "@locusgraph/components";
5
- import { HistoryRow } from "./history-row.js";
6
+ import { shouldVirtualize } from "../../shared/virtual/use-list-virtualizer.js";
7
+ import { HistoryRow } from "./row/history-row.js";
6
8
  import { groupThreadsByDay } from "./thread-groups.js";
7
- export function History({ threads, activeId = null, onSelect, onNew, onRename, onArchive, label = "Conversations", emptyText = "No conversations yet.", now = new Date(), className, ...props }) {
8
- const groups = groupThreadsByDay(threads, now);
9
- return (_jsxs("nav", { "data-slot": "history", "aria-label": label, className: cn("flex min-h-0 flex-col gap-2", className), ...props, children: [_jsxs("div", { className: "flex h-7 items-center justify-between gap-2 px-2", children: [_jsx("span", { className: "text-sm font-medium text-foreground", children: label }), onNew && (_jsxs(Button, { type: "button", variant: "outline", size: "xs", onClick: onNew, children: [_jsx(PlusIcon, {}), "New chat"] }))] }), threads.length === 0 ? (_jsx("p", { className: "px-2 py-6 text-sm text-muted-foreground", children: emptyText })) : (_jsx(ScrollArea, { className: "min-h-0 flex-1", children: _jsx("div", { className: "flex flex-col gap-4 pr-2.5 pb-2", children: groups.map((group) => (_jsxs("section", { "aria-labelledby": `thread-group-${group.key}`, children: [_jsx("h3", { id: `thread-group-${group.key}`, className: "eyebrow px-2 pb-1", suppressHydrationWarning: true, children: group.label }), _jsx("ul", { className: "flex flex-col", children: group.threads.map((thread) => (_jsx(HistoryRow, { thread: thread, active: thread.id === activeId, onSelect: onSelect, onRename: onRename, onArchive: onArchive }, thread.id))) })] }, group.key))) }) }))] }));
9
+ import { VirtualHistoryList } from "./virtual-history-list.js";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ export function History(t0) {
12
+ const $ = _c(35);
13
+ let className;
14
+ let now;
15
+ let onArchive;
16
+ let onNew;
17
+ let onRename;
18
+ let onSelect;
19
+ let props;
20
+ let t1;
21
+ let t2;
22
+ let t3;
23
+ let t4;
24
+ let threads;
25
+ if ($[0] !== t0) {
26
+ ({
27
+ threads,
28
+ activeId: t1,
29
+ onSelect,
30
+ onNew,
31
+ onRename,
32
+ onArchive,
33
+ label: t2,
34
+ emptyText: t3,
35
+ now,
36
+ virtualize: t4,
37
+ className,
38
+ ...props
39
+ } = t0);
40
+ $[0] = t0;
41
+ $[1] = className;
42
+ $[2] = now;
43
+ $[3] = onArchive;
44
+ $[4] = onNew;
45
+ $[5] = onRename;
46
+ $[6] = onSelect;
47
+ $[7] = props;
48
+ $[8] = t1;
49
+ $[9] = t2;
50
+ $[10] = t3;
51
+ $[11] = t4;
52
+ $[12] = threads;
53
+ } else {
54
+ className = $[1];
55
+ now = $[2];
56
+ onArchive = $[3];
57
+ onNew = $[4];
58
+ onRename = $[5];
59
+ onSelect = $[6];
60
+ props = $[7];
61
+ t1 = $[8];
62
+ t2 = $[9];
63
+ t3 = $[10];
64
+ t4 = $[11];
65
+ threads = $[12];
66
+ }
67
+ const activeId = t1 === undefined ? null : t1;
68
+ const label = t2 === undefined ? "Conversations" : t2;
69
+ const emptyText = t3 === undefined ? "No conversations yet." : t3;
70
+ const virtualize = t4 === undefined ? true : t4;
71
+ let t5;
72
+ if ($[13] !== activeId || $[14] !== className || $[15] !== emptyText || $[16] !== label || $[17] !== now || $[18] !== onArchive || $[19] !== onNew || $[20] !== onRename || $[21] !== onSelect || $[22] !== props || $[23] !== threads || $[24] !== virtualize) {
73
+ const groups = groupThreadsByDay(threads, now ?? new Date());
74
+ let t6;
75
+ if ($[26] !== className) {
76
+ t6 = cn("flex min-h-0 flex-col gap-2", className);
77
+ $[26] = className;
78
+ $[27] = t6;
79
+ } else {
80
+ t6 = $[27];
81
+ }
82
+ let t7;
83
+ if ($[28] !== label) {
84
+ t7 = /*#__PURE__*/_jsx("span", {
85
+ className: "text-sm font-medium text-foreground",
86
+ children: label
87
+ });
88
+ $[28] = label;
89
+ $[29] = t7;
90
+ } else {
91
+ t7 = $[29];
92
+ }
93
+ let t8;
94
+ if ($[30] !== onNew) {
95
+ t8 = onNew && /*#__PURE__*/_jsxs(Button, {
96
+ type: "button",
97
+ variant: "outline",
98
+ size: "xs",
99
+ onClick: onNew,
100
+ children: [/*#__PURE__*/_jsx(PlusIcon, {}), "New chat"]
101
+ });
102
+ $[30] = onNew;
103
+ $[31] = t8;
104
+ } else {
105
+ t8 = $[31];
106
+ }
107
+ let t9;
108
+ if ($[32] !== t7 || $[33] !== t8) {
109
+ t9 = /*#__PURE__*/_jsxs("div", {
110
+ className: "flex h-7 items-center justify-between gap-2 px-2",
111
+ children: [t7, t8]
112
+ });
113
+ $[32] = t7;
114
+ $[33] = t8;
115
+ $[34] = t9;
116
+ } else {
117
+ t9 = $[34];
118
+ }
119
+ t5 = /*#__PURE__*/_jsxs("nav", {
120
+ "data-slot": "history",
121
+ "aria-label": label,
122
+ className: t6,
123
+ ...props,
124
+ children: [t9, threads.length === 0 ? /*#__PURE__*/_jsx("p", {
125
+ className: "px-2 py-6 text-sm text-muted-foreground",
126
+ children: emptyText
127
+ }) : /*#__PURE__*/_jsx(ScrollArea, {
128
+ className: "min-h-0 flex-1",
129
+ children: shouldVirtualize(threads.length, virtualize) ? /*#__PURE__*/_jsx("div", {
130
+ className: "pr-2.5 pb-2",
131
+ children: /*#__PURE__*/_jsx(VirtualHistoryList, {
132
+ groups: groups,
133
+ label: label,
134
+ activeId: activeId,
135
+ onSelect: onSelect,
136
+ onRename: onRename,
137
+ onArchive: onArchive
138
+ })
139
+ }) : /*#__PURE__*/_jsx("div", {
140
+ className: "flex flex-col gap-4 pr-2.5 pb-2",
141
+ children: groups.map(group => /*#__PURE__*/_jsxs("section", {
142
+ "aria-labelledby": `thread-group-${group.key}`,
143
+ children: [/*#__PURE__*/_jsx("h3", {
144
+ id: `thread-group-${group.key}`,
145
+ className: "eyebrow px-2 pb-1",
146
+ suppressHydrationWarning: true,
147
+ children: group.label
148
+ }), /*#__PURE__*/_jsx("ul", {
149
+ className: "flex flex-col",
150
+ children: group.threads.map(thread => /*#__PURE__*/_jsx(HistoryRow, {
151
+ thread: thread,
152
+ active: thread.id === activeId,
153
+ onSelect: onSelect,
154
+ onRename: onRename,
155
+ onArchive: onArchive
156
+ }, thread.id))
157
+ })]
158
+ }, group.key))
159
+ })
160
+ })]
161
+ });
162
+ $[13] = activeId;
163
+ $[14] = className;
164
+ $[15] = emptyText;
165
+ $[16] = label;
166
+ $[17] = now;
167
+ $[18] = onArchive;
168
+ $[19] = onNew;
169
+ $[20] = onRename;
170
+ $[21] = onSelect;
171
+ $[22] = props;
172
+ $[23] = threads;
173
+ $[24] = virtualize;
174
+ $[25] = t5;
175
+ } else {
176
+ t5 = $[25];
177
+ }
178
+ return t5;
10
179
  }
@@ -1,14 +1,15 @@
1
+ import { type ComponentProps } from "react";
1
2
  export type HistoryItem = {
2
3
  id: string;
3
4
  title: string;
4
5
  updatedAt: string;
5
6
  };
6
- type HistoryRowProps = {
7
+ type HistoryRowProps = Omit<ComponentProps<"li">, "onSelect"> & {
7
8
  thread: HistoryItem;
8
9
  active: boolean;
9
10
  onSelect: (id: string) => void;
10
11
  onRename?: (id: string, title: string) => void;
11
12
  onArchive?: (id: string) => void;
12
13
  };
13
- export declare function HistoryRow({ thread, active, onSelect, onRename, onArchive }: HistoryRowProps): import("react").JSX.Element;
14
+ export declare function HistoryRow({ thread, active, onSelect, onRename, onArchive, className, ...props }: HistoryRowProps): import("react").JSX.Element;
14
15
  export {};
@@ -0,0 +1,137 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ import { useState } from "react";
4
+ import { formatTimeOfDay } from "../thread-groups.js";
5
+ import { ThreadItemMenu } from "./thread-item-menu.js";
6
+ import { ThreadTitleEditor } from "./thread-title-editor.js";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ const timeHiddenByMenuClass = "max-sm:hidden sm:group-focus-within:invisible sm:group-hover:invisible sm:group-has-[[data-state=open]]:invisible";
9
+ export function HistoryRow(t0) {
10
+ const $ = _c(33);
11
+ let active;
12
+ let className;
13
+ let onArchive;
14
+ let onRename;
15
+ let onSelect;
16
+ let props;
17
+ let thread;
18
+ if ($[0] !== t0) {
19
+ ({
20
+ thread,
21
+ active,
22
+ onSelect,
23
+ onRename,
24
+ onArchive,
25
+ className,
26
+ ...props
27
+ } = t0);
28
+ $[0] = t0;
29
+ $[1] = active;
30
+ $[2] = className;
31
+ $[3] = onArchive;
32
+ $[4] = onRename;
33
+ $[5] = onSelect;
34
+ $[6] = props;
35
+ $[7] = thread;
36
+ } else {
37
+ active = $[1];
38
+ className = $[2];
39
+ onArchive = $[3];
40
+ onRename = $[4];
41
+ onSelect = $[5];
42
+ props = $[6];
43
+ thread = $[7];
44
+ }
45
+ const [editing, setEditing] = useState(false);
46
+ const hasMenu = onRename !== undefined || onArchive !== undefined;
47
+ const t1 = active || undefined;
48
+ const t2 = active ? "bg-accent text-accent-foreground before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-foreground" : "text-foreground/85 hover:bg-accent/40";
49
+ let t3;
50
+ if ($[8] !== className || $[9] !== t2) {
51
+ t3 = cn("group relative flex items-center motion-safe:transition-colors", t2, className);
52
+ $[8] = className;
53
+ $[9] = t2;
54
+ $[10] = t3;
55
+ } else {
56
+ t3 = $[10];
57
+ }
58
+ let t4;
59
+ if ($[11] !== active || $[12] !== editing || $[13] !== hasMenu || $[14] !== onRename || $[15] !== onSelect || $[16] !== thread.id || $[17] !== thread.title || $[18] !== thread.updatedAt) {
60
+ t4 = editing && onRename ? /*#__PURE__*/_jsx("div", {
61
+ className: "flex-1 px-1 py-0.5",
62
+ children: /*#__PURE__*/_jsx(ThreadTitleEditor, {
63
+ title: thread.title,
64
+ onCommit: title => {
65
+ onRename(thread.id, title);
66
+ setEditing(false);
67
+ },
68
+ onCancel: () => setEditing(false)
69
+ })
70
+ }) : /*#__PURE__*/_jsxs("button", {
71
+ type: "button",
72
+ "aria-current": active ? "page" : undefined,
73
+ onClick: () => onSelect(thread.id),
74
+ onDoubleClick: onRename ? () => setEditing(true) : undefined,
75
+ className: cn("flex min-w-0 flex-1 items-center gap-3 py-1.5 pl-2 text-left text-sm outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring", hasMenu ? "pr-8 sm:pr-2" : "pr-2", active && "font-medium"),
76
+ children: [/*#__PURE__*/_jsx("span", {
77
+ className: "min-w-0 flex-1 truncate",
78
+ children: thread.title
79
+ }), /*#__PURE__*/_jsx("time", {
80
+ dateTime: thread.updatedAt,
81
+ suppressHydrationWarning: true,
82
+ className: cn("shrink-0 font-mono text-[11px] font-normal text-muted-foreground tabular-nums", hasMenu && timeHiddenByMenuClass),
83
+ children: formatTimeOfDay(thread.updatedAt)
84
+ })]
85
+ });
86
+ $[11] = active;
87
+ $[12] = editing;
88
+ $[13] = hasMenu;
89
+ $[14] = onRename;
90
+ $[15] = onSelect;
91
+ $[16] = thread.id;
92
+ $[17] = thread.title;
93
+ $[18] = thread.updatedAt;
94
+ $[19] = t4;
95
+ } else {
96
+ t4 = $[19];
97
+ }
98
+ let t5;
99
+ if ($[20] !== editing || $[21] !== hasMenu || $[22] !== onArchive || $[23] !== onRename || $[24] !== thread.id || $[25] !== thread.title) {
100
+ t5 = hasMenu && !editing && /*#__PURE__*/_jsx("div", {
101
+ className: "absolute top-1/2 right-1 -translate-y-1/2",
102
+ children: /*#__PURE__*/_jsx(ThreadItemMenu, {
103
+ title: thread.title,
104
+ onRename: onRename ? () => setEditing(true) : undefined,
105
+ onArchive: onArchive ? () => onArchive(thread.id) : undefined
106
+ })
107
+ });
108
+ $[20] = editing;
109
+ $[21] = hasMenu;
110
+ $[22] = onArchive;
111
+ $[23] = onRename;
112
+ $[24] = thread.id;
113
+ $[25] = thread.title;
114
+ $[26] = t5;
115
+ } else {
116
+ t5 = $[26];
117
+ }
118
+ let t6;
119
+ if ($[27] !== props || $[28] !== t1 || $[29] !== t3 || $[30] !== t4 || $[31] !== t5) {
120
+ t6 = /*#__PURE__*/_jsxs("li", {
121
+ "data-slot": "history-item",
122
+ "data-active": t1,
123
+ className: t3,
124
+ ...props,
125
+ children: [t4, t5]
126
+ });
127
+ $[27] = props;
128
+ $[28] = t1;
129
+ $[29] = t3;
130
+ $[30] = t4;
131
+ $[31] = t5;
132
+ $[32] = t6;
133
+ } else {
134
+ t6 = $[32];
135
+ }
136
+ return t6;
137
+ }
@@ -0,0 +1,84 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Archive as ArchiveIcon, OverflowMenuHorizontal as EllipsisIcon, Edit as PencilIcon } from "@carbon/icons-react";
3
+ import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@locusgraph/components";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ export function ThreadItemMenu(t0) {
6
+ const $ = _c(13);
7
+ const {
8
+ title,
9
+ onRename,
10
+ onArchive
11
+ } = t0;
12
+ const t1 = `Options for ${title}`;
13
+ let t2;
14
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
15
+ t2 = /*#__PURE__*/_jsx(EllipsisIcon, {});
16
+ $[0] = t2;
17
+ } else {
18
+ t2 = $[0];
19
+ }
20
+ let t3;
21
+ if ($[1] !== t1) {
22
+ t3 = /*#__PURE__*/_jsx(DropdownMenuTrigger, {
23
+ asChild: true,
24
+ children: /*#__PURE__*/_jsx(Button, {
25
+ type: "button",
26
+ variant: "ghost",
27
+ size: "icon-xs",
28
+ "aria-label": t1,
29
+ className: "shrink-0 text-muted-foreground sm:opacity-0 sm:group-focus-within:opacity-100 sm:group-hover:opacity-100 sm:data-[state=open]:opacity-100",
30
+ children: t2
31
+ })
32
+ });
33
+ $[1] = t1;
34
+ $[2] = t3;
35
+ } else {
36
+ t3 = $[2];
37
+ }
38
+ let t4;
39
+ if ($[3] !== onRename) {
40
+ t4 = onRename && /*#__PURE__*/_jsxs(DropdownMenuItem, {
41
+ onSelect: onRename,
42
+ children: [/*#__PURE__*/_jsx(PencilIcon, {}), "Rename"]
43
+ });
44
+ $[3] = onRename;
45
+ $[4] = t4;
46
+ } else {
47
+ t4 = $[4];
48
+ }
49
+ let t5;
50
+ if ($[5] !== onArchive) {
51
+ t5 = onArchive && /*#__PURE__*/_jsxs(DropdownMenuItem, {
52
+ onSelect: onArchive,
53
+ children: [/*#__PURE__*/_jsx(ArchiveIcon, {}), "Archive"]
54
+ });
55
+ $[5] = onArchive;
56
+ $[6] = t5;
57
+ } else {
58
+ t5 = $[6];
59
+ }
60
+ let t6;
61
+ if ($[7] !== t4 || $[8] !== t5) {
62
+ t6 = /*#__PURE__*/_jsxs(DropdownMenuContent, {
63
+ align: "end",
64
+ children: [t4, t5]
65
+ });
66
+ $[7] = t4;
67
+ $[8] = t5;
68
+ $[9] = t6;
69
+ } else {
70
+ t6 = $[9];
71
+ }
72
+ let t7;
73
+ if ($[10] !== t3 || $[11] !== t6) {
74
+ t7 = /*#__PURE__*/_jsxs(DropdownMenu, {
75
+ children: [t3, t6]
76
+ });
77
+ $[10] = t3;
78
+ $[11] = t6;
79
+ $[12] = t7;
80
+ } else {
81
+ t7 = $[12];
82
+ }
83
+ return t7;
84
+ }
@@ -0,0 +1,81 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Input } from "@locusgraph/components";
3
+ import { useState } from "react";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ export function ThreadTitleEditor(t0) {
6
+ const $ = _c(13);
7
+ const {
8
+ title,
9
+ onCommit,
10
+ onCancel
11
+ } = t0;
12
+ const [draft, setDraft] = useState(title);
13
+ let t1;
14
+ if ($[0] !== draft || $[1] !== onCancel || $[2] !== onCommit || $[3] !== title) {
15
+ t1 = () => {
16
+ const trimmed = draft.trim();
17
+ if (trimmed && trimmed !== title) {
18
+ onCommit(trimmed);
19
+ } else {
20
+ onCancel();
21
+ }
22
+ };
23
+ $[0] = draft;
24
+ $[1] = onCancel;
25
+ $[2] = onCommit;
26
+ $[3] = title;
27
+ $[4] = t1;
28
+ } else {
29
+ t1 = $[4];
30
+ }
31
+ const commit = t1;
32
+ let t2;
33
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
34
+ t2 = event => setDraft(event.target.value);
35
+ $[5] = t2;
36
+ } else {
37
+ t2 = $[5];
38
+ }
39
+ let t3;
40
+ if ($[6] !== commit || $[7] !== onCancel) {
41
+ t3 = event_1 => {
42
+ if (event_1.key === "Enter") {
43
+ event_1.preventDefault();
44
+ commit();
45
+ }
46
+ if (event_1.key === "Escape") {
47
+ event_1.preventDefault();
48
+ onCancel();
49
+ }
50
+ };
51
+ $[6] = commit;
52
+ $[7] = onCancel;
53
+ $[8] = t3;
54
+ } else {
55
+ t3 = $[8];
56
+ }
57
+ let t4;
58
+ if ($[9] !== commit || $[10] !== draft || $[11] !== t3) {
59
+ t4 = /*#__PURE__*/_jsx(Input, {
60
+ "data-slot": "thread-title-editor",
61
+ "aria-label": "Chat title",
62
+ autoFocus: true,
63
+ value: draft,
64
+ className: "h-7 text-sm",
65
+ onChange: t2,
66
+ onFocus: _temp,
67
+ onBlur: commit,
68
+ onKeyDown: t3
69
+ });
70
+ $[9] = commit;
71
+ $[10] = draft;
72
+ $[11] = t3;
73
+ $[12] = t4;
74
+ } else {
75
+ t4 = $[12];
76
+ }
77
+ return t4;
78
+ }
79
+ function _temp(event_0) {
80
+ return event_0.target.select();
81
+ }
@@ -1,4 +1,4 @@
1
- import type { HistoryItem } from "./history-row.js";
1
+ import type { HistoryItem } from "./row/history-row.js";
2
2
  export type ThreadGroup = {
3
3
  key: string;
4
4
  label: string;
@@ -1,46 +1,52 @@
1
1
  const timeOfDay = new Intl.DateTimeFormat("en-US", {
2
- hour: "2-digit",
3
- minute: "2-digit",
4
- hourCycle: "h23",
2
+ hour: "2-digit",
3
+ minute: "2-digit",
4
+ hourCycle: "h23"
5
+ });
6
+ const calendarDate = new Intl.DateTimeFormat("en-US", {
7
+ dateStyle: "medium"
5
8
  });
6
- const calendarDate = new Intl.DateTimeFormat("en-US", { dateStyle: "medium" });
7
9
  function localDayStart(value) {
8
- const date = new Date(value);
9
- if (Number.isNaN(date.getTime())) {
10
- return undefined;
11
- }
12
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
10
+ const date = new Date(value);
11
+ if (Number.isNaN(date.getTime())) {
12
+ return undefined;
13
+ }
14
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
13
15
  }
14
16
  function daysBetween(earlier, later) {
15
- const utcOf = (date) => Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
16
- return Math.round((utcOf(later) - utcOf(earlier)) / 86_400_000);
17
+ const utcOf = date => Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
18
+ return Math.round((utcOf(later) - utcOf(earlier)) / 86_400_000);
17
19
  }
18
20
  function dayLabel(day, today) {
19
- if (!day) {
20
- return "Earlier";
21
- }
22
- const daysAgo = today ? daysBetween(day, today) : Number.NaN;
23
- if (daysAgo === 0) {
24
- return "Today";
25
- }
26
- if (daysAgo === 1) {
27
- return "Yesterday";
28
- }
29
- return calendarDate.format(day);
21
+ if (!day) {
22
+ return "Earlier";
23
+ }
24
+ const daysAgo = today ? daysBetween(day, today) : Number.NaN;
25
+ if (daysAgo === 0) {
26
+ return "Today";
27
+ }
28
+ if (daysAgo === 1) {
29
+ return "Yesterday";
30
+ }
31
+ return calendarDate.format(day);
30
32
  }
31
33
  export function formatTimeOfDay(value) {
32
- const date = new Date(value);
33
- return Number.isNaN(date.getTime()) ? "" : timeOfDay.format(date);
34
+ const date = new Date(value);
35
+ return Number.isNaN(date.getTime()) ? "" : timeOfDay.format(date);
34
36
  }
35
37
  export function groupThreadsByDay(threads, now) {
36
- const today = localDayStart(now);
37
- const groups = new Map();
38
- for (const thread of threads) {
39
- const day = localDayStart(thread.updatedAt);
40
- const key = day ? String(day.getTime()) : "earlier";
41
- const group = groups.get(key) ?? { key, label: dayLabel(day, today), threads: [] };
42
- group.threads.push(thread);
43
- groups.set(key, group);
44
- }
45
- return [...groups.values()];
38
+ const today = localDayStart(now);
39
+ const groups = new Map();
40
+ for (const thread of threads) {
41
+ const day = localDayStart(thread.updatedAt);
42
+ const key = day ? String(day.getTime()) : "earlier";
43
+ const group = groups.get(key) ?? {
44
+ key,
45
+ label: dayLabel(day, today),
46
+ threads: []
47
+ };
48
+ group.threads.push(thread);
49
+ groups.set(key, group);
50
+ }
51
+ return [...groups.values()];
46
52
  }
@@ -0,0 +1,11 @@
1
+ import type { ThreadGroup } from "./thread-groups.js";
2
+ type VirtualHistoryListProps = {
3
+ groups: ThreadGroup[];
4
+ label: string;
5
+ activeId: string | null;
6
+ onSelect: (id: string) => void;
7
+ onRename?: (id: string, title: string) => void;
8
+ onArchive?: (id: string) => void;
9
+ };
10
+ export declare function VirtualHistoryList({ groups, label, activeId, onSelect, onRename, onArchive, }: VirtualHistoryListProps): import("react").JSX.Element;
11
+ export {};