@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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { cn } from "@locusgraph/components";
|
|
2
|
+
import { cloneElement, isValidElement, useEffect, useLayoutEffect } from "react";
|
|
3
|
+
import { rowOffsetStyle, useListVirtualizer, virtualRowClassName } from "../../shared/virtual/use-list-virtualizer.js";
|
|
4
|
+
import { gapBeforeItem, isPositionable } from "./chat-item-spacing.js";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const estimatedTurnHeightPx = 180;
|
|
7
|
+
function itemKey(item, index) {
|
|
8
|
+
return isValidElement(item) && item.key !== null ? item.key : index;
|
|
9
|
+
}
|
|
10
|
+
function withSetPosition(item, index, count) {
|
|
11
|
+
if (!isPositionable(item)) {
|
|
12
|
+
return item;
|
|
13
|
+
}
|
|
14
|
+
return cloneElement(item, {
|
|
15
|
+
"aria-posinset": index + 1,
|
|
16
|
+
"aria-setsize": count
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function VirtualChatItems({
|
|
20
|
+
items,
|
|
21
|
+
viewportRef,
|
|
22
|
+
onScrollingChange
|
|
23
|
+
}) {
|
|
24
|
+
const {
|
|
25
|
+
virtualizer,
|
|
26
|
+
rows,
|
|
27
|
+
totalSize,
|
|
28
|
+
isScrolling,
|
|
29
|
+
itemProps
|
|
30
|
+
} = useListVirtualizer({
|
|
31
|
+
count: items.length,
|
|
32
|
+
getScrollElement: () => viewportRef.current,
|
|
33
|
+
estimateSize: () => estimatedTurnHeightPx,
|
|
34
|
+
getItemKey: index => itemKey(items[index], index),
|
|
35
|
+
anchorTo: "end"
|
|
36
|
+
});
|
|
37
|
+
useLayoutEffect(() => {
|
|
38
|
+
virtualizer.scrollToEnd();
|
|
39
|
+
}, [virtualizer]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
onScrollingChange(isScrolling);
|
|
42
|
+
}, [isScrolling, onScrollingChange]);
|
|
43
|
+
return /*#__PURE__*/_jsx("div", {
|
|
44
|
+
"data-slot": "chat-virtual-list",
|
|
45
|
+
className: "relative w-full",
|
|
46
|
+
style: {
|
|
47
|
+
height: totalSize
|
|
48
|
+
},
|
|
49
|
+
children: rows.map(row => /*#__PURE__*/_jsx("div", {
|
|
50
|
+
"data-slot": "chat-item",
|
|
51
|
+
...itemProps(row.index),
|
|
52
|
+
className: cn(virtualRowClassName, "flex flex-col"),
|
|
53
|
+
style: {
|
|
54
|
+
...rowOffsetStyle(row.start),
|
|
55
|
+
paddingTop: gapBeforeItem(items, row.index)
|
|
56
|
+
},
|
|
57
|
+
children: withSetPosition(items[row.index], row.index, items.length)
|
|
58
|
+
}, row.key))
|
|
59
|
+
});
|
|
60
|
+
}
|
|
@@ -1,23 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ArrowUp as ArrowUpIcon, Attachment as PaperclipIcon, StopFilledAlt as SquareIcon, } from "@carbon/icons-react";
|
|
1
|
+
import { ArrowUp as ArrowUpIcon, Attachment as PaperclipIcon, StopFilledAlt as SquareIcon } from "@carbon/icons-react";
|
|
3
2
|
import { Button } from "@locusgraph/components";
|
|
4
3
|
import { useRef } from "react";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
5
5
|
export function isComposerBusy(status) {
|
|
6
|
-
|
|
6
|
+
return status === "submitting" || status === "streaming";
|
|
7
7
|
}
|
|
8
|
-
export function ComposerSubmit({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export function ComposerSubmit({
|
|
9
|
+
status,
|
|
10
|
+
canSend,
|
|
11
|
+
onStop
|
|
12
|
+
}) {
|
|
13
|
+
if (isComposerBusy(status)) {
|
|
14
|
+
return /*#__PURE__*/_jsxs(Button, {
|
|
15
|
+
type: "button",
|
|
16
|
+
size: "sm",
|
|
17
|
+
variant: "outline",
|
|
18
|
+
"data-slot": "composer-stop",
|
|
19
|
+
"aria-label": "Stop",
|
|
20
|
+
disabled: !onStop,
|
|
21
|
+
onClick: onStop,
|
|
22
|
+
children: [/*#__PURE__*/_jsx(SquareIcon, {
|
|
23
|
+
"aria-hidden": "true",
|
|
24
|
+
className: "size-2.5 fill-current"
|
|
25
|
+
}), "Stop"]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
29
|
+
type: "submit",
|
|
30
|
+
size: "icon-sm",
|
|
31
|
+
"data-slot": "composer-send",
|
|
32
|
+
"aria-label": "Send",
|
|
33
|
+
disabled: !canSend,
|
|
34
|
+
children: /*#__PURE__*/_jsx(ArrowUpIcon, {
|
|
35
|
+
"aria-hidden": "true"
|
|
36
|
+
})
|
|
37
|
+
});
|
|
13
38
|
}
|
|
14
|
-
export function ComposerAttachButton({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
export function ComposerAttachButton({
|
|
40
|
+
accept,
|
|
41
|
+
disabled,
|
|
42
|
+
onAttachFiles
|
|
43
|
+
}) {
|
|
44
|
+
const inputRef = useRef(null);
|
|
45
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
46
|
+
children: [/*#__PURE__*/_jsx("input", {
|
|
47
|
+
ref: inputRef,
|
|
48
|
+
type: "file",
|
|
49
|
+
multiple: true,
|
|
50
|
+
hidden: true,
|
|
51
|
+
accept: accept,
|
|
52
|
+
tabIndex: -1,
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
onChange: event => {
|
|
55
|
+
const picked = Array.from(event.currentTarget.files ?? []);
|
|
56
|
+
event.currentTarget.value = "";
|
|
57
|
+
if (picked.length > 0) {
|
|
58
|
+
onAttachFiles(picked);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
62
|
+
type: "button",
|
|
63
|
+
size: "icon-sm",
|
|
64
|
+
variant: "ghost",
|
|
65
|
+
"data-slot": "composer-attach",
|
|
66
|
+
"aria-label": "Attach files",
|
|
67
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
68
|
+
disabled: disabled,
|
|
69
|
+
onClick: () => inputRef.current?.click(),
|
|
70
|
+
children: /*#__PURE__*/_jsx(PaperclipIcon, {
|
|
71
|
+
"aria-hidden": "true"
|
|
72
|
+
})
|
|
73
|
+
})]
|
|
74
|
+
});
|
|
23
75
|
}
|
|
@@ -1,42 +1,340 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
4
|
import { cn, Textarea } from "@locusgraph/components";
|
|
4
5
|
import * as React from "react";
|
|
5
|
-
import { ComposerAttachButton, ComposerSubmit, isComposerBusy
|
|
6
|
+
import { ComposerAttachButton, ComposerSubmit, isComposerBusy } from "./composer-actions.js";
|
|
6
7
|
import { useAutoGrow } from "./use-auto-grow.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
9
|
const noFiles = [];
|
|
8
10
|
function isSendShortcut(event) {
|
|
9
|
-
|
|
11
|
+
return event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing;
|
|
10
12
|
}
|
|
11
|
-
export function Composer(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
export function Composer(t0) {
|
|
14
|
+
const $ = _c(84);
|
|
15
|
+
let accept;
|
|
16
|
+
let attachments;
|
|
17
|
+
let className;
|
|
18
|
+
let errorMessage;
|
|
19
|
+
let modelSlot;
|
|
20
|
+
let onAttachFiles;
|
|
21
|
+
let onStop;
|
|
22
|
+
let onSubmit;
|
|
23
|
+
let onValueChange;
|
|
24
|
+
let props;
|
|
25
|
+
let t1;
|
|
26
|
+
let t2;
|
|
27
|
+
let t3;
|
|
28
|
+
let t4;
|
|
29
|
+
let t5;
|
|
30
|
+
let t6;
|
|
31
|
+
let value;
|
|
32
|
+
if ($[0] !== t0) {
|
|
33
|
+
({
|
|
34
|
+
onSubmit,
|
|
35
|
+
onStop,
|
|
36
|
+
status: t1,
|
|
37
|
+
disabled: t2,
|
|
38
|
+
value,
|
|
39
|
+
defaultValue: t3,
|
|
40
|
+
onValueChange,
|
|
41
|
+
placeholder: t4,
|
|
42
|
+
label: t5,
|
|
43
|
+
files: t6,
|
|
44
|
+
onAttachFiles,
|
|
45
|
+
accept,
|
|
46
|
+
attachments,
|
|
47
|
+
modelSlot,
|
|
48
|
+
errorMessage,
|
|
49
|
+
className,
|
|
50
|
+
...props
|
|
51
|
+
} = t0);
|
|
52
|
+
$[0] = t0;
|
|
53
|
+
$[1] = accept;
|
|
54
|
+
$[2] = attachments;
|
|
55
|
+
$[3] = className;
|
|
56
|
+
$[4] = errorMessage;
|
|
57
|
+
$[5] = modelSlot;
|
|
58
|
+
$[6] = onAttachFiles;
|
|
59
|
+
$[7] = onStop;
|
|
60
|
+
$[8] = onSubmit;
|
|
61
|
+
$[9] = onValueChange;
|
|
62
|
+
$[10] = props;
|
|
63
|
+
$[11] = t1;
|
|
64
|
+
$[12] = t2;
|
|
65
|
+
$[13] = t3;
|
|
66
|
+
$[14] = t4;
|
|
67
|
+
$[15] = t5;
|
|
68
|
+
$[16] = t6;
|
|
69
|
+
$[17] = value;
|
|
70
|
+
} else {
|
|
71
|
+
accept = $[1];
|
|
72
|
+
attachments = $[2];
|
|
73
|
+
className = $[3];
|
|
74
|
+
errorMessage = $[4];
|
|
75
|
+
modelSlot = $[5];
|
|
76
|
+
onAttachFiles = $[6];
|
|
77
|
+
onStop = $[7];
|
|
78
|
+
onSubmit = $[8];
|
|
79
|
+
onValueChange = $[9];
|
|
80
|
+
props = $[10];
|
|
81
|
+
t1 = $[11];
|
|
82
|
+
t2 = $[12];
|
|
83
|
+
t3 = $[13];
|
|
84
|
+
t4 = $[14];
|
|
85
|
+
t5 = $[15];
|
|
86
|
+
t6 = $[16];
|
|
87
|
+
value = $[17];
|
|
88
|
+
}
|
|
89
|
+
const status = t1 === undefined ? "ready" : t1;
|
|
90
|
+
const disabled = t2 === undefined ? false : t2;
|
|
91
|
+
const defaultValue = t3 === undefined ? "" : t3;
|
|
92
|
+
const placeholder = t4 === undefined ? "Ask the agent\u2026" : t4;
|
|
93
|
+
const label = t5 === undefined ? "Message" : t5;
|
|
94
|
+
const files = t6 === undefined ? noFiles : t6;
|
|
95
|
+
const [uncontrolledText, setUncontrolledText] = React.useState(defaultValue);
|
|
96
|
+
const text = value ?? uncontrolledText;
|
|
97
|
+
const errorId = React.useId();
|
|
98
|
+
const textareaRef = React.useRef(null);
|
|
99
|
+
useAutoGrow(textareaRef, text);
|
|
100
|
+
let t7;
|
|
101
|
+
if ($[18] !== status) {
|
|
102
|
+
t7 = isComposerBusy(status);
|
|
103
|
+
$[18] = status;
|
|
104
|
+
$[19] = t7;
|
|
105
|
+
} else {
|
|
106
|
+
t7 = $[19];
|
|
107
|
+
}
|
|
108
|
+
const isBusy = t7;
|
|
109
|
+
let t8;
|
|
110
|
+
if ($[20] !== disabled || $[21] !== files || $[22] !== isBusy || $[23] !== text) {
|
|
111
|
+
t8 = !disabled && !isBusy && (text.trim().length > 0 || files.length > 0);
|
|
112
|
+
$[20] = disabled;
|
|
113
|
+
$[21] = files;
|
|
114
|
+
$[22] = isBusy;
|
|
115
|
+
$[23] = text;
|
|
116
|
+
$[24] = t8;
|
|
117
|
+
} else {
|
|
118
|
+
t8 = $[24];
|
|
119
|
+
}
|
|
120
|
+
const canSend = t8;
|
|
121
|
+
let t9;
|
|
122
|
+
if ($[25] !== onValueChange || $[26] !== value) {
|
|
123
|
+
t9 = next => {
|
|
124
|
+
if (value === undefined) {
|
|
125
|
+
setUncontrolledText(next);
|
|
126
|
+
}
|
|
127
|
+
onValueChange?.(next);
|
|
128
|
+
};
|
|
129
|
+
$[25] = onValueChange;
|
|
130
|
+
$[26] = value;
|
|
131
|
+
$[27] = t9;
|
|
132
|
+
} else {
|
|
133
|
+
t9 = $[27];
|
|
134
|
+
}
|
|
135
|
+
const changeText = t9;
|
|
136
|
+
let t10;
|
|
137
|
+
if ($[28] !== canSend || $[29] !== changeText || $[30] !== files || $[31] !== onSubmit || $[32] !== text) {
|
|
138
|
+
t10 = () => {
|
|
139
|
+
if (!canSend) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
onSubmit(text.trim(), files);
|
|
143
|
+
changeText("");
|
|
144
|
+
};
|
|
145
|
+
$[28] = canSend;
|
|
146
|
+
$[29] = changeText;
|
|
147
|
+
$[30] = files;
|
|
148
|
+
$[31] = onSubmit;
|
|
149
|
+
$[32] = text;
|
|
150
|
+
$[33] = t10;
|
|
151
|
+
} else {
|
|
152
|
+
t10 = $[33];
|
|
153
|
+
}
|
|
154
|
+
const send = t10;
|
|
155
|
+
const showError = status === "error" && errorMessage;
|
|
156
|
+
const t11 = disabled || undefined;
|
|
157
|
+
const t12 = isBusy || undefined;
|
|
158
|
+
let t13;
|
|
159
|
+
if ($[34] !== className) {
|
|
160
|
+
t13 = cn("flex flex-col bg-card text-card-foreground ring-1 ring-border transition-shadow focus-within:ring-foreground/40 data-[status=error]:ring-destructive/60 data-disabled:opacity-60", className);
|
|
161
|
+
$[34] = className;
|
|
162
|
+
$[35] = t13;
|
|
163
|
+
} else {
|
|
164
|
+
t13 = $[35];
|
|
165
|
+
}
|
|
166
|
+
let t14;
|
|
167
|
+
if ($[36] !== send) {
|
|
168
|
+
t14 = event => {
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
send();
|
|
24
171
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
172
|
+
$[36] = send;
|
|
173
|
+
$[37] = t14;
|
|
174
|
+
} else {
|
|
175
|
+
t14 = $[37];
|
|
176
|
+
}
|
|
177
|
+
let t15;
|
|
178
|
+
if ($[38] !== attachments) {
|
|
179
|
+
t15 = attachments && /*#__PURE__*/_jsx("div", {
|
|
180
|
+
"data-slot": "composer-attachments",
|
|
181
|
+
className: "px-3 pt-3 empty:hidden",
|
|
182
|
+
children: attachments
|
|
183
|
+
});
|
|
184
|
+
$[38] = attachments;
|
|
185
|
+
$[39] = t15;
|
|
186
|
+
} else {
|
|
187
|
+
t15 = $[39];
|
|
188
|
+
}
|
|
189
|
+
const t16 = status === "error" || undefined;
|
|
190
|
+
const t17 = showError ? errorId : undefined;
|
|
191
|
+
let t18;
|
|
192
|
+
if ($[40] !== changeText) {
|
|
193
|
+
t18 = event_0 => changeText(event_0.currentTarget.value);
|
|
194
|
+
$[40] = changeText;
|
|
195
|
+
$[41] = t18;
|
|
196
|
+
} else {
|
|
197
|
+
t18 = $[41];
|
|
198
|
+
}
|
|
199
|
+
let t19;
|
|
200
|
+
if ($[42] !== send) {
|
|
201
|
+
t19 = event_1 => {
|
|
202
|
+
if (isSendShortcut(event_1)) {
|
|
203
|
+
event_1.preventDefault();
|
|
204
|
+
send();
|
|
205
|
+
}
|
|
31
206
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
207
|
+
$[42] = send;
|
|
208
|
+
$[43] = t19;
|
|
209
|
+
} else {
|
|
210
|
+
t19 = $[43];
|
|
211
|
+
}
|
|
212
|
+
let t20;
|
|
213
|
+
if ($[44] !== disabled || $[45] !== label || $[46] !== placeholder || $[47] !== t16 || $[48] !== t17 || $[49] !== t18 || $[50] !== t19 || $[51] !== text) {
|
|
214
|
+
t20 = /*#__PURE__*/_jsx(Textarea, {
|
|
215
|
+
ref: textareaRef,
|
|
216
|
+
"aria-label": label,
|
|
217
|
+
"aria-invalid": t16,
|
|
218
|
+
"aria-describedby": t17,
|
|
219
|
+
placeholder: placeholder,
|
|
220
|
+
disabled: disabled,
|
|
221
|
+
value: text,
|
|
222
|
+
rows: 1,
|
|
223
|
+
onChange: t18,
|
|
224
|
+
onKeyDown: t19,
|
|
225
|
+
className: "max-h-48 min-h-14 resize-none border-0 bg-transparent px-4 pt-3.5 pb-1 text-sm leading-relaxed shadow-none placeholder:text-muted-foreground/80 focus-visible:ring-0 dark:bg-transparent"
|
|
226
|
+
});
|
|
227
|
+
$[44] = disabled;
|
|
228
|
+
$[45] = label;
|
|
229
|
+
$[46] = placeholder;
|
|
230
|
+
$[47] = t16;
|
|
231
|
+
$[48] = t17;
|
|
232
|
+
$[49] = t18;
|
|
233
|
+
$[50] = t19;
|
|
234
|
+
$[51] = text;
|
|
235
|
+
$[52] = t20;
|
|
236
|
+
} else {
|
|
237
|
+
t20 = $[52];
|
|
238
|
+
}
|
|
239
|
+
let t21;
|
|
240
|
+
if ($[53] !== errorId || $[54] !== errorMessage || $[55] !== showError) {
|
|
241
|
+
t21 = showError && /*#__PURE__*/_jsx("p", {
|
|
242
|
+
id: errorId,
|
|
243
|
+
role: "alert",
|
|
244
|
+
className: "px-4 pt-1 text-xs text-destructive",
|
|
245
|
+
children: errorMessage
|
|
246
|
+
});
|
|
247
|
+
$[53] = errorId;
|
|
248
|
+
$[54] = errorMessage;
|
|
249
|
+
$[55] = showError;
|
|
250
|
+
$[56] = t21;
|
|
251
|
+
} else {
|
|
252
|
+
t21 = $[56];
|
|
253
|
+
}
|
|
254
|
+
let t22;
|
|
255
|
+
if ($[57] !== accept || $[58] !== disabled || $[59] !== isBusy || $[60] !== onAttachFiles) {
|
|
256
|
+
t22 = onAttachFiles && /*#__PURE__*/_jsx(ComposerAttachButton, {
|
|
257
|
+
accept: accept,
|
|
258
|
+
disabled: disabled || isBusy,
|
|
259
|
+
onAttachFiles: onAttachFiles
|
|
260
|
+
});
|
|
261
|
+
$[57] = accept;
|
|
262
|
+
$[58] = disabled;
|
|
263
|
+
$[59] = isBusy;
|
|
264
|
+
$[60] = onAttachFiles;
|
|
265
|
+
$[61] = t22;
|
|
266
|
+
} else {
|
|
267
|
+
t22 = $[61];
|
|
268
|
+
}
|
|
269
|
+
let t23;
|
|
270
|
+
if ($[62] !== disabled || $[63] !== modelSlot) {
|
|
271
|
+
t23 = modelSlot && /*#__PURE__*/_jsx("div", {
|
|
272
|
+
"data-slot": "composer-model",
|
|
273
|
+
className: cn("min-w-0", disabled && "pointer-events-none opacity-50"),
|
|
274
|
+
children: modelSlot
|
|
275
|
+
});
|
|
276
|
+
$[62] = disabled;
|
|
277
|
+
$[63] = modelSlot;
|
|
278
|
+
$[64] = t23;
|
|
279
|
+
} else {
|
|
280
|
+
t23 = $[64];
|
|
281
|
+
}
|
|
282
|
+
let t24;
|
|
283
|
+
if ($[65] !== canSend || $[66] !== onStop || $[67] !== status) {
|
|
284
|
+
t24 = /*#__PURE__*/_jsx("div", {
|
|
285
|
+
className: "ml-auto",
|
|
286
|
+
children: /*#__PURE__*/_jsx(ComposerSubmit, {
|
|
287
|
+
status: status,
|
|
288
|
+
canSend: canSend,
|
|
289
|
+
onStop: onStop
|
|
290
|
+
})
|
|
291
|
+
});
|
|
292
|
+
$[65] = canSend;
|
|
293
|
+
$[66] = onStop;
|
|
294
|
+
$[67] = status;
|
|
295
|
+
$[68] = t24;
|
|
296
|
+
} else {
|
|
297
|
+
t24 = $[68];
|
|
298
|
+
}
|
|
299
|
+
let t25;
|
|
300
|
+
if ($[69] !== t22 || $[70] !== t23 || $[71] !== t24) {
|
|
301
|
+
t25 = /*#__PURE__*/_jsxs("div", {
|
|
302
|
+
"data-slot": "composer-toolbar",
|
|
303
|
+
className: "flex items-center gap-1 px-2.5 pt-1 pb-2.5",
|
|
304
|
+
children: [t22, t23, t24]
|
|
305
|
+
});
|
|
306
|
+
$[69] = t22;
|
|
307
|
+
$[70] = t23;
|
|
308
|
+
$[71] = t24;
|
|
309
|
+
$[72] = t25;
|
|
310
|
+
} else {
|
|
311
|
+
t25 = $[72];
|
|
312
|
+
}
|
|
313
|
+
let t26;
|
|
314
|
+
if ($[73] !== props || $[74] !== status || $[75] !== t11 || $[76] !== t12 || $[77] !== t13 || $[78] !== t14 || $[79] !== t15 || $[80] !== t20 || $[81] !== t21 || $[82] !== t25) {
|
|
315
|
+
t26 = /*#__PURE__*/_jsxs("form", {
|
|
316
|
+
"data-slot": "composer",
|
|
317
|
+
"data-status": status,
|
|
318
|
+
"data-disabled": t11,
|
|
319
|
+
"aria-busy": t12,
|
|
320
|
+
className: t13,
|
|
321
|
+
onSubmit: t14,
|
|
322
|
+
...props,
|
|
323
|
+
children: [t15, t20, t21, t25]
|
|
324
|
+
});
|
|
325
|
+
$[73] = props;
|
|
326
|
+
$[74] = status;
|
|
327
|
+
$[75] = t11;
|
|
328
|
+
$[76] = t12;
|
|
329
|
+
$[77] = t13;
|
|
330
|
+
$[78] = t14;
|
|
331
|
+
$[79] = t15;
|
|
332
|
+
$[80] = t20;
|
|
333
|
+
$[81] = t21;
|
|
334
|
+
$[82] = t25;
|
|
335
|
+
$[83] = t26;
|
|
336
|
+
} else {
|
|
337
|
+
t26 = $[83];
|
|
338
|
+
}
|
|
339
|
+
return t26;
|
|
42
340
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useLayoutEffect } from "react";
|
|
2
2
|
function supportsFieldSizing() {
|
|
3
|
-
|
|
3
|
+
return typeof CSS !== "undefined" && CSS.supports?.("field-sizing", "content") === true;
|
|
4
4
|
}
|
|
5
5
|
export function useAutoGrow(textareaRef, text) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
useLayoutEffect(() => {
|
|
7
|
+
const textarea = textareaRef.current;
|
|
8
|
+
if (!textarea || supportsFieldSizing() || text === undefined) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
textarea.style.height = "auto";
|
|
12
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
13
|
+
}, [textareaRef, text]);
|
|
14
14
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
const byteUnits = ["B", "KB", "MB", "GB"];
|
|
2
2
|
export function formatBytes(bytes) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
let value = bytes;
|
|
4
|
+
let unitIndex = 0;
|
|
5
|
+
while (value >= 1024 && unitIndex < byteUnits.length - 1) {
|
|
6
|
+
value /= 1024;
|
|
7
|
+
unitIndex += 1;
|
|
8
|
+
}
|
|
9
|
+
const rounded = unitIndex === 0 || value >= 10 ? Math.round(value) : Math.round(value * 10) / 10;
|
|
10
|
+
return `${rounded} ${byteUnits[unitIndex]}`;
|
|
11
11
|
}
|
|
12
12
|
export function isImageFile(item) {
|
|
13
|
-
|
|
13
|
+
return Boolean(item.url && item.mediaType?.startsWith("image/"));
|
|
14
14
|
}
|
|
15
15
|
export function fileExtensionLabel(item) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const extension = item.name.includes(".") ? item.name.split(".").at(-1) : undefined;
|
|
17
|
+
return extension ? extension.toUpperCase() : undefined;
|
|
18
18
|
}
|
|
19
19
|
export function filenameFromUrl(url) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const lastSegment = url.split(/[?#]/)[0]?.split("/").at(-1);
|
|
21
|
+
return lastSegment && !url.startsWith("data:") ? decodeURIComponent(lastSegment) : "Attachment";
|
|
22
22
|
}
|
|
23
23
|
export function fileFromFilePart(part, index) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
return {
|
|
25
|
+
id: `${index}:${part.url.slice(0, 64)}`,
|
|
26
|
+
name: part.filename ?? filenameFromUrl(part.url),
|
|
27
|
+
mediaType: part.mediaType,
|
|
28
|
+
url: part.url
|
|
29
|
+
};
|
|
30
30
|
}
|