@columenlabs/lumen-ui 0.1.235 → 0.1.236

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.
@@ -117,12 +117,20 @@ const wayTest = (k, plan = false) => k?.test
117
117
  : null;
118
118
  /** A provider's mark: its initial on a tile. */
119
119
  const mark = (label) => _jsx(ConnectionLogo, { text: label.charAt(0) });
120
+ /**
121
+ * Whether the app lets this person use `w` of their own on `p` (the app's `ownWays`, the same
122
+ * rule the server pays by). A way it does not allow never shows, even when one is still stored:
123
+ * the server would not run on it, so Settings never says it works.
124
+ */
125
+ const mayOwn = (p, w) => !p.own_ways || p.own_ways.includes(w);
126
+ /** Whether the person has a way of their own on `p` that the app lets them use. */
127
+ const ownUsable = (p) => (mayOwn(p, 'key') && p.own.set) || (mayOwn(p, 'plan') && !!p.plan?.set);
120
128
  /** One provider, collapsed to a row: the person's own key and, where it has one, their plan sign-in. */
121
129
  function OwnProviderKey({ client, p }) {
122
130
  const { apply, refresh } = useApply(client);
123
131
  const ways = [];
124
- const may = (w) => !p.own_ways || p.own_ways.includes(w);
125
- if (p.signin === 'chatgpt' && (may('plan') || p.plan?.set))
132
+ const may = (w) => mayOwn(p, w);
133
+ if (p.signin === 'chatgpt' && may('plan'))
126
134
  ways.push({
127
135
  id: 'plan',
128
136
  label: 'ChatGPT plan',
@@ -139,7 +147,7 @@ function OwnProviderKey({ client, p }) {
139
147
  removeText: 'Your API key, if you set one, runs from then on.',
140
148
  removeLabel: 'Sign out',
141
149
  });
142
- if (may('key') || p.own.set)
150
+ if (may('key'))
143
151
  ways.push({
144
152
  id: 'key',
145
153
  label: 'API key',
@@ -161,10 +169,10 @@ function OwnProviderKey({ client, p }) {
161
169
  function Providers({ client }) {
162
170
  const { apply } = useApply(client);
163
171
  return (_jsx(WithStatus, { client: client, children: (s) => {
164
- // A provider the app gives this person no way of their own on shows no row, unless one is
165
- // still set (so it can be removed).
166
- const rows = s.providers.filter((p) => !p.own_ways || p.own_ways.length > 0 || p.own.set || p.plan?.set);
167
- const ownSet = rows.some((p) => p.own.set || p.plan?.set);
172
+ // A provider the app gives this person no way of their own on shows no row: what shows here
173
+ // is exactly what the server may pay with.
174
+ const rows = s.providers.filter((p) => !p.own_ways || p.own_ways.length > 0);
175
+ const ownSet = rows.some(ownUsable);
168
176
  return (_jsxs("div", { className: "flex flex-col", children: [_jsx(LumenExpandList, { children: rows.map((p) => (_jsx(OwnProviderKey, { client: client, p: p }, p.id))) }), ownSet && (_jsx(Row, { label: "Answers run on", info: "Your own key or plan first, with the shared credits behind it; or the shared credits first.", children: _jsx(LumenSelector, { label: "Answers run on", size: "sm", className: "w-44", value: s.pay, options: [
169
177
  { value: 'own', label: 'Your own first' },
170
178
  { value: 'app', label: 'Shared credits first' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ui",
3
- "version": "0.1.235",
3
+ "version": "0.1.236",
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.235",
52
+ "@columenlabs/lumen-ui-types": "0.1.236",
53
53
  "@dnd-kit/core": "6.3.1",
54
54
  "@dnd-kit/sortable": "10.0.0",
55
55
  "@dnd-kit/utilities": "3.2.2",