@locusgraph/loop 0.2.1 → 0.3.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.
Files changed (66) hide show
  1. package/dist/agent/pulse/gradient-label.js +64 -12
  2. package/dist/agent/pulse/marks/bars-mark.js +39 -15
  3. package/dist/agent/pulse/marks/glyph-mark.js +56 -15
  4. package/dist/agent/pulse/marks/locus-mark.js +38 -12
  5. package/dist/agent/pulse/marks/orb-mark.js +21 -9
  6. package/dist/agent/pulse/pulse.js +1 -1
  7. package/dist/agent/pulse/use-loop-animation.js +35 -12
  8. package/dist/agent/thinking/thinking.js +2 -2
  9. package/dist/agent/tool/tool-status.js +1 -1
  10. package/dist/approval/inbox/inbox-row.js +303 -76
  11. package/dist/approval/inbox/inbox.js +192 -39
  12. package/dist/approval/inbox/virtual-inbox-list.js +104 -26
  13. package/dist/approval/memory/memory-review.js +172 -36
  14. package/dist/approval/memory/memory-row.js +187 -50
  15. package/dist/approval/plan/plan-review.js +225 -73
  16. package/dist/approval/plan/plan-step-row.js +182 -76
  17. package/dist/approval/plan/question-choices.js +132 -44
  18. package/dist/approval/plan/question.js +156 -38
  19. package/dist/approval/run/run-bar.js +125 -39
  20. package/dist/approval/shared/use-focus-on-mount.js +23 -5
  21. package/dist/approval/spend/raise-cap-form.js +223 -48
  22. package/dist/approval/spend/spend-gate.js +157 -40
  23. package/dist/approval/spend/spend-meter.js +1 -1
  24. package/dist/approval/tool/approval.js +196 -35
  25. package/dist/approval/tool/args/args-editor.js +206 -46
  26. package/dist/approval/tool/args/args-field.js +240 -55
  27. package/dist/approval/tool/deny-form.js +125 -36
  28. package/dist/approval/tool/tool-inputs.js +91 -24
  29. package/dist/chat/chat/use-stick-to-bottom.js +115 -60
  30. package/dist/chat/chat/virtual-chat-items.js +129 -34
  31. package/dist/chat/composer/composer-actions.d.ts +1 -2
  32. package/dist/chat/composer/composer-actions.js +132 -49
  33. package/dist/chat/composer/composer-status.d.ts +2 -0
  34. package/dist/chat/composer/composer-status.js +3 -0
  35. package/dist/chat/composer/composer.d.ts +1 -1
  36. package/dist/chat/composer/composer.js +2 -1
  37. package/dist/chat/composer/use-auto-grow.js +25 -8
  38. package/dist/chat/files/files.js +293 -66
  39. package/dist/chat/index.d.ts +1 -1
  40. package/dist/chat/index.js +1 -1
  41. package/dist/chat/reply/markdown-components.js +2 -2
  42. package/dist/cost/context.js +1 -1
  43. package/dist/cost/cost.js +1 -1
  44. package/dist/cost/model-picker.js +174 -42
  45. package/dist/cost/shared/context-breakdown.js +1 -1
  46. package/dist/memory/cite.js +181 -58
  47. package/dist/memory/memorized.js +197 -43
  48. package/dist/memory/recall.js +265 -68
  49. package/dist/memory/shared/disclosure.d.ts +2 -2
  50. package/dist/memory/shared/disclosure.js +1 -1
  51. package/dist/memory/sources.js +232 -52
  52. package/dist/shared/panel.js +1 -1
  53. package/dist/shared/virtual/use-list-virtualizer.js +2 -0
  54. package/dist/thread/actions/branch-switcher.js +97 -21
  55. package/dist/thread/canvas/canvas.js +1 -1
  56. package/dist/thread/canvas/version-switcher.js +128 -31
  57. package/dist/thread/code/code.js +2 -2
  58. package/dist/thread/code/copy-code-button.js +58 -24
  59. package/dist/thread/history/history.js +1 -1
  60. package/dist/thread/history/row/history-row.js +99 -18
  61. package/dist/thread/history/row/thread-item-menu.js +74 -19
  62. package/dist/thread/history/row/thread-title-editor.js +74 -29
  63. package/dist/thread/history/virtual-history-list.js +84 -46
  64. package/dist/thread/starters/starters.js +89 -27
  65. package/dist/thread/use-copied.js +40 -10
  66. package/package.json +3 -3
@@ -1,3 +1,6 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
1
4
  import { useCallback, useEffect, useRef, useState } from "react";
2
5
  const bottomThresholdPx = 48;
3
6
  function distanceFromBottom(element) {
@@ -10,71 +13,123 @@ function scrolledUpByReader(viewport, previous) {
10
13
  return viewport.scrollTop < previous.top && viewport.scrollHeight === previous.height;
11
14
  }
12
15
  export function useStickToBottom() {
16
+ const $ = _c(8);
13
17
  const viewportRef = useRef(null);
14
18
  const contentRef = useRef(null);
15
19
  const stuckRef = useRef(true);
16
- const lastScrollRef = useRef({
17
- top: 0,
18
- height: 0
19
- });
20
+ let t0;
21
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
22
+ t0 = {
23
+ top: 0,
24
+ height: 0
25
+ };
26
+ $[0] = t0;
27
+ } else {
28
+ t0 = $[0];
29
+ }
30
+ const lastScrollRef = useRef(t0);
20
31
  const [isAtBottom, setIsAtBottom] = useState(true);
21
- const pinToBottom = useCallback(() => {
22
- const viewport = viewportRef.current;
23
- if (viewport) {
24
- viewport.scrollTop = viewport.scrollHeight;
25
- }
26
- }, []);
27
- const handleScroll = useCallback(() => {
28
- const viewport = viewportRef.current;
29
- if (!viewport) {
30
- return;
31
- }
32
- const atBottom = distanceFromBottom(viewport) <= bottomThresholdPx;
33
- const readerScrolledUp = scrolledUpByReader(viewport, lastScrollRef.current);
34
- lastScrollRef.current = {
35
- top: viewport.scrollTop,
36
- height: viewport.scrollHeight
32
+ let t1;
33
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
34
+ t1 = () => {
35
+ const viewport = viewportRef.current;
36
+ if (viewport) {
37
+ viewport.scrollTop = viewport.scrollHeight;
38
+ }
39
+ };
40
+ $[1] = t1;
41
+ } else {
42
+ t1 = $[1];
43
+ }
44
+ const pinToBottom = t1;
45
+ let t2;
46
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
47
+ t2 = () => {
48
+ const viewport_0 = viewportRef.current;
49
+ if (!viewport_0) {
50
+ return;
51
+ }
52
+ const atBottom = distanceFromBottom(viewport_0) <= bottomThresholdPx;
53
+ const readerScrolledUp = scrolledUpByReader(viewport_0, lastScrollRef.current);
54
+ lastScrollRef.current = {
55
+ top: viewport_0.scrollTop,
56
+ height: viewport_0.scrollHeight
57
+ };
58
+ if (atBottom) {
59
+ stuckRef.current = true;
60
+ } else {
61
+ if (readerScrolledUp) {
62
+ stuckRef.current = false;
63
+ } else {
64
+ if (stuckRef.current) {
65
+ pinToBottom();
66
+ }
67
+ }
68
+ }
69
+ setIsAtBottom(stuckRef.current);
37
70
  };
38
- if (atBottom) {
71
+ $[2] = t2;
72
+ } else {
73
+ t2 = $[2];
74
+ }
75
+ const handleScroll = t2;
76
+ let t3;
77
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
78
+ t3 = () => {
79
+ const viewport_1 = viewportRef.current;
80
+ if (!viewport_1) {
81
+ return;
82
+ }
39
83
  stuckRef.current = true;
40
- } else if (readerScrolledUp) {
41
- stuckRef.current = false;
42
- } else if (stuckRef.current) {
43
- pinToBottom();
44
- }
45
- setIsAtBottom(stuckRef.current);
46
- }, [pinToBottom]);
47
- const scrollToLatest = useCallback(() => {
48
- const viewport = viewportRef.current;
49
- if (!viewport) {
50
- return;
51
- }
52
- stuckRef.current = true;
53
- setIsAtBottom(true);
54
- viewport.scrollTo({
55
- top: viewport.scrollHeight,
56
- behavior: prefersReducedMotion() ? "auto" : "smooth"
57
- });
58
- }, []);
59
- useEffect(() => {
60
- const content = contentRef.current;
61
- if (!content || typeof ResizeObserver === "undefined") {
62
- return;
63
- }
64
- pinToBottom();
65
- const observer = new ResizeObserver(() => {
66
- if (stuckRef.current) {
67
- pinToBottom();
84
+ setIsAtBottom(true);
85
+ viewport_1.scrollTo({
86
+ top: viewport_1.scrollHeight,
87
+ behavior: prefersReducedMotion() ? "auto" : "smooth"
88
+ });
89
+ };
90
+ $[3] = t3;
91
+ } else {
92
+ t3 = $[3];
93
+ }
94
+ const scrollToLatest = t3;
95
+ let t4;
96
+ let t5;
97
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
98
+ t4 = () => {
99
+ const content = contentRef.current;
100
+ if (!content || typeof ResizeObserver === "undefined") {
101
+ return;
68
102
  }
69
- });
70
- observer.observe(content);
71
- return () => observer.disconnect();
72
- }, [pinToBottom]);
73
- return {
74
- viewportRef,
75
- contentRef,
76
- isAtBottom,
77
- handleScroll,
78
- scrollToLatest
79
- };
103
+ pinToBottom();
104
+ const observer = new ResizeObserver(() => {
105
+ if (stuckRef.current) {
106
+ pinToBottom();
107
+ }
108
+ });
109
+ observer.observe(content);
110
+ return () => observer.disconnect();
111
+ };
112
+ t5 = [pinToBottom];
113
+ $[4] = t4;
114
+ $[5] = t5;
115
+ } else {
116
+ t4 = $[4];
117
+ t5 = $[5];
118
+ }
119
+ useEffect(t4, t5);
120
+ let t6;
121
+ if ($[6] !== isAtBottom) {
122
+ t6 = {
123
+ viewportRef,
124
+ contentRef,
125
+ isAtBottom,
126
+ handleScroll,
127
+ scrollToLatest
128
+ };
129
+ $[6] = isAtBottom;
130
+ $[7] = t6;
131
+ } else {
132
+ t6 = $[7];
133
+ }
134
+ return t6;
80
135
  }
@@ -1,3 +1,6 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
1
4
  import { cn } from "@locusgraph/components";
2
5
  import { cloneElement, isValidElement, useEffect, useLayoutEffect } from "react";
3
6
  import { rowOffsetStyle, useListVirtualizer, virtualRowClassName } from "../../shared/virtual/use-list-virtualizer.js";
@@ -16,45 +19,137 @@ function withSetPosition(item, index, count) {
16
19
  "aria-setsize": count
17
20
  });
18
21
  }
19
- export function VirtualChatItems({
20
- items,
21
- viewportRef,
22
- onScrollingChange
23
- }) {
22
+ export function VirtualChatItems(t0) {
23
+ const $ = _c(27);
24
+ const {
25
+ items,
26
+ viewportRef,
27
+ onScrollingChange
28
+ } = t0;
29
+ let t1;
30
+ if ($[0] !== viewportRef) {
31
+ t1 = () => viewportRef.current;
32
+ $[0] = viewportRef;
33
+ $[1] = t1;
34
+ } else {
35
+ t1 = $[1];
36
+ }
37
+ let t2;
38
+ if ($[2] !== items) {
39
+ t2 = index => itemKey(items[index], index);
40
+ $[2] = items;
41
+ $[3] = t2;
42
+ } else {
43
+ t2 = $[3];
44
+ }
45
+ let t3;
46
+ if ($[4] !== items.length || $[5] !== t1 || $[6] !== t2) {
47
+ t3 = {
48
+ count: items.length,
49
+ getScrollElement: t1,
50
+ estimateSize: _temp,
51
+ getItemKey: t2,
52
+ anchorTo: "end"
53
+ };
54
+ $[4] = items.length;
55
+ $[5] = t1;
56
+ $[6] = t2;
57
+ $[7] = t3;
58
+ } else {
59
+ t3 = $[7];
60
+ }
24
61
  const {
25
62
  virtualizer,
26
63
  rows,
27
64
  totalSize,
28
65
  isScrolling,
29
66
  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: {
67
+ } = useListVirtualizer(t3);
68
+ let t4;
69
+ let t5;
70
+ if ($[8] !== virtualizer) {
71
+ t4 = () => {
72
+ virtualizer.scrollToEnd();
73
+ };
74
+ t5 = [virtualizer];
75
+ $[8] = virtualizer;
76
+ $[9] = t4;
77
+ $[10] = t5;
78
+ } else {
79
+ t4 = $[9];
80
+ t5 = $[10];
81
+ }
82
+ useLayoutEffect(t4, t5);
83
+ let t6;
84
+ let t7;
85
+ if ($[11] !== isScrolling || $[12] !== onScrollingChange) {
86
+ t6 = () => {
87
+ onScrollingChange(isScrolling);
88
+ };
89
+ t7 = [isScrolling, onScrollingChange];
90
+ $[11] = isScrolling;
91
+ $[12] = onScrollingChange;
92
+ $[13] = t6;
93
+ $[14] = t7;
94
+ } else {
95
+ t6 = $[13];
96
+ t7 = $[14];
97
+ }
98
+ useEffect(t6, t7);
99
+ let t8;
100
+ if ($[15] !== totalSize) {
101
+ t8 = {
47
102
  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
- });
103
+ };
104
+ $[15] = totalSize;
105
+ $[16] = t8;
106
+ } else {
107
+ t8 = $[16];
108
+ }
109
+ let t9;
110
+ if ($[17] !== itemProps || $[18] !== items || $[19] !== rows) {
111
+ let t10;
112
+ if ($[21] !== itemProps || $[22] !== items) {
113
+ t10 = row => /*#__PURE__*/_jsx("div", {
114
+ "data-slot": "chat-item",
115
+ ...itemProps(row.index),
116
+ className: cn(virtualRowClassName, "flex flex-col"),
117
+ style: {
118
+ ...rowOffsetStyle(row.start),
119
+ paddingTop: gapBeforeItem(items, row.index)
120
+ },
121
+ children: withSetPosition(items[row.index], row.index, items.length)
122
+ }, row.key);
123
+ $[21] = itemProps;
124
+ $[22] = items;
125
+ $[23] = t10;
126
+ } else {
127
+ t10 = $[23];
128
+ }
129
+ t9 = rows.map(t10);
130
+ $[17] = itemProps;
131
+ $[18] = items;
132
+ $[19] = rows;
133
+ $[20] = t9;
134
+ } else {
135
+ t9 = $[20];
136
+ }
137
+ let t10;
138
+ if ($[24] !== t8 || $[25] !== t9) {
139
+ t10 = /*#__PURE__*/_jsx("div", {
140
+ "data-slot": "chat-virtual-list",
141
+ className: "relative w-full",
142
+ style: t8,
143
+ children: t9
144
+ });
145
+ $[24] = t8;
146
+ $[25] = t9;
147
+ $[26] = t10;
148
+ } else {
149
+ t10 = $[26];
150
+ }
151
+ return t10;
152
+ }
153
+ function _temp() {
154
+ return estimatedTurnHeightPx;
60
155
  }
@@ -1,5 +1,4 @@
1
- export type ComposerStatus = "ready" | "submitting" | "streaming" | "error";
2
- export declare function isComposerBusy(status: ComposerStatus): boolean;
1
+ import { type ComposerStatus } from "./composer-status.js";
3
2
  type ComposerSubmitProps = {
4
3
  status: ComposerStatus;
5
4
  canSend: boolean;
@@ -1,49 +1,102 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
1
4
  import { ArrowUp as ArrowUpIcon, Attachment as PaperclipIcon, StopFilledAlt as SquareIcon } from "@carbon/icons-react";
2
5
  import { Button } from "@locusgraph/components";
3
6
  import { useRef } from "react";
7
+ import { isComposerBusy } from "./composer-status.js";
4
8
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
5
- export function isComposerBusy(status) {
6
- return status === "submitting" || status === "streaming";
7
- }
8
- export function ComposerSubmit({
9
- status,
10
- canSend,
11
- onStop
12
- }) {
9
+ export function ComposerSubmit(t0) {
10
+ const $ = _c(7);
11
+ const {
12
+ status,
13
+ canSend,
14
+ onStop
15
+ } = t0;
13
16
  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, {
17
+ const t1 = !onStop;
18
+ let t2;
19
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
20
+ t2 = /*#__PURE__*/_jsx(SquareIcon, {
23
21
  "aria-hidden": "true",
24
22
  className: "size-2.5 fill-current"
25
- }), "Stop"]
26
- });
23
+ });
24
+ $[0] = t2;
25
+ } else {
26
+ t2 = $[0];
27
+ }
28
+ let t3;
29
+ if ($[1] !== onStop || $[2] !== t1) {
30
+ t3 = /*#__PURE__*/_jsxs(Button, {
31
+ type: "button",
32
+ size: "sm",
33
+ variant: "outline",
34
+ "data-slot": "composer-stop",
35
+ "aria-label": "Stop",
36
+ disabled: t1,
37
+ onClick: onStop,
38
+ children: [t2, "Stop"]
39
+ });
40
+ $[1] = onStop;
41
+ $[2] = t1;
42
+ $[3] = t3;
43
+ } else {
44
+ t3 = $[3];
45
+ }
46
+ return t3;
27
47
  }
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, {
48
+ const t1 = !canSend;
49
+ let t2;
50
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
51
+ t2 = /*#__PURE__*/_jsx(ArrowUpIcon, {
35
52
  "aria-hidden": "true"
36
- })
37
- });
53
+ });
54
+ $[4] = t2;
55
+ } else {
56
+ t2 = $[4];
57
+ }
58
+ let t3;
59
+ if ($[5] !== t1) {
60
+ t3 = /*#__PURE__*/_jsx(Button, {
61
+ type: "submit",
62
+ size: "icon-sm",
63
+ "data-slot": "composer-send",
64
+ "aria-label": "Send",
65
+ disabled: t1,
66
+ children: t2
67
+ });
68
+ $[5] = t1;
69
+ $[6] = t3;
70
+ } else {
71
+ t3 = $[6];
72
+ }
73
+ return t3;
38
74
  }
39
- export function ComposerAttachButton({
40
- accept,
41
- disabled,
42
- onAttachFiles
43
- }) {
75
+ export function ComposerAttachButton(t0) {
76
+ const $ = _c(12);
77
+ const {
78
+ accept,
79
+ disabled,
80
+ onAttachFiles
81
+ } = t0;
44
82
  const inputRef = useRef(null);
45
- return /*#__PURE__*/_jsxs(_Fragment, {
46
- children: [/*#__PURE__*/_jsx("input", {
83
+ let t1;
84
+ if ($[0] !== onAttachFiles) {
85
+ t1 = event => {
86
+ const picked = Array.from(event.currentTarget.files ?? []);
87
+ event.currentTarget.value = "";
88
+ if (picked.length > 0) {
89
+ onAttachFiles(picked);
90
+ }
91
+ };
92
+ $[0] = onAttachFiles;
93
+ $[1] = t1;
94
+ } else {
95
+ t1 = $[1];
96
+ }
97
+ let t2;
98
+ if ($[2] !== accept || $[3] !== t1) {
99
+ t2 = /*#__PURE__*/_jsx("input", {
47
100
  ref: inputRef,
48
101
  type: "file",
49
102
  multiple: true,
@@ -51,14 +104,30 @@ export function ComposerAttachButton({
51
104
  accept: accept,
52
105
  tabIndex: -1,
53
106
  "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, {
107
+ onChange: t1
108
+ });
109
+ $[2] = accept;
110
+ $[3] = t1;
111
+ $[4] = t2;
112
+ } else {
113
+ t2 = $[4];
114
+ }
115
+ let t3;
116
+ let t4;
117
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
118
+ t3 = () => inputRef.current?.click();
119
+ t4 = /*#__PURE__*/_jsx(PaperclipIcon, {
120
+ "aria-hidden": "true"
121
+ });
122
+ $[5] = t3;
123
+ $[6] = t4;
124
+ } else {
125
+ t3 = $[5];
126
+ t4 = $[6];
127
+ }
128
+ let t5;
129
+ if ($[7] !== disabled) {
130
+ t5 = /*#__PURE__*/_jsx(Button, {
62
131
  type: "button",
63
132
  size: "icon-sm",
64
133
  variant: "ghost",
@@ -66,10 +135,24 @@ export function ComposerAttachButton({
66
135
  "aria-label": "Attach files",
67
136
  className: "text-muted-foreground hover:text-foreground",
68
137
  disabled: disabled,
69
- onClick: () => inputRef.current?.click(),
70
- children: /*#__PURE__*/_jsx(PaperclipIcon, {
71
- "aria-hidden": "true"
72
- })
73
- })]
74
- });
138
+ onClick: t3,
139
+ children: t4
140
+ });
141
+ $[7] = disabled;
142
+ $[8] = t5;
143
+ } else {
144
+ t5 = $[8];
145
+ }
146
+ let t6;
147
+ if ($[9] !== t2 || $[10] !== t5) {
148
+ t6 = /*#__PURE__*/_jsxs(_Fragment, {
149
+ children: [t2, t5]
150
+ });
151
+ $[9] = t2;
152
+ $[10] = t5;
153
+ $[11] = t6;
154
+ } else {
155
+ t6 = $[11];
156
+ }
157
+ return t6;
75
158
  }
@@ -0,0 +1,2 @@
1
+ export type ComposerStatus = "ready" | "submitting" | "streaming" | "error";
2
+ export declare function isComposerBusy(status: ComposerStatus): boolean;
@@ -0,0 +1,3 @@
1
+ export function isComposerBusy(status) {
2
+ return status === "submitting" || status === "streaming";
3
+ }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { type ComposerStatus } from "./composer-actions.js";
2
+ import { type ComposerStatus } from "./composer-status.js";
3
3
  export type ComposerProps = Omit<React.ComponentProps<"form">, "onSubmit" | "children"> & {
4
4
  onSubmit: (text: string, files: File[]) => void;
5
5
  onStop?: () => void;
@@ -3,7 +3,8 @@
3
3
  import { c as _c } from "react/compiler-runtime";
4
4
  import { cn, Textarea } from "@locusgraph/components";
5
5
  import * as React from "react";
6
- import { ComposerAttachButton, ComposerSubmit, isComposerBusy } from "./composer-actions.js";
6
+ import { ComposerAttachButton, ComposerSubmit } from "./composer-actions.js";
7
+ import { isComposerBusy } from "./composer-status.js";
7
8
  import { useAutoGrow } from "./use-auto-grow.js";
8
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
10
  const noFiles = [];
@@ -1,14 +1,31 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
1
4
  import { useLayoutEffect } from "react";
2
5
  function supportsFieldSizing() {
3
6
  return typeof CSS !== "undefined" && CSS.supports?.("field-sizing", "content") === true;
4
7
  }
5
8
  export function useAutoGrow(textareaRef, text) {
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]);
9
+ const $ = _c(4);
10
+ let t0;
11
+ let t1;
12
+ if ($[0] !== text || $[1] !== textareaRef) {
13
+ t0 = () => {
14
+ const textarea = textareaRef.current;
15
+ if (!textarea || supportsFieldSizing() || text === undefined) {
16
+ return;
17
+ }
18
+ textarea.style.height = "auto";
19
+ textarea.style.height = `${textarea.scrollHeight}px`;
20
+ };
21
+ t1 = [textareaRef, text];
22
+ $[0] = text;
23
+ $[1] = textareaRef;
24
+ $[2] = t0;
25
+ $[3] = t1;
26
+ } else {
27
+ t0 = $[2];
28
+ t1 = $[3];
29
+ }
30
+ useLayoutEffect(t0, t1);
14
31
  }