@columenlabs/lumen-ui 0.1.250 → 0.1.252

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: ["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, " result", results.length === 1 ? '' : 's'] })), step.error && _jsxs("span", { className: "truncate", children: ["\u00B7 ", step.error] })] }));
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' && i.web?.read && !pages.some((p) => p.url === i.web?.read?.url))
405
- pages.push(i.web.read);
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);
@@ -91,6 +91,8 @@ export function UsageHistoryView({ client, className, }) {
91
91
  const models = perModel(h.rows);
92
92
  return (_jsxs("div", { className: cn('flex min-w-0 flex-col gap-3', className), children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(IconButton, { icon: ChevronLeftIcon, label: "Earlier month", disabled: !older, onClick: () => setMonth(older) }), _jsx("span", { className: "min-w-0 flex-1 truncate text-center font-medium text-sm", children: monthName(h.month) }), _jsx(IconButton, { icon: ChevronRightIcon, label: "Later month", disabled: !newer, onClick: () => setMonth(newer) })] }), _jsxs("div", { className: "flex items-baseline gap-2", children: [_jsx("span", { className: "num font-semibold text-2xl", children: usd(h.usd) }), _jsx("span", { className: "text-muted-foreground text-xs", children: h.entries.length === 1 ? '1 chat or run' : `${h.entries.length} chats and runs` })] }), models.length > 0 && (_jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_auto_auto_auto_auto] gap-x-3 gap-y-0.5 text-xs", children: [_jsx("span", { className: "text-muted-foreground", children: "Model" }), _jsx("span", { className: "text-right text-muted-foreground", children: "Cost" }), _jsx("span", { className: "text-right text-muted-foreground", children: "In" }), _jsx("span", { className: "text-right text-muted-foreground", children: "Out" }), _jsx("span", { className: "text-right text-muted-foreground", children: "Calls" }), models.map((m) => (_jsxs(Fragment, { children: [_jsx("span", { className: "truncate font-medium", title: m.label, children: m.label }), _jsx("span", { className: "num text-right", children: usd(m.usd) }), _jsx("span", { className: "num text-right", children: tokens(m.in) }), _jsx("span", { className: "num text-right", children: tokens(m.out) }), _jsx("span", { className: "num text-right", children: m.calls })] }, m.label)))] })), h.entries.length ? (_jsx("ul", { className: "-my-1.5 max-h-72 divide-y overflow-y-auto", children: h.entries.map((e) => (_jsx(Entry, { e: e }, e.id))) })) : (_jsx("p", { className: "text-muted-foreground text-sm", children: "Nothing used this month." }))] }));
93
93
  }
94
+ /** How the own-key table names calls a plan sign-in paid. */
95
+ const PLAN_NAME = 'ChatGPT plan';
94
96
  /** The ranges the own-key table offers, in days. */
95
97
  const OWN_RANGES = [
96
98
  { id: '1d', days: 1 },
@@ -110,7 +112,7 @@ export function OwnKeyUsage({ client, always, usable, }) {
110
112
  const prev = useAssistantUsage(client, before, !!before && range === '30d').data;
111
113
  if (!now)
112
114
  return null;
113
- const all = [...now.entries, ...(range === '30d' ? (prev?.entries ?? []) : [])].filter((e) => (e.own_usd ?? 0) > 0);
115
+ const all = [...now.entries, ...(range === '30d' ? (prev?.entries ?? []) : [])].filter((e) => (e.own_usd ?? 0) > 0 || (e.own_plan_calls ?? 0) > 0);
114
116
  if (!always && !all.length)
115
117
  return null;
116
118
  const days = OWN_RANGES.find((r) => r.id === range)?.days ?? 7;
@@ -136,7 +138,17 @@ export function OwnKeyUsage({ client, always, usable, }) {
136
138
  const total = sessions.reduce((a, e) => a + (e.own_usd ?? 0), 0) + untracked + gone;
137
139
  const earlier = 'Earlier this month, not per chat';
138
140
  const removedText = 'Key not in use now, not counted';
139
- 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 ? (_jsx(DetailsTable, { head: [
141
+ // Calls a plan sign-in paid: free to the person, so listed by count. A $0 own row from before
142
+ // 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);
146
+ const calls = (n) => (n === 1 ? '1 call' : `${n} calls`);
147
+ // Plan calls no chat or run carries (made before each entry kept its own count).
148
+ const planEarlier = Math.max(0, planCalls - now.entries.reduce((a, e) => a + (e.own_plan_calls ?? 0), 0));
149
+ const planText = `Earlier, ${PLAN_NAME}, ${calls(planEarlier)}`;
150
+ 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: [
140
152
  { label: 'Session', grow: true },
141
153
  { label: 'Date', hideOnPhone: true },
142
154
  { label: 'Amount', right: true },
@@ -144,7 +156,7 @@ export function OwnKeyUsage({ client, always, usable, }) {
144
156
  ...sessions.map((e) => ({
145
157
  key: e.id,
146
158
  cells: [
147
- _jsx("span", { className: "block truncate", title: e.title, children: e.title }, "n"),
159
+ _jsx("span", { className: "block truncate", title: named(e), children: named(e) }, "n"),
148
160
  _jsx("time", { dateTime: new Date(e.at).toISOString(), title: new Date(e.at).toLocaleString(), children: when(e.at) }, "t"),
149
161
  usd(e.own_usd ?? 0),
150
162
  ],
@@ -173,5 +185,17 @@ export function OwnKeyUsage({ client, always, usable, }) {
173
185
  },
174
186
  ]
175
187
  : []),
188
+ ...(planEarlier
189
+ ? [
190
+ {
191
+ key: 'plan',
192
+ cells: [
193
+ _jsx("span", { className: "block truncate text-muted-foreground", title: planText, children: planText }, "n"),
194
+ _jsx("span", {}, "t"),
195
+ usd(0),
196
+ ],
197
+ },
198
+ ]
199
+ : []),
176
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, "."] }))] }));
177
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ui",
3
- "version": "0.1.250",
3
+ "version": "0.1.252",
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.250",
52
+ "@columenlabs/lumen-ui-types": "0.1.252",
53
53
  "@dnd-kit/core": "6.3.1",
54
54
  "@dnd-kit/sortable": "10.0.0",
55
55
  "@dnd-kit/utilities": "3.2.2",