@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.
- package/README.md +2 -0
- package/dist/agent/pulse/gradient-label.js +86 -15
- package/dist/agent/pulse/marks/bars-mark.js +46 -10
- package/dist/agent/pulse/marks/glyph-mark.js +56 -11
- package/dist/agent/pulse/marks/locus-mark.js +63 -28
- package/dist/agent/pulse/marks/orb-mark.js +31 -8
- package/dist/agent/pulse/marks/spinner-mark.js +29 -1
- package/dist/agent/pulse/pulse.js +150 -35
- package/dist/agent/pulse/use-loop-animation.js +36 -17
- package/dist/agent/steps/step-icon.js +110 -24
- package/dist/agent/steps/steps.js +235 -25
- package/dist/agent/thinking/thinking.js +203 -23
- package/dist/agent/thinking/thought-duration.js +7 -9
- package/dist/agent/tool/json-block.js +38 -11
- package/dist/agent/tool/tool-status.js +51 -18
- package/dist/agent/tool/tool.js +184 -6
- package/dist/approval/inbox/inbox-row.d.ts +3 -2
- package/dist/approval/inbox/inbox-row.js +321 -7
- package/dist/approval/inbox/inbox-selection.js +7 -13
- package/dist/approval/inbox/inbox.d.ts +2 -1
- package/dist/approval/inbox/inbox.js +250 -18
- package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
- package/dist/approval/inbox/virtual-inbox-list.js +129 -0
- package/dist/approval/memory/memory-choices.js +27 -22
- package/dist/approval/memory/memory-review.js +242 -17
- package/dist/approval/memory/memory-row.js +215 -19
- package/dist/approval/plan/plan-review.js +279 -28
- package/dist/approval/plan/plan-step-row.js +194 -43
- package/dist/approval/plan/plan-steps.js +24 -23
- package/dist/approval/plan/question-choices.js +158 -39
- package/dist/approval/plan/question.d.ts +1 -1
- package/dist/approval/plan/question.js +223 -26
- package/dist/approval/run/run-bar.js +178 -22
- package/dist/approval/shared/decision-line.js +1 -1
- package/dist/approval/shared/risk-badge.js +47 -16
- package/dist/approval/shared/time.js +5 -8
- package/dist/approval/shared/use-focus-on-mount.js +23 -6
- package/dist/approval/spend/raise-cap-form.js +235 -17
- package/dist/approval/spend/spend-gate.js +239 -21
- package/dist/approval/spend/spend-math.js +7 -8
- package/dist/approval/spend/spend-meter.js +362 -34
- package/dist/approval/tool/approval.js +272 -27
- package/dist/approval/tool/args/args-editor.js +262 -26
- package/dist/approval/tool/args/args-field.js +259 -19
- package/dist/approval/tool/args/args-validation.js +38 -47
- package/dist/approval/tool/deny-form.js +130 -10
- package/dist/approval/tool/tool-inputs.js +127 -38
- package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
- package/dist/chat/chat/chat-item-spacing.js +19 -0
- package/dist/chat/chat/chat.d.ts +2 -1
- package/dist/chat/chat/chat.js +181 -5
- package/dist/chat/chat/use-stick-to-bottom.js +123 -47
- package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
- package/dist/chat/chat/virtual-chat-items.js +153 -0
- package/dist/chat/composer/composer-actions.js +151 -16
- package/dist/chat/composer/composer.js +330 -32
- package/dist/chat/composer/use-auto-grow.js +24 -9
- package/dist/chat/files/file-meta.js +19 -19
- package/dist/chat/files/files.js +316 -28
- package/dist/chat/reply/fenced-code.js +45 -21
- package/dist/chat/reply/markdown-components.js +137 -17
- package/dist/chat/reply/reply.js +105 -10
- package/dist/chat/turn/group-parts.js +43 -29
- package/dist/chat/turn/turn.js +238 -30
- package/dist/cost/context.js +321 -23
- package/dist/cost/cost-steps.js +220 -14
- package/dist/cost/cost.js +521 -27
- package/dist/cost/model-picker.js +181 -6
- package/dist/cost/shared/context-breakdown.js +299 -10
- package/dist/cost/shared/meter-marks.js +107 -9
- package/dist/cost/shared/model-option-row.js +178 -21
- package/dist/cost/shared/step-cost-row.js +248 -20
- package/dist/cost/shared/usage-totals.js +22 -18
- package/dist/memory/cite.js +182 -11
- package/dist/memory/memorized.js +217 -11
- package/dist/memory/recall.js +296 -17
- package/dist/memory/shared/host-label.js +19 -22
- package/dist/memory/shared/source-mark.js +39 -3
- package/dist/memory/sources.js +255 -13
- package/dist/shared/decision-summary.js +133 -14
- package/dist/shared/panel-empty.js +78 -3
- package/dist/shared/panel.js +243 -13
- package/dist/shared/status-dot.js +38 -8
- package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
- package/dist/shared/virtual/use-list-virtualizer.js +68 -0
- package/dist/thread/actions/action-button.js +65 -3
- package/dist/thread/actions/actions.js +184 -13
- package/dist/thread/actions/branch-switcher.js +102 -5
- package/dist/thread/canvas/canvas.js +205 -5
- package/dist/thread/canvas/version-switcher.js +149 -8
- package/dist/thread/code/code.js +186 -24
- package/dist/thread/code/copy-code-button.js +61 -13
- package/dist/thread/code/highlight.js +30 -29
- package/dist/thread/history/history-rows.d.ts +16 -0
- package/dist/thread/history/history-rows.js +23 -0
- package/dist/thread/history/history.d.ts +3 -2
- package/dist/thread/history/history.js +174 -5
- package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
- package/dist/thread/history/row/history-row.js +137 -0
- package/dist/thread/history/row/thread-item-menu.js +84 -0
- package/dist/thread/history/row/thread-title-editor.js +81 -0
- package/dist/thread/history/thread-groups.d.ts +1 -1
- package/dist/thread/history/thread-groups.js +40 -34
- package/dist/thread/history/virtual-history-list.d.ts +11 -0
- package/dist/thread/history/virtual-history-list.js +107 -0
- package/dist/thread/index.d.ts +1 -1
- package/dist/thread/starters/starters.js +92 -7
- package/dist/thread/use-copied.js +45 -15
- package/dist/types.js +1 -1
- package/package.json +6 -4
- package/dist/thread/history/history-row.js +0 -17
- package/dist/thread/history/thread-item-menu.js +0 -6
- package/dist/thread/history/thread-title-editor.js +0 -25
- /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
- /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
|
@@ -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
|
+
}
|
package/dist/thread/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export * from "./canvas/canvas.js";
|
|
|
4
4
|
export type { CanvasVersion } from "./canvas/version-switcher.js";
|
|
5
5
|
export * from "./code/code.js";
|
|
6
6
|
export * from "./history/history.js";
|
|
7
|
-
export type { HistoryItem } from "./history/history-row.js";
|
|
7
|
+
export type { HistoryItem } from "./history/row/history-row.js";
|
|
8
8
|
export * from "./starters/starters.js";
|
|
@@ -1,15 +1,100 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { ArrowUpRight as ArrowUpRightIcon } from "@carbon/icons-react";
|
|
3
3
|
import { cn } from "@locusgraph/components";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
5
|
function textOf(suggestion) {
|
|
5
|
-
|
|
6
|
+
return typeof suggestion === "string" ? suggestion : suggestion.text;
|
|
6
7
|
}
|
|
7
8
|
function labelOf(suggestion) {
|
|
8
|
-
|
|
9
|
+
return typeof suggestion === "string" ? suggestion : suggestion.label ?? suggestion.text;
|
|
9
10
|
}
|
|
10
|
-
export function Starters(
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
export function Starters(t0) {
|
|
12
|
+
const $ = _c(19);
|
|
13
|
+
let className;
|
|
14
|
+
let onSelect;
|
|
15
|
+
let props;
|
|
16
|
+
let suggestions;
|
|
17
|
+
let t1;
|
|
18
|
+
if ($[0] !== t0) {
|
|
19
|
+
({
|
|
20
|
+
suggestions,
|
|
21
|
+
onSelect,
|
|
22
|
+
disabled: t1,
|
|
23
|
+
className,
|
|
24
|
+
...props
|
|
25
|
+
} = t0);
|
|
26
|
+
$[0] = t0;
|
|
27
|
+
$[1] = className;
|
|
28
|
+
$[2] = onSelect;
|
|
29
|
+
$[3] = props;
|
|
30
|
+
$[4] = suggestions;
|
|
31
|
+
$[5] = t1;
|
|
32
|
+
} else {
|
|
33
|
+
className = $[1];
|
|
34
|
+
onSelect = $[2];
|
|
35
|
+
props = $[3];
|
|
36
|
+
suggestions = $[4];
|
|
37
|
+
t1 = $[5];
|
|
38
|
+
}
|
|
39
|
+
const disabled = t1 === undefined ? false : t1;
|
|
40
|
+
if (suggestions.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
let t2;
|
|
44
|
+
if ($[6] !== className) {
|
|
45
|
+
t2 = cn("flex flex-col divide-y bg-card ring-1 ring-border", className);
|
|
46
|
+
$[6] = className;
|
|
47
|
+
$[7] = t2;
|
|
48
|
+
} else {
|
|
49
|
+
t2 = $[7];
|
|
50
|
+
}
|
|
51
|
+
let t3;
|
|
52
|
+
if ($[8] !== disabled || $[9] !== onSelect || $[10] !== suggestions) {
|
|
53
|
+
let t4;
|
|
54
|
+
if ($[12] !== disabled || $[13] !== onSelect) {
|
|
55
|
+
t4 = suggestion => /*#__PURE__*/_jsxs("button", {
|
|
56
|
+
type: "button",
|
|
57
|
+
disabled: disabled,
|
|
58
|
+
onClick: () => onSelect(textOf(suggestion)),
|
|
59
|
+
className: "group flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm outline-none hover:bg-accent/50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 motion-safe:transition-colors",
|
|
60
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
61
|
+
className: "min-w-0 flex-1 text-pretty",
|
|
62
|
+
children: labelOf(suggestion)
|
|
63
|
+
}), /*#__PURE__*/_jsx(ArrowUpRightIcon, {
|
|
64
|
+
"aria-hidden": true,
|
|
65
|
+
className: "size-3.5 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 motion-safe:transition-opacity"
|
|
66
|
+
})]
|
|
67
|
+
}, textOf(suggestion));
|
|
68
|
+
$[12] = disabled;
|
|
69
|
+
$[13] = onSelect;
|
|
70
|
+
$[14] = t4;
|
|
71
|
+
} else {
|
|
72
|
+
t4 = $[14];
|
|
13
73
|
}
|
|
14
|
-
|
|
74
|
+
t3 = suggestions.map(t4);
|
|
75
|
+
$[8] = disabled;
|
|
76
|
+
$[9] = onSelect;
|
|
77
|
+
$[10] = suggestions;
|
|
78
|
+
$[11] = t3;
|
|
79
|
+
} else {
|
|
80
|
+
t3 = $[11];
|
|
81
|
+
}
|
|
82
|
+
let t4;
|
|
83
|
+
if ($[15] !== props || $[16] !== t2 || $[17] !== t3) {
|
|
84
|
+
t4 = /*#__PURE__*/_jsx("div", {
|
|
85
|
+
"data-slot": "starters",
|
|
86
|
+
role: "group",
|
|
87
|
+
"aria-label": "Suggested prompts",
|
|
88
|
+
className: t2,
|
|
89
|
+
...props,
|
|
90
|
+
children: t3
|
|
91
|
+
});
|
|
92
|
+
$[15] = props;
|
|
93
|
+
$[16] = t2;
|
|
94
|
+
$[17] = t3;
|
|
95
|
+
$[18] = t4;
|
|
96
|
+
} else {
|
|
97
|
+
t4 = $[18];
|
|
98
|
+
}
|
|
99
|
+
return t4;
|
|
15
100
|
}
|
|
@@ -1,22 +1,52 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
1
2
|
import { useEffect, useRef, useState } from "react";
|
|
2
3
|
const copiedDurationMs = 1500;
|
|
3
4
|
export function useCopied() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const $ = _c(5);
|
|
6
|
+
const [copied, setCopied] = useState(false);
|
|
7
|
+
const timer = useRef(undefined);
|
|
8
|
+
let t0;
|
|
9
|
+
let t1;
|
|
10
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
11
|
+
t0 = () => () => clearTimeout(timer.current);
|
|
12
|
+
t1 = [];
|
|
13
|
+
$[0] = t0;
|
|
14
|
+
$[1] = t1;
|
|
15
|
+
} else {
|
|
16
|
+
t0 = $[0];
|
|
17
|
+
t1 = $[1];
|
|
18
|
+
}
|
|
19
|
+
useEffect(t0, t1);
|
|
20
|
+
let t2;
|
|
21
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t2 = () => {
|
|
23
|
+
setCopied(true);
|
|
24
|
+
clearTimeout(timer.current);
|
|
25
|
+
timer.current = setTimeout(() => setCopied(false), copiedDurationMs);
|
|
11
26
|
};
|
|
12
|
-
|
|
27
|
+
$[2] = t2;
|
|
28
|
+
} else {
|
|
29
|
+
t2 = $[2];
|
|
30
|
+
}
|
|
31
|
+
const markCopied = t2;
|
|
32
|
+
let t3;
|
|
33
|
+
if ($[3] !== copied) {
|
|
34
|
+
t3 = {
|
|
35
|
+
copied,
|
|
36
|
+
markCopied
|
|
37
|
+
};
|
|
38
|
+
$[3] = copied;
|
|
39
|
+
$[4] = t3;
|
|
40
|
+
} else {
|
|
41
|
+
t3 = $[4];
|
|
42
|
+
}
|
|
43
|
+
return t3;
|
|
13
44
|
}
|
|
14
45
|
export async function writeToClipboard(text) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
46
|
+
try {
|
|
47
|
+
await navigator.clipboard.writeText(text);
|
|
48
|
+
return true;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
22
52
|
}
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locusgraph/loop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Agent components for LocusGraph apps: chat, agent steps, human-in-the-loop approvals, memory and cost. Takes Vercel AI SDK UIMessage parts; never calls a model.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"provenance": true
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@locusgraph/components": "^0.2.
|
|
32
|
+
"@locusgraph/components": "^0.2.1",
|
|
33
33
|
"react": "^19.2.0",
|
|
34
34
|
"react-dom": "^19.2.0"
|
|
35
35
|
},
|
|
@@ -37,23 +37,25 @@
|
|
|
37
37
|
"@carbon/icons-react": "11.89.0",
|
|
38
38
|
"@locusgraph/brand": "0.2.0",
|
|
39
39
|
"@locusgraph/utils": "0.1.1",
|
|
40
|
+
"@tanstack/react-virtual": "3.14.13",
|
|
40
41
|
"react-markdown": "^10.1.0",
|
|
41
42
|
"remark-gfm": "^4.0.1",
|
|
42
43
|
"shiki": "^4.5.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@locusgraph/components": "0.2.
|
|
46
|
+
"@locusgraph/components": "0.2.1",
|
|
46
47
|
"@locusgraph/config": "0.1.1",
|
|
47
48
|
"@types/node": "^22.0.0",
|
|
48
49
|
"@types/react": "^19.2.0",
|
|
49
50
|
"@types/react-dom": "^19.2.0",
|
|
51
|
+
"happy-dom": "20.14.5",
|
|
50
52
|
"react": "19.2.8",
|
|
51
53
|
"react-dom": "19.2.8",
|
|
52
54
|
"typescript": "^7.0.2",
|
|
53
55
|
"vitest": "^5.0.3"
|
|
54
56
|
},
|
|
55
57
|
"scripts": {
|
|
56
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json && cp src/sources.css dist/sources.css && node ../../scripts/esm-extensions.mjs dist",
|
|
58
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && cp src/sources.css dist/sources.css && node ../../scripts/react-compiler.mjs dist && node ../../scripts/esm-extensions.mjs dist",
|
|
57
59
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
58
60
|
"test": "vitest run"
|
|
59
61
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-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
|
-
const timeHiddenByMenuClass = "max-sm:hidden sm:group-focus-within:invisible sm:group-hover:invisible sm:group-has-[[data-state=open]]:invisible";
|
|
8
|
-
export function HistoryRow({ thread, active, onSelect, onRename, onArchive }) {
|
|
9
|
-
const [editing, setEditing] = useState(false);
|
|
10
|
-
const hasMenu = onRename !== undefined || onArchive !== undefined;
|
|
11
|
-
return (_jsxs("li", { "data-slot": "history-item", "data-active": active || undefined, className: cn("group relative flex items-center motion-safe:transition-colors", active
|
|
12
|
-
? "bg-accent text-accent-foreground before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-foreground"
|
|
13
|
-
: "text-foreground/85 hover:bg-accent/40"), children: [editing && onRename ? (_jsx("div", { className: "flex-1 px-1 py-0.5", children: _jsx(ThreadTitleEditor, { title: thread.title, onCommit: (title) => {
|
|
14
|
-
onRename(thread.id, title);
|
|
15
|
-
setEditing(false);
|
|
16
|
-
}, onCancel: () => setEditing(false) }) })) : (_jsxs("button", { type: "button", "aria-current": active ? "page" : undefined, onClick: () => onSelect(thread.id), onDoubleClick: onRename ? () => setEditing(true) : undefined, 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"), children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: thread.title }), _jsx("time", { dateTime: thread.updatedAt, suppressHydrationWarning: true, className: cn("shrink-0 font-mono text-[11px] font-normal text-muted-foreground tabular-nums", hasMenu && timeHiddenByMenuClass), children: formatTimeOfDay(thread.updatedAt) })] })), hasMenu && !editing && (_jsx("div", { className: "absolute top-1/2 right-1 -translate-y-1/2", children: _jsx(ThreadItemMenu, { title: thread.title, onRename: onRename ? () => setEditing(true) : undefined, onArchive: onArchive ? () => onArchive(thread.id) : undefined }) }))] }));
|
|
17
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-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
|
-
export function ThreadItemMenu({ title, onRename, onArchive }) {
|
|
5
|
-
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { type: "button", variant: "ghost", size: "icon-xs", "aria-label": `Options for ${title}`, 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", children: _jsx(EllipsisIcon, {}) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [onRename && (_jsxs(DropdownMenuItem, { onSelect: onRename, children: [_jsx(PencilIcon, {}), "Rename"] })), onArchive && (_jsxs(DropdownMenuItem, { onSelect: onArchive, children: [_jsx(ArchiveIcon, {}), "Archive"] }))] })] }));
|
|
6
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Input } from "@locusgraph/components";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
export function ThreadTitleEditor({ title, onCommit, onCancel }) {
|
|
5
|
-
const [draft, setDraft] = useState(title);
|
|
6
|
-
const commit = () => {
|
|
7
|
-
const trimmed = draft.trim();
|
|
8
|
-
if (trimmed && trimmed !== title) {
|
|
9
|
-
onCommit(trimmed);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
onCancel();
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
return (_jsx(Input, { "data-slot": "thread-title-editor", "aria-label": "Chat title", autoFocus: true, value: draft, className: "h-7 text-sm", onChange: (event) => setDraft(event.target.value), onFocus: (event) => event.target.select(), onBlur: commit, onKeyDown: (event) => {
|
|
16
|
-
if (event.key === "Enter") {
|
|
17
|
-
event.preventDefault();
|
|
18
|
-
commit();
|
|
19
|
-
}
|
|
20
|
-
if (event.key === "Escape") {
|
|
21
|
-
event.preventDefault();
|
|
22
|
-
onCancel();
|
|
23
|
-
}
|
|
24
|
-
} }));
|
|
25
|
-
}
|
|
File without changes
|
|
File without changes
|