@gemboss/ui 0.52.0 → 0.55.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.
- package/CHANGELOG.md +78 -0
- package/README.md +74 -55
- package/catalog/editor.html +1 -1
- package/catalog/index.html +711 -315
- package/gemboss-ui.css +2 -2
- package/package.json +1 -1
- package/parts/components.css +1 -1
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/assistant/engine-settings.tsx +11 -8
- package/src/assistant/engine.tsx +129 -394
- package/src/assistant/index.ts +3 -2
- package/src/assistant-engine.css +1 -1
- package/src/auth.tsx +41 -13
- package/src/dialog.tsx +34 -5
- package/src/editor/picker-grid.tsx +5 -2
- package/src/editor/picker.tsx +40 -26
- package/src/editor/popover.tsx +2 -1
- package/src/editor-insert.css +1 -1
- package/src/editor-picker.css +1 -1
- package/src/engine-plain.js +1 -1
- package/src/escape.ts +16 -0
package/src/assistant/engine.tsx
CHANGED
|
@@ -1,42 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The assistant's ENGINE PICKER — @gemboss/ui (0.25.0, Chris 07/10/2026).
|
|
4
|
+
* The assistant's ENGINE PICKER — @gemboss/ui (0.25.0, Chris 07/10/2026; a door to Settings since 0.52.0, only that since 0.53.0).
|
|
5
5
|
*
|
|
6
6
|
* One chip in the composer row: the engine's name, the model when it is not the default, and a dot for the bridge on the
|
|
7
|
-
* user's machine (green running, amber outdated, red not connected). A click opens
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* user's machine (green running, amber outdated, red not connected). A click opens the surface's SETTINGS on its
|
|
8
|
+
* "AI & engines" section (`onOpenSettings`), which draws what the chip publishes (`EngineSettingsSection`,
|
|
9
|
+
* engine-settings.tsx): Engine (which engine answers, its model, its effort) and Bridge on your machine (what is wrong, its
|
|
10
|
+
* state, its actions, then Install or update: the command with Copy, the pairing code).
|
|
11
11
|
*
|
|
12
|
-
* Why
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* bridge says so in one line in the stream (`BridgeNotice`), whose "Open setup" opens
|
|
12
|
+
* Why: content-radar's Radar Assistant once spent close to half of its frame on an ENGINE / MODEL / EFFORT row and the
|
|
13
|
+
* bridge's install block above the conversation (Chris 07/10: "chèn hết vào không gian chat tốn không gian quá"); 0.25.0 put
|
|
14
|
+
* them in a 360px popup of the chip, Engine · Setup · Status tabs over the chat; 0.52.0 moved them into Settings (Chris
|
|
15
|
+
* 24/10: "đưa hết về nằm trong popup settings để có nhiều không gian hơn… bấm vào đó mở settings"), and 0.53.0 removed the
|
|
16
|
+
* popup once every surface had moved (the condition Chris set for the weight of engine-plain.js). A turn that FAILS because
|
|
17
|
+
* of the bridge says so in one line in the stream (`BridgeNotice`), whose "Open setup" opens Settings on Install or update.
|
|
18
18
|
*
|
|
19
19
|
* The package knows nothing about any bridge. The surface hands in the engines, the models, the efforts, the bridge's
|
|
20
|
-
* status, the command and the code, and hears every change through callbacks.
|
|
21
|
-
*
|
|
22
|
-
* The panel is a non-modal dialog in the browser's TOP LAYER (`popover="manual"`, placed like the kit's menus by
|
|
23
|
-
* `placeFloating`): no scrolling frame cuts it, it stays in the React tree (tokens resolve, events bubble). Escape and an
|
|
24
|
-
* outside click close it; Escape and every close from inside it give focus back to the chip. Tabs are a roving tablist
|
|
25
|
-
* (←/→/Home/End). Its look is `assistant-engine.css`, imported here: a surface that never draws the picker never loads it.
|
|
20
|
+
* status, the command and the code, and hears every change through callbacks. Its look is `assistant-engine.css`, imported
|
|
21
|
+
* here: a surface that never draws the picker never loads it.
|
|
26
22
|
*/
|
|
27
23
|
import "../assistant-engine.css"; // its own entry (0.25.0): not in gemboss-ui.css, not in the assistant frame's sheet
|
|
28
|
-
import React, { useCallback, useEffect, useId,
|
|
29
|
-
import {
|
|
30
|
-
import { canFloatMenus, placeFloating } from "../menu-layer";
|
|
31
|
-
import { EngineMark, isEngineMarkId } from "./engine-mark";
|
|
24
|
+
import React, { useCallback, useEffect, useId, useRef, useState, type ReactNode } from "react";
|
|
25
|
+
import { EngineMark, isEngineMarkId, type EngineMarkId } from "./engine-mark";
|
|
32
26
|
import { requestEngineSettingsFocus, usePublishEngineSettings } from "./engine-settings-store";
|
|
33
27
|
|
|
34
28
|
const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean).join(" ");
|
|
35
|
-
const useBeforePaint = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
36
29
|
|
|
37
30
|
/** running = answers now · outdated = answers, but an update is due · offline = paired, not reachable · unpaired = never
|
|
38
31
|
* set up on this account · checking = not known yet (first poll in flight). */
|
|
39
32
|
export type BridgeState = "running" | "outdated" | "offline" | "unpaired" | "checking";
|
|
33
|
+
/** The part of Settings › AI & engines to bring into view: the top (engine), the bridge's state, its install or update. */
|
|
40
34
|
export type EnginePickerTab = "engine" | "setup" | "status";
|
|
41
35
|
|
|
42
36
|
export interface EngineChoice {
|
|
@@ -52,8 +46,8 @@ export interface EngineChoice {
|
|
|
52
46
|
/** The engine's mark ("claude", "codex": `ENGINE_MARK_ART`). The chip shows it in place of the name when the composer row
|
|
53
47
|
* is too narrow for the name (`ChatComposer` density "icon"); an engine without one keeps its (cut) name. 0.29.0. */
|
|
54
48
|
mark?: string;
|
|
55
|
-
/** THIS engine's models. Give them on every engine and the Engine
|
|
56
|
-
* once, and one click picks the engine and the model together (`onPick`): the admin's
|
|
49
|
+
/** THIS engine's models. Give them on every engine and the Engine card lists each engine with its own models, all at
|
|
50
|
+
* once, and one click picks the engine and the model together (`onPick`): the admin's shape. 0.29.0. */
|
|
57
51
|
models?: readonly Choice[];
|
|
58
52
|
}
|
|
59
53
|
|
|
@@ -88,36 +82,34 @@ export interface BridgeSetup {
|
|
|
88
82
|
pairingCode?: string;
|
|
89
83
|
/** A few lines of how (an <ol>, a sentence). Default: "Paste the command into Terminal, then press Enter." */
|
|
90
84
|
steps?: ReactNode;
|
|
91
|
-
/** Quiet text under the command ("The pairing code stays the same: the
|
|
85
|
+
/** Quiet text under the command ("The pairing code stays the same: the assistant reconnects in a few seconds."). */
|
|
92
86
|
note?: ReactNode;
|
|
93
87
|
}
|
|
94
88
|
|
|
95
89
|
/** Every word the picker says. English, like every surface's chrome (Chris 03/10/2026). */
|
|
96
90
|
export interface EnginePickerLabels {
|
|
97
|
-
chip: string;
|
|
98
|
-
engineTab: string; setupTab: string; statusTab: string;
|
|
91
|
+
chip: string;
|
|
99
92
|
engine: string; model: string; effort: string;
|
|
100
93
|
defaultChoice: string;
|
|
101
94
|
copy: string; copied: string; copyFailed: string; pairingCode: string; steps: string;
|
|
102
95
|
bridge: string; version: string; latest: string; startsAtSignIn: string; machine: string; lastSeen: string;
|
|
103
96
|
yes: string; no: string; unknown: string;
|
|
104
97
|
running: string; outdated: string; offline: string; unpaired: string; checking: string;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
/** @deprecated 0.55.0: nothing draws it (the bridge's state is a badge in its card's head); optional so a surface's label set
|
|
99
|
+
* still type-checks. */
|
|
100
|
+
state?: string;
|
|
101
|
+
/** The heading of the bridge card's install / update part. */
|
|
102
|
+
setupTitle: string;
|
|
109
103
|
}
|
|
110
104
|
export const ENGINE_PICKER_EN: EnginePickerLabels = {
|
|
111
|
-
chip: "Engine",
|
|
112
|
-
engineTab: "Engine", setupTab: "Setup", statusTab: "Status",
|
|
105
|
+
chip: "Engine",
|
|
113
106
|
engine: "Engine", model: "Model", effort: "Effort",
|
|
114
107
|
defaultChoice: "Default",
|
|
115
108
|
copy: "Copy command", copied: "Copied", copyFailed: "Select the command and copy it", pairingCode: "Pairing code", steps: "Paste the command into Terminal, then press Enter.",
|
|
116
109
|
bridge: "Bridge on your machine", version: "Version", latest: "Latest", startsAtSignIn: "Starts at sign-in", machine: "Machine", lastSeen: "Last seen",
|
|
117
110
|
yes: "Yes", no: "No", unknown: "Not known",
|
|
118
111
|
running: "Running", outdated: "Outdated", offline: "Not connected", unpaired: "Not set up", checking: "Checking",
|
|
119
|
-
|
|
120
|
-
state: "State", setupTitle: "Install or update",
|
|
112
|
+
setupTitle: "Install or update",
|
|
121
113
|
};
|
|
122
114
|
|
|
123
115
|
/** The dot's tone per state: one word each, so the CSS has one rule per tone and a test can read it. */
|
|
@@ -132,6 +124,32 @@ const NOTICE_CLASS = { warn: "gb-engine-notice gb-engine-notice--warn", down: "g
|
|
|
132
124
|
const STATE_LABEL: Record<BridgeState, keyof EnginePickerLabels> = {
|
|
133
125
|
running: "running", outdated: "outdated", offline: "offline", unpaired: "unpaired", checking: "checking",
|
|
134
126
|
};
|
|
127
|
+
/** The bridge's state as a dotted badge in the bridge card's head (0.55.0). Its own classes, styled in assistant-engine.css:
|
|
128
|
+
* the kit's ui-badge tones live in kit-plain.css, which the admin does not load (its badge came out grey, no dot). */
|
|
129
|
+
const STATE_BADGE = { ok: "gb-engine-state gb-engine-state--ok", warn: "gb-engine-state gb-engine-state--warn", down: "gb-engine-state gb-engine-state--down", idle: "gb-engine-state gb-engine-state--idle" } as const;
|
|
130
|
+
|
|
131
|
+
/** ONE rule for an engine's picture, the chip's and the Settings row's (0.55.0): `mark`, else an id the kit has artwork for. */
|
|
132
|
+
export function engineMarkOf(engine?: Pick<EngineChoice, "id" | "mark">): EngineMarkId | null {
|
|
133
|
+
if (!engine) return null;
|
|
134
|
+
return engine.mark && isEngineMarkId(engine.mark) ? engine.mark : isEngineMarkId(engine.id) ? engine.id : null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** The bridge's state in words, as the badge in the head of the bridge card (Settings › AI & engines, 0.55.0). */
|
|
138
|
+
export function BridgeStateBadge({ bridge, L }: { bridge: BridgeStatus; L: EnginePickerLabels }) {
|
|
139
|
+
return <span className={STATE_BADGE[BRIDGE_TONE[bridge.state]]}>{L[STATE_LABEL[bridge.state]]}</span>;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** The small picture before an engine's name in Settings (0.55.0): its mark (`mark`, else an id the kit has artwork for),
|
|
143
|
+
* else its initial. Never another engine's logo: a mark that names the wrong engine reads as evidence. */
|
|
144
|
+
export function EngineRowMark({ engine }: { engine: EngineChoice }) {
|
|
145
|
+
const mark = engineMarkOf(engine);
|
|
146
|
+
return (
|
|
147
|
+
<span className="gb-engine-rowmark" data-mark={mark ?? undefined} aria-hidden="true">
|
|
148
|
+
{/* By code point: a label that opens with an emoji gets the emoji, not half of it. */}
|
|
149
|
+
{mark ? <EngineMark engine={mark} decorative /> : (Array.from(engine.label.trim())[0] || "?").toUpperCase()}
|
|
150
|
+
</span>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
135
153
|
|
|
136
154
|
export interface EnginePickerProps {
|
|
137
155
|
engines: readonly EngineChoice[];
|
|
@@ -149,102 +167,63 @@ export interface EnginePickerProps {
|
|
|
149
167
|
onEffortChange?: (id: string) => void;
|
|
150
168
|
/** Effort cannot be set right now; a string says why (its tooltip). */
|
|
151
169
|
effortDisabled?: boolean | string;
|
|
152
|
-
/** Quiet lines under the Engine
|
|
170
|
+
/** Quiet lines under the Engine card's fields: who pays, what this bridge version cannot do yet. */
|
|
153
171
|
notes?: ReactNode;
|
|
154
|
-
/** With models per engine (`EngineChoice.models`): one click on a model picks both
|
|
155
|
-
*
|
|
172
|
+
/** With models per engine (`EngineChoice.models`): one click on a model picks both. Without it the picker calls
|
|
173
|
+
* `onEngineChange` (when the engine changes) then `onModelChange`. 0.29.0. */
|
|
156
174
|
onPick?: (engine: string, model: string) => void;
|
|
157
|
-
/** A switch that did not go through ("Wait for the current answer to finish"): one red line on the Engine
|
|
175
|
+
/** A switch that did not go through ("Wait for the current answer to finish"): one red line on the Engine card. 0.29.0. */
|
|
158
176
|
problem?: ReactNode;
|
|
159
177
|
/** The chip itself is disabled (a switch in flight). `locked` keeps the chip and disables the choices. 0.29.0. */
|
|
160
178
|
disabled?: boolean;
|
|
161
|
-
/** The bridge on the user's machine. Omit for an engine set that runs on the server only: no dot, no
|
|
179
|
+
/** The bridge on the user's machine. Omit for an engine set that runs on the server only: no dot, no bridge card. */
|
|
162
180
|
bridge?: BridgeStatus;
|
|
163
181
|
/** The dot on the chip (default true when `bridge` is given). False when the current engine does not go through the
|
|
164
182
|
* bridge (a server engine): a red dot would say "broken" about something this engine does not use. */
|
|
165
183
|
showBridgeDot?: boolean;
|
|
166
|
-
/** Omit and
|
|
184
|
+
/** Omit and the bridge card has no Install or update part. */
|
|
167
185
|
setup?: BridgeSetup;
|
|
168
186
|
/** Buttons under the status rows ("Forget this machine", "Restart"). */
|
|
169
187
|
statusActions?: ReactNode;
|
|
170
|
-
/**
|
|
171
|
-
open?: boolean;
|
|
188
|
+
/** Called with true while Settings › AI & engines is SEEN, false when it goes: a surface polls its bridge on it. */
|
|
172
189
|
onOpenChange?: (open: boolean) => void;
|
|
173
|
-
tab?: EnginePickerTab;
|
|
174
|
-
onTabChange?: (tab: EnginePickerTab) => void;
|
|
175
190
|
/** While a turn runs the surface may refuse a switch: the chip stays readable, the choices are disabled. */
|
|
176
191
|
locked?: boolean;
|
|
177
|
-
/**
|
|
178
|
-
end?: boolean;
|
|
179
|
-
/** The chip button, for the surface (`useEnginePicker` passes its own: `close()` puts focus back on it). 0.32.0. */
|
|
192
|
+
/** The chip button, for the surface. 0.32.0. */
|
|
180
193
|
chipRef?: React.Ref<HTMLButtonElement>;
|
|
181
|
-
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
|
|
185
|
-
onOpenSettings?: (tab: EnginePickerTab) => void;
|
|
194
|
+
/** The chip opens the surface's SETTINGS on its "AI & engines" section (0.52.0; the only way since 0.53.0, which removed
|
|
195
|
+
* the chip's own popup). Called with "engine" from the chip, with "setup" from `useEnginePicker().openTab("setup")` (a
|
|
196
|
+
* failed turn's Open setup). See engine-settings.tsx. */
|
|
197
|
+
onOpenSettings: (tab: EnginePickerTab) => void;
|
|
186
198
|
labels?: Partial<EnginePickerLabels>;
|
|
187
199
|
className?: string;
|
|
188
200
|
}
|
|
189
201
|
|
|
190
|
-
/**
|
|
191
|
-
* `const p = useEnginePicker(
|
|
202
|
+
/** One picker's door and its "on screen" state, for a surface that also renders a `BridgeNotice`:
|
|
203
|
+
* `const p = useEnginePicker({ onOpenSettings: () => openSettings("ai") });`
|
|
204
|
+
* `<EnginePicker {...p.props} …/> <BridgeNotice onOpenSetup={() => p.openTab("setup")} …/>`
|
|
192
205
|
*
|
|
193
|
-
* `
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
|
|
197
|
-
* outside click still closes without moving focus (`props.onOpenChange(false)`).
|
|
198
|
-
*
|
|
199
|
-
* 0.52.0, `{ onOpenSettings }`: the engine lives in the surface's Settings (see `EnginePickerProps.onOpenSettings`).
|
|
200
|
-
* `openTab("setup")` then opens Settings on that section and brings its install / update part into view; `open` is true
|
|
201
|
-
* while the section is on screen; `close()` does nothing (there is no panel, and the chip sits behind the Settings popup:
|
|
202
|
-
* focus stays on the button in Settings, where a confirm it opens comes back to). */
|
|
203
|
-
export function useEnginePicker(options: EnginePickerTab | { initial?: EnginePickerTab; onOpenSettings?: (tab: EnginePickerTab) => void } = "engine") {
|
|
204
|
-
const initial = typeof options === "string" ? options : options.initial ?? "engine";
|
|
205
|
-
const toSettings = typeof options === "string" ? undefined : options.onOpenSettings;
|
|
206
|
+
* `openTab("setup")` opens Settings with Install or update in view; `open` is true while Settings › AI & engines is SEEN
|
|
207
|
+
* (what a surface polls its bridge on); `close()` does nothing and stays for the surfaces that called it before a confirm
|
|
208
|
+
* (0.32.0, when the chip had a popup): the button is in Settings now, and focus stays on it. */
|
|
209
|
+
export function useEnginePicker(options: { onOpenSettings: (tab: EnginePickerTab) => void }) {
|
|
206
210
|
// The latest opener (a surface passes a new arrow each render), behind one stable function.
|
|
207
|
-
const toSettingsRef = useRef(
|
|
208
|
-
toSettingsRef.current =
|
|
209
|
-
const inSettings = Boolean(toSettings);
|
|
211
|
+
const toSettingsRef = useRef(options.onOpenSettings);
|
|
212
|
+
toSettingsRef.current = options.onOpenSettings;
|
|
210
213
|
const [open, setOpen] = useState(false);
|
|
211
|
-
const [tab, setTab] = useState<EnginePickerTab>(initial);
|
|
212
214
|
const chipRef = useRef<HTMLButtonElement | null>(null);
|
|
213
|
-
const
|
|
215
|
+
const openTab = useCallback((t: EnginePickerTab) => {
|
|
214
216
|
requestEngineSettingsFocus(t);
|
|
215
|
-
toSettingsRef.current
|
|
217
|
+
toSettingsRef.current(t);
|
|
216
218
|
}, []);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
setTab(t); setOpen(true);
|
|
220
|
-
}, [openSettings]);
|
|
221
|
-
// Closing goes back to Engine: after "Open setup" the next click on the chip is about the engine again (review #3885).
|
|
222
|
-
const onOpenChange = useCallback((v: boolean) => { setOpen(v); if (!v) setTab(initial); }, [initial]);
|
|
219
|
+
/** @deprecated 0.53.0: does nothing (the chip has no popup to close); kept so a Stop / Remove handler from 0.32.0 still runs. */
|
|
220
|
+
const close = useCallback(() => {}, []);
|
|
223
221
|
const focusChip = useCallback(() => { chipRef.current?.focus(); }, []);
|
|
224
|
-
|
|
225
|
-
return {
|
|
226
|
-
open, tab, setOpen, setTab, openTab, close, focusChip, chipRef,
|
|
227
|
-
props: { open, onOpenChange, tab, onTabChange: setTab, chipRef, onOpenSettings: inSettings ? openSettings : undefined },
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function availableTabs(p: Pick<EnginePickerProps, "bridge" | "setup">): EnginePickerTab[] {
|
|
232
|
-
return ["engine", ...(p.setup ? ["setup" as const] : []), ...(p.bridge ? ["status" as const] : [])];
|
|
222
|
+
return { open, openTab, close, focusChip, chipRef, props: { onOpenChange: setOpen, chipRef, onOpenSettings: openTab } };
|
|
233
223
|
}
|
|
234
224
|
|
|
235
|
-
/**
|
|
236
|
-
|
|
237
|
-
const tabs = availableTabs(p);
|
|
238
|
-
const [own, setOwn] = useState<EnginePickerTab>("engine");
|
|
239
|
-
const wanted = p.tab ?? own;
|
|
240
|
-
const tab = tabs.includes(wanted) ? wanted : "engine";
|
|
241
|
-
const { tab: controlled, onTabChange } = p;
|
|
242
|
-
const setTab = useCallback((t: EnginePickerTab) => {
|
|
243
|
-
if (controlled === undefined) setOwn(t);
|
|
244
|
-
onTabChange?.(t);
|
|
245
|
-
}, [controlled, onTabChange]);
|
|
246
|
-
return { tabs, tab, setTab, resetOwn: () => setOwn("engine") };
|
|
247
|
-
}
|
|
225
|
+
/** What the Settings section's cards take: the chip's props without its door (`onOpenSettings`), which they never call. */
|
|
226
|
+
export type EngineCardProps = Omit<EnginePickerProps, "onOpenSettings"> & { onOpenSettings?: EnginePickerProps["onOpenSettings"] };
|
|
248
227
|
|
|
249
228
|
/** What the chip says out loud: the engine, the model, and the bridge when it is not fine. */
|
|
250
229
|
export function engineChipName(p: Pick<EnginePickerProps, "engines" | "engine" | "models" | "model" | "bridge">, L: EnginePickerLabels = ENGINE_PICKER_EN): string {
|
|
@@ -256,267 +235,35 @@ export function engineChipName(p: Pick<EnginePickerProps, "engines" | "engine" |
|
|
|
256
235
|
}
|
|
257
236
|
|
|
258
237
|
export function EnginePicker(props: EnginePickerProps) {
|
|
259
|
-
const { engines, engine, models, model, bridge,
|
|
238
|
+
const { engines, engine, models, model, bridge, className, onOpenSettings } = props;
|
|
260
239
|
const L = { ...ENGINE_PICKER_EN, ...props.labels };
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
usePublishEngineSettings(toSettings ? props : null);
|
|
264
|
-
const [ownOpen, setOwnOpen] = useState(false);
|
|
265
|
-
// No panel in Settings: `open` there means "the section is on screen" (useEnginePicker), not a popup to draw.
|
|
266
|
-
const open = toSettings ? false : props.open ?? ownOpen;
|
|
267
|
-
const { tabs, tab, setTab, resetOwn } = useTabs(props);
|
|
268
|
-
// Without the popover API (Safari < 17) a fixed layer inside the assistant's frame is cut by it (overflow, and in the
|
|
269
|
-
// popup and mini modes the frame's backdrop-filter makes it the containing block; full and side have none since
|
|
270
|
-
// 21/10/2026): there the panel goes to <body> through a portal instead.
|
|
271
|
-
// Decided after mount, so the server and the first client render agree.
|
|
272
|
-
const [portal, setPortal] = useState(false);
|
|
273
|
-
useEffect(() => { setPortal(!canFloatMenus()); }, []);
|
|
274
|
-
const chipRef = useRef<HTMLButtonElement | null>(null);
|
|
275
|
-
const outerChipRef = props.chipRef;
|
|
276
|
-
const setChip = useCallback((el: HTMLButtonElement | null) => {
|
|
277
|
-
chipRef.current = el;
|
|
278
|
-
if (typeof outerChipRef === "function") outerChipRef(el);
|
|
279
|
-
else if (outerChipRef) (outerChipRef as { current: HTMLButtonElement | null }).current = el;
|
|
280
|
-
}, [outerChipRef]);
|
|
281
|
-
const panelRef = useRef<HTMLDivElement>(null);
|
|
282
|
-
const panelId = useId();
|
|
283
|
-
|
|
284
|
-
const setOpen = useCallback((v: boolean) => {
|
|
285
|
-
if (props.open === undefined) setOwnOpen(v);
|
|
286
|
-
if (!v) resetOwn();
|
|
287
|
-
props.onOpenChange?.(v);
|
|
288
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
289
|
-
}, [props.open, props.onOpenChange]);
|
|
290
|
-
/** Close and put focus back on the chip: Escape, a pick, the close button. An outside click closes without it (the
|
|
291
|
-
* click already moved focus where the user wanted it). */
|
|
292
|
-
const closeToChip = useCallback(() => { setOpen(false); chipRef.current?.focus(); }, [setOpen]);
|
|
293
|
-
|
|
294
|
-
// Float / sink with `open`, before paint, so the panel is never drawn unplaced.
|
|
295
|
-
useBeforePaint(() => {
|
|
296
|
-
const panel = panelRef.current, chip = chipRef.current;
|
|
297
|
-
if (!panel || !chip) return;
|
|
298
|
-
if (!open) {
|
|
299
|
-
if (canFloatMenus() && panel.matches(":popover-open")) panel.hidePopover();
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (canFloatMenus() && !panel.matches(":popover-open")) panel.showPopover();
|
|
303
|
-
placeFloating(panel, chip, end);
|
|
304
|
-
}, [open, end, tab]);
|
|
305
|
-
|
|
306
|
-
// While open: Escape, outside pointer, and keep it against the chip when the window or a frame around the chip moves.
|
|
307
|
-
useEffect(() => {
|
|
308
|
-
if (!open) return undefined;
|
|
309
|
-
const panel = panelRef.current, chip = chipRef.current;
|
|
310
|
-
if (!panel || !chip) return undefined;
|
|
311
|
-
// Escape with focus in the panel or on the chip closes the panel only: captured first and stopped, so the surface's
|
|
312
|
-
// own Escape (hide the assistant) does not fire on the same key. With focus elsewhere (the composer), it closes the
|
|
313
|
-
// panel and leaves focus alone, and marks the key handled (0.27.0): a surface whose "Escape hides the assistant"
|
|
314
|
-
// checks `defaultPrevented` waits for the next Escape. Before 0.27.0 the key went on unmarked, and React re-renders
|
|
315
|
-
// between this listener and the surface's, so every surface (gemlabs #922, gemfeedback #66) needed a window-capture
|
|
316
|
-
// marker to tell "this Escape closed the picker" from "this one is mine".
|
|
317
|
-
const onKey = (e: KeyboardEvent) => {
|
|
318
|
-
if (e.key !== "Escape" || e.defaultPrevented) return;
|
|
319
|
-
// Not ours: an IME composition (Escape cancels it; the kit's rule, kit-plain.js), or a modal opened from the panel.
|
|
320
|
-
if (e.isComposing || e.keyCode === 229) return;
|
|
321
|
-
const a = document.activeElement;
|
|
322
|
-
const modal = a?.closest?.('dialog[open], [aria-modal="true"]');
|
|
323
|
-
if (modal && !panel.contains(modal)) return;
|
|
324
|
-
e.preventDefault();
|
|
325
|
-
if (a && (panel.contains(a) || chip.contains(a))) { e.stopPropagation(); closeToChip(); }
|
|
326
|
-
else setOpen(false);
|
|
327
|
-
};
|
|
328
|
-
const onDown = (e: PointerEvent) => {
|
|
329
|
-
const t = e.target as Node;
|
|
330
|
-
if (!panel.contains(t) && !chip.contains(t)) setOpen(false);
|
|
331
|
-
};
|
|
332
|
-
// A modal opened from the panel (a confirm behind a Status action) takes the screen: the panel would stay above it in
|
|
333
|
-
// the top layer, over its buttons (review #3903). Close the panel when focus enters a modal that is not the panel.
|
|
334
|
-
const onFocusIn = (e: FocusEvent) => {
|
|
335
|
-
const m = (e.target as Element | null)?.closest?.('dialog[open], [aria-modal="true"]');
|
|
336
|
-
if (m && !panel.contains(m)) setOpen(false);
|
|
337
|
-
};
|
|
338
|
-
const replace = () => placeFloating(panel, chip, end);
|
|
339
|
-
// A scroll moves the panel's anchor only when it scrolls something that holds the chip (the page, a frame around the
|
|
340
|
-
// composer): a chat log streaming beside it does not. One placement per frame at most.
|
|
341
|
-
let frame = 0;
|
|
342
|
-
const onScroll = (e: Event) => {
|
|
343
|
-
const t = e.target as Node | null;
|
|
344
|
-
if (!t || panel.contains(t)) return;
|
|
345
|
-
if (t !== document && (t as Node).nodeType !== 9 && !t.contains(chip)) return;
|
|
346
|
-
if (!frame) frame = requestAnimationFrame(() => { frame = 0; replace(); });
|
|
347
|
-
};
|
|
348
|
-
// Its content changes while open (a poll turns "Allow connection" into the command): re-place on its own resize, or a
|
|
349
|
-
// taller panel runs off the bottom of the screen. placeFloating writes max-height, which the observer ignores (it
|
|
350
|
-
// only fires when the box changes size, and a clamp to the same room settles at once).
|
|
351
|
-
let lastH = -1;
|
|
352
|
-
const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => {
|
|
353
|
-
if (panel.scrollHeight === lastH) return;
|
|
354
|
-
lastH = panel.scrollHeight;
|
|
355
|
-
replace();
|
|
356
|
-
});
|
|
357
|
-
// The panel (it grows while it fits) and its pane (content that grows past a clamped panel).
|
|
358
|
-
ro?.observe(panel);
|
|
359
|
-
const pane = panel.querySelector(".gb-engine-pane");
|
|
360
|
-
if (pane) ro?.observe(pane);
|
|
361
|
-
document.addEventListener("keydown", onKey, true);
|
|
362
|
-
document.addEventListener("pointerdown", onDown, true);
|
|
363
|
-
document.addEventListener("focusin", onFocusIn, true);
|
|
364
|
-
document.addEventListener("scroll", onScroll, true);
|
|
365
|
-
window.addEventListener("resize", replace);
|
|
366
|
-
return () => {
|
|
367
|
-
document.removeEventListener("keydown", onKey, true);
|
|
368
|
-
cancelAnimationFrame(frame);
|
|
369
|
-
document.removeEventListener("pointerdown", onDown, true);
|
|
370
|
-
document.removeEventListener("focusin", onFocusIn, true);
|
|
371
|
-
document.removeEventListener("scroll", onScroll, true);
|
|
372
|
-
window.removeEventListener("resize", replace);
|
|
373
|
-
ro?.disconnect();
|
|
374
|
-
};
|
|
375
|
-
}, [open, end, closeToChip, setOpen]);
|
|
376
|
-
|
|
377
|
-
// Focus goes INTO the panel on open (the selected tab), so a keyboard user lands where the choices are.
|
|
378
|
-
useEffect(() => {
|
|
379
|
-
if (!open) return;
|
|
380
|
-
const t = panelRef.current?.querySelector<HTMLElement>('[role="tab"][aria-selected="true"]')
|
|
381
|
-
?? panelRef.current?.querySelector<HTMLElement>("button:not([disabled])");
|
|
382
|
-
t?.focus();
|
|
383
|
-
// Only on opening: a tab change moves focus by itself (the roving keys), a pick closes.
|
|
384
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
385
|
-
}, [open]);
|
|
386
|
-
|
|
240
|
+
// The chip hands its props to the "AI & engines" section and hears when that section is on screen (engine-settings-store).
|
|
241
|
+
usePublishEngineSettings(props);
|
|
387
242
|
const current = engines.find((e) => e.id === engine);
|
|
388
243
|
const modelLabel = model ? (current?.models ?? models)?.find((m) => m.id === model)?.label : undefined;
|
|
389
|
-
const mark =
|
|
244
|
+
const mark = engineMarkOf(current);
|
|
390
245
|
const tone = bridge && props.showBridgeDot !== false ? BRIDGE_TONE[bridge.state] : null;
|
|
391
246
|
const name = engineChipName(props.showBridgeDot === false ? { ...props, bridge: undefined } : props, L);
|
|
392
|
-
|
|
393
|
-
<>
|
|
394
|
-
{tone ? <span className={DOT_CLASS[tone]} aria-hidden /> : null}
|
|
395
|
-
<span className="gb-engine-chiplabel">
|
|
396
|
-
{current?.label ?? engine}
|
|
397
|
-
{modelLabel ? <span className="gb-engine-chipsub"> · {modelLabel}</span> : null}
|
|
398
|
-
</span>
|
|
399
|
-
{/* Shown instead of the name when the composer is too narrow for it (assistant-engine.css, ChatComposer density). */}
|
|
400
|
-
{mark ? <span className="gb-engine-chipmark"><EngineMark engine={mark} decorative /></span> : null}
|
|
401
|
-
</>
|
|
402
|
-
);
|
|
403
|
-
|
|
404
|
-
if (toSettings) {
|
|
405
|
-
// The same chip, a door to Settings: it opens a dialog (the surface's), so no expanded state or panel id of its own.
|
|
406
|
-
return (
|
|
407
|
-
<span className={cx("gb-engine", className)}>
|
|
408
|
-
<button ref={setChip} type="button" className={mark ? "gb-engine-chip has-mark" : "gb-engine-chip"}
|
|
409
|
-
disabled={props.disabled || undefined} aria-haspopup="dialog" aria-label={name} title={name}
|
|
410
|
-
onClick={() => { requestEngineSettingsFocus("engine"); toSettings("engine"); }}>
|
|
411
|
-
{chipFace}
|
|
412
|
-
</button>
|
|
413
|
-
</span>
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
|
|
247
|
+
// A door to the surface's Settings: it opens a dialog (the surface's), so no expanded state or panel id of its own.
|
|
417
248
|
return (
|
|
418
249
|
<span className={cx("gb-engine", className)}>
|
|
419
|
-
<button
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
onClick={() => setOpen(!open)}
|
|
430
|
-
>
|
|
431
|
-
{chipFace}
|
|
250
|
+
<button ref={props.chipRef} type="button" className={mark ? "gb-engine-chip has-mark" : "gb-engine-chip"}
|
|
251
|
+
disabled={props.disabled || undefined} aria-haspopup="dialog" aria-label={name} title={name}
|
|
252
|
+
onClick={() => onOpenSettings("engine")}>
|
|
253
|
+
{tone ? <span className={DOT_CLASS[tone]} aria-hidden /> : null}
|
|
254
|
+
<span className="gb-engine-chiplabel">
|
|
255
|
+
{current?.label ?? engine}
|
|
256
|
+
{modelLabel ? <span className="gb-engine-chipsub"> · {modelLabel}</span> : null}
|
|
257
|
+
</span>
|
|
258
|
+
{/* Shown instead of the name when the composer is too narrow for it (assistant-engine.css, ChatComposer density). */}
|
|
259
|
+
{mark ? <span className="gb-engine-chipmark"><EngineMark engine={mark} decorative /></span> : null}
|
|
432
260
|
</button>
|
|
433
|
-
{(() => { const panelEl = (<div
|
|
434
|
-
ref={panelRef}
|
|
435
|
-
id={panelId}
|
|
436
|
-
className="gb-engine-panel gemboss-popover-surface"
|
|
437
|
-
role="dialog"
|
|
438
|
-
aria-label={L.dialog}
|
|
439
|
-
// The top layer where the browser has one; otherwise a fixed layer in the tree (assistant-engine.css).
|
|
440
|
-
{...(portal ? {} : { popover: "manual" })}
|
|
441
|
-
hidden={!open}
|
|
442
|
-
data-open={open ? "" : undefined}
|
|
443
|
-
>
|
|
444
|
-
{open ? <PanelBody {...props} L={L} tab={tab} tabs={tabs} setTab={setTab} onPicked={closeToChip} /> : null}
|
|
445
|
-
</div>);
|
|
446
|
-
return portal && typeof document !== "undefined" ? createPortal(panelEl, document.body) : panelEl; })()}
|
|
447
261
|
</span>
|
|
448
262
|
);
|
|
449
263
|
}
|
|
450
264
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
function PanelBody({ L, tab, tabs, setTab, onPicked, ...p }: EnginePickerProps & {
|
|
454
|
-
L: EnginePickerLabels; tab: EnginePickerTab; tabs: EnginePickerTab[]; setTab: (t: EnginePickerTab) => void; onPicked?: () => void;
|
|
455
|
-
}) {
|
|
456
|
-
const base = useId();
|
|
457
|
-
const tabRefs = useRef<Partial<Record<EnginePickerTab, HTMLButtonElement | null>>>({});
|
|
458
|
-
const tabLabel: Record<EnginePickerTab, string> = { engine: L.engineTab, setup: L.setupTab, status: L.statusTab };
|
|
459
|
-
const needsUpdate = p.bridge?.state === "outdated";
|
|
460
|
-
const onTabKey = (e: React.KeyboardEvent) => {
|
|
461
|
-
const i = tabs.indexOf(tab);
|
|
462
|
-
const to = e.key === "ArrowRight" ? tabs[(i + 1) % tabs.length]
|
|
463
|
-
: e.key === "ArrowLeft" ? tabs[(i - 1 + tabs.length) % tabs.length]
|
|
464
|
-
: e.key === "Home" ? tabs[0] : e.key === "End" ? tabs[tabs.length - 1] : null;
|
|
465
|
-
if (!to) return;
|
|
466
|
-
e.preventDefault();
|
|
467
|
-
setTab(to);
|
|
468
|
-
tabRefs.current[to]?.focus();
|
|
469
|
-
};
|
|
470
|
-
return (
|
|
471
|
-
<>
|
|
472
|
-
{tabs.length > 1 ? (
|
|
473
|
-
<div className="ui-tabs gb-engine-tabs" role="tablist" aria-label={L.tabs} onKeyDown={onTabKey}>
|
|
474
|
-
{tabs.map((t) => (
|
|
475
|
-
<button
|
|
476
|
-
key={t}
|
|
477
|
-
ref={(el) => { tabRefs.current[t] = el; }}
|
|
478
|
-
type="button"
|
|
479
|
-
role="tab"
|
|
480
|
-
id={`${base}-tab-${t}`}
|
|
481
|
-
aria-controls={`${base}-pane-${t}`}
|
|
482
|
-
aria-selected={tab === t}
|
|
483
|
-
tabIndex={tab === t ? 0 : -1}
|
|
484
|
-
onClick={() => setTab(t)}
|
|
485
|
-
>
|
|
486
|
-
{tabLabel[t]}
|
|
487
|
-
{/* The same warning the chip's dot gives, on the tab that fixes it. */}
|
|
488
|
-
{t === "setup" && needsUpdate ? <span className="gb-engine-dot gb-engine-dot--warn" role="img" aria-label={L.updateDue} /> : null}
|
|
489
|
-
</button>
|
|
490
|
-
))}
|
|
491
|
-
</div>
|
|
492
|
-
) : null}
|
|
493
|
-
<div
|
|
494
|
-
className="gb-engine-pane"
|
|
495
|
-
role={tabs.length > 1 ? "tabpanel" : undefined}
|
|
496
|
-
id={`${base}-pane-${tab}`}
|
|
497
|
-
aria-labelledby={tabs.length > 1 ? `${base}-tab-${tab}` : undefined}
|
|
498
|
-
>
|
|
499
|
-
{tab === "engine" ? <EngineTab {...p} L={L} onPicked={onPicked} /> : null}
|
|
500
|
-
{tab === "setup" ? <SetupTab setup={p.setup!} bridge={p.bridge} L={L} /> : null}
|
|
501
|
-
{tab === "status" ? <StatusTab bridge={p.bridge!} actions={p.statusActions} L={L} /> : null}
|
|
502
|
-
</div>
|
|
503
|
-
</>
|
|
504
|
-
);
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/** The panel without the chip: the catalog, or a settings page that shows the same three tabs in place. */
|
|
508
|
-
export function EnginePanel(props: EnginePickerProps) {
|
|
509
|
-
const L = { ...ENGINE_PICKER_EN, ...props.labels };
|
|
510
|
-
const { tabs, tab, setTab } = useTabs(props);
|
|
511
|
-
return (
|
|
512
|
-
<div className={cx("gb-engine-panel gb-engine-panel--inline gemboss-popover-surface", props.className)} role="group" aria-label={L.dialog}>
|
|
513
|
-
<PanelBody {...props} L={L} tab={tab} tabs={tabs} setTab={setTab} />
|
|
514
|
-
</div>
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
function Options({ label, items, value, onChange, locked, onPicked, disabledReason }: {
|
|
519
|
-
label: string; items: readonly Choice[]; value: string | undefined; onChange?: (id: string) => void; locked?: boolean; onPicked?: () => void;
|
|
265
|
+
function Options({ label, items, value, onChange, locked, disabledReason }: {
|
|
266
|
+
label: string; items: readonly Choice[]; value: string | undefined; onChange?: (id: string) => void; locked?: boolean;
|
|
520
267
|
disabledReason?: boolean | string;
|
|
521
268
|
}) {
|
|
522
269
|
const id = useId();
|
|
@@ -552,7 +299,7 @@ function Options({ label, items, value, onChange, locked, onPicked, disabledReas
|
|
|
552
299
|
aria-pressed={(value ?? "") === m.id}
|
|
553
300
|
disabled={off}
|
|
554
301
|
title={why ?? m.title}
|
|
555
|
-
onClick={() => { if ((value ?? "") !== m.id) onChange?.(m.id);
|
|
302
|
+
onClick={() => { if ((value ?? "") !== m.id) onChange?.(m.id); }}
|
|
556
303
|
>
|
|
557
304
|
{m.label}
|
|
558
305
|
</button>
|
|
@@ -562,28 +309,25 @@ function Options({ label, items, value, onChange, locked, onPicked, disabledReas
|
|
|
562
309
|
);
|
|
563
310
|
}
|
|
564
311
|
|
|
565
|
-
/** Every engine with its own models, all at once; one click picks both (the admin's
|
|
566
|
-
function EngineGroups({ engines, engine, model, onPick, onEngineChange, onModelChange, locked, L,
|
|
567
|
-
const ownId = useId();
|
|
568
|
-
const id = labelledBy ?? ownId;
|
|
312
|
+
/** Every engine with its own models, all at once; one click picks both (the admin's shape, 0.29.0). */
|
|
313
|
+
function EngineGroups({ engines, engine, model, onPick, onEngineChange, onModelChange, locked, L, labelledBy }: EngineCardProps & { L: EnginePickerLabels; labelledBy: string }) {
|
|
569
314
|
const choose = (e: EngineChoice, m: Choice) => {
|
|
570
|
-
// The pick already in force:
|
|
571
|
-
if (e.id === engine && (model ?? "") === m.id)
|
|
315
|
+
// The pick already in force: change nothing (a surface that starts a new conversation on a switch must not).
|
|
316
|
+
if (e.id === engine && (model ?? "") === m.id) return;
|
|
572
317
|
if (onPick) onPick(e.id, m.id);
|
|
573
318
|
else { if (e.id !== engine) onEngineChange?.(e.id); onModelChange?.(m.id); }
|
|
574
|
-
onPicked?.();
|
|
575
319
|
};
|
|
576
320
|
const canChoose = Boolean(onPick || onEngineChange || onModelChange);
|
|
577
321
|
return (
|
|
578
322
|
<div className="gb-engine-field">
|
|
579
|
-
|
|
580
|
-
<div className="gb-engine-groups" role="group" aria-labelledby={id}>
|
|
323
|
+
<div className="gb-engine-groups" role="group" aria-labelledby={labelledBy}>
|
|
581
324
|
{engines.map((e) => {
|
|
582
325
|
const chosen = e.id === engine;
|
|
583
326
|
const items = e.models && e.models.length ? e.models : [{ id: "", label: L.defaultChoice }];
|
|
584
327
|
return (
|
|
585
328
|
<div key={e.id} className="gb-engine-group" data-current={chosen ? "" : undefined}>
|
|
586
329
|
<span className="gb-engine-rowhead">
|
|
330
|
+
<EngineRowMark engine={e} />
|
|
587
331
|
<span className="gb-engine-rowname">{e.label}</span>
|
|
588
332
|
{e.badge ? <span className={e.badgeTone ? BADGE_CLASS[e.badgeTone] : "ui-badge"}>{e.badge}</span> : null}
|
|
589
333
|
</span>
|
|
@@ -606,17 +350,15 @@ function EngineGroups({ engines, engine, model, onPick, onEngineChange, onModelC
|
|
|
606
350
|
);
|
|
607
351
|
}
|
|
608
352
|
|
|
609
|
-
/** The Engine
|
|
610
|
-
*
|
|
611
|
-
export function EngineTab(props:
|
|
612
|
-
const { engines, engine, onEngineChange, models, model, onModelChange, modelControl, efforts, effort, onEffortChange, effortDisabled, notes, locked, L,
|
|
613
|
-
const ownId = useId();
|
|
614
|
-
const id = labelledBy ?? ownId;
|
|
353
|
+
/** The Engine card's content. `labelledBy`: the card's heading names the engine list, so its own "Engine" label is not
|
|
354
|
+
* drawn a second time under it. */
|
|
355
|
+
export function EngineTab(props: EngineCardProps & { L: EnginePickerLabels; labelledBy: string }) {
|
|
356
|
+
const { engines, engine, onEngineChange, models, model, onModelChange, modelControl, efforts, effort, onEffortChange, effortDisabled, notes, locked, L, labelledBy } = props;
|
|
615
357
|
if (engines.some((e) => e.models && e.models.length)) {
|
|
616
358
|
return (
|
|
617
359
|
<>
|
|
618
360
|
<EngineGroups {...props} />
|
|
619
|
-
{efforts && efforts.length ? <Options label={L.effort} items={efforts} value={effort} onChange={onEffortChange} locked={locked}
|
|
361
|
+
{efforts && efforts.length ? <Options label={L.effort} items={efforts} value={effort} onChange={onEffortChange} locked={locked} disabledReason={effortDisabled} /> : null}
|
|
620
362
|
{props.problem ? <p className="gb-engine-problem" role="alert">{props.problem}</p> : null}
|
|
621
363
|
{notes ? <div className="gb-engine-notes">{notes}</div> : null}
|
|
622
364
|
</>
|
|
@@ -639,8 +381,7 @@ export function EngineTab(props: EnginePickerProps & { L: EnginePickerLabels; on
|
|
|
639
381
|
return (
|
|
640
382
|
<>
|
|
641
383
|
<div className="gb-engine-field">
|
|
642
|
-
|
|
643
|
-
<div className="gb-engine-list" role="radiogroup" aria-labelledby={id} onKeyDown={onKey}>
|
|
384
|
+
<div className="gb-engine-list" role="radiogroup" aria-labelledby={labelledBy} onKeyDown={onKey}>
|
|
644
385
|
{engines.map((e) => (
|
|
645
386
|
<button
|
|
646
387
|
key={e.id}
|
|
@@ -651,9 +392,9 @@ export function EngineTab(props: EnginePickerProps & { L: EnginePickerLabels; on
|
|
|
651
392
|
tabIndex={e.id === stop ? 0 : -1}
|
|
652
393
|
className="gb-engine-row"
|
|
653
394
|
disabled={!can(e)}
|
|
654
|
-
// A new engine keeps the panel open: its models and efforts are the next thing to look at.
|
|
655
395
|
onClick={() => { if (e.id !== engine) onEngineChange?.(e.id); }}
|
|
656
396
|
>
|
|
397
|
+
<EngineRowMark engine={e} />
|
|
657
398
|
<span className="gb-engine-rowhead">
|
|
658
399
|
<span className="gb-engine-rowname">{e.label}</span>
|
|
659
400
|
{e.badge ? <span className={e.badgeTone ? BADGE_CLASS[e.badgeTone] : "ui-badge"}>{e.badge}</span> : null}
|
|
@@ -665,8 +406,8 @@ export function EngineTab(props: EnginePickerProps & { L: EnginePickerLabels; on
|
|
|
665
406
|
</div>
|
|
666
407
|
{modelControl ? (
|
|
667
408
|
<div className="gb-engine-field"><span className="gb-engine-label">{L.model}</span>{modelControl}</div>
|
|
668
|
-
) : models && models.length ? <Options label={L.model} items={models} value={model} onChange={onModelChange} locked={locked}
|
|
669
|
-
{efforts && efforts.length ? <Options label={L.effort} items={efforts} value={effort} onChange={onEffortChange} locked={locked}
|
|
409
|
+
) : models && models.length ? <Options label={L.model} items={models} value={model} onChange={onModelChange} locked={locked} /> : null}
|
|
410
|
+
{efforts && efforts.length ? <Options label={L.effort} items={efforts} value={effort} onChange={onEffortChange} locked={locked} disabledReason={effortDisabled} /> : null}
|
|
670
411
|
{props.problem ? <p className="gb-engine-problem" role="alert">{props.problem}</p> : null}
|
|
671
412
|
{notes ? <div className="gb-engine-notes">{notes}</div> : null}
|
|
672
413
|
</>
|
|
@@ -692,19 +433,17 @@ export async function copyText(text: string): Promise<boolean> {
|
|
|
692
433
|
} catch { return false; }
|
|
693
434
|
}
|
|
694
435
|
|
|
695
|
-
/** What is wrong with the bridge, in one callout
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
{bridge.detail ? <> {bridge.detail}</> : null}
|
|
702
|
-
</p>
|
|
703
|
-
);
|
|
436
|
+
/** What is wrong with the bridge, in one callout under the bridge card's head: the surface's `detail` only (0.55.0). The
|
|
437
|
+
* state is the badge in the head already, so the callout no longer opens with it; with no `detail` there is no callout
|
|
438
|
+
* (Install or update, below, says what to do). */
|
|
439
|
+
export function BridgeCallout({ bridge }: { bridge?: BridgeStatus }) {
|
|
440
|
+
if (!(bridge?.state === "outdated" || bridge?.state === "offline" || bridge?.state === "unpaired") || !bridge.detail) return null;
|
|
441
|
+
return <p className={cx("gb-engine-callout", bridge.state === "outdated" ? "gb-engine-callout--warn" : "gb-engine-callout--down")}>{bridge.detail}</p>;
|
|
704
442
|
}
|
|
705
443
|
|
|
706
|
-
/** The
|
|
707
|
-
|
|
444
|
+
/** The bridge card's Install or update part: the steps, the command with Copy, the pairing code. (What is wrong is the
|
|
445
|
+
* card's callout, above it.) */
|
|
446
|
+
export function SetupTab({ setup, L }: { setup: BridgeSetup; L: EnginePickerLabels }) {
|
|
708
447
|
const [said, setSaid] = useState<"" | "copied" | "failed">("");
|
|
709
448
|
const timer = useRef<number | undefined>(undefined);
|
|
710
449
|
useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
@@ -717,7 +456,6 @@ export function SetupTab({ setup, bridge, L, noCallout = false }: { setup: Bridg
|
|
|
717
456
|
};
|
|
718
457
|
return (
|
|
719
458
|
<>
|
|
720
|
-
{noCallout ? null : <BridgeCallout bridge={bridge} L={L} />}
|
|
721
459
|
{setup.steps || setup.command ?<div className="gb-engine-steps">{setup.steps ?? <p>{L.steps}</p>}</div> : null}
|
|
722
460
|
{setup.command ? (
|
|
723
461
|
<>
|
|
@@ -738,17 +476,14 @@ export function SetupTab({ setup, bridge, L, noCallout = false }: { setup: Bridg
|
|
|
738
476
|
);
|
|
739
477
|
}
|
|
740
478
|
|
|
741
|
-
/** The
|
|
742
|
-
* callout above
|
|
743
|
-
export function StatusTab({ bridge, actions, L
|
|
744
|
-
const tone = BRIDGE_TONE[bridge.state];
|
|
479
|
+
/** The bridge card's rows and actions. Its state is the badge in the card's head (0.55.0: `BridgeStateBadge`, no longer a
|
|
480
|
+
* "State" row), and the callout above the rows already carries `detail`. */
|
|
481
|
+
export function StatusTab({ bridge, actions, L }: { bridge: BridgeStatus; actions?: ReactNode; L: EnginePickerLabels }) {
|
|
745
482
|
const yesNo = (v: boolean | undefined) => (v === undefined ? L.unknown : v ? L.yes : L.no);
|
|
746
|
-
const calledOut =
|
|
483
|
+
const calledOut = bridge.state === "outdated" || bridge.state === "offline" || bridge.state === "unpaired";
|
|
747
484
|
return (
|
|
748
485
|
<>
|
|
749
486
|
<dl className="gb-engine-rows">
|
|
750
|
-
<dt>{inSettings ? L.state ?? ENGINE_PICKER_EN.state : L.bridge}</dt>
|
|
751
|
-
<dd><span className={DOT_CLASS[tone]} aria-hidden /> {L[STATE_LABEL[bridge.state]]}</dd>
|
|
752
487
|
{bridge.version ? <><dt>{L.version}</dt><dd>{bridge.version}{bridge.latest && bridge.latest !== bridge.version ? ` · ${L.latest} ${bridge.latest}` : ""}</dd></> : null}
|
|
753
488
|
<dt>{L.startsAtSignIn}</dt><dd>{yesNo(bridge.autostart)}</dd>
|
|
754
489
|
{bridge.machine ? <><dt>{L.machine}</dt><dd>{bridge.machine}</dd></> : null}
|
|
@@ -762,8 +497,8 @@ export function StatusTab({ bridge, actions, L, inSettings = false }: { bridge:
|
|
|
762
497
|
|
|
763
498
|
/**
|
|
764
499
|
* ONE line in the chat stream, for a turn that actually failed because of the bridge ("The bridge on your machine is
|
|
765
|
-
* not connected."), with "Open setup" that opens
|
|
766
|
-
* "outdated" all the time, this says "this turn failed, here is why" once.
|
|
500
|
+
* not connected."), with "Open setup" that opens Settings › AI & engines on Install or update (`useEnginePicker().openTab`).
|
|
501
|
+
* Never a standing block: the chip's dot says "outdated" all the time, this says "this turn failed, here is why" once.
|
|
767
502
|
*/
|
|
768
503
|
export function BridgeNotice({ children, onOpenSetup, action = "Open setup", tone = "down", className }: {
|
|
769
504
|
children: ReactNode;
|