@locusgraph/loop 0.3.0 → 0.4.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 (130) hide show
  1. package/dist/agent/index.d.ts +1 -1
  2. package/dist/agent/pulse/gradient-label.js +70 -17
  3. package/dist/agent/pulse/marks/bars-mark.js +39 -15
  4. package/dist/agent/pulse/marks/glyph-mark.js +57 -16
  5. package/dist/agent/pulse/marks/locus-mark.js +39 -13
  6. package/dist/agent/pulse/marks/orb-mark.js +21 -9
  7. package/dist/agent/pulse/pulse.js +1 -1
  8. package/dist/agent/pulse/use-loop-animation.d.ts +0 -1
  9. package/dist/agent/pulse/use-loop-animation.js +36 -15
  10. package/dist/agent/steps/step-icon.js +20 -13
  11. package/dist/agent/steps/steps.js +39 -37
  12. package/dist/agent/thinking/thinking.js +65 -62
  13. package/dist/agent/tool/json-block.js +10 -7
  14. package/dist/agent/tool/tool-status.d.ts +2 -0
  15. package/dist/agent/tool/tool-status.js +16 -13
  16. package/dist/agent/tool/tool.d.ts +8 -1
  17. package/dist/agent/tool/tool.js +238 -119
  18. package/dist/approval/inbox/inbox-row.d.ts +3 -3
  19. package/dist/approval/inbox/inbox-row.js +248 -86
  20. package/dist/approval/inbox/inbox.d.ts +3 -3
  21. package/dist/approval/inbox/inbox.js +251 -57
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +3 -3
  23. package/dist/approval/inbox/virtual-inbox-list.js +107 -30
  24. package/dist/approval/memory/memory-review.js +228 -91
  25. package/dist/approval/memory/memory-row.js +192 -56
  26. package/dist/approval/plan/plan-review.js +241 -108
  27. package/dist/approval/plan/plan-step-row.js +184 -77
  28. package/dist/approval/plan/plan-steps.d.ts +1 -1
  29. package/dist/approval/plan/plan-steps.js +2 -2
  30. package/dist/approval/plan/question-choices.js +139 -48
  31. package/dist/approval/plan/question.js +189 -67
  32. package/dist/approval/run/run-bar.js +138 -49
  33. package/dist/approval/shared/approval-line.d.ts +27 -0
  34. package/dist/approval/shared/approval-line.js +85 -0
  35. package/dist/approval/shared/risk-badge.d.ts +3 -5
  36. package/dist/approval/shared/risk-badge.js +11 -19
  37. package/dist/approval/shared/time.d.ts +0 -1
  38. package/dist/approval/shared/time.js +0 -1
  39. package/dist/approval/shared/use-focus-on-mount.js +23 -5
  40. package/dist/approval/shared/use-focus-when-settled.d.ts +2 -0
  41. package/dist/approval/shared/use-focus-when-settled.js +18 -0
  42. package/dist/approval/spend/raise-cap-form.d.ts +2 -2
  43. package/dist/approval/spend/raise-cap-form.js +235 -52
  44. package/dist/approval/spend/spend-gate.js +200 -106
  45. package/dist/approval/spend/spend-math.d.ts +1 -0
  46. package/dist/approval/spend/spend-math.js +5 -2
  47. package/dist/approval/spend/spend-meter.js +5 -5
  48. package/dist/approval/tool/approval.js +157 -96
  49. package/dist/approval/tool/args/args-editor.js +232 -81
  50. package/dist/approval/tool/args/args-field.js +333 -60
  51. package/dist/approval/tool/deny-form.js +114 -32
  52. package/dist/approval/tool/tool-inputs.js +93 -33
  53. package/dist/chat/chat/chat.js +5 -4
  54. package/dist/chat/chat/use-stick-to-bottom.js +116 -63
  55. package/dist/chat/chat/virtual-chat-items.js +129 -34
  56. package/dist/chat/composer/composer-actions.d.ts +1 -2
  57. package/dist/chat/composer/composer-actions.js +136 -50
  58. package/dist/chat/composer/composer-status.d.ts +2 -0
  59. package/dist/chat/composer/composer-status.js +3 -0
  60. package/dist/chat/composer/composer.d.ts +1 -1
  61. package/dist/chat/composer/composer.js +6 -4
  62. package/dist/chat/composer/use-auto-grow.js +29 -8
  63. package/dist/chat/files/files.js +296 -67
  64. package/dist/chat/index.d.ts +1 -1
  65. package/dist/chat/index.js +1 -1
  66. package/dist/chat/reply/fenced-code.js +1 -1
  67. package/dist/chat/reply/markdown-components.js +9 -116
  68. package/dist/chat/reply/reply.js +2 -2
  69. package/dist/chat/turn/group-parts.d.ts +1 -0
  70. package/dist/chat/turn/group-parts.js +6 -3
  71. package/dist/chat/turn/turn.js +13 -4
  72. package/dist/cost/context.js +3 -3
  73. package/dist/cost/cost-steps.js +31 -30
  74. package/dist/cost/cost.js +39 -39
  75. package/dist/cost/model-picker.js +176 -43
  76. package/dist/cost/shared/context-breakdown.js +10 -11
  77. package/dist/cost/shared/model-option-row.js +4 -3
  78. package/dist/cost/shared/step-cost-row.js +11 -12
  79. package/dist/cost/shared/usage-totals.d.ts +1 -0
  80. package/dist/cost/shared/usage-totals.js +19 -1
  81. package/dist/memory/cite.js +190 -59
  82. package/dist/memory/memorized.js +231 -62
  83. package/dist/memory/recall.js +272 -85
  84. package/dist/memory/shared/host-label.d.ts +1 -1
  85. package/dist/memory/shared/host-label.js +2 -2
  86. package/dist/memory/shared/source-mark.js +1 -1
  87. package/dist/memory/sources.d.ts +2 -1
  88. package/dist/memory/sources.js +277 -62
  89. package/dist/shared/decision-summary.js +2 -1
  90. package/dist/shared/line.d.ts +10 -0
  91. package/dist/shared/line.js +11 -0
  92. package/dist/shared/live-status.d.ts +3 -0
  93. package/dist/shared/live-status.js +11 -0
  94. package/dist/shared/reduced-motion.d.ts +1 -0
  95. package/dist/shared/reduced-motion.js +3 -0
  96. package/dist/shared/virtual/use-list-virtualizer.js +2 -0
  97. package/dist/thread/actions/action-button.js +1 -1
  98. package/dist/thread/actions/actions.d.ts +3 -1
  99. package/dist/thread/actions/actions.js +100 -81
  100. package/dist/thread/actions/branch-switcher.js +129 -23
  101. package/dist/thread/canvas/canvas-meta.d.ts +9 -0
  102. package/dist/thread/canvas/canvas-meta.js +35 -0
  103. package/dist/thread/canvas/canvas.d.ts +1 -1
  104. package/dist/thread/canvas/canvas.js +64 -74
  105. package/dist/thread/canvas/version-switcher.d.ts +1 -0
  106. package/dist/thread/canvas/version-switcher.js +161 -45
  107. package/dist/thread/code/code.js +4 -6
  108. package/dist/thread/code/copy-code-button.d.ts +2 -1
  109. package/dist/thread/code/copy-code-button.js +91 -26
  110. package/dist/thread/history/history.d.ts +1 -1
  111. package/dist/thread/history/history.js +104 -104
  112. package/dist/thread/history/row/history-row.js +106 -22
  113. package/dist/thread/history/row/thread-item-menu.js +84 -20
  114. package/dist/thread/history/row/thread-title-editor.js +74 -29
  115. package/dist/thread/history/virtual-history-list.js +83 -46
  116. package/dist/thread/index.d.ts +1 -0
  117. package/dist/thread/index.js +1 -0
  118. package/dist/thread/starters/starters.js +91 -28
  119. package/dist/thread/use-copied.js +40 -10
  120. package/package.json +6 -6
  121. package/dist/agent/shared/status-dot.d.ts +0 -1
  122. package/dist/agent/shared/status-dot.js +0 -1
  123. package/dist/approval/shared/decision-line.d.ts +0 -1
  124. package/dist/approval/shared/decision-line.js +0 -1
  125. package/dist/memory/shared/disclosure.d.ts +0 -6
  126. package/dist/memory/shared/disclosure.js +0 -6
  127. package/dist/shared/panel.d.ts +0 -19
  128. package/dist/shared/panel.js +0 -77
  129. package/dist/shared/status-dot.d.ts +0 -6
  130. package/dist/shared/status-dot.js +0 -20
@@ -18,7 +18,7 @@ const compactCount = new Intl.NumberFormat("en-US", {
18
18
  maximumFractionDigits: 1
19
19
  });
20
20
  export function formatTokensShort(tokens) {
21
- return compactCount.format(tokens);
21
+ return compactCount.format(tokens).replace("K", "k");
22
22
  }
23
23
  export function formatDuration(durationMs) {
24
24
  if (durationMs < 1000) return `${Math.round(durationMs)}ms`;
@@ -28,3 +28,21 @@ export function formatDuration(durationMs) {
28
28
  const remainder = Math.round(seconds % 60);
29
29
  return `${minutes}m ${String(remainder).padStart(2, "0")}s`;
30
30
  }
31
+ export function wholePercentsOf(parts, whole) {
32
+ if (whole <= 0) return parts.map(() => 0);
33
+ const exact = parts.map(part => part / whole * 100);
34
+ const sum = parts.reduce((total, part) => total + part, 0);
35
+ if (sum !== whole) return exact.map(percent => Math.round(percent));
36
+ const floors = exact.map(percent => Math.floor(percent));
37
+ const missing = 100 - floors.reduce((total, percent) => total + percent, 0);
38
+ const byLargestRemainder = exact.map((percent, index) => ({
39
+ index,
40
+ remainder: percent - Math.floor(percent)
41
+ })).sort((first, second) => second.remainder - first.remainder);
42
+ for (const {
43
+ index
44
+ } of byLargestRemainder.slice(0, missing)) {
45
+ floors[index] = (floors[index] ?? 0) + 1;
46
+ }
47
+ return floors;
48
+ }
@@ -1,69 +1,200 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
1
4
  import { cn, HoverCard, HoverCardContent, HoverCardTrigger } from "@locusgraph/components";
2
5
  import { hostLabel } from "./shared/host-label.js";
3
6
  import { SourceMark } from "./shared/source-mark.js";
4
7
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- const pillClass = "inline-flex h-4 min-w-4 items-center justify-center bg-muted px-1 font-mono text-[11px] leading-none font-medium text-foreground/80 tabular-nums no-underline ring-1 ring-border transition-colors duration-150 outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/70 motion-reduce:transition-none";
8
+ const pillClass = "inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-muted px-1 text-2xs leading-none font-medium text-muted-foreground tabular-nums no-underline transition-colors duration-150 locus-focus-ring hover:bg-interactive/15 hover:text-interactive data-[state=open]:bg-interactive/15 data-[state=open]:text-interactive motion-reduce:transition-none";
6
9
  export function citationLabel(citation) {
7
10
  return `Source ${citation.index}: ${citation.title}`;
8
11
  }
9
- export function Cite({
10
- citation,
11
- onOpen,
12
- className
13
- }) {
14
- const host = hostLabel(citation.url);
15
- const label = citationLabel(citation);
16
- const open = event => {
17
- if (!onOpen) return;
18
- event.preventDefault();
19
- onOpen(citation);
20
- };
21
- return /*#__PURE__*/_jsx("sup", {
22
- "data-slot": "cite",
23
- "data-index": citation.index,
24
- className: cn("relative -top-1 ml-0.5 align-baseline leading-none", className),
25
- children: /*#__PURE__*/_jsxs(HoverCard, {
12
+ export function Cite(t0) {
13
+ const $ = _c(37);
14
+ const {
15
+ citation,
16
+ onOpen,
17
+ className
18
+ } = t0;
19
+ let t1;
20
+ if ($[0] !== citation.url) {
21
+ t1 = hostLabel(citation.url);
22
+ $[0] = citation.url;
23
+ $[1] = t1;
24
+ } else {
25
+ t1 = $[1];
26
+ }
27
+ const host = t1;
28
+ let t2;
29
+ if ($[2] !== citation) {
30
+ t2 = citationLabel(citation);
31
+ $[2] = citation;
32
+ $[3] = t2;
33
+ } else {
34
+ t2 = $[3];
35
+ }
36
+ const label = t2;
37
+ let t3;
38
+ if ($[4] !== citation || $[5] !== onOpen) {
39
+ t3 = event => {
40
+ if (!onOpen) {
41
+ return;
42
+ }
43
+ event.preventDefault();
44
+ onOpen(citation);
45
+ };
46
+ $[4] = citation;
47
+ $[5] = onOpen;
48
+ $[6] = t3;
49
+ } else {
50
+ t3 = $[6];
51
+ }
52
+ const open = t3;
53
+ const t4 = citation.index;
54
+ let t5;
55
+ if ($[7] !== className) {
56
+ t5 = cn("relative -top-1 ml-0.5 align-baseline leading-none", className);
57
+ $[7] = className;
58
+ $[8] = t5;
59
+ } else {
60
+ t5 = $[8];
61
+ }
62
+ let t6;
63
+ if ($[9] !== citation.index || $[10] !== citation.url || $[11] !== label || $[12] !== onOpen || $[13] !== open) {
64
+ t6 = /*#__PURE__*/_jsx(HoverCardTrigger, {
65
+ asChild: true,
66
+ children: citation.url ? /*#__PURE__*/_jsx("a", {
67
+ href: citation.url,
68
+ target: "_blank",
69
+ rel: "noreferrer",
70
+ "aria-label": onOpen ? label : `${label}, opens in a new tab`,
71
+ onClick: open,
72
+ className: pillClass,
73
+ children: citation.index
74
+ }) : onOpen ? /*#__PURE__*/_jsx("button", {
75
+ type: "button",
76
+ "aria-label": label,
77
+ onClick: open,
78
+ className: pillClass,
79
+ children: citation.index
80
+ }) : /*#__PURE__*/_jsx("span", {
81
+ role: "note",
82
+ tabIndex: 0,
83
+ "aria-label": label,
84
+ className: pillClass,
85
+ children: citation.index
86
+ })
87
+ });
88
+ $[9] = citation.index;
89
+ $[10] = citation.url;
90
+ $[11] = label;
91
+ $[12] = onOpen;
92
+ $[13] = open;
93
+ $[14] = t6;
94
+ } else {
95
+ t6 = $[14];
96
+ }
97
+ let t7;
98
+ if ($[15] !== citation) {
99
+ t7 = /*#__PURE__*/_jsx(SourceMark, {
100
+ citation: citation
101
+ });
102
+ $[15] = citation;
103
+ $[16] = t7;
104
+ } else {
105
+ t7 = $[16];
106
+ }
107
+ const t8 = host ?? "Source";
108
+ let t9;
109
+ if ($[17] !== t8) {
110
+ t9 = /*#__PURE__*/_jsx("span", {
111
+ className: "truncate",
112
+ children: t8
113
+ });
114
+ $[17] = t8;
115
+ $[18] = t9;
116
+ } else {
117
+ t9 = $[18];
118
+ }
119
+ let t10;
120
+ if ($[19] !== t7 || $[20] !== t9) {
121
+ t10 = /*#__PURE__*/_jsxs("span", {
122
+ className: "flex min-w-0 items-center gap-2 text-xs text-faint",
123
+ children: [t7, t9]
124
+ });
125
+ $[19] = t7;
126
+ $[20] = t9;
127
+ $[21] = t10;
128
+ } else {
129
+ t10 = $[21];
130
+ }
131
+ let t11;
132
+ if ($[22] !== citation.title) {
133
+ t11 = /*#__PURE__*/_jsx("span", {
134
+ className: "text-sm leading-snug font-medium",
135
+ children: citation.title
136
+ });
137
+ $[22] = citation.title;
138
+ $[23] = t11;
139
+ } else {
140
+ t11 = $[23];
141
+ }
142
+ let t12;
143
+ if ($[24] !== citation.snippet) {
144
+ t12 = citation.snippet && /*#__PURE__*/_jsx("p", {
145
+ className: "line-clamp-4 text-xs leading-relaxed text-muted-foreground",
146
+ children: citation.snippet
147
+ });
148
+ $[24] = citation.snippet;
149
+ $[25] = t12;
150
+ } else {
151
+ t12 = $[25];
152
+ }
153
+ let t13;
154
+ if ($[26] !== t10 || $[27] !== t11 || $[28] !== t12) {
155
+ t13 = /*#__PURE__*/_jsxs(HoverCardContent, {
156
+ "data-slot": "cite-card",
157
+ side: "bottom",
158
+ align: "start",
159
+ sideOffset: 6,
160
+ collisionPadding: 12,
161
+ className: "flex w-72 flex-col gap-2 rounded-none border-0 p-4 ring-1 ring-border",
162
+ children: [t10, t11, t12]
163
+ });
164
+ $[26] = t10;
165
+ $[27] = t11;
166
+ $[28] = t12;
167
+ $[29] = t13;
168
+ } else {
169
+ t13 = $[29];
170
+ }
171
+ let t14;
172
+ if ($[30] !== t13 || $[31] !== t6) {
173
+ t14 = /*#__PURE__*/_jsxs(HoverCard, {
26
174
  openDelay: 150,
27
175
  closeDelay: 100,
28
- children: [/*#__PURE__*/_jsx(HoverCardTrigger, {
29
- asChild: true,
30
- children: citation.url ? /*#__PURE__*/_jsx("a", {
31
- href: citation.url,
32
- target: "_blank",
33
- rel: "noreferrer",
34
- "aria-label": label,
35
- onClick: open,
36
- className: pillClass,
37
- children: citation.index
38
- }) : /*#__PURE__*/_jsx("button", {
39
- type: "button",
40
- "aria-label": label,
41
- onClick: open,
42
- className: pillClass,
43
- children: citation.index
44
- })
45
- }), /*#__PURE__*/_jsxs(HoverCardContent, {
46
- "data-slot": "cite-card",
47
- side: "bottom",
48
- align: "start",
49
- sideOffset: 6,
50
- className: "flex w-72 flex-col gap-2 rounded-none border-0 p-4 ring-1 ring-border",
51
- children: [/*#__PURE__*/_jsxs("span", {
52
- className: "locus-eyebrow flex min-w-0 items-center gap-2",
53
- children: [/*#__PURE__*/_jsx(SourceMark, {
54
- citation: citation
55
- }), /*#__PURE__*/_jsx("span", {
56
- className: "truncate",
57
- children: host ?? "Source"
58
- })]
59
- }), /*#__PURE__*/_jsx("span", {
60
- className: "text-sm leading-snug font-medium",
61
- children: citation.title
62
- }), citation.snippet && /*#__PURE__*/_jsx("p", {
63
- className: "line-clamp-4 text-xs leading-relaxed text-muted-foreground",
64
- children: citation.snippet
65
- })]
66
- })]
67
- })
68
- });
176
+ children: [t6, t13]
177
+ });
178
+ $[30] = t13;
179
+ $[31] = t6;
180
+ $[32] = t14;
181
+ } else {
182
+ t14 = $[32];
183
+ }
184
+ let t15;
185
+ if ($[33] !== citation.index || $[34] !== t14 || $[35] !== t5) {
186
+ t15 = /*#__PURE__*/_jsx("sup", {
187
+ "data-slot": "cite",
188
+ "data-index": t4,
189
+ className: t5,
190
+ children: t14
191
+ });
192
+ $[33] = citation.index;
193
+ $[34] = t14;
194
+ $[35] = t5;
195
+ $[36] = t15;
196
+ } else {
197
+ t15 = $[36];
198
+ }
199
+ return t15;
69
200
  }
@@ -1,73 +1,242 @@
1
- import { BookmarkAdd as BookmarkPlusIcon, Checkmark as CheckIcon, Undo as Undo2Icon } from "@carbon/icons-react";
2
- import { Button, cn } from "@locusgraph/components";
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { cn } from "@locusgraph/components";
3
5
  import { pluralize } from "@locusgraph/utils";
4
- import { StatusDot } from "../shared/status-dot.js";
5
- import { eyebrowClass, ruledListClass } from "./shared/disclosure.js";
6
+ import { BookmarkSimple as BookmarkPlusIcon } from "@phosphor-icons/react/ssr";
7
+ import { useEffect, useRef } from "react";
8
+ import { lineDetailClass, lineMemoryIconClass, lineMemoryObjectClass, lineRowClass } from "../shared/line.js";
6
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ function savedCount(items) {
11
+ return items.filter(item => item.status === "saved").length;
12
+ }
7
13
  export function memorizedSummary(items) {
8
- const saved = items.filter(item => item.status === "saved").length;
9
- return `Saved ${pluralize(saved, "memory", "memories")}`;
14
+ return `Saved ${pluralize(savedCount(items), "memory", "memories")}`;
10
15
  }
11
- export function Memorized({
12
- items,
13
- onUndo,
14
- className
15
- }) {
16
- if (items.length === 0) return null;
17
- return /*#__PURE__*/_jsxs("section", {
18
- "data-slot": "memorized",
19
- "aria-label": "Saved to memory",
20
- className: cn("flex min-w-0 flex-col gap-2", className),
21
- children: [/*#__PURE__*/_jsxs("header", {
22
- "aria-live": "polite",
23
- className: cn("flex items-center gap-2 py-1", eyebrowClass),
24
- children: [/*#__PURE__*/_jsx(BookmarkPlusIcon, {
16
+ export function Memorized(t0) {
17
+ const $ = _c(19);
18
+ const {
19
+ items,
20
+ onUndo,
21
+ className
22
+ } = t0;
23
+ if (items.length === 0) {
24
+ return null;
25
+ }
26
+ let t1;
27
+ if ($[0] !== className) {
28
+ t1 = cn("flex min-w-0 flex-col", className);
29
+ $[0] = className;
30
+ $[1] = t1;
31
+ } else {
32
+ t1 = $[1];
33
+ }
34
+ let t2;
35
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
36
+ t2 = /*#__PURE__*/_jsx("span", {
37
+ "aria-hidden": true,
38
+ className: lineMemoryIconClass,
39
+ children: /*#__PURE__*/_jsx(BookmarkPlusIcon, {
40
+ weight: "bold",
25
41
  "aria-hidden": true
26
- }), memorizedSummary(items)]
27
- }), /*#__PURE__*/_jsx("ul", {
28
- className: ruledListClass,
29
- children: items.map(item => /*#__PURE__*/_jsx(MemorizedRow, {
42
+ })
43
+ });
44
+ $[2] = t2;
45
+ } else {
46
+ t2 = $[2];
47
+ }
48
+ let t3;
49
+ if ($[3] !== items) {
50
+ t3 = pluralize(savedCount(items), "memory", "memories");
51
+ $[3] = items;
52
+ $[4] = t3;
53
+ } else {
54
+ t3 = $[4];
55
+ }
56
+ let t4;
57
+ if ($[5] !== t3) {
58
+ t4 = /*#__PURE__*/_jsxs("header", {
59
+ "aria-live": "polite",
60
+ className: lineRowClass,
61
+ children: [t2, /*#__PURE__*/_jsxs("span", {
62
+ className: "truncate",
63
+ children: ["Saved", " ", /*#__PURE__*/_jsx("span", {
64
+ className: lineMemoryObjectClass,
65
+ children: t3
66
+ })]
67
+ })]
68
+ });
69
+ $[5] = t3;
70
+ $[6] = t4;
71
+ } else {
72
+ t4 = $[6];
73
+ }
74
+ let t5;
75
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
76
+ t5 = cn(lineDetailClass, "flex flex-col pb-2 text-muted-foreground");
77
+ $[7] = t5;
78
+ } else {
79
+ t5 = $[7];
80
+ }
81
+ let t6;
82
+ if ($[8] !== items || $[9] !== onUndo) {
83
+ let t7;
84
+ if ($[11] !== onUndo) {
85
+ t7 = item => /*#__PURE__*/_jsx(MemorizedRow, {
30
86
  item: item,
31
87
  onUndo: onUndo
32
- }, item.id))
33
- })]
34
- });
88
+ }, item.id);
89
+ $[11] = onUndo;
90
+ $[12] = t7;
91
+ } else {
92
+ t7 = $[12];
93
+ }
94
+ t6 = items.map(t7);
95
+ $[8] = items;
96
+ $[9] = onUndo;
97
+ $[10] = t6;
98
+ } else {
99
+ t6 = $[10];
100
+ }
101
+ let t7;
102
+ if ($[13] !== t6) {
103
+ t7 = /*#__PURE__*/_jsx("ul", {
104
+ className: t5,
105
+ children: t6
106
+ });
107
+ $[13] = t6;
108
+ $[14] = t7;
109
+ } else {
110
+ t7 = $[14];
111
+ }
112
+ let t8;
113
+ if ($[15] !== t1 || $[16] !== t4 || $[17] !== t7) {
114
+ t8 = /*#__PURE__*/_jsxs("section", {
115
+ "data-slot": "memorized",
116
+ "aria-label": "Saved to memory",
117
+ className: t1,
118
+ children: [t4, t7]
119
+ });
120
+ $[15] = t1;
121
+ $[16] = t4;
122
+ $[17] = t7;
123
+ $[18] = t8;
124
+ } else {
125
+ t8 = $[18];
126
+ }
127
+ return t8;
35
128
  }
36
- function MemorizedRow({
37
- item,
38
- onUndo
39
- }) {
129
+ function MemorizedRow(t0) {
130
+ const $ = _c(22);
131
+ const {
132
+ item,
133
+ onUndo
134
+ } = t0;
40
135
  const undone = item.status === "undone";
41
- return /*#__PURE__*/_jsxs("li", {
42
- "data-slot": "memorized-item",
43
- "data-status": item.status,
44
- className: "flex min-h-11 items-center gap-3 px-3 py-2.5",
45
- children: [/*#__PURE__*/_jsx(CheckIcon, {
46
- "aria-hidden": true,
47
- className: cn("size-3.5 shrink-0", undone ? "text-muted-foreground/40" : "text-good")
48
- }), /*#__PURE__*/_jsxs("span", {
49
- className: "flex min-w-0 flex-1 flex-col gap-0.5",
50
- children: [/*#__PURE__*/_jsx("span", {
51
- className: cn("text-sm font-medium", undone && "font-normal text-muted-foreground line-through decoration-muted-foreground"),
52
- children: item.text
53
- }), item.kind && /*#__PURE__*/_jsx("span", {
54
- className: "font-mono text-xs text-muted-foreground",
55
- children: item.kind
56
- })]
57
- }), undone ? /*#__PURE__*/_jsxs("span", {
58
- className: "locus-eyebrow flex shrink-0 items-center gap-1.5",
59
- children: [/*#__PURE__*/_jsx(StatusDot, {
60
- tone: "idle"
61
- }), "Undone"]
62
- }) : onUndo && /*#__PURE__*/_jsxs(Button, {
63
- variant: "ghost",
64
- size: "xs",
65
- className: "-mr-2 text-muted-foreground hover:text-foreground",
136
+ const undoneLabel = useRef(null);
137
+ const undoWasPressed = useRef(false);
138
+ let t1;
139
+ let t2;
140
+ if ($[0] !== undone) {
141
+ t1 = () => {
142
+ if (undone && undoWasPressed.current) {
143
+ undoWasPressed.current = false;
144
+ undoneLabel.current?.focus();
145
+ }
146
+ };
147
+ t2 = [undone];
148
+ $[0] = undone;
149
+ $[1] = t1;
150
+ $[2] = t2;
151
+ } else {
152
+ t1 = $[1];
153
+ t2 = $[2];
154
+ }
155
+ useEffect(t1, t2);
156
+ const t3 = item.status;
157
+ const t4 = undone && "text-faint line-through decoration-faint";
158
+ let t5;
159
+ if ($[3] !== t4) {
160
+ t5 = cn(t4);
161
+ $[3] = t4;
162
+ $[4] = t5;
163
+ } else {
164
+ t5 = $[4];
165
+ }
166
+ let t6;
167
+ if ($[5] !== item.text || $[6] !== t5) {
168
+ t6 = /*#__PURE__*/_jsx("span", {
169
+ className: t5,
170
+ children: item.text
171
+ });
172
+ $[5] = item.text;
173
+ $[6] = t5;
174
+ $[7] = t6;
175
+ } else {
176
+ t6 = $[7];
177
+ }
178
+ let t7;
179
+ if ($[8] !== item.kind) {
180
+ t7 = item.kind && /*#__PURE__*/_jsx("span", {
181
+ className: "text-xs text-faint",
182
+ children: item.kind
183
+ });
184
+ $[8] = item.kind;
185
+ $[9] = t7;
186
+ } else {
187
+ t7 = $[9];
188
+ }
189
+ let t8;
190
+ if ($[10] !== t6 || $[11] !== t7) {
191
+ t8 = /*#__PURE__*/_jsxs("span", {
192
+ className: "flex min-w-0 flex-wrap items-baseline gap-x-1.5",
193
+ children: [t6, t7]
194
+ });
195
+ $[10] = t6;
196
+ $[11] = t7;
197
+ $[12] = t8;
198
+ } else {
199
+ t8 = $[12];
200
+ }
201
+ let t9;
202
+ if ($[13] !== item.id || $[14] !== item.text || $[15] !== onUndo || $[16] !== undone) {
203
+ t9 = undone ? /*#__PURE__*/_jsx("span", {
204
+ ref: undoneLabel,
205
+ tabIndex: -1,
206
+ className: "shrink-0 text-xs text-faint locus-focus-ring",
207
+ children: "Undone"
208
+ }) : onUndo && /*#__PURE__*/_jsx("button", {
209
+ type: "button",
66
210
  "aria-label": `Undo saving ${item.text}`,
67
- onClick: () => onUndo(item.id),
68
- children: [/*#__PURE__*/_jsx(Undo2Icon, {
69
- "aria-hidden": true
70
- }), "Undo"]
71
- })]
72
- });
211
+ onClick: () => {
212
+ undoWasPressed.current = true;
213
+ onUndo(item.id);
214
+ },
215
+ className: "shrink-0 text-xs text-faint locus-focus-ring transition-colors hover:text-interactive",
216
+ children: "Undo"
217
+ });
218
+ $[13] = item.id;
219
+ $[14] = item.text;
220
+ $[15] = onUndo;
221
+ $[16] = undone;
222
+ $[17] = t9;
223
+ } else {
224
+ t9 = $[17];
225
+ }
226
+ let t10;
227
+ if ($[18] !== item.status || $[19] !== t8 || $[20] !== t9) {
228
+ t10 = /*#__PURE__*/_jsxs("li", {
229
+ "data-slot": "memorized-item",
230
+ "data-status": t3,
231
+ className: "flex min-w-0 items-baseline gap-3 py-1",
232
+ children: [t8, t9]
233
+ });
234
+ $[18] = item.status;
235
+ $[19] = t8;
236
+ $[20] = t9;
237
+ $[21] = t10;
238
+ } else {
239
+ t10 = $[21];
240
+ }
241
+ return t10;
73
242
  }