@locusgraph/loop 0.2.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.
Files changed (68) hide show
  1. package/dist/agent/pulse/gradient-label.js +12 -62
  2. package/dist/agent/pulse/marks/bars-mark.js +15 -37
  3. package/dist/agent/pulse/marks/glyph-mark.js +15 -54
  4. package/dist/agent/pulse/marks/locus-mark.js +12 -36
  5. package/dist/agent/pulse/marks/orb-mark.js +9 -19
  6. package/dist/agent/pulse/marks/spinner-mark.js +20 -29
  7. package/dist/agent/pulse/pulse.js +36 -123
  8. package/dist/agent/pulse/use-loop-animation.js +12 -33
  9. package/dist/agent/steps/step-icon.js +26 -96
  10. package/dist/agent/steps/steps.js +47 -210
  11. package/dist/agent/tool/json-block.js +11 -31
  12. package/dist/agent/tool/tool-status.js +12 -35
  13. package/dist/approval/inbox/inbox-row.js +76 -301
  14. package/dist/approval/inbox/inbox.js +39 -190
  15. package/dist/approval/inbox/virtual-inbox-list.js +26 -102
  16. package/dist/approval/memory/memory-review.js +36 -170
  17. package/dist/approval/memory/memory-row.js +50 -185
  18. package/dist/approval/plan/plan-review.js +73 -223
  19. package/dist/approval/plan/plan-step-row.js +76 -180
  20. package/dist/approval/plan/question-choices.js +44 -130
  21. package/dist/approval/plan/question.js +38 -154
  22. package/dist/approval/run/run-bar.js +39 -123
  23. package/dist/approval/shared/risk-badge.js +9 -24
  24. package/dist/approval/shared/use-focus-on-mount.js +5 -21
  25. package/dist/approval/spend/raise-cap-form.js +48 -221
  26. package/dist/approval/spend/spend-gate.js +40 -155
  27. package/dist/approval/spend/spend-meter.js +85 -312
  28. package/dist/approval/tool/approval.js +35 -194
  29. package/dist/approval/tool/args/args-editor.js +46 -204
  30. package/dist/approval/tool/args/args-field.js +55 -238
  31. package/dist/approval/tool/deny-form.js +36 -123
  32. package/dist/approval/tool/tool-inputs.js +23 -88
  33. package/dist/chat/chat/use-stick-to-bottom.js +60 -113
  34. package/dist/chat/chat/virtual-chat-items.js +34 -127
  35. package/dist/chat/composer/composer-actions.js +46 -129
  36. package/dist/chat/composer/use-auto-grow.js +8 -23
  37. package/dist/chat/files/files.js +66 -291
  38. package/dist/chat/reply/fenced-code.js +10 -32
  39. package/dist/chat/reply/reply.js +24 -99
  40. package/dist/chat/turn/turn.js +46 -197
  41. package/dist/cost/context.js +65 -282
  42. package/dist/cost/cost-steps.js +42 -195
  43. package/dist/cost/cost.js +108 -497
  44. package/dist/cost/model-picker.js +42 -172
  45. package/dist/cost/shared/context-breakdown.js +64 -280
  46. package/dist/cost/shared/meter-marks.js +34 -92
  47. package/dist/cost/shared/model-option-row.js +35 -158
  48. package/dist/cost/shared/step-cost-row.js +37 -222
  49. package/dist/memory/cite.js +58 -179
  50. package/dist/memory/memorized.js +42 -194
  51. package/dist/memory/recall.js +68 -263
  52. package/dist/memory/shared/source-mark.js +10 -38
  53. package/dist/memory/sources.js +52 -230
  54. package/dist/shared/decision-summary.js +35 -117
  55. package/dist/shared/panel-empty.js +15 -73
  56. package/dist/shared/panel.js +65 -239
  57. package/dist/shared/status-dot.js +10 -32
  58. package/dist/thread/actions/action-button.js +10 -53
  59. package/dist/thread/actions/branch-switcher.js +21 -95
  60. package/dist/thread/canvas/version-switcher.js +31 -126
  61. package/dist/thread/code/copy-code-button.js +24 -56
  62. package/dist/thread/history/row/history-row.js +18 -97
  63. package/dist/thread/history/row/thread-item-menu.js +19 -72
  64. package/dist/thread/history/row/thread-title-editor.js +29 -72
  65. package/dist/thread/history/virtual-history-list.js +46 -82
  66. package/dist/thread/starters/starters.js +27 -87
  67. package/dist/thread/use-copied.js +10 -38
  68. package/package.json +3 -3
@@ -1,135 +1,48 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { Button, Label, Textarea } from "@locusgraph/components";
3
2
  import { useId, useState } from "react";
4
3
  import { PanelBody, PanelFooter } from "../../shared/panel.js";
5
4
  import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
6
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- export function DenyForm(t0) {
8
- const $ = _c(24);
9
- const {
10
- onDeny,
11
- onBack
12
- } = t0;
6
+ export function DenyForm({
7
+ onDeny,
8
+ onBack
9
+ }) {
13
10
  const [reason, setReason] = useState("");
14
11
  const reasonId = useId();
15
12
  const reasonRef = useFocusOnMount(true);
16
- let t1;
17
- if ($[0] !== reason) {
18
- t1 = reason.trim();
19
- $[0] = reason;
20
- $[1] = t1;
21
- } else {
22
- t1 = $[1];
23
- }
24
- const trimmed = t1;
25
- let t2;
26
- if ($[2] !== onDeny || $[3] !== trimmed) {
27
- t2 = event => {
13
+ const trimmed = reason.trim();
14
+ return /*#__PURE__*/_jsxs("form", {
15
+ "data-slot": "deny-form",
16
+ onSubmit: event => {
28
17
  event.preventDefault();
29
18
  onDeny(trimmed === "" ? undefined : trimmed);
30
- };
31
- $[2] = onDeny;
32
- $[3] = trimmed;
33
- $[4] = t2;
34
- } else {
35
- t2 = $[4];
36
- }
37
- let t3;
38
- if ($[5] !== reasonId) {
39
- t3 = /*#__PURE__*/_jsx(Label, {
40
- htmlFor: reasonId,
41
- className: "text-xs font-normal text-muted-foreground",
42
- children: "Reason for the agent (optional)"
43
- });
44
- $[5] = reasonId;
45
- $[6] = t3;
46
- } else {
47
- t3 = $[6];
48
- }
49
- let t4;
50
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
51
- t4 = event_0 => setReason(event_0.target.value);
52
- $[7] = t4;
53
- } else {
54
- t4 = $[7];
55
- }
56
- let t5;
57
- if ($[8] !== reason || $[9] !== reasonId || $[10] !== reasonRef) {
58
- t5 = /*#__PURE__*/_jsx(Textarea, {
59
- id: reasonId,
60
- ref: reasonRef,
61
- value: reason,
62
- placeholder: "Tell the agent what to do instead",
63
- onChange: t4
64
- });
65
- $[8] = reason;
66
- $[9] = reasonId;
67
- $[10] = reasonRef;
68
- $[11] = t5;
69
- } else {
70
- t5 = $[11];
71
- }
72
- let t6;
73
- if ($[12] !== t3 || $[13] !== t5) {
74
- t6 = /*#__PURE__*/_jsxs(PanelBody, {
19
+ },
20
+ children: [/*#__PURE__*/_jsxs(PanelBody, {
75
21
  className: "gap-2 pt-0",
76
- children: [t3, t5]
77
- });
78
- $[12] = t3;
79
- $[13] = t5;
80
- $[14] = t6;
81
- } else {
82
- t6 = $[14];
83
- }
84
- let t7;
85
- if ($[15] !== onBack) {
86
- t7 = /*#__PURE__*/_jsx(Button, {
87
- type: "button",
88
- variant: "ghost",
89
- size: "sm",
90
- onClick: onBack,
91
- children: "Back"
92
- });
93
- $[15] = onBack;
94
- $[16] = t7;
95
- } else {
96
- t7 = $[16];
97
- }
98
- let t8;
99
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
100
- t8 = /*#__PURE__*/_jsx(Button, {
101
- type: "submit",
102
- variant: "destructive",
103
- size: "sm",
104
- children: "Send denial"
105
- });
106
- $[17] = t8;
107
- } else {
108
- t8 = $[17];
109
- }
110
- let t9;
111
- if ($[18] !== t7) {
112
- t9 = /*#__PURE__*/_jsxs(PanelFooter, {
113
- children: [t7, t8]
114
- });
115
- $[18] = t7;
116
- $[19] = t9;
117
- } else {
118
- t9 = $[19];
119
- }
120
- let t10;
121
- if ($[20] !== t2 || $[21] !== t6 || $[22] !== t9) {
122
- t10 = /*#__PURE__*/_jsxs("form", {
123
- "data-slot": "deny-form",
124
- onSubmit: t2,
125
- children: [t6, t9]
126
- });
127
- $[20] = t2;
128
- $[21] = t6;
129
- $[22] = t9;
130
- $[23] = t10;
131
- } else {
132
- t10 = $[23];
133
- }
134
- return t10;
22
+ children: [/*#__PURE__*/_jsx(Label, {
23
+ htmlFor: reasonId,
24
+ className: "text-xs font-normal text-muted-foreground",
25
+ children: "Reason for the agent (optional)"
26
+ }), /*#__PURE__*/_jsx(Textarea, {
27
+ id: reasonId,
28
+ ref: reasonRef,
29
+ value: reason,
30
+ placeholder: "Tell the agent what to do instead",
31
+ onChange: event => setReason(event.target.value)
32
+ })]
33
+ }), /*#__PURE__*/_jsxs(PanelFooter, {
34
+ children: [/*#__PURE__*/_jsx(Button, {
35
+ type: "button",
36
+ variant: "ghost",
37
+ size: "sm",
38
+ onClick: onBack,
39
+ children: "Back"
40
+ }), /*#__PURE__*/_jsx(Button, {
41
+ type: "submit",
42
+ variant: "destructive",
43
+ size: "sm",
44
+ children: "Send denial"
45
+ })]
46
+ })]
47
+ });
135
48
  }
@@ -1,4 +1,3 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { cn } from "@locusgraph/components";
3
2
  import { useId, useState } from "react";
4
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -37,106 +36,42 @@ export function humanizeKey(key) {
37
36
  function rawJson(input) {
38
37
  return JSON.stringify(input, null, 2) ?? "undefined";
39
38
  }
40
- export function ToolInputs(t0) {
41
- const $ = _c(22);
42
- const {
43
- input,
44
- muted: t1
45
- } = t0;
46
- const muted = t1 === undefined ? false : t1;
39
+ export function ToolInputs({
40
+ input,
41
+ muted = false
42
+ }) {
47
43
  const [showRaw, setShowRaw] = useState(false);
48
44
  const rawId = useId();
49
- let entries;
50
- let t2;
51
- let t3;
52
- let t4;
53
- if ($[0] !== input || $[1] !== muted || $[2] !== showRaw) {
54
- entries = isPlainRecord(input) ? Object.entries(input) : null;
55
- t2 = "tool-inputs";
56
- t3 = "flex flex-col gap-2";
57
- t4 = entries && !showRaw && /*#__PURE__*/_jsxs("dl", {
45
+ const entries = isPlainRecord(input) ? Object.entries(input) : null;
46
+ return /*#__PURE__*/_jsxs("div", {
47
+ "data-slot": "tool-inputs",
48
+ className: "flex flex-col gap-2",
49
+ children: [entries && !showRaw && /*#__PURE__*/_jsxs("dl", {
58
50
  className: cn("-mx-5 flex flex-col divide-y border-y text-sm", muted && "text-muted-foreground"),
59
- children: [entries.map(_temp), entries.length === 0 && /*#__PURE__*/_jsx("div", {
51
+ children: [entries.map(([key, value]) => /*#__PURE__*/_jsxs("div", {
52
+ className: "grid grid-cols-[minmax(0,8.5rem)_minmax(0,1fr)] items-baseline gap-3 px-5 py-2.5",
53
+ children: [/*#__PURE__*/_jsx("dt", {
54
+ className: "text-xs text-muted-foreground",
55
+ children: humanizeKey(key)
56
+ }), /*#__PURE__*/_jsx("dd", {
57
+ className: "font-mono text-sm break-words",
58
+ children: readableValue(value)
59
+ })]
60
+ }, key)), entries.length === 0 && /*#__PURE__*/_jsx("div", {
60
61
  className: "px-5 py-2.5 text-xs text-muted-foreground",
61
62
  children: "No inputs."
62
63
  })]
63
- });
64
- $[0] = input;
65
- $[1] = muted;
66
- $[2] = showRaw;
67
- $[3] = entries;
68
- $[4] = t2;
69
- $[5] = t3;
70
- $[6] = t4;
71
- } else {
72
- entries = $[3];
73
- t2 = $[4];
74
- t3 = $[5];
75
- t4 = $[6];
76
- }
77
- let t5;
78
- if ($[7] !== entries || $[8] !== input || $[9] !== rawId || $[10] !== showRaw) {
79
- t5 = (showRaw || !entries) && /*#__PURE__*/_jsx("pre", {
64
+ }), (showRaw || !entries) && /*#__PURE__*/_jsx("pre", {
80
65
  id: rawId,
81
66
  className: "overflow-x-auto bg-muted/40 p-3 font-mono text-xs",
82
67
  children: rawJson(input)
83
- });
84
- $[7] = entries;
85
- $[8] = input;
86
- $[9] = rawId;
87
- $[10] = showRaw;
88
- $[11] = t5;
89
- } else {
90
- t5 = $[11];
91
- }
92
- let t6;
93
- if ($[12] !== entries || $[13] !== rawId || $[14] !== showRaw) {
94
- t6 = entries && /*#__PURE__*/_jsx("button", {
68
+ }), entries && /*#__PURE__*/_jsx("button", {
95
69
  type: "button",
96
70
  className: "eyebrow self-start outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/70 motion-safe:transition-colors",
97
71
  "aria-expanded": showRaw,
98
72
  "aria-controls": showRaw ? rawId : undefined,
99
- onClick: () => setShowRaw(_temp2),
73
+ onClick: () => setShowRaw(current => !current),
100
74
  children: showRaw ? "Show fields" : "Show raw"
101
- });
102
- $[12] = entries;
103
- $[13] = rawId;
104
- $[14] = showRaw;
105
- $[15] = t6;
106
- } else {
107
- t6 = $[15];
108
- }
109
- let t7;
110
- if ($[16] !== t2 || $[17] !== t3 || $[18] !== t4 || $[19] !== t5 || $[20] !== t6) {
111
- t7 = /*#__PURE__*/_jsxs("div", {
112
- "data-slot": t2,
113
- className: t3,
114
- children: [t4, t5, t6]
115
- });
116
- $[16] = t2;
117
- $[17] = t3;
118
- $[18] = t4;
119
- $[19] = t5;
120
- $[20] = t6;
121
- $[21] = t7;
122
- } else {
123
- t7 = $[21];
124
- }
125
- return t7;
126
- }
127
- function _temp2(current) {
128
- return !current;
129
- }
130
- function _temp(t0) {
131
- const [key, value] = t0;
132
- return /*#__PURE__*/_jsxs("div", {
133
- className: "grid grid-cols-[minmax(0,8.5rem)_minmax(0,1fr)] items-baseline gap-3 px-5 py-2.5",
134
- children: [/*#__PURE__*/_jsx("dt", {
135
- className: "text-xs text-muted-foreground",
136
- children: humanizeKey(key)
137
- }), /*#__PURE__*/_jsx("dd", {
138
- className: "font-mono text-sm break-words",
139
- children: readableValue(value)
140
75
  })]
141
- }, key);
76
+ });
142
77
  }
@@ -1,4 +1,3 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { useCallback, useEffect, useRef, useState } from "react";
3
2
  const bottomThresholdPx = 48;
4
3
  function distanceFromBottom(element) {
@@ -11,123 +10,71 @@ function scrolledUpByReader(viewport, previous) {
11
10
  return viewport.scrollTop < previous.top && viewport.scrollHeight === previous.height;
12
11
  }
13
12
  export function useStickToBottom() {
14
- const $ = _c(8);
15
13
  const viewportRef = useRef(null);
16
14
  const contentRef = useRef(null);
17
15
  const stuckRef = useRef(true);
18
- let t0;
19
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
20
- t0 = {
21
- top: 0,
22
- height: 0
23
- };
24
- $[0] = t0;
25
- } else {
26
- t0 = $[0];
27
- }
28
- const lastScrollRef = useRef(t0);
16
+ const lastScrollRef = useRef({
17
+ top: 0,
18
+ height: 0
19
+ });
29
20
  const [isAtBottom, setIsAtBottom] = useState(true);
30
- let t1;
31
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
32
- t1 = () => {
33
- const viewport = viewportRef.current;
34
- if (viewport) {
35
- viewport.scrollTop = viewport.scrollHeight;
36
- }
37
- };
38
- $[1] = t1;
39
- } else {
40
- t1 = $[1];
41
- }
42
- const pinToBottom = t1;
43
- let t2;
44
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
45
- t2 = () => {
46
- const viewport_0 = viewportRef.current;
47
- if (!viewport_0) {
48
- return;
49
- }
50
- const atBottom = distanceFromBottom(viewport_0) <= bottomThresholdPx;
51
- const readerScrolledUp = scrolledUpByReader(viewport_0, lastScrollRef.current);
52
- lastScrollRef.current = {
53
- top: viewport_0.scrollTop,
54
- height: viewport_0.scrollHeight
55
- };
56
- if (atBottom) {
57
- stuckRef.current = true;
58
- } else {
59
- if (readerScrolledUp) {
60
- stuckRef.current = false;
61
- } else {
62
- if (stuckRef.current) {
63
- pinToBottom();
64
- }
65
- }
66
- }
67
- setIsAtBottom(stuckRef.current);
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
68
37
  };
69
- $[2] = t2;
70
- } else {
71
- t2 = $[2];
72
- }
73
- const handleScroll = t2;
74
- let t3;
75
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
76
- t3 = () => {
77
- const viewport_1 = viewportRef.current;
78
- if (!viewport_1) {
79
- return;
80
- }
38
+ if (atBottom) {
81
39
  stuckRef.current = true;
82
- setIsAtBottom(true);
83
- viewport_1.scrollTo({
84
- top: viewport_1.scrollHeight,
85
- behavior: prefersReducedMotion() ? "auto" : "smooth"
86
- });
87
- };
88
- $[3] = t3;
89
- } else {
90
- t3 = $[3];
91
- }
92
- const scrollToLatest = t3;
93
- let t4;
94
- let t5;
95
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
96
- t4 = () => {
97
- const content = contentRef.current;
98
- if (!content || typeof ResizeObserver === "undefined") {
99
- return;
100
- }
40
+ } else if (readerScrolledUp) {
41
+ stuckRef.current = false;
42
+ } else if (stuckRef.current) {
101
43
  pinToBottom();
102
- const observer = new ResizeObserver(() => {
103
- if (stuckRef.current) {
104
- pinToBottom();
105
- }
106
- });
107
- observer.observe(content);
108
- return () => observer.disconnect();
109
- };
110
- t5 = [pinToBottom];
111
- $[4] = t4;
112
- $[5] = t5;
113
- } else {
114
- t4 = $[4];
115
- t5 = $[5];
116
- }
117
- useEffect(t4, t5);
118
- let t6;
119
- if ($[6] !== isAtBottom) {
120
- t6 = {
121
- viewportRef,
122
- contentRef,
123
- isAtBottom,
124
- handleScroll,
125
- scrollToLatest
126
- };
127
- $[6] = isAtBottom;
128
- $[7] = t6;
129
- } else {
130
- t6 = $[7];
131
- }
132
- return t6;
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();
68
+ }
69
+ });
70
+ observer.observe(content);
71
+ return () => observer.disconnect();
72
+ }, [pinToBottom]);
73
+ return {
74
+ viewportRef,
75
+ contentRef,
76
+ isAtBottom,
77
+ handleScroll,
78
+ scrollToLatest
79
+ };
133
80
  }
@@ -1,4 +1,3 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { cn } from "@locusgraph/components";
3
2
  import { cloneElement, isValidElement, useEffect, useLayoutEffect } from "react";
4
3
  import { rowOffsetStyle, useListVirtualizer, virtualRowClassName } from "../../shared/virtual/use-list-virtualizer.js";
@@ -17,137 +16,45 @@ function withSetPosition(item, index, count) {
17
16
  "aria-setsize": count
18
17
  });
19
18
  }
20
- export function VirtualChatItems(t0) {
21
- const $ = _c(27);
22
- const {
23
- items,
24
- viewportRef,
25
- onScrollingChange
26
- } = t0;
27
- let t1;
28
- if ($[0] !== viewportRef) {
29
- t1 = () => viewportRef.current;
30
- $[0] = viewportRef;
31
- $[1] = t1;
32
- } else {
33
- t1 = $[1];
34
- }
35
- let t2;
36
- if ($[2] !== items) {
37
- t2 = index => itemKey(items[index], index);
38
- $[2] = items;
39
- $[3] = t2;
40
- } else {
41
- t2 = $[3];
42
- }
43
- let t3;
44
- if ($[4] !== items.length || $[5] !== t1 || $[6] !== t2) {
45
- t3 = {
46
- count: items.length,
47
- getScrollElement: t1,
48
- estimateSize: _temp,
49
- getItemKey: t2,
50
- anchorTo: "end"
51
- };
52
- $[4] = items.length;
53
- $[5] = t1;
54
- $[6] = t2;
55
- $[7] = t3;
56
- } else {
57
- t3 = $[7];
58
- }
19
+ export function VirtualChatItems({
20
+ items,
21
+ viewportRef,
22
+ onScrollingChange
23
+ }) {
59
24
  const {
60
25
  virtualizer,
61
26
  rows,
62
27
  totalSize,
63
28
  isScrolling,
64
29
  itemProps
65
- } = useListVirtualizer(t3);
66
- let t4;
67
- let t5;
68
- if ($[8] !== virtualizer) {
69
- t4 = () => {
70
- virtualizer.scrollToEnd();
71
- };
72
- t5 = [virtualizer];
73
- $[8] = virtualizer;
74
- $[9] = t4;
75
- $[10] = t5;
76
- } else {
77
- t4 = $[9];
78
- t5 = $[10];
79
- }
80
- useLayoutEffect(t4, t5);
81
- let t6;
82
- let t7;
83
- if ($[11] !== isScrolling || $[12] !== onScrollingChange) {
84
- t6 = () => {
85
- onScrollingChange(isScrolling);
86
- };
87
- t7 = [isScrolling, onScrollingChange];
88
- $[11] = isScrolling;
89
- $[12] = onScrollingChange;
90
- $[13] = t6;
91
- $[14] = t7;
92
- } else {
93
- t6 = $[13];
94
- t7 = $[14];
95
- }
96
- useEffect(t6, t7);
97
- let t8;
98
- if ($[15] !== totalSize) {
99
- t8 = {
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: {
100
47
  height: totalSize
101
- };
102
- $[15] = totalSize;
103
- $[16] = t8;
104
- } else {
105
- t8 = $[16];
106
- }
107
- let t9;
108
- if ($[17] !== itemProps || $[18] !== items || $[19] !== rows) {
109
- let t10;
110
- if ($[21] !== itemProps || $[22] !== items) {
111
- t10 = row => /*#__PURE__*/_jsx("div", {
112
- "data-slot": "chat-item",
113
- ...itemProps(row.index),
114
- className: cn(virtualRowClassName, "flex flex-col"),
115
- style: {
116
- ...rowOffsetStyle(row.start),
117
- paddingTop: gapBeforeItem(items, row.index)
118
- },
119
- children: withSetPosition(items[row.index], row.index, items.length)
120
- }, row.key);
121
- $[21] = itemProps;
122
- $[22] = items;
123
- $[23] = t10;
124
- } else {
125
- t10 = $[23];
126
- }
127
- t9 = rows.map(t10);
128
- $[17] = itemProps;
129
- $[18] = items;
130
- $[19] = rows;
131
- $[20] = t9;
132
- } else {
133
- t9 = $[20];
134
- }
135
- let t10;
136
- if ($[24] !== t8 || $[25] !== t9) {
137
- t10 = /*#__PURE__*/_jsx("div", {
138
- "data-slot": "chat-virtual-list",
139
- className: "relative w-full",
140
- style: t8,
141
- children: t9
142
- });
143
- $[24] = t8;
144
- $[25] = t9;
145
- $[26] = t10;
146
- } else {
147
- t10 = $[26];
148
- }
149
- return t10;
150
- }
151
- function _temp() {
152
- return estimatedTurnHeightPx;
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
+ });
153
60
  }