@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
@@ -26,7 +26,7 @@ function RingContent({
26
26
  percent: percent,
27
27
  status: status
28
28
  }), /*#__PURE__*/_jsxs("span", {
29
- className: "font-mono text-[11px] tabular-nums",
29
+ className: "font-mono text-2xs tabular-nums",
30
30
  children: [percent, "%"]
31
31
  })]
32
32
  });
@@ -40,7 +40,7 @@ function BarContent({
40
40
  }) {
41
41
  return /*#__PURE__*/_jsxs(_Fragment, {
42
42
  children: [/*#__PURE__*/_jsxs("span", {
43
- className: "flex items-baseline justify-between gap-4 font-mono text-[11px] tabular-nums",
43
+ className: "flex items-baseline justify-between gap-4 font-mono text-2xs tabular-nums",
44
44
  children: [/*#__PURE__*/_jsx("span", {
45
45
  className: "locus-eyebrow",
46
46
  children: label
@@ -80,7 +80,7 @@ export function Context({
80
80
  "aria-valuenow": percent,
81
81
  "aria-valuetext": `${percent}%, ${summary}`,
82
82
  tabIndex: hasBreakdown ? 0 : undefined,
83
- className: cn("outline-none focus-visible:ring-2 focus-visible:ring-ring/70", statusTone[status], variant === "ring" ? "inline-flex h-6 items-center gap-1.5 rounded-full px-2 transition-colors duration-150 motion-reduce:transition-none" : "flex w-full flex-col gap-2", variant === "ring" && hasBreakdown && "cursor-default hover:bg-accent", className),
83
+ className: cn("locus-focus-ring", statusTone[status], variant === "ring" ? "inline-flex h-control-xs items-center gap-1.5 rounded-full px-2 transition-colors duration-150 motion-reduce:transition-none" : "flex w-full flex-col gap-2", variant === "ring" && hasBreakdown && "cursor-default hover:bg-accent", className),
84
84
  children: variant === "ring" ? /*#__PURE__*/_jsx(RingContent, {
85
85
  percent: percent,
86
86
  status: status
@@ -1,9 +1,9 @@
1
- import { Roadmap as ChartNoAxesGanttIcon } from "@carbon/icons-react";
2
- import { formatCount, formatMicroUsd, pluralize } from "@locusgraph/utils";
3
- import { ApprovalPanel, PanelHeader } from "../shared/panel.js";
4
- import { PanelEmpty } from "../shared/panel-empty.js";
1
+ import { cn } from "@locusgraph/components";
2
+ import { formatMicroUsd } from "@locusgraph/utils";
3
+ import { ChartBarHorizontal as ChartNoAxesGanttIcon } from "@phosphor-icons/react/ssr";
4
+ import { lineIconClass, lineRowClass } from "../shared/line.js";
5
5
  import { isWastedStep, StepCostRow } from "./shared/step-cost-row.js";
6
- import { formatDuration, sumUsage } from "./shared/usage-totals.js";
6
+ import { formatDuration, formatTokensShort, sumUsage } from "./shared/usage-totals.js";
7
7
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
8
8
  export function stepCostTotals(steps) {
9
9
  const totals = sumUsage(steps.map(step => step.usage));
@@ -20,18 +20,13 @@ function Totals({
20
20
  }) {
21
21
  return /*#__PURE__*/_jsxs("div", {
22
22
  "data-slot": "step-cost-totals",
23
- className: "flex flex-col gap-1 px-5 pt-2 pb-4",
23
+ className: "flex items-baseline gap-3 pb-2 pl-6 tabular-nums",
24
24
  children: [/*#__PURE__*/_jsx("span", {
25
- className: "text-2xl font-semibold tracking-tight tabular-nums",
25
+ className: "text-xl font-semibold tracking-tight text-foreground",
26
26
  children: formatMicroUsd(totals.costMicroUsd)
27
27
  }), /*#__PURE__*/_jsxs("span", {
28
- className: "flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground tabular-nums",
29
- children: [/*#__PURE__*/_jsxs("span", {
30
- children: [formatCount(totals.inputTokens), " in \xB7 ", formatCount(totals.outputTokens), " out", totals.durationMs > 0 && ` · ${formatDuration(totals.durationMs)}`]
31
- }), totals.wastedMicroUsd > 0 && /*#__PURE__*/_jsxs("span", {
32
- className: "text-destructive",
33
- children: ["Wasted on failures ", formatMicroUsd(totals.wastedMicroUsd)]
34
- })]
28
+ className: "text-xs text-faint",
29
+ children: [formatTokensShort(totals.inputTokens), " in \xB7 ", formatTokensShort(totals.outputTokens), " out", totals.durationMs > 0 && ` · ${formatDuration(totals.durationMs)}`]
35
30
  })]
36
31
  });
37
32
  }
@@ -44,28 +39,34 @@ export function CostSteps({
44
39
  const totals = stepCostTotals(steps);
45
40
  const maxCost = Math.max(0, ...steps.map(step => step.usage.costMicroUsd));
46
41
  const running = steps.some(step => step.status === "running");
47
- return /*#__PURE__*/_jsxs(ApprovalPanel, {
42
+ return /*#__PURE__*/_jsxs("section", {
48
43
  "data-slot": "cost-steps",
49
44
  "aria-label": label,
50
- className: className,
51
- children: [/*#__PURE__*/_jsx(PanelHeader, {
52
- icon: /*#__PURE__*/_jsx(ChartNoAxesGanttIcon, {
53
- "aria-hidden": true
54
- }),
55
- eyebrow: label,
56
- aside: steps.length > 0 ? pluralize(steps.length, "step") : undefined,
57
- status: running ? "Running" : undefined,
58
- tone: "running"
59
- }), steps.length === 0 ? /*#__PURE__*/_jsx(PanelEmpty, {
60
- icon: /*#__PURE__*/_jsx(ChartNoAxesGanttIcon, {
61
- "aria-hidden": true
62
- }),
63
- title: emptyText
45
+ className: cn("flex min-w-0 flex-col", className),
46
+ children: [/*#__PURE__*/_jsxs("header", {
47
+ className: lineRowClass,
48
+ children: [/*#__PURE__*/_jsx("span", {
49
+ "aria-hidden": true,
50
+ className: lineIconClass,
51
+ children: /*#__PURE__*/_jsx(ChartNoAxesGanttIcon, {
52
+ weight: "bold",
53
+ "aria-hidden": true
54
+ })
55
+ }), /*#__PURE__*/_jsx("span", {
56
+ className: "truncate",
57
+ children: label
58
+ }), running && /*#__PURE__*/_jsx("span", {
59
+ className: "shrink-0 text-warn motion-safe:locus-shimmer",
60
+ children: "Running"
61
+ })]
62
+ }), steps.length === 0 ? /*#__PURE__*/_jsx("p", {
63
+ className: "pl-6 text-sm text-faint",
64
+ children: emptyText
64
65
  }) : /*#__PURE__*/_jsxs(_Fragment, {
65
66
  children: [/*#__PURE__*/_jsx(Totals, {
66
67
  totals: totals
67
68
  }), /*#__PURE__*/_jsx("ol", {
68
- className: "flex flex-col divide-y divide-border border-t border-border",
69
+ className: "flex flex-col pl-6",
69
70
  children: steps.map(step => /*#__PURE__*/_jsx(StepCostRow, {
70
71
  step: step,
71
72
  maxCost: maxCost,
package/dist/cost/cost.js CHANGED
@@ -1,8 +1,8 @@
1
- import { Money as CoinsIcon } from "@carbon/icons-react";
2
1
  import { cn } from "@locusgraph/components";
3
- import { formatCount, formatMicroUsd, pluralize } from "@locusgraph/utils";
4
- import { ApprovalPanel, PanelHeader } from "../shared/panel.js";
5
- import { sumUsage } from "./shared/usage-totals.js";
2
+ import { formatMicroUsd, pluralize } from "@locusgraph/utils";
3
+ import { Coins as CoinsIcon } from "@phosphor-icons/react/ssr";
4
+ import { lineIconClass, lineRowClass } from "../shared/line.js";
5
+ import { formatTokensShort, sumUsage } from "./shared/usage-totals.js";
6
6
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
7
7
  function attemptsOf(usage) {
8
8
  return Array.isArray(usage) ? usage : [usage];
@@ -31,13 +31,13 @@ function CompactCost({
31
31
  "data-slot": "cost",
32
32
  "data-variant": "compact",
33
33
  "data-failed": totals.failedAttempts > 0 || undefined,
34
- className: cn("inline-flex flex-wrap items-baseline gap-x-3 gap-y-0.5 font-mono text-[11px] text-muted-foreground tabular-nums", className),
34
+ className: cn("inline-flex flex-wrap items-baseline gap-x-3 gap-y-0.5 text-xs text-faint tabular-nums", className),
35
35
  children: [/*#__PURE__*/_jsx("span", {
36
- className: "font-medium text-foreground",
36
+ className: "font-medium text-muted-foreground",
37
37
  children: formatMicroUsd(totals.costMicroUsd)
38
38
  }), /*#__PURE__*/_jsxs("span", {
39
39
  className: "whitespace-nowrap",
40
- children: [formatCount(totals.inputTokens), " in \xB7 ", formatCount(totals.outputTokens), " out"]
40
+ children: [formatTokensShort(totals.inputTokens), " in \xB7 ", formatTokensShort(totals.outputTokens), " out"]
41
41
  }), model && /*#__PURE__*/_jsx("span", {
42
42
  children: model
43
43
  }), /*#__PURE__*/_jsx(WastedNote, {
@@ -46,30 +46,26 @@ function CompactCost({
46
46
  });
47
47
  }
48
48
  function AttemptRow({
49
- attempt,
50
- position
49
+ attempt
51
50
  }) {
52
51
  return /*#__PURE__*/_jsxs("li", {
53
52
  "data-slot": "cost-attempt",
54
53
  "data-failed": attempt.failed || undefined,
55
- className: "grid grid-cols-[1fr_auto_4.5rem] items-baseline gap-x-4 px-5 py-2.5 text-sm tabular-nums",
54
+ className: "flex items-baseline justify-between gap-4 py-0.5 text-sm tabular-nums",
56
55
  children: [/*#__PURE__*/_jsxs("span", {
57
56
  className: "flex min-w-0 items-baseline gap-2",
58
- children: [/*#__PURE__*/_jsxs("span", {
59
- className: "locus-eyebrow",
60
- children: ["#", position + 1]
61
- }), /*#__PURE__*/_jsx("span", {
62
- className: cn("truncate", attempt.failed && "text-muted-foreground"),
57
+ children: [/*#__PURE__*/_jsx("span", {
58
+ className: cn("truncate normal-nums", attempt.failed ? "text-muted-foreground" : "text-foreground"),
63
59
  children: attempt.model ?? "Attempt"
64
60
  }), attempt.failed && /*#__PURE__*/_jsx("span", {
65
- className: "font-mono text-[11px] tracking-wide text-destructive uppercase",
61
+ className: "text-xs font-medium text-destructive",
66
62
  children: "Failed"
67
63
  })]
68
64
  }), /*#__PURE__*/_jsxs("span", {
69
- className: "font-mono text-[11px] text-muted-foreground max-sm:hidden",
70
- children: [formatCount(attempt.inputTokens), " in \xB7 ", formatCount(attempt.outputTokens), " out"]
65
+ className: "ml-auto text-xs text-faint",
66
+ children: [formatTokensShort(attempt.inputTokens), " in \xB7 ", formatTokensShort(attempt.outputTokens), " out"]
71
67
  }), /*#__PURE__*/_jsx("span", {
72
- className: cn("text-right font-mono text-xs", attempt.failed && "text-muted-foreground line-through"),
68
+ className: cn("shrink-0", attempt.failed ? "text-faint line-through decoration-faint" : "text-foreground"),
73
69
  children: formatMicroUsd(attempt.costMicroUsd)
74
70
  })]
75
71
  });
@@ -81,39 +77,43 @@ function DetailedCost({
81
77
  className
82
78
  }) {
83
79
  const failed = totals.failedAttempts > 0;
84
- return /*#__PURE__*/_jsxs(ApprovalPanel, {
80
+ return /*#__PURE__*/_jsxs("section", {
85
81
  "data-slot": "cost",
86
82
  "data-variant": "detailed",
87
83
  "data-failed": failed || undefined,
88
84
  "aria-label": label,
89
- className: className,
90
- children: [/*#__PURE__*/_jsx(PanelHeader, {
91
- icon: /*#__PURE__*/_jsx(CoinsIcon, {
92
- "aria-hidden": true
93
- }),
94
- eyebrow: label,
95
- aside: pluralize(attempts.length, "attempt")
85
+ className: cn("flex min-w-0 flex-col", className),
86
+ children: [/*#__PURE__*/_jsxs("header", {
87
+ className: lineRowClass,
88
+ children: [/*#__PURE__*/_jsx("span", {
89
+ "aria-hidden": true,
90
+ className: lineIconClass,
91
+ children: /*#__PURE__*/_jsx(CoinsIcon, {
92
+ weight: "bold",
93
+ "aria-hidden": true
94
+ })
95
+ }), /*#__PURE__*/_jsx("span", {
96
+ className: "truncate",
97
+ children: label
98
+ })]
96
99
  }), /*#__PURE__*/_jsxs("div", {
97
- className: "flex flex-col gap-1 px-5 pt-2 pb-4",
100
+ className: "flex flex-wrap items-baseline gap-x-3 gap-y-0.5 pb-2 pl-6 text-xs tabular-nums",
98
101
  children: [/*#__PURE__*/_jsx("span", {
99
- className: "text-2xl font-semibold tracking-tight tabular-nums",
102
+ className: "text-xl font-semibold tracking-tight text-foreground",
100
103
  children: formatMicroUsd(totals.costMicroUsd)
101
104
  }), /*#__PURE__*/_jsxs("span", {
102
- className: "flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground tabular-nums",
103
- children: [/*#__PURE__*/_jsxs("span", {
104
- children: [formatCount(totals.inputTokens), " in \xB7 ", formatCount(totals.outputTokens), " out"]
105
- }), /*#__PURE__*/_jsx(WastedNote, {
106
- totals: totals
107
- })]
105
+ className: "text-faint",
106
+ children: [formatTokensShort(totals.inputTokens), " in \xB7 ", formatTokensShort(totals.outputTokens), " out"]
107
+ }), /*#__PURE__*/_jsx(WastedNote, {
108
+ totals: totals
108
109
  })]
109
- }), /*#__PURE__*/_jsx("ol", {
110
- className: "flex flex-col divide-y divide-border border-t border-border",
110
+ }), attempts.length > 1 && /*#__PURE__*/_jsx("ol", {
111
+ className: "flex max-w-sm flex-col pl-6",
111
112
  children: attempts.map((attempt, position) =>
112
113
  /*#__PURE__*/
113
114
  // biome-ignore lint/suspicious/noArrayIndexKey: attempts carry no id and keep their order
114
115
  _jsx(AttemptRow, {
115
- attempt: attempt,
116
- position: position
116
+ attempt: attempt
117
117
  }, position))
118
118
  })]
119
119
  });
@@ -1,54 +1,187 @@
1
- import { ChevronDown as ChevronDownIcon } from "@carbon/icons-react";
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
2
4
  import { cn, DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuTrigger } from "@locusgraph/components";
5
+ import { CaretDown as ChevronDownIcon } from "@phosphor-icons/react/ssr";
3
6
  import { ModelOptionRow } from "./shared/model-option-row.js";
4
7
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
8
  export { modelPriceLabel } from "./shared/model-option-row.js";
6
- export function ModelPicker({
7
- models,
8
- value,
9
- onChange,
10
- label = "Model",
11
- disabled = false,
12
- className
13
- }) {
14
- const selected = models.find(model => model.id === value);
15
- return /*#__PURE__*/_jsxs(DropdownMenu, {
16
- children: [/*#__PURE__*/_jsxs(DropdownMenuTrigger, {
9
+ export function ModelPicker(t0) {
10
+ const $ = _c(36);
11
+ const {
12
+ models,
13
+ value,
14
+ onChange,
15
+ label: t1,
16
+ disabled: t2,
17
+ className
18
+ } = t0;
19
+ const label = t1 === undefined ? "Model" : t1;
20
+ const disabled = t2 === undefined ? false : t2;
21
+ let t3;
22
+ if ($[0] !== models || $[1] !== value) {
23
+ let t4;
24
+ if ($[3] !== value) {
25
+ t4 = model => model.id === value;
26
+ $[3] = value;
27
+ $[4] = t4;
28
+ } else {
29
+ t4 = $[4];
30
+ }
31
+ t3 = models.find(t4);
32
+ $[0] = models;
33
+ $[1] = value;
34
+ $[2] = t3;
35
+ } else {
36
+ t3 = $[2];
37
+ }
38
+ const selected = t3;
39
+ const t4 = `${label}: ${selected?.name ?? "none selected"}`;
40
+ let t5;
41
+ if ($[5] !== className) {
42
+ t5 = cn("group inline-flex h-control-sm max-w-full items-center gap-1.5 rounded-full px-2.5 text-xs locus-focus-ring transition-colors duration-150 hover:bg-accent disabled:pointer-events-none disabled:opacity-50 data-[state=open]:bg-accent motion-reduce:transition-none", className);
43
+ $[5] = className;
44
+ $[6] = t5;
45
+ } else {
46
+ t5 = $[6];
47
+ }
48
+ const t6 = selected?.name ?? label;
49
+ let t7;
50
+ if ($[7] !== t6) {
51
+ t7 = /*#__PURE__*/_jsx("span", {
52
+ className: "truncate font-medium",
53
+ children: t6
54
+ });
55
+ $[7] = t6;
56
+ $[8] = t7;
57
+ } else {
58
+ t7 = $[8];
59
+ }
60
+ let t8;
61
+ if ($[9] !== selected) {
62
+ t8 = selected && /*#__PURE__*/_jsx("span", {
63
+ className: "truncate text-muted-foreground max-sm:hidden",
64
+ children: selected.provider
65
+ });
66
+ $[9] = selected;
67
+ $[10] = t8;
68
+ } else {
69
+ t8 = $[10];
70
+ }
71
+ let t9;
72
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
73
+ t9 = /*#__PURE__*/_jsx(ChevronDownIcon, {
74
+ weight: "bold",
75
+ "aria-hidden": true,
76
+ className: "size-3 shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180 motion-reduce:transition-none"
77
+ });
78
+ $[11] = t9;
79
+ } else {
80
+ t9 = $[11];
81
+ }
82
+ let t10;
83
+ if ($[12] !== disabled || $[13] !== t4 || $[14] !== t5 || $[15] !== t7 || $[16] !== t8 || $[17] !== value) {
84
+ t10 = /*#__PURE__*/_jsxs(DropdownMenuTrigger, {
17
85
  "data-slot": "model-picker",
18
86
  "data-value": value,
19
87
  disabled: disabled,
20
- "aria-label": `${label}: ${selected?.name ?? "none selected"}`,
21
- className: cn("group inline-flex h-7 max-w-full items-center gap-1.5 rounded-full px-2.5 text-xs outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:opacity-50 data-[state=open]:bg-accent motion-reduce:transition-none", className),
22
- children: [/*#__PURE__*/_jsx("span", {
23
- className: "truncate font-medium",
24
- children: selected?.name ?? label
25
- }), selected && /*#__PURE__*/_jsx("span", {
26
- className: "truncate text-muted-foreground max-sm:hidden",
27
- children: selected.provider
28
- }), /*#__PURE__*/_jsx(ChevronDownIcon, {
29
- "aria-hidden": true,
30
- className: "size-3 shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180 motion-reduce:transition-none"
31
- })]
32
- }), /*#__PURE__*/_jsxs(DropdownMenuContent, {
88
+ "aria-label": t4,
89
+ className: t5,
90
+ children: [t7, t8, t9]
91
+ });
92
+ $[12] = disabled;
93
+ $[13] = t4;
94
+ $[14] = t5;
95
+ $[15] = t7;
96
+ $[16] = t8;
97
+ $[17] = value;
98
+ $[18] = t10;
99
+ } else {
100
+ t10 = $[18];
101
+ }
102
+ let t11;
103
+ if ($[19] !== label) {
104
+ t11 = /*#__PURE__*/_jsx("span", {
105
+ children: label
106
+ });
107
+ $[19] = label;
108
+ $[20] = t11;
109
+ } else {
110
+ t11 = $[20];
111
+ }
112
+ let t12;
113
+ if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
114
+ t12 = /*#__PURE__*/_jsx("span", {
115
+ className: "pr-7",
116
+ children: "Per 1M tokens"
117
+ });
118
+ $[21] = t12;
119
+ } else {
120
+ t12 = $[21];
121
+ }
122
+ let t13;
123
+ if ($[22] !== t11) {
124
+ t13 = /*#__PURE__*/_jsxs(DropdownMenuLabel, {
125
+ className: "locus-eyebrow flex justify-between gap-3 px-3 pt-2.5 pb-1 font-normal",
126
+ children: [t11, t12]
127
+ });
128
+ $[22] = t11;
129
+ $[23] = t13;
130
+ } else {
131
+ t13 = $[23];
132
+ }
133
+ let t14;
134
+ if ($[24] !== models) {
135
+ t14 = models.map(_temp);
136
+ $[24] = models;
137
+ $[25] = t14;
138
+ } else {
139
+ t14 = $[25];
140
+ }
141
+ let t15;
142
+ if ($[26] !== onChange || $[27] !== t14 || $[28] !== value) {
143
+ t15 = /*#__PURE__*/_jsx(DropdownMenuRadioGroup, {
144
+ value: value,
145
+ onValueChange: onChange,
146
+ className: "flex flex-col pb-1",
147
+ children: t14
148
+ });
149
+ $[26] = onChange;
150
+ $[27] = t14;
151
+ $[28] = value;
152
+ $[29] = t15;
153
+ } else {
154
+ t15 = $[29];
155
+ }
156
+ let t16;
157
+ if ($[30] !== t13 || $[31] !== t15) {
158
+ t16 = /*#__PURE__*/_jsxs(DropdownMenuContent, {
33
159
  align: "start",
34
160
  sideOffset: 6,
35
161
  className: "w-80 rounded-none border-0 bg-popover p-0 shadow-overlay ring-1 ring-border",
36
- children: [/*#__PURE__*/_jsxs(DropdownMenuLabel, {
37
- className: "locus-eyebrow flex justify-between gap-3 border-b border-border px-3 py-2 font-normal",
38
- children: [/*#__PURE__*/_jsx("span", {
39
- children: label
40
- }), /*#__PURE__*/_jsx("span", {
41
- className: "pr-7",
42
- children: "Per 1M tokens"
43
- })]
44
- }), /*#__PURE__*/_jsx(DropdownMenuRadioGroup, {
45
- value: value,
46
- onValueChange: onChange,
47
- className: "flex flex-col divide-y divide-border",
48
- children: models.map(model => /*#__PURE__*/_jsx(ModelOptionRow, {
49
- model: model
50
- }, model.id))
51
- })]
52
- })]
53
- });
162
+ children: [t13, t15]
163
+ });
164
+ $[30] = t13;
165
+ $[31] = t15;
166
+ $[32] = t16;
167
+ } else {
168
+ t16 = $[32];
169
+ }
170
+ let t17;
171
+ if ($[33] !== t10 || $[34] !== t16) {
172
+ t17 = /*#__PURE__*/_jsxs(DropdownMenu, {
173
+ children: [t10, t16]
174
+ });
175
+ $[33] = t10;
176
+ $[34] = t16;
177
+ $[35] = t17;
178
+ } else {
179
+ t17 = $[35];
180
+ }
181
+ return t17;
182
+ }
183
+ function _temp(model_0) {
184
+ return /*#__PURE__*/_jsx(ModelOptionRow, {
185
+ model: model_0
186
+ }, model_0.id);
54
187
  }
@@ -1,6 +1,7 @@
1
1
  import { cn } from "@locusgraph/components";
2
- import { formatCount, quotaPercent } from "@locusgraph/utils";
2
+ import { formatCount } from "@locusgraph/utils";
3
3
  import { MeterBar } from "./meter-marks.js";
4
+ import { wholePercentsOf } from "./usage-totals.js";
4
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
6
  const statusWord = {
6
7
  ok: "Room left",
@@ -15,11 +16,11 @@ const statusDot = {
15
16
  function SegmentRow({
16
17
  label,
17
18
  tokens,
18
- limitTokens,
19
+ percent,
19
20
  muted = false
20
21
  }) {
21
22
  return /*#__PURE__*/_jsxs("li", {
22
- className: cn("grid grid-cols-[1fr_auto_3rem] items-baseline gap-x-3 px-4 py-2 text-xs tabular-nums", muted && "text-muted-foreground"),
23
+ className: cn("grid grid-cols-[1fr_auto_3rem] items-baseline gap-x-3 px-4 py-1.5 text-xs tabular-nums", muted && "text-muted-foreground"),
23
24
  children: [/*#__PURE__*/_jsx("span", {
24
25
  className: "truncate",
25
26
  children: label
@@ -28,10 +29,7 @@ function SegmentRow({
28
29
  children: formatCount(tokens)
29
30
  }), /*#__PURE__*/_jsxs("span", {
30
31
  className: "text-right font-mono text-muted-foreground",
31
- children: [quotaPercent({
32
- used: tokens,
33
- included: limitTokens
34
- }), "%"]
32
+ children: [percent, "%"]
35
33
  })]
36
34
  });
37
35
  }
@@ -44,6 +42,7 @@ export function ContextBreakdown({
44
42
  breakdown
45
43
  }) {
46
44
  const freeTokens = Math.max(limitTokens - usedTokens, 0);
45
+ const shares = wholePercentsOf([...breakdown.map(segment => segment.tokens), freeTokens], limitTokens);
47
46
  return /*#__PURE__*/_jsxs("div", {
48
47
  "data-slot": "context-breakdown",
49
48
  className: "flex flex-col",
@@ -74,15 +73,15 @@ export function ContextBreakdown({
74
73
  status: status
75
74
  })]
76
75
  }), /*#__PURE__*/_jsxs("ul", {
77
- className: "flex flex-col divide-y divide-border border-t border-border",
78
- children: [breakdown.map(segment => /*#__PURE__*/_jsx(SegmentRow, {
76
+ className: "flex flex-col pb-2",
77
+ children: [breakdown.map((segment, index) => /*#__PURE__*/_jsx(SegmentRow, {
79
78
  label: segment.label,
80
79
  tokens: segment.tokens,
81
- limitTokens: limitTokens
80
+ percent: shares[index] ?? 0
82
81
  }, segment.label)), /*#__PURE__*/_jsx(SegmentRow, {
83
82
  label: "Free",
84
83
  tokens: freeTokens,
85
- limitTokens: limitTokens,
84
+ percent: shares.at(-1) ?? 0,
86
85
  muted: true
87
86
  })]
88
87
  })]
@@ -1,6 +1,6 @@
1
- import { Checkmark as CheckIcon } from "@carbon/icons-react";
2
1
  import { DropdownMenuRadioItem } from "@locusgraph/components";
3
2
  import { formatMicroUsd } from "@locusgraph/utils";
3
+ import { Check as CheckIcon } from "@phosphor-icons/react/ssr";
4
4
  import { formatTokensShort } from "./usage-totals.js";
5
5
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
6
6
  const speedLabel = {
@@ -25,7 +25,7 @@ function PriceColumn({
25
25
  const input = model.inputPerMillionMicroUsd;
26
26
  const output = model.outputPerMillionMicroUsd;
27
27
  return /*#__PURE__*/_jsxs("span", {
28
- className: "flex flex-col items-end font-mono text-[11px] text-muted-foreground tabular-nums",
28
+ className: "flex flex-col items-end font-mono text-2xs text-muted-foreground tabular-nums",
29
29
  children: [input !== undefined && /*#__PURE__*/_jsxs("span", {
30
30
  children: [formatMicroUsd(input), " in"]
31
31
  }), output !== undefined && /*#__PURE__*/_jsxs("span", {
@@ -53,12 +53,13 @@ export function ModelOptionRow({
53
53
  children: model.provider
54
54
  })]
55
55
  }), facts.length > 0 && /*#__PURE__*/_jsx("span", {
56
- className: "font-mono text-[11px] text-muted-foreground tabular-nums",
56
+ className: "font-mono text-2xs text-muted-foreground tabular-nums",
57
57
  children: facts.join(" · ")
58
58
  })]
59
59
  }), /*#__PURE__*/_jsx(PriceColumn, {
60
60
  model: model
61
61
  }), /*#__PURE__*/_jsx(CheckIcon, {
62
+ weight: "bold",
62
63
  "aria-hidden": true,
63
64
  className: "size-4 text-foreground opacity-0 group-data-[state=checked]:opacity-100"
64
65
  })]
@@ -7,9 +7,8 @@ export function isWastedStep(step) {
7
7
  }
8
8
  function barTone(step) {
9
9
  if (isWastedStep(step)) return "bg-destructive";
10
- if (step.status === "retried") return "bg-warn/40";
11
10
  if (step.status === "running") return "bg-warn/60 motion-safe:animate-pulse";
12
- return "bg-primary/35";
11
+ return "bg-muted-foreground/50";
13
12
  }
14
13
  const statusMark = {
15
14
  failed: {
@@ -22,11 +21,11 @@ const statusMark = {
22
21
  },
23
22
  running: {
24
23
  text: "Running",
25
- className: "text-muted-foreground"
24
+ className: "text-muted-foreground motion-safe:locus-shimmer"
26
25
  },
27
26
  skipped: {
28
27
  text: "Skipped",
29
- className: "text-muted-foreground"
28
+ className: "font-normal text-faint"
30
29
  }
31
30
  };
32
31
  function barWidth(cost, maxCost) {
@@ -47,30 +46,30 @@ export function StepCostRow({
47
46
  "data-status": step.status,
48
47
  "data-wasted": wasted || undefined,
49
48
  "aria-label": `${step.title}: ${formatMicroUsd(cost)}, ${share}% of run${mark ? `, ${mark.text.toLowerCase()}` : ""}`,
50
- className: "grid grid-cols-[minmax(0,11rem)_1fr_3.5rem_4.5rem] items-center gap-x-4 gap-y-1.5 px-5 py-2.5 text-sm tabular-nums max-sm:grid-cols-[1fr_auto_auto]",
49
+ className: "grid grid-cols-[minmax(0,11rem)_1fr_3.5rem_4.5rem] items-center gap-x-4 gap-y-1.5 py-1 text-sm tabular-nums max-sm:grid-cols-[1fr_auto_auto]",
51
50
  children: [/*#__PURE__*/_jsxs("span", {
52
- className: "flex min-w-0 items-baseline gap-2",
51
+ className: "flex min-w-0 items-baseline gap-x-2 max-sm:flex-wrap",
53
52
  children: [/*#__PURE__*/_jsx("span", {
54
- className: cn("truncate", step.status === "skipped" && "text-muted-foreground"),
53
+ className: cn("text-foreground normal-nums sm:truncate", step.status === "skipped" && "text-faint"),
55
54
  children: step.title
56
55
  }), mark && /*#__PURE__*/_jsx("span", {
57
- className: cn("shrink-0 font-mono text-[11px] tracking-wide uppercase", mark.className),
56
+ className: cn("shrink-0 text-xs font-medium", mark.className),
58
57
  children: mark.text
59
58
  })]
60
59
  }), /*#__PURE__*/_jsx("span", {
61
60
  "aria-hidden": true,
62
- className: "relative h-1.5 w-full bg-muted-foreground/10 max-sm:col-span-3 max-sm:row-start-2",
61
+ className: "relative h-1 w-full overflow-hidden rounded-full bg-muted-foreground/10 max-sm:col-span-3 max-sm:row-start-2",
63
62
  children: /*#__PURE__*/_jsx("span", {
64
- className: cn("absolute inset-y-0 left-0 transition-[width] duration-300 motion-reduce:transition-none", barTone(step)),
63
+ className: cn("absolute inset-y-0 left-0 rounded-full transition-[width] duration-300 motion-reduce:transition-none", barTone(step)),
65
64
  style: {
66
65
  width: `${barWidth(cost, maxCost)}%`
67
66
  }
68
67
  })
69
68
  }), /*#__PURE__*/_jsx("span", {
70
- className: "text-right font-mono text-[11px] text-muted-foreground",
69
+ className: "text-right text-xs text-faint",
71
70
  children: step.durationMs !== undefined ? formatDuration(step.durationMs) : ""
72
71
  }), /*#__PURE__*/_jsx("span", {
73
- className: cn("text-right font-mono text-xs", wasted && "text-destructive"),
72
+ className: cn("text-right", wasted ? "text-destructive" : "text-foreground"),
74
73
  children: formatMicroUsd(cost)
75
74
  })]
76
75
  });
@@ -9,3 +9,4 @@ export type UsageTotals = {
9
9
  export declare function sumUsage(attempts: RunUsage[]): UsageTotals;
10
10
  export declare function formatTokensShort(tokens: number): string;
11
11
  export declare function formatDuration(durationMs: number): string;
12
+ export declare function wholePercentsOf(parts: number[], whole: number): number[];