@locusgraph/loop 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/pulse/gradient-label.js +86 -15
  3. package/dist/agent/pulse/marks/bars-mark.js +46 -10
  4. package/dist/agent/pulse/marks/glyph-mark.js +56 -11
  5. package/dist/agent/pulse/marks/locus-mark.js +63 -28
  6. package/dist/agent/pulse/marks/orb-mark.js +31 -8
  7. package/dist/agent/pulse/marks/spinner-mark.js +29 -1
  8. package/dist/agent/pulse/pulse.js +150 -35
  9. package/dist/agent/pulse/use-loop-animation.js +36 -17
  10. package/dist/agent/steps/step-icon.js +110 -24
  11. package/dist/agent/steps/steps.js +235 -25
  12. package/dist/agent/thinking/thinking.js +203 -23
  13. package/dist/agent/thinking/thought-duration.js +7 -9
  14. package/dist/agent/tool/json-block.js +38 -11
  15. package/dist/agent/tool/tool-status.js +51 -18
  16. package/dist/agent/tool/tool.js +184 -6
  17. package/dist/approval/inbox/inbox-row.d.ts +3 -2
  18. package/dist/approval/inbox/inbox-row.js +321 -7
  19. package/dist/approval/inbox/inbox-selection.js +7 -13
  20. package/dist/approval/inbox/inbox.d.ts +2 -1
  21. package/dist/approval/inbox/inbox.js +250 -18
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  23. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  24. package/dist/approval/memory/memory-choices.js +27 -22
  25. package/dist/approval/memory/memory-review.js +242 -17
  26. package/dist/approval/memory/memory-row.js +215 -19
  27. package/dist/approval/plan/plan-review.js +279 -28
  28. package/dist/approval/plan/plan-step-row.js +194 -43
  29. package/dist/approval/plan/plan-steps.js +24 -23
  30. package/dist/approval/plan/question-choices.js +158 -39
  31. package/dist/approval/plan/question.d.ts +1 -1
  32. package/dist/approval/plan/question.js +223 -26
  33. package/dist/approval/run/run-bar.js +178 -22
  34. package/dist/approval/shared/decision-line.js +1 -1
  35. package/dist/approval/shared/risk-badge.js +47 -16
  36. package/dist/approval/shared/time.js +5 -8
  37. package/dist/approval/shared/use-focus-on-mount.js +23 -6
  38. package/dist/approval/spend/raise-cap-form.js +235 -17
  39. package/dist/approval/spend/spend-gate.js +239 -21
  40. package/dist/approval/spend/spend-math.js +7 -8
  41. package/dist/approval/spend/spend-meter.js +362 -34
  42. package/dist/approval/tool/approval.js +272 -27
  43. package/dist/approval/tool/args/args-editor.js +262 -26
  44. package/dist/approval/tool/args/args-field.js +259 -19
  45. package/dist/approval/tool/args/args-validation.js +38 -47
  46. package/dist/approval/tool/deny-form.js +130 -10
  47. package/dist/approval/tool/tool-inputs.js +127 -38
  48. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  49. package/dist/chat/chat/chat-item-spacing.js +19 -0
  50. package/dist/chat/chat/chat.d.ts +2 -1
  51. package/dist/chat/chat/chat.js +181 -5
  52. package/dist/chat/chat/use-stick-to-bottom.js +123 -47
  53. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  54. package/dist/chat/chat/virtual-chat-items.js +153 -0
  55. package/dist/chat/composer/composer-actions.js +151 -16
  56. package/dist/chat/composer/composer.js +330 -32
  57. package/dist/chat/composer/use-auto-grow.js +24 -9
  58. package/dist/chat/files/file-meta.js +19 -19
  59. package/dist/chat/files/files.js +316 -28
  60. package/dist/chat/reply/fenced-code.js +45 -21
  61. package/dist/chat/reply/markdown-components.js +137 -17
  62. package/dist/chat/reply/reply.js +105 -10
  63. package/dist/chat/turn/group-parts.js +43 -29
  64. package/dist/chat/turn/turn.js +238 -30
  65. package/dist/cost/context.js +321 -23
  66. package/dist/cost/cost-steps.js +220 -14
  67. package/dist/cost/cost.js +521 -27
  68. package/dist/cost/model-picker.js +181 -6
  69. package/dist/cost/shared/context-breakdown.js +299 -10
  70. package/dist/cost/shared/meter-marks.js +107 -9
  71. package/dist/cost/shared/model-option-row.js +178 -21
  72. package/dist/cost/shared/step-cost-row.js +248 -20
  73. package/dist/cost/shared/usage-totals.js +22 -18
  74. package/dist/memory/cite.js +182 -11
  75. package/dist/memory/memorized.js +217 -11
  76. package/dist/memory/recall.js +296 -17
  77. package/dist/memory/shared/host-label.js +19 -22
  78. package/dist/memory/shared/source-mark.js +39 -3
  79. package/dist/memory/sources.js +255 -13
  80. package/dist/shared/decision-summary.js +133 -14
  81. package/dist/shared/panel-empty.js +78 -3
  82. package/dist/shared/panel.js +243 -13
  83. package/dist/shared/status-dot.js +38 -8
  84. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  85. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  86. package/dist/thread/actions/action-button.js +65 -3
  87. package/dist/thread/actions/actions.js +184 -13
  88. package/dist/thread/actions/branch-switcher.js +102 -5
  89. package/dist/thread/canvas/canvas.js +205 -5
  90. package/dist/thread/canvas/version-switcher.js +149 -8
  91. package/dist/thread/code/code.js +186 -24
  92. package/dist/thread/code/copy-code-button.js +61 -13
  93. package/dist/thread/code/highlight.js +30 -29
  94. package/dist/thread/history/history-rows.d.ts +16 -0
  95. package/dist/thread/history/history-rows.js +23 -0
  96. package/dist/thread/history/history.d.ts +3 -2
  97. package/dist/thread/history/history.js +174 -5
  98. package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
  99. package/dist/thread/history/row/history-row.js +137 -0
  100. package/dist/thread/history/row/thread-item-menu.js +84 -0
  101. package/dist/thread/history/row/thread-title-editor.js +81 -0
  102. package/dist/thread/history/thread-groups.d.ts +1 -1
  103. package/dist/thread/history/thread-groups.js +40 -34
  104. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  105. package/dist/thread/history/virtual-history-list.js +107 -0
  106. package/dist/thread/index.d.ts +1 -1
  107. package/dist/thread/starters/starters.js +92 -7
  108. package/dist/thread/use-copied.js +45 -15
  109. package/dist/types.js +1 -1
  110. package/package.json +6 -4
  111. package/dist/thread/history/history-row.js +0 -17
  112. package/dist/thread/history/thread-item-menu.js +0 -6
  113. package/dist/thread/history/thread-title-editor.js +0 -25
  114. /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
  115. /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
@@ -1,11 +1,152 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { ChevronDown as ChevronDownIcon } from "@carbon/icons-react";
3
- import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from "@locusgraph/components";
3
+ import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger } from "@locusgraph/components";
4
4
  import { formatDate } from "@locusgraph/utils";
5
- export function VersionSwitcher({ versions, current, onVersionChange }) {
6
- const label = (_jsxs("span", { className: "flex items-center gap-2 font-mono text-[11px] tabular-nums", children: [_jsx("span", { "data-slot": "canvas-current-version", children: current.label }), versions.length > 1 && _jsxs("span", { className: "text-muted-foreground", children: ["of ", versions.length] }), _jsx("time", { dateTime: current.createdAt, className: "text-muted-foreground", children: formatDate(current.createdAt) })] }));
7
- if (versions.length < 2 || !onVersionChange) {
8
- return label;
9
- }
10
- return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "ghost", size: "xs", className: "-ml-2 font-normal", "aria-label": `Version ${current.label}, choose another version`, children: [label, _jsx(ChevronDownIcon, {})] }) }), _jsx(DropdownMenuContent, { align: "start", sideOffset: 6, children: _jsx(DropdownMenuRadioGroup, { value: current.id, onValueChange: onVersionChange, children: versions.map((version) => (_jsxs(DropdownMenuRadioItem, { value: version.id, children: [_jsx("span", { className: "font-mono text-xs", children: version.label }), _jsx("span", { className: "ml-auto pl-4 text-xs text-muted-foreground", children: formatDate(version.createdAt) })] }, version.id))) }) })] }));
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ export function VersionSwitcher(t0) {
7
+ const $ = _c(26);
8
+ const {
9
+ versions,
10
+ current,
11
+ onVersionChange
12
+ } = t0;
13
+ let t1;
14
+ if ($[0] !== current.label) {
15
+ t1 = /*#__PURE__*/_jsx("span", {
16
+ "data-slot": "canvas-current-version",
17
+ children: current.label
18
+ });
19
+ $[0] = current.label;
20
+ $[1] = t1;
21
+ } else {
22
+ t1 = $[1];
23
+ }
24
+ let t2;
25
+ if ($[2] !== versions.length) {
26
+ t2 = versions.length > 1 && /*#__PURE__*/_jsxs("span", {
27
+ className: "text-muted-foreground",
28
+ children: ["of ", versions.length]
29
+ });
30
+ $[2] = versions.length;
31
+ $[3] = t2;
32
+ } else {
33
+ t2 = $[3];
34
+ }
35
+ const t3 = current.createdAt;
36
+ let t4;
37
+ if ($[4] !== current.createdAt) {
38
+ t4 = formatDate(current.createdAt);
39
+ $[4] = current.createdAt;
40
+ $[5] = t4;
41
+ } else {
42
+ t4 = $[5];
43
+ }
44
+ let t5;
45
+ if ($[6] !== current.createdAt || $[7] !== t4) {
46
+ t5 = /*#__PURE__*/_jsx("time", {
47
+ dateTime: t3,
48
+ className: "text-muted-foreground",
49
+ children: t4
50
+ });
51
+ $[6] = current.createdAt;
52
+ $[7] = t4;
53
+ $[8] = t5;
54
+ } else {
55
+ t5 = $[8];
56
+ }
57
+ let t6;
58
+ if ($[9] !== t1 || $[10] !== t2 || $[11] !== t5) {
59
+ t6 = /*#__PURE__*/_jsxs("span", {
60
+ className: "flex items-center gap-2 font-mono text-[11px] tabular-nums",
61
+ children: [t1, t2, t5]
62
+ });
63
+ $[9] = t1;
64
+ $[10] = t2;
65
+ $[11] = t5;
66
+ $[12] = t6;
67
+ } else {
68
+ t6 = $[12];
69
+ }
70
+ const label = t6;
71
+ if (versions.length < 2 || !onVersionChange) {
72
+ return label;
73
+ }
74
+ const t7 = `Version ${current.label}, choose another version`;
75
+ let t8;
76
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
77
+ t8 = /*#__PURE__*/_jsx(ChevronDownIcon, {});
78
+ $[13] = t8;
79
+ } else {
80
+ t8 = $[13];
81
+ }
82
+ let t9;
83
+ if ($[14] !== label || $[15] !== t7) {
84
+ t9 = /*#__PURE__*/_jsx(DropdownMenuTrigger, {
85
+ asChild: true,
86
+ children: /*#__PURE__*/_jsxs(Button, {
87
+ type: "button",
88
+ variant: "ghost",
89
+ size: "xs",
90
+ className: "-ml-2 font-normal",
91
+ "aria-label": t7,
92
+ children: [label, t8]
93
+ })
94
+ });
95
+ $[14] = label;
96
+ $[15] = t7;
97
+ $[16] = t9;
98
+ } else {
99
+ t9 = $[16];
100
+ }
101
+ const t10 = current.id;
102
+ let t11;
103
+ if ($[17] !== versions) {
104
+ t11 = versions.map(_temp);
105
+ $[17] = versions;
106
+ $[18] = t11;
107
+ } else {
108
+ t11 = $[18];
109
+ }
110
+ let t12;
111
+ if ($[19] !== current.id || $[20] !== onVersionChange || $[21] !== t11) {
112
+ t12 = /*#__PURE__*/_jsx(DropdownMenuContent, {
113
+ align: "start",
114
+ sideOffset: 6,
115
+ children: /*#__PURE__*/_jsx(DropdownMenuRadioGroup, {
116
+ value: t10,
117
+ onValueChange: onVersionChange,
118
+ children: t11
119
+ })
120
+ });
121
+ $[19] = current.id;
122
+ $[20] = onVersionChange;
123
+ $[21] = t11;
124
+ $[22] = t12;
125
+ } else {
126
+ t12 = $[22];
127
+ }
128
+ let t13;
129
+ if ($[23] !== t12 || $[24] !== t9) {
130
+ t13 = /*#__PURE__*/_jsxs(DropdownMenu, {
131
+ children: [t9, t12]
132
+ });
133
+ $[23] = t12;
134
+ $[24] = t9;
135
+ $[25] = t13;
136
+ } else {
137
+ t13 = $[25];
138
+ }
139
+ return t13;
140
+ }
141
+ function _temp(version) {
142
+ return /*#__PURE__*/_jsxs(DropdownMenuRadioItem, {
143
+ value: version.id,
144
+ children: [/*#__PURE__*/_jsx("span", {
145
+ className: "font-mono text-xs",
146
+ children: version.label
147
+ }), /*#__PURE__*/_jsx("span", {
148
+ className: "ml-auto pl-4 text-xs text-muted-foreground",
149
+ children: formatDate(version.createdAt)
150
+ })]
151
+ }, version.id);
11
152
  }
@@ -1,33 +1,195 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
3
4
  import { cn } from "@locusgraph/components";
4
5
  import { useEffect, useState } from "react";
5
6
  import { CopyCodeButton } from "./copy-code-button.js";
6
7
  import { highlightToHtml } from "./highlight.js";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
9
  const codeAreaClass = cn("overflow-x-auto bg-muted/40 px-4 py-3 font-mono text-xs leading-relaxed", "[&_pre]:bg-transparent! [&_pre]:outline-none", "[&_.shiki_span]:text-(--shiki-light) dark:[&_.shiki_span]:text-(--shiki-dark)");
8
10
  function useHighlightedHtml(code, language) {
9
- const [html, setHtml] = useState(null);
10
- useEffect(() => {
11
- let current = true;
12
- setHtml(null);
13
- highlightToHtml(code, language)
14
- .then((highlighted) => {
15
- if (current) {
16
- setHtml(highlighted);
17
- }
18
- })
19
- .catch(() => {
20
- if (current) {
21
- setHtml(null);
22
- }
23
- });
24
- return () => {
25
- current = false;
26
- };
27
- }, [code, language]);
28
- return html;
11
+ const $ = _c(4);
12
+ const [html, setHtml] = useState(null);
13
+ let t0;
14
+ let t1;
15
+ if ($[0] !== code || $[1] !== language) {
16
+ t0 = () => {
17
+ let current = true;
18
+ setHtml(null);
19
+ highlightToHtml(code, language).then(highlighted => {
20
+ if (current) {
21
+ setHtml(highlighted);
22
+ }
23
+ }).catch(() => {
24
+ if (current) {
25
+ setHtml(null);
26
+ }
27
+ });
28
+ return () => {
29
+ current = false;
30
+ };
31
+ };
32
+ t1 = [code, language];
33
+ $[0] = code;
34
+ $[1] = language;
35
+ $[2] = t0;
36
+ $[3] = t1;
37
+ } else {
38
+ t0 = $[2];
39
+ t1 = $[3];
40
+ }
41
+ useEffect(t0, t1);
42
+ return html;
29
43
  }
30
- export function Code({ code, language = "text", filename, showCopy = true, onCopy, className, ...props }) {
31
- const html = useHighlightedHtml(code, language);
32
- return (_jsxs("figure", { "data-slot": "code", "data-language": language, className: cn("min-w-0 bg-card text-card-foreground ring-1 ring-border", className), ...props, children: [_jsxs("figcaption", { className: "flex h-8 items-center justify-between gap-2 border-b pr-1 pl-3", children: [filename ? (_jsx("span", { className: "min-w-0 truncate font-mono text-xs text-foreground", children: filename })) : (_jsx("span", { className: "eyebrow", children: language })), _jsxs("span", { className: "flex shrink-0 items-center gap-2", children: [filename && _jsx("span", { className: "eyebrow", children: language }), showCopy && _jsx(CopyCodeButton, { code: code, onCopy: onCopy })] })] }), html ? (_jsx("div", { "data-slot": "code-area", className: codeAreaClass, dangerouslySetInnerHTML: { __html: html } })) : (_jsx("pre", { "data-slot": "code-area", className: codeAreaClass, children: _jsx("code", { children: code }) }))] }));
44
+ export function Code(t0) {
45
+ const $ = _c(35);
46
+ let className;
47
+ let code;
48
+ let filename;
49
+ let onCopy;
50
+ let props;
51
+ let t1;
52
+ let t2;
53
+ if ($[0] !== t0) {
54
+ ({
55
+ code,
56
+ language: t1,
57
+ filename,
58
+ showCopy: t2,
59
+ onCopy,
60
+ className,
61
+ ...props
62
+ } = t0);
63
+ $[0] = t0;
64
+ $[1] = className;
65
+ $[2] = code;
66
+ $[3] = filename;
67
+ $[4] = onCopy;
68
+ $[5] = props;
69
+ $[6] = t1;
70
+ $[7] = t2;
71
+ } else {
72
+ className = $[1];
73
+ code = $[2];
74
+ filename = $[3];
75
+ onCopy = $[4];
76
+ props = $[5];
77
+ t1 = $[6];
78
+ t2 = $[7];
79
+ }
80
+ const language = t1 === undefined ? "text" : t1;
81
+ const showCopy = t2 === undefined ? true : t2;
82
+ const html = useHighlightedHtml(code, language);
83
+ let t3;
84
+ if ($[8] !== className) {
85
+ t3 = cn("min-w-0 bg-card text-card-foreground ring-1 ring-border", className);
86
+ $[8] = className;
87
+ $[9] = t3;
88
+ } else {
89
+ t3 = $[9];
90
+ }
91
+ let t4;
92
+ if ($[10] !== filename || $[11] !== language) {
93
+ t4 = filename ? /*#__PURE__*/_jsx("span", {
94
+ className: "min-w-0 truncate font-mono text-xs text-foreground",
95
+ children: filename
96
+ }) : /*#__PURE__*/_jsx("span", {
97
+ className: "eyebrow",
98
+ children: language
99
+ });
100
+ $[10] = filename;
101
+ $[11] = language;
102
+ $[12] = t4;
103
+ } else {
104
+ t4 = $[12];
105
+ }
106
+ let t5;
107
+ if ($[13] !== filename || $[14] !== language) {
108
+ t5 = filename && /*#__PURE__*/_jsx("span", {
109
+ className: "eyebrow",
110
+ children: language
111
+ });
112
+ $[13] = filename;
113
+ $[14] = language;
114
+ $[15] = t5;
115
+ } else {
116
+ t5 = $[15];
117
+ }
118
+ let t6;
119
+ if ($[16] !== code || $[17] !== onCopy || $[18] !== showCopy) {
120
+ t6 = showCopy && /*#__PURE__*/_jsx(CopyCodeButton, {
121
+ code: code,
122
+ onCopy: onCopy
123
+ });
124
+ $[16] = code;
125
+ $[17] = onCopy;
126
+ $[18] = showCopy;
127
+ $[19] = t6;
128
+ } else {
129
+ t6 = $[19];
130
+ }
131
+ let t7;
132
+ if ($[20] !== t5 || $[21] !== t6) {
133
+ t7 = /*#__PURE__*/_jsxs("span", {
134
+ className: "flex shrink-0 items-center gap-2",
135
+ children: [t5, t6]
136
+ });
137
+ $[20] = t5;
138
+ $[21] = t6;
139
+ $[22] = t7;
140
+ } else {
141
+ t7 = $[22];
142
+ }
143
+ let t8;
144
+ if ($[23] !== t4 || $[24] !== t7) {
145
+ t8 = /*#__PURE__*/_jsxs("figcaption", {
146
+ className: "flex h-8 items-center justify-between gap-2 border-b pr-1 pl-3",
147
+ children: [t4, t7]
148
+ });
149
+ $[23] = t4;
150
+ $[24] = t7;
151
+ $[25] = t8;
152
+ } else {
153
+ t8 = $[25];
154
+ }
155
+ let t9;
156
+ if ($[26] !== code || $[27] !== html) {
157
+ t9 = html ? /*#__PURE__*/_jsx("div", {
158
+ "data-slot": "code-area",
159
+ className: codeAreaClass,
160
+ dangerouslySetInnerHTML: {
161
+ __html: html
162
+ }
163
+ }) : /*#__PURE__*/_jsx("pre", {
164
+ "data-slot": "code-area",
165
+ className: codeAreaClass,
166
+ children: /*#__PURE__*/_jsx("code", {
167
+ children: code
168
+ })
169
+ });
170
+ $[26] = code;
171
+ $[27] = html;
172
+ $[28] = t9;
173
+ } else {
174
+ t9 = $[28];
175
+ }
176
+ let t10;
177
+ if ($[29] !== language || $[30] !== props || $[31] !== t3 || $[32] !== t8 || $[33] !== t9) {
178
+ t10 = /*#__PURE__*/_jsxs("figure", {
179
+ "data-slot": "code",
180
+ "data-language": language,
181
+ className: t3,
182
+ ...props,
183
+ children: [t8, t9]
184
+ });
185
+ $[29] = language;
186
+ $[30] = props;
187
+ $[31] = t3;
188
+ $[32] = t8;
189
+ $[33] = t9;
190
+ $[34] = t10;
191
+ } else {
192
+ t10 = $[34];
193
+ }
194
+ return t10;
33
195
  }
@@ -1,18 +1,66 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { Checkmark as CheckIcon, Copy as CopyIcon } from "@carbon/icons-react";
3
3
  import { Button } from "@locusgraph/components";
4
4
  import { useCopied, writeToClipboard } from "../use-copied.js";
5
- export function CopyCodeButton({ code, onCopy }) {
6
- const { copied, markCopied } = useCopied();
7
- const copy = async () => {
8
- if (onCopy) {
9
- onCopy(code);
10
- markCopied();
11
- return;
12
- }
13
- if (await writeToClipboard(code)) {
14
- markCopied();
15
- }
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export function CopyCodeButton(t0) {
7
+ const $ = _c(10);
8
+ const {
9
+ code,
10
+ onCopy
11
+ } = t0;
12
+ const {
13
+ copied,
14
+ markCopied
15
+ } = useCopied();
16
+ let t1;
17
+ if ($[0] !== code || $[1] !== markCopied || $[2] !== onCopy) {
18
+ t1 = async () => {
19
+ if (onCopy) {
20
+ onCopy(code);
21
+ markCopied();
22
+ return;
23
+ }
24
+ if (await writeToClipboard(code)) {
25
+ markCopied();
26
+ }
16
27
  };
17
- return (_jsx(Button, { type: "button", variant: "ghost", size: "icon-xs", "aria-label": copied ? "Copied" : "Copy code", className: "text-muted-foreground hover:text-foreground", onClick: copy, children: copied ? _jsx(CheckIcon, { className: "text-good" }) : _jsx(CopyIcon, {}) }));
28
+ $[0] = code;
29
+ $[1] = markCopied;
30
+ $[2] = onCopy;
31
+ $[3] = t1;
32
+ } else {
33
+ t1 = $[3];
34
+ }
35
+ const copy = t1;
36
+ const t2 = copied ? "Copied" : "Copy code";
37
+ let t3;
38
+ if ($[4] !== copied) {
39
+ t3 = copied ? /*#__PURE__*/_jsx(CheckIcon, {
40
+ className: "text-good"
41
+ }) : /*#__PURE__*/_jsx(CopyIcon, {});
42
+ $[4] = copied;
43
+ $[5] = t3;
44
+ } else {
45
+ t3 = $[5];
46
+ }
47
+ let t4;
48
+ if ($[6] !== copy || $[7] !== t2 || $[8] !== t3) {
49
+ t4 = /*#__PURE__*/_jsx(Button, {
50
+ type: "button",
51
+ variant: "ghost",
52
+ size: "icon-xs",
53
+ "aria-label": t2,
54
+ className: "text-muted-foreground hover:text-foreground",
55
+ onClick: copy,
56
+ children: t3
57
+ });
58
+ $[6] = copy;
59
+ $[7] = t2;
60
+ $[8] = t3;
61
+ $[9] = t4;
62
+ } else {
63
+ t4 = $[9];
64
+ }
65
+ return t4;
18
66
  }
@@ -2,38 +2,39 @@ const lightTheme = "github-light";
2
2
  const darkTheme = "github-dark";
3
3
  let highlighter;
4
4
  function loadHighlighter() {
5
- highlighter ??= Promise.all([
6
- import("shiki/core"),
7
- import("shiki/engine/javascript"),
8
- import("shiki/themes"),
9
- ]).then(([core, engine, themes]) => core.createHighlighterCore({
10
- themes: [themes.bundledThemes[lightTheme](), themes.bundledThemes[darkTheme]()],
11
- langs: [],
12
- engine: engine.createJavaScriptRegexEngine(),
13
- }));
14
- return highlighter;
5
+ highlighter ??= Promise.all([import("shiki/core"), import("shiki/engine/javascript"), import("shiki/themes")]).then(([core, engine, themes]) => core.createHighlighterCore({
6
+ themes: [themes.bundledThemes[lightTheme](), themes.bundledThemes[darkTheme]()],
7
+ langs: [],
8
+ engine: engine.createJavaScriptRegexEngine()
9
+ }));
10
+ return highlighter;
15
11
  }
16
12
  async function loadLanguage(loaded, language) {
17
- if (loaded.getLoadedLanguages().includes(language)) {
18
- return true;
19
- }
20
- const { bundledLanguages } = await import("shiki/langs");
21
- const loader = bundledLanguages[language];
22
- if (!loader) {
23
- return false;
24
- }
25
- await loaded.loadLanguage(loader());
13
+ if (loaded.getLoadedLanguages().includes(language)) {
26
14
  return true;
15
+ }
16
+ const {
17
+ bundledLanguages
18
+ } = await import("shiki/langs");
19
+ const loader = bundledLanguages[language];
20
+ if (!loader) {
21
+ return false;
22
+ }
23
+ await loaded.loadLanguage(loader());
24
+ return true;
27
25
  }
28
26
  export async function highlightToHtml(code, language) {
29
- const normalized = language.toLowerCase();
30
- const loaded = await loadHighlighter();
31
- if (!(await loadLanguage(loaded, normalized))) {
32
- return null;
33
- }
34
- return loaded.codeToHtml(code, {
35
- lang: normalized,
36
- themes: { light: lightTheme, dark: darkTheme },
37
- defaultColor: false,
38
- });
27
+ const normalized = language.toLowerCase();
28
+ const loaded = await loadHighlighter();
29
+ if (!(await loadLanguage(loaded, normalized))) {
30
+ return null;
31
+ }
32
+ return loaded.codeToHtml(code, {
33
+ lang: normalized,
34
+ themes: {
35
+ light: lightTheme,
36
+ dark: darkTheme
37
+ },
38
+ defaultColor: false
39
+ });
39
40
  }
@@ -0,0 +1,16 @@
1
+ import type { HistoryItem } from "./row/history-row.js";
2
+ import type { ThreadGroup } from "./thread-groups.js";
3
+ export type HistoryListRow = {
4
+ kind: "group";
5
+ key: string;
6
+ groupKey: string;
7
+ label: string;
8
+ } | {
9
+ kind: "thread";
10
+ key: string;
11
+ thread: HistoryItem;
12
+ position: number;
13
+ groupSize: number;
14
+ };
15
+ export declare function historyListRows(groups: ThreadGroup[]): HistoryListRow[];
16
+ export declare function estimatedRowHeight(row: HistoryListRow, index: number): number;
@@ -0,0 +1,23 @@
1
+ export function historyListRows(groups) {
2
+ return groups.flatMap(group => [{
3
+ kind: "group",
4
+ key: `group:${group.key}`,
5
+ groupKey: group.key,
6
+ label: group.label
7
+ }, ...group.threads.map((thread, index) => ({
8
+ kind: "thread",
9
+ key: thread.id,
10
+ thread,
11
+ position: index + 1,
12
+ groupSize: group.threads.length
13
+ }))]);
14
+ }
15
+ const groupLabelHeightPx = 24;
16
+ const groupGapPx = 16;
17
+ const threadRowHeightPx = 32;
18
+ export function estimatedRowHeight(row, index) {
19
+ if (row.kind === "thread") {
20
+ return threadRowHeightPx;
21
+ }
22
+ return index === 0 ? groupLabelHeightPx : groupLabelHeightPx + groupGapPx;
23
+ }
@@ -1,5 +1,5 @@
1
1
  import type { ComponentProps } from "react";
2
- import { type HistoryItem } from "./history-row.js";
2
+ import { type HistoryItem } from "./row/history-row.js";
3
3
  type HistoryProps = Omit<ComponentProps<"nav">, "onSelect"> & {
4
4
  threads: HistoryItem[];
5
5
  activeId?: string | null;
@@ -10,6 +10,7 @@ type HistoryProps = Omit<ComponentProps<"nav">, "onSelect"> & {
10
10
  label?: string;
11
11
  emptyText?: string;
12
12
  now?: Date | string;
13
+ virtualize?: boolean;
13
14
  };
14
- export declare function History({ threads, activeId, onSelect, onNew, onRename, onArchive, label, emptyText, now, className, ...props }: HistoryProps): import("react").JSX.Element;
15
+ export declare function History({ threads, activeId, onSelect, onNew, onRename, onArchive, label, emptyText, now, virtualize, className, ...props }: HistoryProps): import("react").JSX.Element;
15
16
  export {};