@columenlabs/lumen-ui 0.1.251 → 0.1.253
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.
|
@@ -386,9 +386,9 @@ function pathOf(url) {
|
|
|
386
386
|
/** A web step: a search, its results folded under it, or one page read. */
|
|
387
387
|
function WebStep({ step, live }) {
|
|
388
388
|
const web = step.web ?? {};
|
|
389
|
-
const results = web.results ?? [];
|
|
389
|
+
const results = (web.lookup ? web.reads : web.results) ?? [];
|
|
390
390
|
const icon = live ? (_jsx(Spinner, { className: "size-3" })) : !step.ok ? (_jsx(CircleAlertIcon, { className: "size-3.5 shrink-0" })) : web.read ? (_jsx(GlobeIcon, { className: "size-3.5 shrink-0" })) : (_jsx(SearchIcon, { className: "size-3.5 shrink-0" }));
|
|
391
|
-
const line = (_jsxs(_Fragment, { children: [icon, web.tried ? (_jsxs("span", { className: "truncate", title: web.tried.url, children: ["Could not open ", _jsx("span", { className: "text-foreground", children: hostOf(web.tried.url) })] })) : web.read ? (_jsxs("span", { className: "truncate", title: web.read.title ?? web.read.url, children: ["Read ", _jsx("span", { className: "text-foreground", children: hostOf(web.read.url) }), pathOf(web.read.url) && ` · ${pathOf(web.read.url)}`] })) : (_jsxs("span", { className: "truncate", title: web.query, children: [
|
|
391
|
+
const line = (_jsxs(_Fragment, { children: [icon, web.tried ? (_jsxs("span", { className: "truncate", title: web.tried.url, children: ["Could not open ", _jsx("span", { className: "text-foreground", children: hostOf(web.tried.url) })] })) : web.read ? (_jsxs("span", { className: "truncate", title: web.read.title ?? web.read.url, children: ["Read ", _jsx("span", { className: "text-foreground", children: hostOf(web.read.url) }), pathOf(web.read.url) && ` · ${pathOf(web.read.url)}`] })) : (_jsxs("span", { className: "truncate", title: web.query, children: [web.lookup ? 'Looked up' : 'Searched the web', web.query ? ': ' : '', web.query && _jsx("span", { className: "text-foreground", children: web.query })] })), !live && !web.read && !web.tried && step.ok && (_jsxs("span", { className: "ml-auto shrink-0 tabular-nums", children: [results.length, " ", web.lookup ? 'source' : 'result', results.length === 1 ? '' : 's'] })), step.error && _jsxs("span", { className: "truncate", children: ["\u00B7 ", step.error] })] }));
|
|
392
392
|
const cls = cn('flex min-w-0 items-center gap-1.5 text-xs', step.ok ? 'text-muted-foreground' : 'text-loss');
|
|
393
393
|
if (!results.length)
|
|
394
394
|
return _jsx("p", { className: cls, children: line });
|
|
@@ -401,8 +401,10 @@ function turnPages(items) {
|
|
|
401
401
|
for (const i of list) {
|
|
402
402
|
if (i.kind === 'handoff')
|
|
403
403
|
walk(i.items);
|
|
404
|
-
else if (i.kind === 'step'
|
|
405
|
-
|
|
404
|
+
else if (i.kind === 'step')
|
|
405
|
+
for (const p of i.web?.read ? [i.web.read] : (i.web?.reads ?? []))
|
|
406
|
+
if (!pages.some((x) => x.url === p.url))
|
|
407
|
+
pages.push(p);
|
|
406
408
|
}
|
|
407
409
|
};
|
|
408
410
|
walk(items);
|
|
@@ -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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
203
|
+
amount(0, planListEarlier, planTitle(0, planListEarlier)),
|
|
196
204
|
],
|
|
197
205
|
},
|
|
198
206
|
]
|
|
199
207
|
: []),
|
|
200
|
-
], foot: [
|
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@columenlabs/lumen-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.253",
|
|
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.
|
|
52
|
+
"@columenlabs/lumen-ui-types": "0.1.253",
|
|
53
53
|
"@dnd-kit/core": "6.3.1",
|
|
54
54
|
"@dnd-kit/sortable": "10.0.0",
|
|
55
55
|
"@dnd-kit/utilities": "3.2.2",
|