@columenlabs/lumen-ui 0.1.252 → 0.1.254

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.
@@ -135,20 +135,28 @@ export function OwnKeyUsage({ client, always, usable, }) {
135
135
  const left = ownMonth - tagged - removed;
136
136
  const untracked = left >= 0.01 ? left : 0;
137
137
  const gone = removed >= 0.01 ? removed : 0;
138
- const total = sessions.reduce((a, e) => a + (e.own_usd ?? 0), 0) + untracked + gone;
138
+ // A plan sign-in's calls at API rates (an estimate; the plan charged $0), so plan use counts too.
139
+ const planRows = now.rows.filter((r) => r.payer === 'own' && !r.free && (r.way === 'plan' || (!r.way && r.usd < 0.0005)));
140
+ const planListMonth = planRows.reduce((a, r) => a + (r.list_usd ?? 0), 0);
141
+ const planListEarlier = Math.max(0, planListMonth - now.entries.reduce((a, e) => a + (e.own_plan_usd ?? 0), 0));
142
+ const keyTotal = sessions.reduce((a, e) => a + (e.own_usd ?? 0), 0) + untracked + gone;
143
+ const planTotal = sessions.reduce((a, e) => a + (e.own_plan_usd ?? 0), 0);
139
144
  const earlier = 'Earlier this month, not per chat';
140
145
  const removedText = 'Key not in use now, not counted';
141
146
  // Calls a plan sign-in paid: free to the person, so listed by count. A $0 own row from before
142
147
  // rows recorded their way is a plan's too (a key call always costs something).
143
- const planCalls = now.rows
144
- .filter((r) => r.payer === 'own' && !r.free && (r.way === 'plan' || (!r.way && r.usd < 0.0005)))
145
- .reduce((a, r) => a + r.calls, 0);
148
+ const planCalls = planRows.reduce((a, r) => a + r.calls, 0);
146
149
  const calls = (n) => (n === 1 ? '1 call' : `${n} calls`);
147
150
  // Plan calls no chat or run carries (made before each entry kept its own count).
148
151
  const planEarlier = Math.max(0, planCalls - now.entries.reduce((a, e) => a + (e.own_plan_calls ?? 0), 0));
149
152
  const planText = `Earlier, ${PLAN_NAME}, ${calls(planEarlier)}`;
150
153
  const named = (e) => e.own_plan_calls ? `${e.title} · ${PLAN_NAME}, ${calls(e.own_plan_calls)}` : e.title;
151
- return (_jsxs("div", { className: "flex flex-col gap-2 border-t border-border/60 pb-3 first:border-t-0", children: [_jsx(SettingField, { label: "Spent on your keys", info: "Each chat and run your own key or plan paid for, by its last use.", className: "border-t-0", end: _jsx(ToggleGroup, { type: "single", variant: "outline", size: "sm", spacing: 0, value: range, "aria-label": "Range", onValueChange: (v) => v && setRange(v), children: OWN_RANGES.map((r) => (_jsx(ToggleGroupItem, { value: r.id, "aria-label": `Last ${r.id}`, children: r.id }, r.id))) }) }), sessions.length || untracked || gone || planEarlier ? (_jsx(DetailsTable, { head: [
154
+ const total = keyTotal + planTotal + (planEarlier ? planListEarlier : 0);
155
+ const anyPlan = planTotal > 0 || (planEarlier > 0 && planListEarlier > 0);
156
+ // An amount with plan calls in it reads ≈: the plan's part is what API rates would charge.
157
+ const amount = (key, plan, title) => plan > 0 ? (_jsxs("span", { title: title, children: ["\u2248", usd(key + plan)] }, "a")) : (usd(key));
158
+ const planTitle = (key, plan) => `${key > 0 ? `${usd(key)} on your key + ` : ''}about ${usd(plan)} at API rates on your ${PLAN_NAME}, which charged $0`;
159
+ return (_jsxs("div", { className: "flex flex-col gap-2 border-t border-border/60 pb-3 first:border-t-0", children: [_jsx(SettingField, { label: "Spent on your keys", info: "Each chat and run your own key or plan paid for, by its last use. A \u2248 amount prices plan calls at API rates; the plan charges $0.", className: "border-t-0", end: _jsx(ToggleGroup, { type: "single", variant: "outline", size: "sm", spacing: 0, value: range, "aria-label": "Range", onValueChange: (v) => v && setRange(v), children: OWN_RANGES.map((r) => (_jsx(ToggleGroupItem, { value: r.id, "aria-label": `Last ${r.id}`, children: r.id }, r.id))) }) }), sessions.length || untracked || gone || planEarlier ? (_jsx(DetailsTable, { head: [
152
160
  { label: 'Session', grow: true },
153
161
  { label: 'Date', hideOnPhone: true },
154
162
  { label: 'Amount', right: true },
@@ -158,7 +166,7 @@ export function OwnKeyUsage({ client, always, usable, }) {
158
166
  cells: [
159
167
  _jsx("span", { className: "block truncate", title: named(e), children: named(e) }, "n"),
160
168
  _jsx("time", { dateTime: new Date(e.at).toISOString(), title: new Date(e.at).toLocaleString(), children: when(e.at) }, "t"),
161
- usd(e.own_usd ?? 0),
169
+ amount(e.own_usd ?? 0, e.own_plan_usd ?? 0, planTitle(e.own_usd ?? 0, e.own_plan_usd ?? 0)),
162
170
  ],
163
171
  })),
164
172
  ...(untracked
@@ -192,10 +200,16 @@ export function OwnKeyUsage({ client, always, usable, }) {
192
200
  cells: [
193
201
  _jsx("span", { className: "block truncate text-muted-foreground", title: planText, children: planText }, "n"),
194
202
  _jsx("span", {}, "t"),
195
- usd(0),
203
+ amount(0, planListEarlier, planTitle(0, planListEarlier)),
196
204
  ],
197
205
  },
198
206
  ]
199
207
  : []),
200
- ], foot: ['Total', _jsx("span", { className: "max-md:hidden" }, "d"), usd(total)] })) : (_jsxs("p", { className: "text-muted-foreground text-sm", children: ["Nothing spent on your keys in the last ", range, "."] }))] }));
208
+ ], foot: [
209
+ 'Total',
210
+ _jsx("span", { className: "max-md:hidden" }, "d"),
211
+ anyPlan
212
+ ? amount(keyTotal, total - keyTotal, planTitle(keyTotal, total - keyTotal))
213
+ : usd(total),
214
+ ] })) : (_jsxs("p", { className: "text-muted-foreground text-sm", children: ["Nothing spent on your keys in the last ", range, "."] }))] }));
201
215
  }
@@ -74,7 +74,14 @@ export function applyEvent(prev, e) {
74
74
  if (last?.kind === 'text')
75
75
  sink[sink.length - 1] = { kind: 'text', text: last.text };
76
76
  break;
77
- case 'step_start':
77
+ case 'step_start': {
78
+ // A second start for the same call words it again, now that its arguments are in.
79
+ const at = sink.findIndex((i) => i.kind === 'step' && i.id === e.data.id);
80
+ const running = at >= 0 ? sink[at] : undefined;
81
+ if (running?.kind === 'step' && 'live' in running && running.live) {
82
+ sink[at] = { ...running, title: e.data.title };
83
+ break;
84
+ }
78
85
  sink.push({
79
86
  kind: 'step',
80
87
  id: e.data.id,
@@ -86,6 +93,7 @@ export function applyEvent(prev, e) {
86
93
  ...(e.data.write ? { writing: true } : {}),
87
94
  });
88
95
  break;
96
+ }
89
97
  case 'step': {
90
98
  const { handoff: _h, ...step } = e.data;
91
99
  const at = sink.findIndex((i) => i.kind === 'step' && i.id === step.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ui",
3
- "version": "0.1.252",
3
+ "version": "0.1.254",
4
4
  "description": "Lumen: shared React components (frame, views, widgets, charts, drawers).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  "@codemirror/lang-javascript": "6.2.5",
50
50
  "@codemirror/lang-json": "6.0.2",
51
51
  "@codemirror/lang-sql": "6.10.0",
52
- "@columenlabs/lumen-ui-types": "0.1.252",
52
+ "@columenlabs/lumen-ui-types": "0.1.254",
53
53
  "@dnd-kit/core": "6.3.1",
54
54
  "@dnd-kit/sortable": "10.0.0",
55
55
  "@dnd-kit/utilities": "3.2.2",