@locusgraph/loop 0.0.0-stage → 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 (214) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -2
  3. package/dist/agent/index.d.ts +5 -0
  4. package/dist/agent/index.js +5 -0
  5. package/dist/agent/pulse/gradient-label.d.ts +7 -0
  6. package/dist/agent/pulse/gradient-label.js +94 -0
  7. package/dist/agent/pulse/marks/bars-mark.d.ts +1 -0
  8. package/dist/agent/pulse/marks/bars-mark.js +51 -0
  9. package/dist/agent/pulse/marks/glyph-mark.d.ts +4 -0
  10. package/dist/agent/pulse/marks/glyph-mark.js +62 -0
  11. package/dist/agent/pulse/marks/locus-mark.d.ts +1 -0
  12. package/dist/agent/pulse/marks/locus-mark.js +73 -0
  13. package/dist/agent/pulse/marks/orb-mark.d.ts +1 -0
  14. package/dist/agent/pulse/marks/orb-mark.js +34 -0
  15. package/dist/agent/pulse/marks/spinner-mark.d.ts +1 -0
  16. package/dist/agent/pulse/marks/spinner-mark.js +32 -0
  17. package/dist/agent/pulse/pulse-tone.d.ts +1 -0
  18. package/dist/agent/pulse/pulse-tone.js +1 -0
  19. package/dist/agent/pulse/pulse.d.ts +12 -0
  20. package/dist/agent/pulse/pulse.js +166 -0
  21. package/dist/agent/pulse/use-loop-animation.d.ts +2 -0
  22. package/dist/agent/pulse/use-loop-animation.js +40 -0
  23. package/dist/agent/shared/status-dot.d.ts +1 -0
  24. package/dist/agent/shared/status-dot.js +1 -0
  25. package/dist/agent/steps/step-icon.d.ts +8 -0
  26. package/dist/agent/steps/step-icon.js +117 -0
  27. package/dist/agent/steps/steps.d.ts +7 -0
  28. package/dist/agent/steps/steps.js +249 -0
  29. package/dist/agent/thinking/thinking.d.ts +6 -0
  30. package/dist/agent/thinking/thinking.js +211 -0
  31. package/dist/agent/thinking/thought-duration.d.ts +2 -0
  32. package/dist/agent/thinking/thought-duration.js +11 -0
  33. package/dist/agent/tool/json-block.d.ts +5 -0
  34. package/dist/agent/tool/json-block.js +42 -0
  35. package/dist/agent/tool/tool-status.d.ts +6 -0
  36. package/dist/agent/tool/tool-status.js +59 -0
  37. package/dist/agent/tool/tool.d.ts +7 -0
  38. package/dist/agent/tool/tool.js +192 -0
  39. package/dist/approval/inbox/inbox-row.d.ts +12 -0
  40. package/dist/approval/inbox/inbox-row.js +328 -0
  41. package/dist/approval/inbox/inbox-selection.d.ts +6 -0
  42. package/dist/approval/inbox/inbox-selection.js +15 -0
  43. package/dist/approval/inbox/inbox.d.ts +12 -0
  44. package/dist/approval/inbox/inbox.js +258 -0
  45. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  46. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  47. package/dist/approval/index.d.ts +9 -0
  48. package/dist/approval/index.js +8 -0
  49. package/dist/approval/memory/memory-choices.d.ts +10 -0
  50. package/dist/approval/memory/memory-choices.js +35 -0
  51. package/dist/approval/memory/memory-review.d.ts +11 -0
  52. package/dist/approval/memory/memory-review.js +256 -0
  53. package/dist/approval/memory/memory-row.d.ts +9 -0
  54. package/dist/approval/memory/memory-row.js +226 -0
  55. package/dist/approval/plan/plan-review.d.ts +13 -0
  56. package/dist/approval/plan/plan-review.js +289 -0
  57. package/dist/approval/plan/plan-step-row.d.ts +13 -0
  58. package/dist/approval/plan/plan-step-row.js +201 -0
  59. package/dist/approval/plan/plan-steps.d.ts +8 -0
  60. package/dist/approval/plan/plan-steps.js +30 -0
  61. package/dist/approval/plan/question-choices.d.ts +10 -0
  62. package/dist/approval/plan/question-choices.js +166 -0
  63. package/dist/approval/plan/question.d.ts +18 -0
  64. package/dist/approval/plan/question.js +232 -0
  65. package/dist/approval/run/run-bar.d.ts +13 -0
  66. package/dist/approval/run/run-bar.js +189 -0
  67. package/dist/approval/shared/decision-line.d.ts +1 -0
  68. package/dist/approval/shared/decision-line.js +1 -0
  69. package/dist/approval/shared/risk-badge.d.ts +10 -0
  70. package/dist/approval/shared/risk-badge.js +57 -0
  71. package/dist/approval/shared/time.d.ts +3 -0
  72. package/dist/approval/shared/time.js +12 -0
  73. package/dist/approval/shared/use-focus-on-mount.d.ts +2 -0
  74. package/dist/approval/shared/use-focus-on-mount.js +26 -0
  75. package/dist/approval/spend/raise-cap-form.d.ts +8 -0
  76. package/dist/approval/spend/raise-cap-form.js +244 -0
  77. package/dist/approval/spend/spend-gate.d.ts +16 -0
  78. package/dist/approval/spend/spend-gate.js +250 -0
  79. package/dist/approval/spend/spend-math.d.ts +5 -0
  80. package/dist/approval/spend/spend-math.js +17 -0
  81. package/dist/approval/spend/spend-meter.d.ts +10 -0
  82. package/dist/approval/spend/spend-meter.js +377 -0
  83. package/dist/approval/tool/approval.d.ts +14 -0
  84. package/dist/approval/tool/approval.js +290 -0
  85. package/dist/approval/tool/args/args-editor.d.ts +16 -0
  86. package/dist/approval/tool/args/args-editor.js +273 -0
  87. package/dist/approval/tool/args/args-field.d.ts +11 -0
  88. package/dist/approval/tool/args/args-field.js +268 -0
  89. package/dist/approval/tool/args/args-validation.d.ts +8 -0
  90. package/dist/approval/tool/args/args-validation.js +50 -0
  91. package/dist/approval/tool/deny-form.d.ts +6 -0
  92. package/dist/approval/tool/deny-form.js +135 -0
  93. package/dist/approval/tool/tool-inputs.d.ts +6 -0
  94. package/dist/approval/tool/tool-inputs.js +142 -0
  95. package/dist/approval/types.d.ts +59 -0
  96. package/dist/approval/types.js +1 -0
  97. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  98. package/dist/chat/chat/chat-item-spacing.js +19 -0
  99. package/dist/chat/chat/chat.d.ts +8 -0
  100. package/dist/chat/chat/chat.js +187 -0
  101. package/dist/chat/chat/use-stick-to-bottom.d.ts +7 -0
  102. package/dist/chat/chat/use-stick-to-bottom.js +133 -0
  103. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  104. package/dist/chat/chat/virtual-chat-items.js +153 -0
  105. package/dist/chat/composer/composer-actions.d.ts +15 -0
  106. package/dist/chat/composer/composer-actions.js +158 -0
  107. package/dist/chat/composer/composer.d.ts +20 -0
  108. package/dist/chat/composer/composer.js +340 -0
  109. package/dist/chat/composer/use-auto-grow.d.ts +2 -0
  110. package/dist/chat/composer/use-auto-grow.js +29 -0
  111. package/dist/chat/files/file-meta.d.ts +13 -0
  112. package/dist/chat/files/file-meta.js +30 -0
  113. package/dist/chat/files/files.d.ts +9 -0
  114. package/dist/chat/files/files.js +327 -0
  115. package/dist/chat/index.d.ts +7 -0
  116. package/dist/chat/index.js +7 -0
  117. package/dist/chat/reply/fenced-code.d.ts +8 -0
  118. package/dist/chat/reply/fenced-code.js +53 -0
  119. package/dist/chat/reply/markdown-components.d.ts +2 -0
  120. package/dist/chat/reply/markdown-components.js +142 -0
  121. package/dist/chat/reply/reply.d.ts +8 -0
  122. package/dist/chat/reply/reply.js +116 -0
  123. package/dist/chat/turn/group-parts.d.ts +24 -0
  124. package/dist/chat/turn/group-parts.js +49 -0
  125. package/dist/chat/turn/turn.d.ts +11 -0
  126. package/dist/chat/turn/turn.js +253 -0
  127. package/dist/cost/context.d.ts +13 -0
  128. package/dist/cost/context.js +333 -0
  129. package/dist/cost/cost-steps.d.ts +17 -0
  130. package/dist/cost/cost-steps.js +230 -0
  131. package/dist/cost/cost.d.ts +8 -0
  132. package/dist/cost/cost.js +531 -0
  133. package/dist/cost/index.d.ts +4 -0
  134. package/dist/cost/index.js +4 -0
  135. package/dist/cost/model-picker.d.ts +11 -0
  136. package/dist/cost/model-picker.js +184 -0
  137. package/dist/cost/shared/context-breakdown.d.ts +15 -0
  138. package/dist/cost/shared/context-breakdown.js +306 -0
  139. package/dist/cost/shared/meter-marks.d.ts +9 -0
  140. package/dist/cost/shared/meter-marks.js +114 -0
  141. package/dist/cost/shared/model-option-row.d.ts +14 -0
  142. package/dist/cost/shared/model-option-row.js +189 -0
  143. package/dist/cost/shared/step-cost-row.d.ts +15 -0
  144. package/dist/cost/shared/step-cost-row.js +262 -0
  145. package/dist/cost/shared/usage-totals.d.ts +11 -0
  146. package/dist/cost/shared/usage-totals.js +30 -0
  147. package/dist/index.d.ts +7 -0
  148. package/dist/index.js +7 -0
  149. package/dist/memory/cite.d.ts +8 -0
  150. package/dist/memory/cite.js +190 -0
  151. package/dist/memory/index.d.ts +5 -0
  152. package/dist/memory/index.js +4 -0
  153. package/dist/memory/memorized.d.ts +14 -0
  154. package/dist/memory/memorized.js +225 -0
  155. package/dist/memory/recall.d.ts +9 -0
  156. package/dist/memory/recall.js +303 -0
  157. package/dist/memory/shared/disclosure.d.ts +6 -0
  158. package/dist/memory/shared/disclosure.js +6 -0
  159. package/dist/memory/shared/host-label.d.ts +6 -0
  160. package/dist/memory/shared/host-label.js +31 -0
  161. package/dist/memory/shared/source-mark.d.ts +5 -0
  162. package/dist/memory/shared/source-mark.js +42 -0
  163. package/dist/memory/sources.d.ts +9 -0
  164. package/dist/memory/sources.js +264 -0
  165. package/dist/shared/decision-summary.d.ts +18 -0
  166. package/dist/shared/decision-summary.js +144 -0
  167. package/dist/shared/panel-empty.d.ts +8 -0
  168. package/dist/shared/panel-empty.js +80 -0
  169. package/dist/shared/panel.d.ts +19 -0
  170. package/dist/shared/panel.js +251 -0
  171. package/dist/shared/status-dot.d.ts +6 -0
  172. package/dist/shared/status-dot.js +42 -0
  173. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  174. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  175. package/dist/sources.css +1 -0
  176. package/dist/thread/actions/action-button.d.ts +8 -0
  177. package/dist/thread/actions/action-button.js +67 -0
  178. package/dist/thread/actions/actions.d.ts +13 -0
  179. package/dist/thread/actions/actions.js +192 -0
  180. package/dist/thread/actions/branch-switcher.d.ts +10 -0
  181. package/dist/thread/actions/branch-switcher.js +104 -0
  182. package/dist/thread/canvas/canvas.d.ts +14 -0
  183. package/dist/thread/canvas/canvas.js +212 -0
  184. package/dist/thread/canvas/version-switcher.d.ts +12 -0
  185. package/dist/thread/canvas/version-switcher.js +152 -0
  186. package/dist/thread/code/code.d.ts +10 -0
  187. package/dist/thread/code/code.js +195 -0
  188. package/dist/thread/code/copy-code-button.d.ts +6 -0
  189. package/dist/thread/code/copy-code-button.js +66 -0
  190. package/dist/thread/code/highlight.d.ts +1 -0
  191. package/dist/thread/code/highlight.js +40 -0
  192. package/dist/thread/history/history-rows.d.ts +16 -0
  193. package/dist/thread/history/history-rows.js +23 -0
  194. package/dist/thread/history/history.d.ts +16 -0
  195. package/dist/thread/history/history.js +179 -0
  196. package/dist/thread/history/row/history-row.d.ts +15 -0
  197. package/dist/thread/history/row/history-row.js +137 -0
  198. package/dist/thread/history/row/thread-item-menu.d.ts +7 -0
  199. package/dist/thread/history/row/thread-item-menu.js +84 -0
  200. package/dist/thread/history/row/thread-title-editor.d.ts +7 -0
  201. package/dist/thread/history/row/thread-title-editor.js +81 -0
  202. package/dist/thread/history/thread-groups.d.ts +8 -0
  203. package/dist/thread/history/thread-groups.js +52 -0
  204. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  205. package/dist/thread/history/virtual-history-list.js +107 -0
  206. package/dist/thread/index.d.ts +8 -0
  207. package/dist/thread/index.js +5 -0
  208. package/dist/thread/starters/starters.d.ts +12 -0
  209. package/dist/thread/starters/starters.js +100 -0
  210. package/dist/thread/use-copied.d.ts +5 -0
  211. package/dist/thread/use-copied.js +52 -0
  212. package/dist/types.d.ts +70 -0
  213. package/dist/types.js +3 -0
  214. package/package.json +59 -3
@@ -0,0 +1,179 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { Add as PlusIcon } from "@carbon/icons-react";
5
+ import { Button, cn, ScrollArea } from "@locusgraph/components";
6
+ import { shouldVirtualize } from "../../shared/virtual/use-list-virtualizer.js";
7
+ import { HistoryRow } from "./row/history-row.js";
8
+ import { groupThreadsByDay } from "./thread-groups.js";
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;
179
+ }
@@ -0,0 +1,15 @@
1
+ import { type ComponentProps } from "react";
2
+ export type HistoryItem = {
3
+ id: string;
4
+ title: string;
5
+ updatedAt: string;
6
+ };
7
+ type HistoryRowProps = Omit<ComponentProps<"li">, "onSelect"> & {
8
+ thread: HistoryItem;
9
+ active: boolean;
10
+ onSelect: (id: string) => void;
11
+ onRename?: (id: string, title: string) => void;
12
+ onArchive?: (id: string) => void;
13
+ };
14
+ export declare function HistoryRow({ thread, active, onSelect, onRename, onArchive, className, ...props }: HistoryRowProps): import("react").JSX.Element;
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,7 @@
1
+ type ThreadItemMenuProps = {
2
+ title: string;
3
+ onRename?: () => void;
4
+ onArchive?: () => void;
5
+ };
6
+ export declare function ThreadItemMenu({ title, onRename, onArchive }: ThreadItemMenuProps): import("react").JSX.Element;
7
+ export {};
@@ -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,7 @@
1
+ type ThreadTitleEditorProps = {
2
+ title: string;
3
+ onCommit: (title: string) => void;
4
+ onCancel: () => void;
5
+ };
6
+ export declare function ThreadTitleEditor({ title, onCommit, onCancel }: ThreadTitleEditorProps): import("react").JSX.Element;
7
+ export {};
@@ -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
+ }
@@ -0,0 +1,8 @@
1
+ import type { HistoryItem } from "./row/history-row.js";
2
+ export type ThreadGroup = {
3
+ key: string;
4
+ label: string;
5
+ threads: HistoryItem[];
6
+ };
7
+ export declare function formatTimeOfDay(value: string): string;
8
+ export declare function groupThreadsByDay(threads: HistoryItem[], now: Date | string): ThreadGroup[];
@@ -0,0 +1,52 @@
1
+ const timeOfDay = new Intl.DateTimeFormat("en-US", {
2
+ hour: "2-digit",
3
+ minute: "2-digit",
4
+ hourCycle: "h23"
5
+ });
6
+ const calendarDate = new Intl.DateTimeFormat("en-US", {
7
+ dateStyle: "medium"
8
+ });
9
+ function localDayStart(value) {
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());
15
+ }
16
+ function daysBetween(earlier, later) {
17
+ const utcOf = date => Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
18
+ return Math.round((utcOf(later) - utcOf(earlier)) / 86_400_000);
19
+ }
20
+ function dayLabel(day, today) {
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);
32
+ }
33
+ export function formatTimeOfDay(value) {
34
+ const date = new Date(value);
35
+ return Number.isNaN(date.getTime()) ? "" : timeOfDay.format(date);
36
+ }
37
+ export function groupThreadsByDay(threads, now) {
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()];
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 {};
@@ -0,0 +1,107 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ import { useRef } from "react";
4
+ import { rowOffsetStyle, useListVirtualizer, virtualRowClassName } from "../../shared/virtual/use-list-virtualizer.js";
5
+ import { estimatedRowHeight, historyListRows } from "./history-rows.js";
6
+ import { HistoryRow } from "./row/history-row.js";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ function scrollAreaViewportOf(element) {
9
+ return element?.closest("[data-slot=scroll-area-viewport]") ?? null;
10
+ }
11
+ export function VirtualHistoryList(t0) {
12
+ const $ = _c(12);
13
+ const {
14
+ groups,
15
+ label,
16
+ activeId,
17
+ onSelect,
18
+ onRename,
19
+ onArchive
20
+ } = t0;
21
+ const listRef = useRef(null);
22
+ const rows = historyListRows(groups);
23
+ const {
24
+ rows: visibleRows,
25
+ totalSize,
26
+ itemProps
27
+ } = useListVirtualizer({
28
+ count: rows.length,
29
+ getScrollElement: () => scrollAreaViewportOf(listRef.current),
30
+ estimateSize: index => estimatedRowHeight(rows[index], index),
31
+ getItemKey: index_0 => rows[index_0].key
32
+ });
33
+ let t1;
34
+ if ($[0] !== activeId || $[1] !== onArchive || $[2] !== onRename || $[3] !== onSelect) {
35
+ t1 = thread => ({
36
+ thread,
37
+ active: thread.id === activeId,
38
+ onSelect,
39
+ onRename,
40
+ onArchive
41
+ });
42
+ $[0] = activeId;
43
+ $[1] = onArchive;
44
+ $[2] = onRename;
45
+ $[3] = onSelect;
46
+ $[4] = t1;
47
+ } else {
48
+ t1 = $[4];
49
+ }
50
+ const threadRowProps = t1;
51
+ const t2 = "history-list";
52
+ const t3 = "relative";
53
+ let t4;
54
+ if ($[5] !== totalSize) {
55
+ t4 = {
56
+ height: totalSize
57
+ };
58
+ $[5] = totalSize;
59
+ $[6] = t4;
60
+ } else {
61
+ t4 = $[6];
62
+ }
63
+ const t5 = visibleRows.map(virtualRow => {
64
+ const row = rows[virtualRow.index];
65
+ if (row.kind === "group") {
66
+ return /*#__PURE__*/_jsx("li", {
67
+ role: "presentation",
68
+ ...itemProps(virtualRow.index),
69
+ className: cn(virtualRowClassName, virtualRow.index > 0 && "pt-4"),
70
+ style: rowOffsetStyle(virtualRow.start),
71
+ children: /*#__PURE__*/_jsx("h3", {
72
+ id: `thread-group-${row.groupKey}`,
73
+ className: "eyebrow px-2 pb-1",
74
+ suppressHydrationWarning: true,
75
+ children: row.label
76
+ })
77
+ }, virtualRow.key);
78
+ }
79
+ return /*#__PURE__*/_jsx(HistoryRow, {
80
+ ...threadRowProps(row.thread),
81
+ ...itemProps(virtualRow.index),
82
+ "aria-posinset": row.position,
83
+ "aria-setsize": row.groupSize,
84
+ className: virtualRowClassName,
85
+ style: rowOffsetStyle(virtualRow.start)
86
+ }, virtualRow.key);
87
+ });
88
+ let t6;
89
+ if ($[7] !== label || $[8] !== listRef || $[9] !== t4 || $[10] !== t5) {
90
+ t6 = /*#__PURE__*/_jsx("ul", {
91
+ ref: listRef,
92
+ "data-slot": t2,
93
+ "aria-label": label,
94
+ className: t3,
95
+ style: t4,
96
+ children: t5
97
+ });
98
+ $[7] = label;
99
+ $[8] = listRef;
100
+ $[9] = t4;
101
+ $[10] = t5;
102
+ $[11] = t6;
103
+ } else {
104
+ t6 = $[11];
105
+ }
106
+ return t6;
107
+ }