@gemboss/ui 0.70.2 → 0.71.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 +257 -2
- package/README.md +25 -9
- package/catalog/editor.html +1 -1
- package/catalog/index.html +48 -46
- package/gemboss-ui.css +4 -4
- package/package.json +17 -1
- package/parts/components.css +2 -2
- package/parts/core.css +1 -1
- package/parts/shell.css +2 -2
- package/src/app-nav.css +1 -1
- package/src/app-shell.css +1 -1
- package/src/assistant/chat.tsx +118 -16
- package/src/assistant/composer-menus.tsx +7 -2
- package/src/assistant/dock.ts +97 -10
- package/src/assistant/hold.ts +51 -0
- package/src/assistant/host.tsx +231 -124
- package/src/assistant/index.ts +4 -2
- package/src/assistant/provider.tsx +121 -24
- package/src/assistant/sessions.tsx +54 -20
- package/src/assistant/window-host.tsx +215 -0
- package/src/assistant/window.ts +120 -0
- package/src/assistant-chat.css +1 -1
- package/src/assistant-hold.css +1 -0
- package/src/assistant-places.css +1 -0
- package/src/assistant-plain.js +1 -1
- package/src/assistant-window-plain.js +1 -0
- package/src/assistant-window.css +1 -0
- package/src/assistant.css +1 -1
- package/src/auth-extras.css +1 -1
- package/src/auth-footer.css +1 -1
- package/src/auth-steps.css +1 -1
- package/src/auth.css +1 -1
- package/src/chat-attachments.css +1 -1
- package/src/chat-cards.css +1 -1
- package/src/chat-composer-menus.css +1 -1
- package/src/chat-composer.css +1 -1
- package/src/chat-plain.js +6 -6
- package/src/chat-voice.css +1 -1
- package/src/chat.css +1 -1
- package/src/collections.css +1 -1
- package/src/create-shell.css +1 -1
- package/src/editor/controls.tsx +28 -4
- package/src/editor/field-control.tsx +11 -2
- package/src/editor/field-spec.ts +6 -2
- package/src/editor-color.css +1 -1
- package/src/editor-empty.css +1 -0
- package/src/editor-insert.css +1 -1
- package/src/editor-inspector-frame.css +1 -1
- package/src/editor-picker-grid.css +1 -1
- package/src/editor-picker.css +1 -1
- package/src/editor-popover.css +1 -1
- package/src/editor-repeater.css +1 -1
- package/src/editor-tiles.css +1 -1
- package/src/editor.css +1 -1
- package/src/email-editor.css +1 -1
- package/src/feedback-dialog.css +1 -0
- package/src/feedback-dialog.tsx +122 -0
- package/src/gemboss-field.css +1 -1
- package/src/gems.css +1 -1
- package/src/icon-frame.tsx +31 -0
- package/src/icons.tsx +9 -9
- package/src/index.ts +1 -0
- package/src/job-card.css +1 -1
- package/src/kit-plain.css +1 -1
- package/src/language-switcher.css +1 -1
- package/src/list-page.css +1 -1
- package/src/list-toolbar.css +1 -1
- package/src/members.css +1 -1
- package/src/menu-extras.css +1 -1
- package/src/menu-select.css +1 -1
- package/src/menu.tsx +9 -4
- package/src/narration.css +1 -1
- package/src/pager-extras.css +1 -1
- package/src/pager.css +1 -1
- package/src/portal.css +1 -1
- package/src/question-card.css +1 -1
- package/src/rail-fold.css +1 -1
- package/src/reactions.css +1 -1
- package/src/report-charts.css +1 -1
- package/src/service-switcher.css +1 -1
- package/src/session-rail-plain.js +1 -1
- package/src/settings-dialog.css +1 -1
- package/src/setup-guide.css +1 -1
- package/src/shell.css +1 -1
- package/src/site.css +1 -1
- package/src/skill-card.css +1 -1
- package/src/skill-flow.css +1 -1
- package/src/skill-pages.css +1 -1
- package/src/skill-view.css +1 -1
- package/src/stage-path.css +1 -1
- package/src/status-list.css +1 -1
- package/src/team-chat.css +1 -1
- package/src/tray-plain.js +1 -0
- package/src/tray-search.tsx +116 -0
- package/src/tray.css +1 -0
- package/src/tray.tsx +250 -0
- package/src/ui.css +1 -1
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* - `dockedEvent` — announced when a rail click opened the popup instead of the full screen, so the
|
|
12
12
|
* shell can close its mobile drawer
|
|
13
13
|
* - `bodyClassPrefix` — `<prefix>-busy` / `<prefix>-unread` on <body>, which the rail item reads
|
|
14
|
+
* - `defaultShape` — the place a person who never chose one gets (12/11/2026; the kit's default is the side panel). The admin
|
|
15
|
+
* passes "left": Chris, "ai chat mặc định mở, nằm ở bên trái"; there it also opens on load (below).
|
|
14
16
|
*/
|
|
15
17
|
import React, { createContext, startTransition, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState, type ReactNode } from "react";
|
|
16
18
|
import {
|
|
@@ -18,7 +20,10 @@ import {
|
|
|
18
20
|
initialAssistantDockState,
|
|
19
21
|
DOCK_DEFAULT_OFFSET_RIGHT,
|
|
20
22
|
openingDockHeight,
|
|
23
|
+
ASSISTANT_HOLD_ATTR,
|
|
24
|
+
SIDE_FITS_QUERY,
|
|
21
25
|
type AssistantFloatShape,
|
|
26
|
+
type AssistantPresentation,
|
|
22
27
|
SIDE_DEFAULT_WIDTH,
|
|
23
28
|
type AssistantDockState,
|
|
24
29
|
} from "./dock";
|
|
@@ -30,27 +35,40 @@ export interface AssistantOptions {
|
|
|
30
35
|
isOnFullPage?: () => boolean;
|
|
31
36
|
dockedEvent?: string;
|
|
32
37
|
bodyClassPrefix?: string;
|
|
38
|
+
defaultShape?: AssistantFloatShape;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
/** Storage keys. `lastMode` is the last shape the seller actually used: "full", "dock" or "
|
|
41
|
+
/** Storage keys. `lastMode` is the last shape the seller actually used: "full", "dock", "side" or "left" — nothing
|
|
36
42
|
* else is worth reopening as. Module-level so the callbacks below stay identity-stable. */
|
|
37
|
-
// `
|
|
38
|
-
//
|
|
39
|
-
|
|
43
|
+
// `place` (12/11/2026), the person's chosen place, written only when they pick one in ⋯'s places. It replaces `shape`, which
|
|
44
|
+
// was not only a choice: Ask Gem and Draft with Gem wrote "side" (openSide) on a press that chose no place, so a stored "side" cannot
|
|
45
|
+
// be told from a seller who never chose, and reading it would keep them off a new default. Its "dock" was only ever "Float as a
|
|
46
|
+
// popup", a choice, and is carried over. (`shape` itself replaced `floatShape` on 04/10/2026, which recorded the default it was given.)
|
|
47
|
+
const storageKey = (prefix: string, k: "dockHeight" | "dockOffsetRight" | "lastMode" | "sideWidth" | "shape" | "place" | "presentation") => `${prefix}.${k}`;
|
|
40
48
|
|
|
41
49
|
/**
|
|
42
50
|
* The width of the content area the side panel sits in: the window minus the rail. Measured from `main`'s LEFT
|
|
43
51
|
* edge (where the rail ends), never from main's width — with the panel open, main is already narrower by the panel.
|
|
52
|
+
* `left` (12/11/2026): the left panel is open, so main starts after it; the rail's edge is where that panel stands,
|
|
53
|
+
* `--gb-rail-w` (240 where it is not set), the same value its CSS reads (assistant-places.css).
|
|
44
54
|
*/
|
|
45
|
-
export function sideAvailable(): number {
|
|
55
|
+
export function sideAvailable(left = false): number {
|
|
46
56
|
if (typeof window === "undefined") return 0;
|
|
47
|
-
const
|
|
48
|
-
|
|
57
|
+
const main = document.querySelector(".gemboss-platform-main");
|
|
58
|
+
const vw = document.documentElement.clientWidth || window.innerWidth;
|
|
59
|
+
if (left) {
|
|
60
|
+
const rail = main ? parseFloat(getComputedStyle(main).getPropertyValue("--gb-rail-w")) : NaN;
|
|
61
|
+
return vw - (Number.isFinite(rail) ? rail : 240);
|
|
62
|
+
}
|
|
63
|
+
return vw - (main?.getBoundingClientRect().left ?? 0);
|
|
49
64
|
}
|
|
50
65
|
|
|
51
66
|
/** The custom property the page reads to make room for the side panel (`.gemboss-platform-main` does it itself;
|
|
52
67
|
* a surface with its own layout reads the same variable). */
|
|
53
68
|
export const SIDE_WIDTH_VAR = "--gb-assistant-side-w";
|
|
69
|
+
/** The LEFT panel's width, for the page's left margin (12/11/2026). Its own name: a surface's right-anchored overlays read
|
|
70
|
+
* SIDE_WIDTH_VAR as "a panel on the right takes this much" (the admin's Search & AI sheet, the desktop invite). */
|
|
71
|
+
export const LEFT_WIDTH_VAR = "--gb-assistant-left-w";
|
|
54
72
|
|
|
55
73
|
const ADMIN_FULL_PATH = "/app/assistant";
|
|
56
74
|
const DEFAULTS: Required<AssistantOptions> = {
|
|
@@ -59,8 +77,13 @@ const DEFAULTS: Required<AssistantOptions> = {
|
|
|
59
77
|
isOnFullPage: () => window.location.pathname.startsWith(ADMIN_FULL_PATH),
|
|
60
78
|
dockedEvent: "gemboss:assistant-docked",
|
|
61
79
|
bodyClassPrefix: "gemboss-assistant",
|
|
80
|
+
defaultShape: initialAssistantDockState.floatShape,
|
|
62
81
|
};
|
|
63
82
|
|
|
83
|
+
/** Only WHERE the assistant is drawn, in its own context: a shell that lays itself out around the assistant (the admin folds its
|
|
84
|
+
* rail while the chat is on the left) reads this and is not drawn again on every busy flip, page fact or open. */
|
|
85
|
+
const PresentationCtx = createContext<AssistantPresentation>("hidden");
|
|
86
|
+
|
|
64
87
|
export interface AssistantDockApi extends AssistantDockState {
|
|
65
88
|
/** Specifics the CURRENT screen registered about itself, for the assistant to read. */
|
|
66
89
|
pageFacts: string[];
|
|
@@ -73,6 +96,8 @@ export interface AssistantDockApi extends AssistantDockState {
|
|
|
73
96
|
openDock: () => void;
|
|
74
97
|
/** Pin to the full-height side panel. Only a host that allows it (`allowSide`) offers the button. */
|
|
75
98
|
openSide: () => void;
|
|
99
|
+
/** Pin to the full-height panel on the LEFT of the page. Only a host that allows it (`allowLeft`) offers the button. */
|
|
100
|
+
openLeft: () => void;
|
|
76
101
|
/** Back on screen in the last working shape — popup or side panel (`floatShape`). */
|
|
77
102
|
reopen: () => void;
|
|
78
103
|
minimize: () => void;
|
|
@@ -86,6 +111,10 @@ export interface AssistantDockApi extends AssistantDockState {
|
|
|
86
111
|
setSideWidth: (width: number) => void;
|
|
87
112
|
/** The host registers whether it offers the side panel (`allowSide`). */
|
|
88
113
|
setSideAllowed: (allowed: boolean) => void;
|
|
114
|
+
/** The host registers whether it offers the left panel (`allowLeft`). */
|
|
115
|
+
setLeftAllowed: (allowed: boolean) => void;
|
|
116
|
+
/** The storage prefix (`options.storagePrefix`): the floating window's chrome keeps its place under `<prefix>.window` (12/11/2026). */
|
|
117
|
+
storagePrefix: string;
|
|
89
118
|
}
|
|
90
119
|
|
|
91
120
|
const Ctx = createContext<AssistantDockApi | null>(null);
|
|
@@ -95,7 +124,10 @@ const Ctx = createContext<AssistantDockApi | null>(null);
|
|
|
95
124
|
* See `./dock.ts` for the transition rules and why they exist.
|
|
96
125
|
*/
|
|
97
126
|
export function AssistantProvider({ options, children }: { options?: AssistantOptions; children: ReactNode }) {
|
|
98
|
-
|
|
127
|
+
// The place a person who never chose one gets is the surface's (`defaultShape`), from the first render: a press before the stored
|
|
128
|
+
// choice is read already opens it there.
|
|
129
|
+
const [state, dispatch] = useReducer(assistantDockReducer, options?.defaultShape,
|
|
130
|
+
(shape?: AssistantFloatShape) => (shape ? { ...initialAssistantDockState, floatShape: shape } : initialAssistantDockState));
|
|
99
131
|
// Read through a ref: the options object is usually built inline, and the effects below must not
|
|
100
132
|
// re-subscribe (or re-read storage) every render because of it.
|
|
101
133
|
const opts = useRef<Required<AssistantOptions>>({ ...DEFAULTS, ...options });
|
|
@@ -106,6 +138,8 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
106
138
|
// briefly alive, and a blind "clear on unmount" would leave the assistant reading an empty screen.
|
|
107
139
|
const factsOwner = useRef<string>("");
|
|
108
140
|
const [pageFacts, setPageFacts] = useState<string[]>([]);
|
|
141
|
+
/** The stored state has been read (the mount effect below): until then the load's open is not decided. */
|
|
142
|
+
const [restored, setRestored] = useState(false);
|
|
109
143
|
const publishPageFacts = useCallback((owner: string, facts: string[]) => {
|
|
110
144
|
factsOwner.current = owner;
|
|
111
145
|
setPageFacts(facts);
|
|
@@ -144,16 +178,36 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
144
178
|
restore({ type: "slide", offsetRight: rawOffset, ...offsetBounds() });
|
|
145
179
|
}
|
|
146
180
|
// The working shape outlives a reload: `lastMode` cannot stand in for it, since opening full screen overwrites it.
|
|
147
|
-
const
|
|
148
|
-
|
|
181
|
+
const placeKey = storageKey(opts.current.storagePrefix, "place");
|
|
182
|
+
let chosen = window.localStorage.getItem(placeKey);
|
|
183
|
+
if (chosen === null) {
|
|
184
|
+
// The key before `place` (see storageKey): its "dock" was a choice and is kept; its "side" may not have been, so it is not read.
|
|
185
|
+
const old = window.localStorage.getItem(storageKey(opts.current.storagePrefix, "shape"));
|
|
186
|
+
if (old === "dock") { chosen = old; window.localStorage.setItem(placeKey, old); }
|
|
187
|
+
}
|
|
188
|
+
window.localStorage.removeItem(storageKey(opts.current.storagePrefix, "shape"));
|
|
189
|
+
// `?? `: a surface may pass `defaultShape: undefined`, which the options spread lets through over the kit's default.
|
|
190
|
+
const shape = chosen === "side" || chosen === "dock" || chosen === "left" ? chosen : opts.current.defaultShape ?? initialAssistantDockState.floatShape;
|
|
191
|
+
restore({ type: "restore-float", shape });
|
|
149
192
|
// The pre-0.8.0 key: never read again (it holds the old default, not a choice) — drop it so storage has one answer.
|
|
150
193
|
window.localStorage.removeItem(`${opts.current.storagePrefix}.floatShape`);
|
|
151
194
|
const storedSide = Number(window.localStorage.getItem(storageKey(opts.current.storagePrefix, "sideWidth")));
|
|
152
195
|
if (Number.isFinite(storedSide) && storedSide > 0) {
|
|
153
196
|
requestedSide.current = storedSide;
|
|
154
|
-
|
|
197
|
+
// Against the room of the place it will open in: a left panel's beside the rail, not main's left edge, which the left panel's
|
|
198
|
+
// hold (hold.ts) has already moved over by the panel (600 stored at 1440 restored as 380, then 600 again: CLS 0.2).
|
|
199
|
+
restore({ type: "side-resize", width: storedSide, available: sideAvailable(shape === "left") });
|
|
155
200
|
}
|
|
201
|
+
// THE LEFT PANEL IS OPEN BY DEFAULT (12/11/2026, Chris: "ai chat mặc định mở, nằm ở bên trái"): a person whose place is the left
|
|
202
|
+
// panel, chosen or the surface's `defaultShape` (the admin's), finds it open when the app loads, beside the page, not folded away. Not on the assistant's own page (that is full
|
|
203
|
+
// screen), not when they closed or folded it earlier in this tab (`presentation` in sessionStorage, below), and only into the
|
|
204
|
+
// left panel itself: the host, mounted by this, says before its first paint whether it offers the panel here (the window, a page
|
|
205
|
+
// an editor covers), and the reducer opens it or leaves it closed, never a stand-in popup (dock.ts `opensLeft`).
|
|
206
|
+
const closedHere = window.sessionStorage.getItem(storageKey(opts.current.storagePrefix, "presentation"));
|
|
207
|
+
if (shape === "left" && window.matchMedia?.(SIDE_FITS_QUERY).matches && !opts.current.isOnFullPage()
|
|
208
|
+
&& closedHere !== "hidden" && closedHere !== "mini") restore({ type: "open-left-on-load" });
|
|
156
209
|
} catch { /* private mode — defaults are fine */ }
|
|
210
|
+
startTransition(() => setRestored(true));
|
|
157
211
|
}), []);
|
|
158
212
|
|
|
159
213
|
/**
|
|
@@ -168,6 +222,9 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
168
222
|
const requestedOffset = useRef(DOCK_DEFAULT_OFFSET_RIGHT);
|
|
169
223
|
/** …and the same for the side panel's width: a width chosen on a 27" screen comes back there. */
|
|
170
224
|
const requestedSide = useRef(SIDE_DEFAULT_WIDTH);
|
|
225
|
+
/** Whether the left panel is up, for the measures taken outside a render (the resize listener, a drag). */
|
|
226
|
+
const leftNow = useRef(false);
|
|
227
|
+
leftNow.current = state.presentation === "left";
|
|
171
228
|
|
|
172
229
|
/**
|
|
173
230
|
* How far the popup may travel in THIS window.
|
|
@@ -193,7 +250,7 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
193
250
|
// …and sideways too. `requestedOffset` was being written and never read, so a window that got
|
|
194
251
|
// narrower left the popup where a wider one had allowed it: on the rail, or past the edge.
|
|
195
252
|
dispatch({ type: "slide", offsetRight: requestedOffset.current, ...offsetBounds() });
|
|
196
|
-
dispatch({ type: "side-resize", width: requestedSide.current, available: sideAvailable() });
|
|
253
|
+
dispatch({ type: "side-resize", width: requestedSide.current, available: sideAvailable(leftNow.current) });
|
|
197
254
|
};
|
|
198
255
|
window.addEventListener("resize", onResize);
|
|
199
256
|
return () => window.removeEventListener("resize", onResize);
|
|
@@ -217,7 +274,7 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
217
274
|
|
|
218
275
|
const setSideWidth = useCallback((width: number) => {
|
|
219
276
|
requestedSide.current = Math.round(width);
|
|
220
|
-
dispatch({ type: "side-resize", width, available: sideAvailable() });
|
|
277
|
+
dispatch({ type: "side-resize", width, available: sideAvailable(leftNow.current) });
|
|
221
278
|
try { window.localStorage.setItem(storageKey(opts.current.storagePrefix, "sideWidth"), String(Math.round(width))); } catch { /* best-effort */ }
|
|
222
279
|
}, []);
|
|
223
280
|
|
|
@@ -243,14 +300,25 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
243
300
|
// write landed between two restores and turned a saved "dock" back into "side" on every reload (review #3744).
|
|
244
301
|
const sideAllowedNow = useRef(false);
|
|
245
302
|
sideAllowedNow.current = state.sideAllowed;
|
|
303
|
+
const leftAllowedNow = useRef(false);
|
|
304
|
+
leftAllowedNow.current = state.leftAllowed;
|
|
246
305
|
const saveShape = useCallback((shape: AssistantFloatShape) => {
|
|
247
|
-
try { window.localStorage.setItem(storageKey(opts.current.storagePrefix, "
|
|
306
|
+
try { window.localStorage.setItem(storageKey(opts.current.storagePrefix, "place"), shape); } catch { /* best-effort */ }
|
|
248
307
|
}, []);
|
|
249
308
|
|
|
250
309
|
useEffect(() => {
|
|
251
|
-
if (state.presentation !== "full" && state.presentation !== "dock" && state.presentation !== "side") return;
|
|
310
|
+
if (state.presentation !== "full" && state.presentation !== "dock" && state.presentation !== "side" && state.presentation !== "left") return;
|
|
252
311
|
try { window.localStorage.setItem(storageKey(opts.current.storagePrefix, "lastMode"), state.presentation); } catch { /* best-effort */ }
|
|
253
312
|
}, [state.presentation]);
|
|
313
|
+
// Where it is in THIS tab, once it has been on screen (the plain frame keeps the same key): the left panel's open-on-load above
|
|
314
|
+
// leaves it closed after the person closed or folded it here. Not written before it was first shown: a tab that never had it on
|
|
315
|
+
// screen has nothing to say (mounted is not enough: the load's wait for the left panel mounts it closed, `opensLeft`).
|
|
316
|
+
const shownOnce = useRef(false);
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
if (state.presentation !== "hidden") shownOnce.current = true;
|
|
319
|
+
if (!shownOnce.current) return;
|
|
320
|
+
try { window.sessionStorage.setItem(storageKey(opts.current.storagePrefix, "presentation"), state.presentation); } catch { /* best-effort */ }
|
|
321
|
+
}, [state.presentation]);
|
|
254
322
|
|
|
255
323
|
/**
|
|
256
324
|
* Intercept the rail's Assistant link when the popup is what they last used.
|
|
@@ -277,7 +345,7 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
277
345
|
// Any OTHER link to the full chat ("Open in chat" in a page's content) keeps the old rule: it navigates unless
|
|
278
346
|
// the person last worked in the popup or the panel (review #3744: it was swallowed for every fresh browser).
|
|
279
347
|
const rail = !!anchor.closest(".gnav-assistant");
|
|
280
|
-
if (rail ? last === "full" : last !== "dock" && last !== "side") return;
|
|
348
|
+
if (rail ? last === "full" : last !== "dock" && last !== "side" && last !== "left") return;
|
|
281
349
|
e.preventDefault();
|
|
282
350
|
e.stopPropagation();
|
|
283
351
|
dispatch({ type: "reopen" });
|
|
@@ -308,21 +376,37 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
308
376
|
// was clamped against whatever window it was last drawn in (or never, on a first open), and a resize is the only
|
|
309
377
|
// other moment that re-clamps.
|
|
310
378
|
useEffect(() => {
|
|
311
|
-
if (state.presentation === "side"
|
|
379
|
+
if (state.presentation === "side" || state.presentation === "left") {
|
|
380
|
+
dispatch({ type: "side-resize", width: requestedSide.current, available: sideAvailable(state.presentation === "left") });
|
|
381
|
+
}
|
|
312
382
|
}, [state.presentation]);
|
|
313
383
|
|
|
384
|
+
// The left panel makes room the same way, on the other side: `<prefix>-left` and its own width variable (LEFT_WIDTH_VAR).
|
|
314
385
|
useEffect(() => {
|
|
315
386
|
const p = opts.current.bodyClassPrefix;
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
387
|
+
const side = state.presentation === "side";
|
|
388
|
+
const left = state.presentation === "left";
|
|
389
|
+
document.body.classList.toggle(`${p}-side`, side);
|
|
390
|
+
document.body.classList.toggle(`${p}-left`, left);
|
|
391
|
+
if (side) document.body.style.setProperty(SIDE_WIDTH_VAR, `${state.sideWidth}px`);
|
|
319
392
|
else document.body.style.removeProperty(SIDE_WIDTH_VAR);
|
|
393
|
+
if (left) document.body.style.setProperty(LEFT_WIDTH_VAR, `${state.sideWidth}px`);
|
|
394
|
+
else document.body.style.removeProperty(LEFT_WIDTH_VAR);
|
|
320
395
|
return () => {
|
|
321
|
-
document.body.classList.remove(`${p}-side`);
|
|
396
|
+
document.body.classList.remove(`${p}-side`, `${p}-left`);
|
|
322
397
|
document.body.style.removeProperty(SIDE_WIDTH_VAR);
|
|
398
|
+
document.body.style.removeProperty(LEFT_WIDTH_VAR);
|
|
323
399
|
};
|
|
324
400
|
}, [state.presentation, state.sideWidth]);
|
|
325
401
|
|
|
402
|
+
// The left panel's place held from the first paint (assistant/hold.ts) is given back once the load's open is decided: the stored state
|
|
403
|
+
// read, and the host's word heard (`opensLeft`). After the body-class effect above, so a panel that opened already has its room.
|
|
404
|
+
useEffect(() => {
|
|
405
|
+
if (!restored || state.opensLeft) return;
|
|
406
|
+
document.documentElement.removeAttribute(ASSISTANT_HOLD_ATTR);
|
|
407
|
+
document.documentElement.style.removeProperty(LEFT_WIDTH_VAR);
|
|
408
|
+
}, [restored, state.opensLeft, state.presentation]);
|
|
409
|
+
|
|
326
410
|
// Every action is identity-STABLE (dispatch is). Children register these as callbacks and one of
|
|
327
411
|
// them — the chat's busy reporter — is read in an unmount cleanup, where a changing identity would
|
|
328
412
|
// fire a spurious "the run ended" on every state change.
|
|
@@ -331,9 +415,11 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
331
415
|
const openDock = useCallback(() => { dispatch({ type: "dock" }); saveShape("dock"); }, [saveShape]);
|
|
332
416
|
// Not offered here (narrow window, host without the panel): the reducer gives the popup and nothing is recorded.
|
|
333
417
|
const openSide = useCallback(() => { dispatch({ type: "side" }); if (sideAllowedNow.current) saveShape("side"); }, [saveShape]);
|
|
418
|
+
const openLeft = useCallback(() => { dispatch({ type: "left" }); if (leftAllowedNow.current) saveShape("left"); }, [saveShape]);
|
|
334
419
|
const reopen = useCallback(() => dispatch({ type: "reopen" }), []);
|
|
335
420
|
// Urgent, not a transition like the restore above: the host registers it before paint on the first open (host.tsx).
|
|
336
421
|
const setSideAllowed = useCallback((allowed: boolean) => dispatch({ type: "side-allowed", allowed }), []);
|
|
422
|
+
const setLeftAllowed = useCallback((allowed: boolean) => dispatch({ type: "left-allowed", allowed }), []);
|
|
337
423
|
const minimize = useCallback(() => dispatch({ type: "minimize" }), []);
|
|
338
424
|
const dismiss = useCallback(() => dispatch({ type: "dismiss" }), []);
|
|
339
425
|
const setBusy = useCallback((busy: boolean) => dispatch({ type: "busy", busy }), []);
|
|
@@ -341,10 +427,21 @@ export function AssistantProvider({ options, children }: { options?: AssistantOp
|
|
|
341
427
|
const api = useMemo<AssistantDockApi>(() => ({
|
|
342
428
|
...state,
|
|
343
429
|
pageFacts, publishPageFacts, retractPageFacts,
|
|
344
|
-
enterFull, leaveFull, openDock, openSide, reopen, minimize, dismiss, setBusy, setDockHeight, setDockOffsetRight, setSideWidth,
|
|
345
|
-
|
|
430
|
+
enterFull, leaveFull, openDock, openSide, openLeft, reopen, minimize, dismiss, setBusy, setDockHeight, setDockOffsetRight, setSideWidth,
|
|
431
|
+
setSideAllowed, setLeftAllowed, storagePrefix: opts.current.storagePrefix,
|
|
432
|
+
}), [state, pageFacts, publishPageFacts, retractPageFacts, enterFull, leaveFull, openDock, openSide, openLeft, reopen, minimize, dismiss, setBusy,
|
|
433
|
+
setDockHeight, setDockOffsetRight, setSideWidth, setSideAllowed, setLeftAllowed]);
|
|
434
|
+
|
|
435
|
+
return <Ctx.Provider value={api}><PresentationCtx.Provider value={state.presentation}>{children}</PresentationCtx.Provider></Ctx.Provider>;
|
|
436
|
+
}
|
|
346
437
|
|
|
347
|
-
|
|
438
|
+
/**
|
|
439
|
+
* Where the assistant is drawn right now, and nothing else (12/11/2026). For a shell that lays itself out around it: the admin
|
|
440
|
+
* folds its rail to icons while the chat stands on the LEFT and opens it again when the chat closes or moves. Changes only when
|
|
441
|
+
* the shape does. Outside a provider: "hidden".
|
|
442
|
+
*/
|
|
443
|
+
export function useAssistantPresentation(): AssistantPresentation {
|
|
444
|
+
return useContext(PresentationCtx);
|
|
348
445
|
}
|
|
349
446
|
|
|
350
447
|
export function useAssistant(): AssistantDockApi {
|
|
@@ -13,8 +13,16 @@
|
|
|
13
13
|
* sessions themselves, and what opening, renaming, pinning, deleting or exporting one does. Those
|
|
14
14
|
* are the surface's, through callbacks. Collapse and keyboard shortcuts are the surface's too (the
|
|
15
15
|
* admin only lets its full-screen page own the keyboard).
|
|
16
|
+
*
|
|
17
|
+
* Its WIDTH is the rail's (13/11/2026, Chris: "cái chat ở full mode ko có resize cái panel bên trái danh sách chat ấy"): the rail is a
|
|
18
|
+
* tray (../tray.tsx), with the tray's seam on its right edge, dragged or moved by the keys, the width kept per browser (`widthKey`).
|
|
19
|
+
* tray.css places it, and only where the rail is a column of threads: not collapsed, not at phone width.
|
|
16
20
|
*/
|
|
17
|
-
|
|
21
|
+
// The rail's width and its seam are placed by the tray's sheet (tray.tsx imports it too; named here because the rail's rules are in it).
|
|
22
|
+
import "../tray.css";
|
|
23
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from "react";
|
|
24
|
+
import { TrayEdge, useTrayWidth, type TraySize } from "../tray";
|
|
25
|
+
import { TraySearch } from "../tray-search";
|
|
18
26
|
|
|
19
27
|
/** One conversation in the rail. `updatedAt` is epoch ms. */
|
|
20
28
|
export interface AssistantSession {
|
|
@@ -75,6 +83,8 @@ export interface SessionRailLabels {
|
|
|
75
83
|
/** Relative time, and the locale for dates older than a week. */
|
|
76
84
|
justNow: string; minutesAgo: (m: number) => string; hoursAgo: (h: number) => string; daysAgo: (d: number) => string;
|
|
77
85
|
dateLocale: string;
|
|
86
|
+
/** The seam on the rail's right edge. */
|
|
87
|
+
resize: string;
|
|
78
88
|
/** The popup's open-chat tabs. */
|
|
79
89
|
openChats: string; newChatN: (n: number) => string; tabWorking: (title: string) => string;
|
|
80
90
|
closeChat: string; closeChatRunning: string; closeChatSr: string; closeChatRunningSr: string;
|
|
@@ -87,12 +97,17 @@ export const SESSION_RAIL_EN: SessionRailLabels = {
|
|
|
87
97
|
working: "working", options: "Options", save: "Save", cancel: "Cancel",
|
|
88
98
|
pin: "Pin", unpin: "Unpin", rename: "Rename", exportMarkdown: "Export Markdown", remove: "Delete", confirmRemove: "Delete this chat?",
|
|
89
99
|
justNow: "just now", minutesAgo: (m) => `${m} min ago`, hoursAgo: (h) => `${h} hr ago`,
|
|
90
|
-
daysAgo: (d) => `${d} day${d > 1 ? "s" : ""} ago`, dateLocale: "en-US",
|
|
100
|
+
daysAgo: (d) => `${d} day${d > 1 ? "s" : ""} ago`, dateLocale: "en-US", resize: "Resize the list",
|
|
91
101
|
openChats: "Open chats", newChatN: (n) => `New chat ${n}`, tabWorking: (t) => `${t} — working`,
|
|
92
102
|
closeChat: "Close this chat", closeChatRunning: "Working — closing this stops it",
|
|
93
103
|
closeChatSr: "Close this chat", closeChatRunningSr: "Close and stop the run",
|
|
94
104
|
};
|
|
95
105
|
|
|
106
|
+
/** The rail's widths (a tray's, ../tray.tsx): the tray's range, and the 264px it has always opened at. session-rail-plain.js says the same. */
|
|
107
|
+
export const SESSION_RAIL_SIZE: TraySize = { min: 240, max: 480, initial: 264 };
|
|
108
|
+
/** Where the rail's width is kept unless the surface names its own key (`widthKey`). */
|
|
109
|
+
export const SESSION_RAIL_WIDTH_KEY = "gemboss.assistant.rail";
|
|
110
|
+
|
|
96
111
|
/** Short relative time for the thread list. */
|
|
97
112
|
export function relativeTime(ts: number, L: SessionRailLabels = SESSION_RAIL_EN, now = Date.now()): string {
|
|
98
113
|
const m = Math.floor((now - ts) / 60000);
|
|
@@ -142,8 +157,8 @@ export function groupSessions(sessions: AssistantSession[], L: SessionRailLabels
|
|
|
142
157
|
*/
|
|
143
158
|
export function SessionRail({
|
|
144
159
|
sessions, unlistedIds = [], activeId, pendingId, busyIds = [], collapsed, onToggleCollapsed,
|
|
145
|
-
onNewChat, newChatTitle, onOpen, onRename, onTogglePin, onDelete, onExport, head, top, footer, searchRef, searchShown = true, onSearchDone,
|
|
146
|
-
labels, icons, titleMaxLength = 200,
|
|
160
|
+
onNewChat, newChatTitle, onOpen, onRename, onTogglePin, onDelete, onExport, head, top, footer, searchRef, searchReturnTo, searchShown = true, onSearchDone,
|
|
161
|
+
labels, icons, titleMaxLength = 200, widthKey = SESSION_RAIL_WIDTH_KEY,
|
|
147
162
|
}: {
|
|
148
163
|
/** Pinned-first, newest-first — the order the rail shows them in. */
|
|
149
164
|
sessions: AssistantSession[];
|
|
@@ -185,6 +200,10 @@ export function SessionRail({
|
|
|
185
200
|
footer?: ReactNode;
|
|
186
201
|
/** The search input, so the surface can focus it from a shortcut. */
|
|
187
202
|
searchRef?: React.Ref<HTMLInputElement>;
|
|
203
|
+
/** Where Escape and the box's × put the focus: the surface's own search button (`head`), not the page (TraySearch `returnTo`). */
|
|
204
|
+
searchReturnTo?: React.RefObject<HTMLElement | null>;
|
|
205
|
+
/** Where the width a person sets is kept in this browser (default SESSION_RAIL_WIDTH_KEY). */
|
|
206
|
+
widthKey?: string;
|
|
188
207
|
labels?: Partial<SessionRailLabels>;
|
|
189
208
|
icons?: Partial<SessionRailIcons>;
|
|
190
209
|
}) {
|
|
@@ -344,7 +363,7 @@ export function SessionRail({
|
|
|
344
363
|
);
|
|
345
364
|
|
|
346
365
|
return (
|
|
347
|
-
<
|
|
366
|
+
<RailBox collapsed={collapsed} widthKey={widthKey} label={L.resize}>
|
|
348
367
|
<div className="gemboss-assistant-rail-top">
|
|
349
368
|
{head ?? <>
|
|
350
369
|
<button type="button" className="gemboss-assistant-newchat" onClick={onNewChat} title={newChatTitle ?? L.newChat}>
|
|
@@ -364,21 +383,20 @@ export function SessionRail({
|
|
|
364
383
|
</div>
|
|
365
384
|
|
|
366
385
|
{sessions.length > 0 && (searchShown || query) && (
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
{
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
</div>
|
|
386
|
+
// The kit's tray search (../tray-search): the same box the Inbox's list opens from its icon.
|
|
387
|
+
<TraySearch
|
|
388
|
+
value={query}
|
|
389
|
+
onChange={setQuery}
|
|
390
|
+
onDone={() => onSearchDone?.()}
|
|
391
|
+
inputRef={searchRef}
|
|
392
|
+
returnTo={searchReturnTo}
|
|
393
|
+
placeholder={L.searchPlaceholder}
|
|
394
|
+
label={L.searchLabel}
|
|
395
|
+
clearLabel={L.clearSearch}
|
|
396
|
+
hint="/"
|
|
397
|
+
icon={<I.search />}
|
|
398
|
+
closeIcon={<I.close />}
|
|
399
|
+
/>
|
|
382
400
|
)}
|
|
383
401
|
|
|
384
402
|
{top}
|
|
@@ -401,6 +419,22 @@ export function SessionRail({
|
|
|
401
419
|
</div>
|
|
402
420
|
|
|
403
421
|
{footer}
|
|
422
|
+
</RailBox>
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* The rail's box: the aside, its width (a tray's, useTrayWidth: its room is the layout it stands in, beside the page's floor) and the
|
|
428
|
+
* seam last, none on the 60px strip. Its own component so a drag frame or a new room re-renders this box and not the threads: the
|
|
429
|
+
* rail's content comes in as `children`, the same elements on each of these renders (review of #7378).
|
|
430
|
+
*/
|
|
431
|
+
function RailBox({ collapsed, widthKey, label, children }: { collapsed: boolean; widthKey: string; label: string; children: ReactNode }) {
|
|
432
|
+
const tray = useTrayWidth<HTMLElement>({ storageKey: widthKey, size: SESSION_RAIL_SIZE, inParent: true });
|
|
433
|
+
return (
|
|
434
|
+
<aside ref={tray.ref} className={`gemboss-assistant-rail${collapsed ? " is-collapsed" : ""}`}
|
|
435
|
+
style={{ "--gb-tray-w": `${tray.shown}px`, "--gb-tray-min": `${SESSION_RAIL_SIZE.min}px` } as CSSProperties}>
|
|
436
|
+
{children}
|
|
437
|
+
{collapsed ? null : <TrayEdge tray={tray} label={label} />}
|
|
404
438
|
</aside>
|
|
405
439
|
);
|
|
406
440
|
}
|