@locusgraph/loop 0.1.0 → 0.2.1
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 +36 -15
- package/dist/agent/pulse/marks/bars-mark.js +24 -10
- package/dist/agent/pulse/marks/glyph-mark.js +17 -11
- package/dist/agent/pulse/marks/locus-mark.js +39 -28
- package/dist/agent/pulse/marks/orb-mark.js +21 -8
- package/dist/agent/pulse/marks/spinner-mark.js +20 -1
- package/dist/agent/pulse/pulse.js +63 -35
- package/dist/agent/pulse/use-loop-animation.js +14 -16
- package/dist/agent/steps/step-icon.js +40 -24
- package/dist/agent/steps/steps.js +72 -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 +18 -11
- package/dist/agent/tool/tool-status.js +28 -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 +96 -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 +99 -18
- package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
- package/dist/approval/inbox/virtual-inbox-list.js +53 -0
- package/dist/approval/memory/memory-choices.js +27 -22
- package/dist/approval/memory/memory-review.js +108 -17
- package/dist/approval/memory/memory-row.js +80 -19
- package/dist/approval/plan/plan-review.js +129 -28
- package/dist/approval/plan/plan-step-row.js +91 -44
- package/dist/approval/plan/plan-steps.js +24 -23
- package/dist/approval/plan/question-choices.js +73 -40
- package/dist/approval/plan/question.d.ts +1 -1
- package/dist/approval/plan/question.js +108 -27
- package/dist/approval/run/run-bar.js +94 -22
- package/dist/approval/shared/decision-line.js +1 -1
- package/dist/approval/shared/risk-badge.js +32 -16
- package/dist/approval/shared/time.js +5 -8
- package/dist/approval/shared/use-focus-on-mount.js +7 -6
- package/dist/approval/spend/raise-cap-form.js +64 -19
- package/dist/approval/spend/spend-gate.js +124 -21
- package/dist/approval/spend/spend-math.js +7 -8
- package/dist/approval/spend/spend-meter.js +136 -35
- package/dist/approval/tool/approval.js +113 -27
- package/dist/approval/tool/args/args-editor.js +104 -26
- package/dist/approval/tool/args/args-field.js +79 -22
- package/dist/approval/tool/args/args-validation.js +38 -47
- package/dist/approval/tool/deny-form.js +43 -10
- package/dist/approval/tool/tool-inputs.js +62 -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 +71 -48
- package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
- package/dist/chat/chat/virtual-chat-items.js +60 -0
- package/dist/chat/composer/composer-actions.js +69 -17
- package/dist/chat/composer/composer.js +330 -32
- package/dist/chat/composer/use-auto-grow.js +9 -9
- package/dist/chat/files/file-meta.js +19 -19
- package/dist/chat/files/files.js +92 -29
- package/dist/chat/reply/fenced-code.js +23 -21
- package/dist/chat/reply/markdown-components.js +137 -17
- package/dist/chat/reply/reply.js +30 -10
- package/dist/chat/turn/group-parts.js +43 -29
- package/dist/chat/turn/turn.js +87 -30
- package/dist/cost/context.js +104 -23
- package/dist/cost/cost-steps.js +67 -14
- package/dist/cost/cost.js +128 -23
- package/dist/cost/model-picker.js +51 -6
- package/dist/cost/shared/context-breakdown.js +83 -10
- package/dist/cost/shared/meter-marks.js +49 -9
- package/dist/cost/shared/model-option-row.js +56 -22
- package/dist/cost/shared/step-cost-row.js +65 -22
- package/dist/cost/shared/usage-totals.js +22 -18
- package/dist/memory/cite.js +62 -12
- package/dist/memory/memorized.js +65 -11
- package/dist/memory/recall.js +101 -17
- package/dist/memory/shared/host-label.js +19 -22
- package/dist/memory/shared/source-mark.js +11 -3
- package/dist/memory/sources.js +78 -14
- package/dist/shared/decision-summary.js +51 -14
- package/dist/shared/panel-empty.js +20 -3
- package/dist/shared/panel.js +69 -13
- package/dist/shared/status-dot.js +16 -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 +22 -3
- package/dist/thread/actions/actions.js +184 -13
- package/dist/thread/actions/branch-switcher.js +28 -5
- package/dist/thread/canvas/canvas.js +205 -5
- package/dist/thread/canvas/version-switcher.js +54 -8
- package/dist/thread/code/code.js +186 -24
- package/dist/thread/code/copy-code-button.js +30 -14
- 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 +58 -0
- package/dist/thread/history/row/thread-item-menu.js +31 -0
- package/dist/thread/history/row/thread-title-editor.js +38 -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 +71 -0
- package/dist/thread/index.d.ts +1 -1
- package/dist/thread/starters/starters.js +33 -8
- package/dist/thread/use-copied.js +18 -16
- 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
package/dist/memory/sources.js
CHANGED
|
@@ -1,22 +1,86 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { ChevronRight as ChevronRightIcon } from "@carbon/icons-react";
|
|
3
2
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger, cn } from "@locusgraph/components";
|
|
4
3
|
import { pluralize } from "@locusgraph/utils";
|
|
5
|
-
import { chevronClass, collapsibleTriggerClass, interactiveRowClass, ruledListClass, ruledRowClass
|
|
4
|
+
import { chevronClass, collapsibleTriggerClass, interactiveRowClass, ruledListClass, ruledRowClass } from "./shared/disclosure.js";
|
|
6
5
|
import { hostLabel, sourceKey, toCitation } from "./shared/host-label.js";
|
|
7
6
|
import { SourceMark } from "./shared/source-mark.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
8
|
const stackedMarkLimit = 3;
|
|
9
|
-
export function Sources({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
export function Sources({
|
|
10
|
+
sources,
|
|
11
|
+
onOpen,
|
|
12
|
+
defaultOpen = false,
|
|
13
|
+
className
|
|
14
|
+
}) {
|
|
15
|
+
if (sources.length === 0) return null;
|
|
16
|
+
const citations = sources.map(toCitation);
|
|
17
|
+
return /*#__PURE__*/_jsxs(Collapsible, {
|
|
18
|
+
"data-slot": "sources",
|
|
19
|
+
defaultOpen: defaultOpen,
|
|
20
|
+
className: cn("flex min-w-0 flex-col gap-2", className),
|
|
21
|
+
children: [/*#__PURE__*/_jsxs(CollapsibleTrigger, {
|
|
22
|
+
className: collapsibleTriggerClass,
|
|
23
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
24
|
+
"aria-hidden": true,
|
|
25
|
+
className: "flex -space-x-1",
|
|
26
|
+
children: citations.slice(0, stackedMarkLimit).map((citation, position) => /*#__PURE__*/_jsx(SourceMark, {
|
|
27
|
+
citation: citation,
|
|
28
|
+
className: "ring-card"
|
|
29
|
+
}, sourceKey(sources[position], position)))
|
|
30
|
+
}), "Used ", pluralize(sources.length, "source"), /*#__PURE__*/_jsx(ChevronRightIcon, {
|
|
31
|
+
"aria-hidden": true,
|
|
32
|
+
className: chevronClass
|
|
33
|
+
})]
|
|
34
|
+
}), /*#__PURE__*/_jsx(CollapsibleContent, {
|
|
35
|
+
children: /*#__PURE__*/_jsx("ol", {
|
|
36
|
+
className: ruledListClass,
|
|
37
|
+
children: citations.map((citation, position) => /*#__PURE__*/_jsx(SourceRow, {
|
|
38
|
+
citation: citation,
|
|
39
|
+
onOpen: onOpen
|
|
40
|
+
}, sourceKey(sources[position], position)))
|
|
41
|
+
})
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
14
44
|
}
|
|
15
|
-
function SourceRow({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
45
|
+
function SourceRow({
|
|
46
|
+
citation,
|
|
47
|
+
onOpen
|
|
48
|
+
}) {
|
|
49
|
+
const host = hostLabel(citation.url);
|
|
50
|
+
const showHost = host !== undefined && host !== citation.title;
|
|
51
|
+
const content = /*#__PURE__*/_jsxs(_Fragment, {
|
|
52
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
53
|
+
className: "w-4 shrink-0 font-mono text-xs text-muted-foreground tabular-nums",
|
|
54
|
+
children: citation.index
|
|
55
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
56
|
+
className: "min-w-0 flex-1 truncate",
|
|
57
|
+
children: citation.title
|
|
58
|
+
}), showHost && /*#__PURE__*/_jsx("span", {
|
|
59
|
+
className: "max-w-[40%] shrink-0 truncate text-xs text-muted-foreground",
|
|
60
|
+
children: host
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
const rowClass = ruledRowClass;
|
|
64
|
+
const label = `Open source ${citation.index}: ${citation.title}`;
|
|
65
|
+
return /*#__PURE__*/_jsx("li", {
|
|
66
|
+
"data-slot": "sources-item",
|
|
67
|
+
"data-index": citation.index,
|
|
68
|
+
children: onOpen ? /*#__PURE__*/_jsx("button", {
|
|
69
|
+
type: "button",
|
|
70
|
+
"aria-label": label,
|
|
71
|
+
onClick: () => onOpen(citation),
|
|
72
|
+
className: cn(rowClass, interactiveRowClass),
|
|
73
|
+
children: content
|
|
74
|
+
}) : citation.url ? /*#__PURE__*/_jsx("a", {
|
|
75
|
+
href: citation.url,
|
|
76
|
+
target: "_blank",
|
|
77
|
+
rel: "noreferrer",
|
|
78
|
+
"aria-label": label,
|
|
79
|
+
className: cn(rowClass, interactiveRowClass),
|
|
80
|
+
children: content
|
|
81
|
+
}) : /*#__PURE__*/_jsx("div", {
|
|
82
|
+
className: rowClass,
|
|
83
|
+
children: content
|
|
84
|
+
})
|
|
85
|
+
});
|
|
22
86
|
}
|
|
@@ -1,25 +1,62 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { Checkmark as CheckIcon, Close as XIcon } from "@carbon/icons-react";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
const decisionTimeFormat = new Intl.DateTimeFormat("en-US", {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
dateStyle: "medium",
|
|
5
|
+
timeStyle: "short",
|
|
6
|
+
timeZone: "UTC"
|
|
7
7
|
});
|
|
8
8
|
export function toDate(value) {
|
|
9
|
-
|
|
9
|
+
return value instanceof Date ? value : new Date(value);
|
|
10
10
|
}
|
|
11
11
|
export function isoOf(value) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const date = toDate(value);
|
|
13
|
+
return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
|
|
14
14
|
}
|
|
15
15
|
export function formatDecidedAt(value) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const date = toDate(value);
|
|
17
|
+
return Number.isNaN(date.getTime()) ? "" : `${decisionTimeFormat.format(date)} UTC`;
|
|
18
18
|
}
|
|
19
|
-
function DecisionMeta({
|
|
20
|
-
|
|
19
|
+
function DecisionMeta({
|
|
20
|
+
decision,
|
|
21
|
+
verb
|
|
22
|
+
}) {
|
|
23
|
+
return /*#__PURE__*/_jsxs("p", {
|
|
24
|
+
className: "text-xs text-muted-foreground",
|
|
25
|
+
children: [verb, decision.by && ` by ${decision.by}`, decision.at !== undefined && /*#__PURE__*/_jsxs(_Fragment, {
|
|
26
|
+
children: [" · ", /*#__PURE__*/_jsx("time", {
|
|
27
|
+
dateTime: isoOf(decision.at),
|
|
28
|
+
className: "tabular-nums",
|
|
29
|
+
children: formatDecidedAt(decision.at)
|
|
30
|
+
})]
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
21
33
|
}
|
|
22
|
-
export function DecisionSummary({
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
export function DecisionSummary({
|
|
35
|
+
decision,
|
|
36
|
+
result,
|
|
37
|
+
approvedVerb = "Approved",
|
|
38
|
+
deniedVerb = "Denied"
|
|
39
|
+
}) {
|
|
40
|
+
const Icon = decision.approved ? CheckIcon : XIcon;
|
|
41
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
42
|
+
"data-slot": "decision-summary",
|
|
43
|
+
"data-approved": decision.approved,
|
|
44
|
+
className: "flex items-start gap-2.5 text-sm",
|
|
45
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
46
|
+
"aria-hidden": true,
|
|
47
|
+
className: `mt-0.5 size-4 shrink-0 ${decision.approved ? "text-good" : "text-destructive"}`
|
|
48
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
49
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
50
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
51
|
+
className: "font-medium",
|
|
52
|
+
children: result
|
|
53
|
+
}), /*#__PURE__*/_jsx(DecisionMeta, {
|
|
54
|
+
decision: decision,
|
|
55
|
+
verb: decision.approved ? approvedVerb : deniedVerb
|
|
56
|
+
}), decision.reason && /*#__PURE__*/_jsxs("p", {
|
|
57
|
+
className: "text-xs text-muted-foreground",
|
|
58
|
+
children: ["Reason: ", decision.reason]
|
|
59
|
+
})]
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
25
62
|
}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { cn } from "@locusgraph/components";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
export function PanelEmpty({
|
|
4
|
+
icon,
|
|
5
|
+
title,
|
|
6
|
+
description,
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}) {
|
|
10
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
11
|
+
"data-slot": "panel-empty",
|
|
12
|
+
...props,
|
|
13
|
+
className: cn("flex flex-col items-center gap-1 px-6 pt-8 pb-10 text-center [&_svg]:mb-1 [&_svg]:size-5 [&_svg]:text-muted-foreground", className),
|
|
14
|
+
children: [icon, /*#__PURE__*/_jsx("p", {
|
|
15
|
+
className: "text-sm font-medium",
|
|
16
|
+
children: title
|
|
17
|
+
}), description && /*#__PURE__*/_jsx("p", {
|
|
18
|
+
className: "max-w-xs text-xs text-muted-foreground",
|
|
19
|
+
children: description
|
|
20
|
+
})]
|
|
21
|
+
});
|
|
5
22
|
}
|
package/dist/shared/panel.js
CHANGED
|
@@ -1,21 +1,77 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { cn } from "@locusgraph/components";
|
|
3
2
|
import { StatusDot } from "./status-dot.js";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
export function ApprovalPanel({
|
|
5
|
+
className,
|
|
6
|
+
...props
|
|
7
|
+
}) {
|
|
8
|
+
return /*#__PURE__*/_jsx("section", {
|
|
9
|
+
className: cn("flex min-w-0 flex-col bg-card text-card-foreground ring-1 ring-border", className),
|
|
10
|
+
...props
|
|
11
|
+
});
|
|
6
12
|
}
|
|
7
|
-
export function PanelHeader({
|
|
8
|
-
|
|
13
|
+
export function PanelHeader({
|
|
14
|
+
icon,
|
|
15
|
+
eyebrow,
|
|
16
|
+
status,
|
|
17
|
+
tone = "idle",
|
|
18
|
+
aside
|
|
19
|
+
}) {
|
|
20
|
+
return /*#__PURE__*/_jsxs("header", {
|
|
21
|
+
"data-slot": "panel-header",
|
|
22
|
+
className: "eyebrow flex items-center gap-2 px-5 pt-4 [&_svg]:size-3.5 [&_svg]:shrink-0",
|
|
23
|
+
children: [icon, /*#__PURE__*/_jsx("span", {
|
|
24
|
+
className: "min-w-0 truncate",
|
|
25
|
+
children: eyebrow
|
|
26
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
27
|
+
className: "ml-auto flex shrink-0 items-center gap-1.5",
|
|
28
|
+
children: [aside && /*#__PURE__*/_jsx("span", {
|
|
29
|
+
className: "mr-2 tabular-nums",
|
|
30
|
+
children: aside
|
|
31
|
+
}), status && /*#__PURE__*/_jsxs(_Fragment, {
|
|
32
|
+
children: [/*#__PURE__*/_jsx(StatusDot, {
|
|
33
|
+
tone: tone
|
|
34
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
35
|
+
children: status
|
|
36
|
+
})]
|
|
37
|
+
})]
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
9
40
|
}
|
|
10
|
-
export function PanelTitle({
|
|
11
|
-
|
|
41
|
+
export function PanelTitle({
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
}) {
|
|
45
|
+
return /*#__PURE__*/_jsx("h3", {
|
|
46
|
+
className: cn("px-5 pt-2 font-sans text-base leading-snug font-semibold tracking-tight text-balance", className),
|
|
47
|
+
...props
|
|
48
|
+
});
|
|
12
49
|
}
|
|
13
|
-
export function PanelBody({
|
|
14
|
-
|
|
50
|
+
export function PanelBody({
|
|
51
|
+
className,
|
|
52
|
+
...props
|
|
53
|
+
}) {
|
|
54
|
+
return /*#__PURE__*/_jsx("div", {
|
|
55
|
+
className: cn("flex flex-col gap-4 px-5 pt-4 pb-5", className),
|
|
56
|
+
...props
|
|
57
|
+
});
|
|
15
58
|
}
|
|
16
|
-
export function PanelFooter({
|
|
17
|
-
|
|
59
|
+
export function PanelFooter({
|
|
60
|
+
className,
|
|
61
|
+
...props
|
|
62
|
+
}) {
|
|
63
|
+
return /*#__PURE__*/_jsx("div", {
|
|
64
|
+
className: cn("flex flex-wrap items-center justify-end gap-2 border-t bg-muted/70 px-5 py-3", className),
|
|
65
|
+
...props
|
|
66
|
+
});
|
|
18
67
|
}
|
|
19
|
-
export function LiveStatus({
|
|
20
|
-
|
|
68
|
+
export function LiveStatus({
|
|
69
|
+
message
|
|
70
|
+
}) {
|
|
71
|
+
return /*#__PURE__*/_jsx("p", {
|
|
72
|
+
role: "status",
|
|
73
|
+
"aria-live": "polite",
|
|
74
|
+
className: "sr-only",
|
|
75
|
+
children: message
|
|
76
|
+
});
|
|
21
77
|
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { cn } from "@locusgraph/components";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
export const statusDotTones = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
running: "bg-warn motion-safe:animate-pulse",
|
|
5
|
+
waiting: "bg-warn motion-safe:animate-pulse",
|
|
6
|
+
done: "bg-good",
|
|
7
|
+
danger: "bg-destructive",
|
|
8
|
+
idle: "bg-muted-foreground/50"
|
|
9
9
|
};
|
|
10
|
-
export function StatusDot({
|
|
11
|
-
|
|
10
|
+
export function StatusDot({
|
|
11
|
+
tone,
|
|
12
|
+
className
|
|
13
|
+
}) {
|
|
14
|
+
return /*#__PURE__*/_jsx("span", {
|
|
15
|
+
"aria-hidden": true,
|
|
16
|
+
"data-slot": "status-dot",
|
|
17
|
+
"data-tone": tone,
|
|
18
|
+
className: cn("size-1.5 shrink-0 rounded-full", statusDotTones[tone], className)
|
|
19
|
+
});
|
|
12
20
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type CSSProperties, type FocusEvent } from "react";
|
|
2
|
+
export declare const virtualizeAboveCount = 50;
|
|
3
|
+
export declare function shouldVirtualize(count: number, virtualize: boolean | undefined): boolean;
|
|
4
|
+
export type ListVirtualizerOptions = {
|
|
5
|
+
count: number;
|
|
6
|
+
getScrollElement: () => HTMLElement | null;
|
|
7
|
+
estimateSize: (index: number) => number;
|
|
8
|
+
getItemKey: (index: number) => string | number;
|
|
9
|
+
anchorTo?: "start" | "end";
|
|
10
|
+
};
|
|
11
|
+
export declare function useListVirtualizer({ count, getScrollElement, estimateSize, getItemKey, anchorTo, }: ListVirtualizerOptions): {
|
|
12
|
+
virtualizer: import("@tanstack/react-virtual").ReactVirtualizer<HTMLElement, HTMLElement>;
|
|
13
|
+
rows: import("@tanstack/react-virtual").VirtualItem[];
|
|
14
|
+
totalSize: number;
|
|
15
|
+
isScrolling: boolean;
|
|
16
|
+
itemProps: (index: number) => {
|
|
17
|
+
"data-index": number;
|
|
18
|
+
ref: (node: HTMLElement | null) => void;
|
|
19
|
+
onFocus: () => void;
|
|
20
|
+
onBlur: (event: FocusEvent<HTMLElement>) => void;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const virtualRowClassName = "absolute top-0 left-0 w-full";
|
|
24
|
+
export declare function rowOffsetStyle(start: number): CSSProperties;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
export const virtualizeAboveCount = 50;
|
|
4
|
+
const serverViewportRect = {
|
|
5
|
+
width: 0,
|
|
6
|
+
height: 800
|
|
7
|
+
};
|
|
8
|
+
export function shouldVirtualize(count, virtualize) {
|
|
9
|
+
return virtualize !== false && count > virtualizeAboveCount;
|
|
10
|
+
}
|
|
11
|
+
function offsetOfLastScreen(count, estimateSize) {
|
|
12
|
+
let total = 0;
|
|
13
|
+
for (let index = 0; index < count; index += 1) total += estimateSize(index);
|
|
14
|
+
return Math.max(0, total - serverViewportRect.height);
|
|
15
|
+
}
|
|
16
|
+
function keepFocusedRendered(indexes, focusedIndex, count) {
|
|
17
|
+
if (focusedIndex === null || focusedIndex >= count || indexes.includes(focusedIndex)) {
|
|
18
|
+
return indexes;
|
|
19
|
+
}
|
|
20
|
+
return [...indexes, focusedIndex].sort((a, b) => a - b);
|
|
21
|
+
}
|
|
22
|
+
function focusLeft(event) {
|
|
23
|
+
return !event.currentTarget.contains(event.relatedTarget);
|
|
24
|
+
}
|
|
25
|
+
export function useListVirtualizer({
|
|
26
|
+
count,
|
|
27
|
+
getScrollElement,
|
|
28
|
+
estimateSize,
|
|
29
|
+
getItemKey,
|
|
30
|
+
anchorTo = "start"
|
|
31
|
+
}) {
|
|
32
|
+
"use no memo";
|
|
33
|
+
|
|
34
|
+
const [focusedIndex, setFocusedIndex] = useState(null);
|
|
35
|
+
const rangeExtractor = useCallback(range => keepFocusedRendered(defaultRangeExtractor(range), focusedIndex, range.count), [focusedIndex]);
|
|
36
|
+
const virtualizer = useVirtualizer({
|
|
37
|
+
count,
|
|
38
|
+
getScrollElement,
|
|
39
|
+
estimateSize,
|
|
40
|
+
getItemKey,
|
|
41
|
+
rangeExtractor,
|
|
42
|
+
anchorTo,
|
|
43
|
+
initialRect: serverViewportRect,
|
|
44
|
+
initialOffset: () => anchorTo === "end" ? offsetOfLastScreen(count, estimateSize) : 0,
|
|
45
|
+
overscan: 6
|
|
46
|
+
});
|
|
47
|
+
const itemProps = index => ({
|
|
48
|
+
"data-index": index,
|
|
49
|
+
ref: virtualizer.measureElement,
|
|
50
|
+
onFocus: () => setFocusedIndex(index),
|
|
51
|
+
onBlur: event => {
|
|
52
|
+
if (focusLeft(event)) setFocusedIndex(null);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
virtualizer,
|
|
57
|
+
rows: virtualizer.getVirtualItems(),
|
|
58
|
+
totalSize: virtualizer.getTotalSize(),
|
|
59
|
+
isScrolling: virtualizer.isScrolling,
|
|
60
|
+
itemProps
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export const virtualRowClassName = "absolute top-0 left-0 w-full";
|
|
64
|
+
export function rowOffsetStyle(start) {
|
|
65
|
+
return {
|
|
66
|
+
transform: `translateY(${start}px)`
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { Button, Tooltip, TooltipContent, TooltipTrigger } from "@locusgraph/components";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
export function ActionButton({
|
|
4
|
+
label,
|
|
5
|
+
children,
|
|
6
|
+
...props
|
|
7
|
+
}) {
|
|
8
|
+
return /*#__PURE__*/_jsxs(Tooltip, {
|
|
9
|
+
children: [/*#__PURE__*/_jsx(TooltipTrigger, {
|
|
10
|
+
asChild: true,
|
|
11
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
12
|
+
type: "button",
|
|
13
|
+
variant: "ghost",
|
|
14
|
+
size: "icon-sm",
|
|
15
|
+
"aria-label": label,
|
|
16
|
+
className: "text-muted-foreground hover:bg-accent hover:text-foreground [&_svg]:size-4",
|
|
17
|
+
...props,
|
|
18
|
+
children: children
|
|
19
|
+
})
|
|
20
|
+
}), /*#__PURE__*/_jsx(TooltipContent, {
|
|
21
|
+
children: label
|
|
22
|
+
})]
|
|
23
|
+
});
|
|
5
24
|
}
|
|
@@ -1,21 +1,192 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { Checkmark as CheckIcon, Copy as CopyIcon, Renew as RefreshCwIcon, ThumbsDown as ThumbsDownIcon, ThumbsUp as ThumbsUpIcon } from "@carbon/icons-react";
|
|
4
5
|
import { cn, TooltipProvider } from "@locusgraph/components";
|
|
5
6
|
import { useCopied } from "../use-copied.js";
|
|
6
7
|
import { ActionButton } from "./action-button.js";
|
|
7
8
|
import { BranchSwitcher } from "./branch-switcher.js";
|
|
9
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
10
|
function toggledFeedback(current, chosen) {
|
|
9
|
-
|
|
11
|
+
return current === chosen ? null : chosen;
|
|
10
12
|
}
|
|
11
|
-
export function Actions(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
export function Actions(t0) {
|
|
14
|
+
const $ = _c(40);
|
|
15
|
+
let branch;
|
|
16
|
+
let className;
|
|
17
|
+
let onBranchChange;
|
|
18
|
+
let onCopy;
|
|
19
|
+
let onFeedback;
|
|
20
|
+
let onRetry;
|
|
21
|
+
let props;
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[0] !== t0) {
|
|
24
|
+
({
|
|
25
|
+
onCopy,
|
|
26
|
+
onRetry,
|
|
27
|
+
feedback: t1,
|
|
28
|
+
onFeedback,
|
|
29
|
+
branch,
|
|
30
|
+
onBranchChange,
|
|
31
|
+
className,
|
|
32
|
+
...props
|
|
33
|
+
} = t0);
|
|
34
|
+
$[0] = t0;
|
|
35
|
+
$[1] = branch;
|
|
36
|
+
$[2] = className;
|
|
37
|
+
$[3] = onBranchChange;
|
|
38
|
+
$[4] = onCopy;
|
|
39
|
+
$[5] = onFeedback;
|
|
40
|
+
$[6] = onRetry;
|
|
41
|
+
$[7] = props;
|
|
42
|
+
$[8] = t1;
|
|
43
|
+
} else {
|
|
44
|
+
branch = $[1];
|
|
45
|
+
className = $[2];
|
|
46
|
+
onBranchChange = $[3];
|
|
47
|
+
onCopy = $[4];
|
|
48
|
+
onFeedback = $[5];
|
|
49
|
+
onRetry = $[6];
|
|
50
|
+
props = $[7];
|
|
51
|
+
t1 = $[8];
|
|
52
|
+
}
|
|
53
|
+
const feedback = t1 === undefined ? null : t1;
|
|
54
|
+
const {
|
|
55
|
+
copied,
|
|
56
|
+
markCopied
|
|
57
|
+
} = useCopied();
|
|
58
|
+
const showBranch = branch !== undefined && branch.count > 1 && onBranchChange !== undefined;
|
|
59
|
+
if (!onCopy && !onRetry && !onFeedback && !showBranch) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
let t2;
|
|
63
|
+
if ($[9] !== className) {
|
|
64
|
+
t2 = cn("flex items-center gap-0.5", className);
|
|
65
|
+
$[9] = className;
|
|
66
|
+
$[10] = t2;
|
|
67
|
+
} else {
|
|
68
|
+
t2 = $[10];
|
|
69
|
+
}
|
|
70
|
+
let t3;
|
|
71
|
+
if ($[11] !== branch || $[12] !== onBranchChange || $[13] !== showBranch) {
|
|
72
|
+
t3 = showBranch && /*#__PURE__*/_jsx(BranchSwitcher, {
|
|
73
|
+
branch: branch,
|
|
74
|
+
onBranchChange: onBranchChange
|
|
75
|
+
});
|
|
76
|
+
$[11] = branch;
|
|
77
|
+
$[12] = onBranchChange;
|
|
78
|
+
$[13] = showBranch;
|
|
79
|
+
$[14] = t3;
|
|
80
|
+
} else {
|
|
81
|
+
t3 = $[14];
|
|
82
|
+
}
|
|
83
|
+
let t4;
|
|
84
|
+
if ($[15] !== onCopy || $[16] !== onFeedback || $[17] !== onRetry || $[18] !== showBranch) {
|
|
85
|
+
t4 = showBranch && (onCopy || onRetry || onFeedback) && /*#__PURE__*/_jsx("span", {
|
|
86
|
+
"aria-hidden": true,
|
|
87
|
+
className: "mx-1 h-3.5 w-px bg-border"
|
|
88
|
+
});
|
|
89
|
+
$[15] = onCopy;
|
|
90
|
+
$[16] = onFeedback;
|
|
91
|
+
$[17] = onRetry;
|
|
92
|
+
$[18] = showBranch;
|
|
93
|
+
$[19] = t4;
|
|
94
|
+
} else {
|
|
95
|
+
t4 = $[19];
|
|
96
|
+
}
|
|
97
|
+
let t5;
|
|
98
|
+
if ($[20] !== copied || $[21] !== markCopied || $[22] !== onCopy) {
|
|
99
|
+
t5 = onCopy && /*#__PURE__*/_jsx(ActionButton, {
|
|
100
|
+
label: copied ? "Copied" : "Copy",
|
|
101
|
+
onClick: () => {
|
|
102
|
+
onCopy();
|
|
103
|
+
markCopied();
|
|
104
|
+
},
|
|
105
|
+
children: copied ? /*#__PURE__*/_jsx(CheckIcon, {
|
|
106
|
+
className: "text-good"
|
|
107
|
+
}) : /*#__PURE__*/_jsx(CopyIcon, {})
|
|
108
|
+
});
|
|
109
|
+
$[20] = copied;
|
|
110
|
+
$[21] = markCopied;
|
|
111
|
+
$[22] = onCopy;
|
|
112
|
+
$[23] = t5;
|
|
113
|
+
} else {
|
|
114
|
+
t5 = $[23];
|
|
115
|
+
}
|
|
116
|
+
let t6;
|
|
117
|
+
if ($[24] !== onRetry) {
|
|
118
|
+
t6 = onRetry && /*#__PURE__*/_jsx(ActionButton, {
|
|
119
|
+
label: "Retry",
|
|
120
|
+
onClick: onRetry,
|
|
121
|
+
children: /*#__PURE__*/_jsx(RefreshCwIcon, {})
|
|
122
|
+
});
|
|
123
|
+
$[24] = onRetry;
|
|
124
|
+
$[25] = t6;
|
|
125
|
+
} else {
|
|
126
|
+
t6 = $[25];
|
|
127
|
+
}
|
|
128
|
+
let t7;
|
|
129
|
+
if ($[26] !== feedback || $[27] !== onFeedback) {
|
|
130
|
+
t7 = onFeedback && /*#__PURE__*/_jsxs(_Fragment, {
|
|
131
|
+
children: [/*#__PURE__*/_jsx(ActionButton, {
|
|
132
|
+
label: "Good response",
|
|
133
|
+
"aria-pressed": feedback === "up",
|
|
134
|
+
className: cn(feedback === "up" && "text-foreground"),
|
|
135
|
+
onClick: () => onFeedback(toggledFeedback(feedback, "up")),
|
|
136
|
+
children: /*#__PURE__*/_jsx(ThumbsUpIcon, {
|
|
137
|
+
className: cn(feedback === "up" && "fill-current")
|
|
138
|
+
})
|
|
139
|
+
}), /*#__PURE__*/_jsx(ActionButton, {
|
|
140
|
+
label: "Bad response",
|
|
141
|
+
"aria-pressed": feedback === "down",
|
|
142
|
+
className: cn(feedback === "down" && "text-foreground"),
|
|
143
|
+
onClick: () => onFeedback(toggledFeedback(feedback, "down")),
|
|
144
|
+
children: /*#__PURE__*/_jsx(ThumbsDownIcon, {
|
|
145
|
+
className: cn(feedback === "down" && "fill-current")
|
|
146
|
+
})
|
|
147
|
+
})]
|
|
148
|
+
});
|
|
149
|
+
$[26] = feedback;
|
|
150
|
+
$[27] = onFeedback;
|
|
151
|
+
$[28] = t7;
|
|
152
|
+
} else {
|
|
153
|
+
t7 = $[28];
|
|
154
|
+
}
|
|
155
|
+
let t8;
|
|
156
|
+
if ($[29] !== copied) {
|
|
157
|
+
t8 = copied && /*#__PURE__*/_jsx("span", {
|
|
158
|
+
role: "status",
|
|
159
|
+
className: "sr-only",
|
|
160
|
+
children: "Copied"
|
|
161
|
+
});
|
|
162
|
+
$[29] = copied;
|
|
163
|
+
$[30] = t8;
|
|
164
|
+
} else {
|
|
165
|
+
t8 = $[30];
|
|
166
|
+
}
|
|
167
|
+
let t9;
|
|
168
|
+
if ($[31] !== props || $[32] !== t2 || $[33] !== t3 || $[34] !== t4 || $[35] !== t5 || $[36] !== t6 || $[37] !== t7 || $[38] !== t8) {
|
|
169
|
+
t9 = /*#__PURE__*/_jsx(TooltipProvider, {
|
|
170
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
171
|
+
"data-slot": "actions",
|
|
172
|
+
role: "toolbar",
|
|
173
|
+
"aria-label": "Message actions",
|
|
174
|
+
className: t2,
|
|
175
|
+
...props,
|
|
176
|
+
children: [t3, t4, t5, t6, t7, t8]
|
|
177
|
+
})
|
|
178
|
+
});
|
|
179
|
+
$[31] = props;
|
|
180
|
+
$[32] = t2;
|
|
181
|
+
$[33] = t3;
|
|
182
|
+
$[34] = t4;
|
|
183
|
+
$[35] = t5;
|
|
184
|
+
$[36] = t6;
|
|
185
|
+
$[37] = t7;
|
|
186
|
+
$[38] = t8;
|
|
187
|
+
$[39] = t9;
|
|
188
|
+
} else {
|
|
189
|
+
t9 = $[39];
|
|
190
|
+
}
|
|
191
|
+
return t9;
|
|
21
192
|
}
|