@gemboss/ui 0.70.1 → 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 +289 -0
- package/README.md +31 -10
- package/catalog/editor.html +1 -1
- package/catalog/index.html +48 -46
- package/gemboss-ui.css +4 -4
- package/package.json +19 -1
- package/parts/components.css +2 -2
- package/parts/core.css +1 -1
- package/parts/shell.css +2 -2
- package/src/account-extras.css +1 -0
- package/src/account-row.tsx +44 -0
- package/src/account.tsx +5 -3
- package/src/app-nav.css +1 -1
- package/src/app-shell.css +1 -1
- package/src/assistant/bridge.tsx +22 -2
- 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 +4 -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-compose.css +1 -0
- package/src/stage-compose.tsx +78 -0
- 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
package/src/app-shell.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:where(html,body,button){font-family:var(--gemboss-font-sans)}:where(body){font-size:13px;line-height:20px;font-weight:450;color:var(--gemboss-text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:where(h1,h2,h3){letter-spacing:-.01em;line-height:1.3}:where(.gemboss-platform-shell) :where(h1,h2,h3,h4,h5,h6,p):where(:not([class])):not(:where(.ui-prose,[data-content],[class*=prose i],[class*=markdown i],.md-body,.recap-md,.asst-md,.article-body) *){margin:0;font-size:1em;font-weight:inherit;line-height:inherit}.gemboss-topbar-start{display:flex;align-items:center;gap:8px;min-width:0}.gemboss-topbar-center{display:flex;justify-content:center;min-width:0}.gemboss-topbar-end{display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0}@media (max-width: 760px){.gemboss-topbar-center{flex:1 1 0;min-width:96px;justify-content:flex-start}.gemboss-topbar-center:empty{min-width:0}.gemboss-topbar-end:empty{display:none}.gemboss-topbar-end{flex:0 0 auto}.gemboss-topbar-start{flex:0 1 auto}.gemboss-topbar-start>.gemboss-mobile-menu-btn{flex:0 0 auto}.gemboss-topbar-start>.gb-brand{min-width:44px}}.gnav-heading{padding:10px 12px 4px;font-size:var(--gemboss-fs-micro);font-weight:600;line-height:1.2;letter-spacing:.08em;text-transform:uppercase;color:var(--gemboss-text-muted)}.gnav-scroll>.gnav-heading:first-child,.gnav-scroll>.gnav-section:first-child>.gnav-heading:first-child{padding-top:2px}.gnav-
|
|
1
|
+
:where(html,body,button){font-family:var(--gemboss-font-sans)}:where(body){font-size:13px;line-height:20px;font-weight:450;color:var(--gemboss-text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:where(h1,h2,h3){letter-spacing:-.01em;line-height:1.3}:where(.gemboss-platform-shell) :where(h1,h2,h3,h4,h5,h6,p):where(:not([class])):not(:where(.ui-prose,[data-content],[class*=prose i],[class*=markdown i],.md-body,.recap-md,.asst-md,.article-body) *){margin:0;font-size:1em;font-weight:inherit;line-height:inherit}.gemboss-topbar-start{display:flex;align-items:center;gap:8px;min-width:0}.gemboss-topbar-center{display:flex;justify-content:center;min-width:0}.gemboss-topbar-end{display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0}@media (max-width: 760px){.gemboss-topbar-center{flex:1 1 0;min-width:96px;justify-content:flex-start}.gemboss-topbar-center:empty{min-width:0}.gemboss-topbar-end:empty{display:none}.gemboss-topbar-end{flex:0 0 auto}.gemboss-topbar-start{flex:0 1 auto}.gemboss-topbar-start>.gemboss-mobile-menu-btn{flex:0 0 auto}.gemboss-topbar-start>.gb-brand{min-width:44px}}.gnav-heading{padding:10px 12px 4px;font-size:var(--gemboss-fs-micro);font-weight:600;line-height:1.2;letter-spacing:.08em;text-transform:uppercase;color:var(--gemboss-text-muted)}.gnav-scroll>.gnav-heading:first-child,.gnav-scroll>.gnav-section:first-child>.gnav-heading:first-child{padding-top:2px}.gnav-item:is([aria-busy=true],:has(>.gnav-pending)),.gnav-subitem:is([aria-busy=true],:has(>.gnav-pending)){cursor:progress}.gnav-item:is([aria-busy=true],:has(>.gnav-pending))>.gnav-ico>*{visibility:hidden}.gnav-item:is([aria-busy=true],:has(>.gnav-pending))>.gnav-ico:after,.gnav-subitem:is([aria-busy=true],:has(>.gnav-pending)):after,.gb-pending-mark{content:"";display:inline-block;vertical-align:middle;grid-area:1 / 1;flex:none;box-sizing:border-box;width:20px;height:20px;border-radius:50%;border:2px solid color-mix(in srgb,currentColor 18%,transparent);border-top-color:currentColor;animation:gnav-spin .7s linear infinite}.gnav-subitem:is([aria-busy=true],:has(>.gnav-pending)):after{position:absolute;left:22px;top:50%;margin-top:-6px;width:12px;height:12px;border-width:1.5px}@keyframes gnav-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.gnav-item:is([aria-busy=true],:has(>.gnav-pending))>.gnav-ico:after,.gnav-subitem:is([aria-busy=true],:has(>.gnav-pending)):after,.gb-pending-mark{animation-duration:2s}}a[data-gb-pending]:has(>.gb-pending-mark),a[data-gb-pending][aria-busy=true]{cursor:progress}a[data-gb-pending]>.gb-pending-mark{display:inline-block;width:12px;height:12px;border-width:1.5px;margin-left:6px;vertical-align:-1px}a[data-gb-pending=corner]{position:relative}a[data-gb-pending=corner]>.gb-pending-mark{position:absolute;top:12px;right:12px;width:16px;height:16px;margin:0}.gb-route-holding{padding-top:4px}.gb-route-holding .ui-skeleton{gap:16px}.gb-route-holding__heading{margin:0 0 20px;font-size:20px;font-weight:650;line-height:1.3;color:var(--gemboss-text)}.gb-route-holding .ui-skeleton__line{height:10px}.gb-route-holding .ui-skeleton__line.gb-route-holding__title{height:20px;width:34%;margin-bottom:8px}.gb-route-holding .ui-skeleton__line:nth-last-child(4){width:46%}.gb-route-holding .ui-skeleton__line:nth-last-child(3){width:92%}.gb-route-holding .ui-skeleton__line:nth-last-child(2){width:78%}.gb-route-holding .ui-skeleton__line:nth-last-child(1){width:61%}.gb-route-cover{display:none}html[data-gb-navigating] .gb-route-cover{display:block;position:fixed;inset:56px 0 0 240px;z-index:5;overflow:hidden;box-sizing:border-box;padding:24px;background:var(--gemboss-app-bg);pointer-events:none;animation:gb-route-cover-in .08s ease-out both}@keyframes gb-route-cover-in{0%{opacity:0}to{opacity:1}}@media (max-width: 760px){html[data-gb-navigating] .gb-route-cover{left:0;padding:16px}}@media (prefers-reduced-motion: reduce){html[data-gb-navigating] .gb-route-cover{animation-duration:0s}}.gnav-pending{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.gb-brand{min-width:0;height:40px;margin:0;padding:0 8px;border-radius:var(--gemboss-radius-md);display:inline-flex;align-items:center;gap:4.5px;color:var(--gb-brand-ink, #14151a);text-decoration:none;transition:background-color var(--gemboss-transition-base) ease}@media (hover: hover){.gb-brand:hover{background:var(--gemboss-hover)}}.gb-brand:focus-visible{outline:2px solid var(--gemboss-primary);outline-offset:2px}.gb-brand-gem{display:block;flex:0 0 auto}.gb-brand-name{font-family:Inter,var(--gemboss-font-sans);font-size:13.3px;font-weight:700;letter-spacing:-.13px;line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}@media (max-width: 460px){.gb-brand-name{display:none}.gb-brand{min-width:44px;height:44px;justify-content:center}}.gemboss-topbar-search{width:100%;max-width:560px;height:36px;min-width:0;margin:0 auto;border:1px solid var(--gemboss-field-line);border-radius:var(--gemboss-radius-md);background:var(--gemboss-field-bg);padding:0 8px 0 12px;display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:8px;align-items:center;color:var(--gemboss-text-muted)}@media (hover: hover){.gemboss-topbar-search:hover{border-color:var(--gemboss-field-line-hover);background:var(--gemboss-field-bg-hover)}}.gemboss-topbar-search:focus-within{border-color:var(--gemboss-field-line-active);background:var(--gemboss-surface)}.gemboss-topbar-search-icon{width:18px;height:18px;color:currentColor}.gemboss-topbar-search-input{min-width:0;height:calc(100% + 2px);border:0;background:transparent;padding:0;margin:-1px 0;font:inherit;font-size:var(--gemboss-fs-body);line-height:18px;color:var(--gemboss-field-ink);outline:none}.gemboss-topbar-search-input::placeholder{color:var(--gemboss-field-placeholder);opacity:1}.gemboss-topbar-search-kbd{border:1px solid var(--gemboss-field-line);border-radius:var(--gemboss-radius-sm);background:var(--gemboss-surface);padding:1px 6px;color:var(--gemboss-text-muted);font-family:inherit;font-size:var(--gemboss-fs-micro);line-height:16px}.gemboss-topbar-search:focus-within .gemboss-topbar-search-kbd{display:none}@media (pointer: coarse),(max-width: 47.9975em){.gemboss-topbar-search{height:44px}}@media (max-width: 460px){.gemboss-topbar-search-kbd{display:none}}.ui-page{box-sizing:border-box;width:100%;min-width:0;max-width:var(--ui-content-max, 900px);margin-inline:auto}.ui-page--feed{max-width:720px}.ui-page--form{max-width:662px}.ui-page--canvas{max-width:1440px}.ui-page--full{max-width:none}@media (max-width: 47.9975em){.gemboss-assistant-collapse,.gemboss-assistant-newchat{min-height:44px;min-width:44px}}
|
package/src/assistant/bridge.tsx
CHANGED
|
@@ -343,8 +343,28 @@ export interface BridgeApi {
|
|
|
343
343
|
setBridge: React.Dispatch<React.SetStateAction<BridgeProbe>>;
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
/** Keep `cur` when the user is in the middle of it ("asking")
|
|
347
|
-
|
|
346
|
+
/** Keep `cur` when the user is in the middle of it ("asking"). A probe that found the same state brings its newer data (a paired
|
|
347
|
+
* bridge's engines: a CLI signed in or out on the machine, 12/11/2026, found moving the toolkits to 0.70.1) and keeps the user's
|
|
348
|
+
* notes on `cur` (lost, off, wrong, dismissed); nothing new, `cur` itself (no new object for every effect keyed on it). */
|
|
349
|
+
/** The user's notes on a probe (BridgeProbe): what a probe in the same state does not know and must not erase. One list, read
|
|
350
|
+
* for copying and for comparing, so a note added to BridgeProbe is added here once. */
|
|
351
|
+
const PROBE_NOTES = ["lost", "off", "wrong", "dismissed"] as const;
|
|
352
|
+
/** A probe's content in one stable string: keys sorted at every depth, and a note that is false the same as one that is absent. */
|
|
353
|
+
const probeKey = (p: BridgeProbe): string => {
|
|
354
|
+
const sorted = (v: unknown): unknown => (v && typeof v === "object" && !Array.isArray(v)
|
|
355
|
+
? Object.fromEntries(Object.keys(v as object).sort().map((k) => [k, sorted((v as Record<string, unknown>)[k])]))
|
|
356
|
+
: v);
|
|
357
|
+
const plain: Record<string, unknown> = { ...p };
|
|
358
|
+
for (const n of PROBE_NOTES) if (!plain[n]) delete plain[n];
|
|
359
|
+
return JSON.stringify(sorted(plain));
|
|
360
|
+
};
|
|
361
|
+
const keepUnlessNew = (res: BridgeProbe) => (cur: BridgeProbe): BridgeProbe => {
|
|
362
|
+
if (cur.state === "asking") return cur;
|
|
363
|
+
if (cur.state !== res.state) return res;
|
|
364
|
+
const next: BridgeProbe = { ...res };
|
|
365
|
+
for (const n of PROBE_NOTES) if (cur[n]) (next as unknown as Record<string, unknown>)[n] = cur[n];
|
|
366
|
+
return probeKey(next) === probeKey(cur) ? cur : next;
|
|
367
|
+
};
|
|
348
368
|
/** The server's engines, or null when it did not answer with them (not OK, not JSON, no `engines`). One reader for the first
|
|
349
369
|
* read and for refresh(), so the two cannot drift. */
|
|
350
370
|
const readEngines = (url: string | null): Promise<BridgeEngines | null> =>
|
package/src/assistant/chat.tsx
CHANGED
|
@@ -585,11 +585,79 @@ function crowded(box: HTMLElement): boolean {
|
|
|
585
585
|
const bar = box.querySelector<HTMLElement>(".gemboss-ec-toolbar");
|
|
586
586
|
if (lead && lead.scrollWidth > lead.clientWidth + 1) return true;
|
|
587
587
|
if (bar && bar.scrollWidth > bar.clientWidth + 1) return true;
|
|
588
|
+
// One row (composerRows): the lead leaves the words no room. The toolbar has no box of its own there, so this is its overflow.
|
|
589
|
+
if (box.dataset.rows === "1" && cramped(box)) return true;
|
|
588
590
|
for (const l of box.querySelectorAll<HTMLElement>(LABEL_SEL)) if (l.offsetParent !== null && l.scrollWidth > l.clientWidth + 1) return true;
|
|
589
591
|
for (const c of box.querySelectorAll<HTMLElement>(CHIP_SEL)) if (c.offsetParent !== null && c.tagName !== "SELECT" && c.scrollWidth > c.clientWidth + 1) return true;
|
|
590
592
|
return false;
|
|
591
593
|
}
|
|
592
594
|
|
|
595
|
+
/**
|
|
596
|
+
* ONE ROW OR TWO (12/11/2026, Chris: "cả input bên dưới cũng nên là một dòng; nếu viết dài thì nó dãn ra thành 2 dòng"). A box with
|
|
597
|
+
* something in its lead ("+", ✦, a chip) is one row while the words fit on one line: lead, text, tools, send (`data-rows="1"`,
|
|
598
|
+
* assistant-chat.css). Once they need a second line it is two: the text over the toolbar (`data-rows="2"`, the layout before).
|
|
599
|
+
* Only CSS changes between them: the text box is the same element, so the caret, the focus and the selection stay where they are.
|
|
600
|
+
*
|
|
601
|
+
* MEASURED, NOT COUNTED: the words' height in the ONE-ROW layout, against one line's (the box's line-height). Always measured in
|
|
602
|
+
* that layout, set for a moment before paint, so the second row's wider box never decides (that is the feedback that would
|
|
603
|
+
* flicker). HYSTERESIS: on two rows, it goes back only when the words fit one line with 24px to spare, so a word at the edge
|
|
604
|
+
* does not flip it on every key. Empty is one row, unless the box was given a `shortPlaceholder` and even that is wider than the one-row
|
|
605
|
+
* field (13/11/2026: 34px at 320 under a finger, "Ask Gem…" cut): then two rows, where the field is the box's width, as the same width
|
|
606
|
+
* under a mouse already is. A lead that leaves the words no room (under 48px, or pushed onto a line of their own: a wide chip in a
|
|
607
|
+
* narrow box) is two rows. Null: an empty lead, which is one row already (chat-composer.css `:has(lead:empty)`).
|
|
608
|
+
* chat-plain.js measures the same way (`rowsFor`).
|
|
609
|
+
*/
|
|
610
|
+
/** On one row, the words do not share the line with the lead and send (the box wraps, for the full-width rows over it), or have
|
|
611
|
+
* under 48px of it. */
|
|
612
|
+
function cramped(box: HTMLElement): boolean {
|
|
613
|
+
const ta = box.querySelector("textarea");
|
|
614
|
+
if (!ta) return false;
|
|
615
|
+
const t = ta.getBoundingClientRect();
|
|
616
|
+
const beside = (sel: string) => { const r = box.querySelector(sel)?.getBoundingClientRect(); return !r || (r.top < t.bottom && r.bottom > t.top); };
|
|
617
|
+
return ta.clientWidth < 48 || !beside(".gemboss-ec-toolbar-lead") || !beside(".gemboss-ec-toolbar > :is(button[type=submit], .gemboss-ec-stop)");
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
export function composerRows(box: HTMLElement, ta: HTMLTextAreaElement, least?: string): "1" | "2" | null {
|
|
621
|
+
if (!box.querySelector(".gemboss-ec-toolbar-lead")?.firstElementChild) return null;
|
|
622
|
+
const was = box.dataset.rows;
|
|
623
|
+
// On one row already: measured as it stands, nothing written (review of #7341: a forced layout on every key). The box is one line
|
|
624
|
+
// tall there, so words that wrap show as a scroll height past it.
|
|
625
|
+
if (was === "1") {
|
|
626
|
+
const cs = getComputedStyle(ta);
|
|
627
|
+
const words = ta.value ? ta.scrollHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom) : 0;
|
|
628
|
+
return cramped(box) || unshown(ta, cs, least) || words > (parseFloat(cs.lineHeight) || parseFloat(cs.fontSize) * 1.5) * 1.5 ? "2" : "1";
|
|
629
|
+
}
|
|
630
|
+
box.dataset.rows = "1";
|
|
631
|
+
const st = ta.style;
|
|
632
|
+
const keep = [st.height, st.minHeight, st.maxWidth];
|
|
633
|
+
const cs = getComputedStyle(ta);
|
|
634
|
+
const line = parseFloat(cs.lineHeight) || parseFloat(cs.fontSize) * 1.5;
|
|
635
|
+
// The room itself, as `cramped`: no 24px kept (an empty box changes rows only on a new width, never as keys go), so the admin's
|
|
636
|
+
// composer gate and the box read the same room (review of #7350).
|
|
637
|
+
const narrow = cramped(box) || unshown(ta, cs, least);
|
|
638
|
+
// Two rows: as wide as one row's text would be, less the 24px that keeps it there.
|
|
639
|
+
if (was === "2") st.maxWidth = `${Math.max(0, ta.clientWidth - 24)}px`;
|
|
640
|
+
st.height = "0px"; st.minHeight = "0px";
|
|
641
|
+
const words = ta.value ? ta.scrollHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom) : 0;
|
|
642
|
+
[st.height, st.minHeight, st.maxWidth] = keep;
|
|
643
|
+
if (was) box.dataset.rows = was; else delete box.dataset.rows;
|
|
644
|
+
return narrow || words > line * 1.5 ? "2" : "1";
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/** The field's width for words: the text box less its padding. */
|
|
648
|
+
const fieldWidth = (ta: HTMLTextAreaElement, cs: CSSStyleDeclaration) => ta.clientWidth - parseFloat(cs.paddingLeft) - parseFloat(cs.paddingRight);
|
|
649
|
+
/** Empty, and `least` (the shortest placeholder it has) is wider than the field: it would show cut. */
|
|
650
|
+
const unshown = (ta: HTMLTextAreaElement, cs: CSSStyleDeclaration, least?: string) => !ta.value && !!least && textWidth(least, cs) > fieldWidth(ta, cs);
|
|
651
|
+
|
|
652
|
+
/** How wide `text` is in `cs`'s font (one canvas, kept). */
|
|
653
|
+
let measureCtx: CanvasRenderingContext2D | null = null;
|
|
654
|
+
function textWidth(text: string, cs: CSSStyleDeclaration): number {
|
|
655
|
+
measureCtx ??= document.createElement("canvas").getContext("2d");
|
|
656
|
+
if (!measureCtx) return 0;
|
|
657
|
+
measureCtx.font = `${cs.fontStyle} ${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;
|
|
658
|
+
return measureCtx.measureText(text).width;
|
|
659
|
+
}
|
|
660
|
+
|
|
593
661
|
/** The paperclip every composer draws: one glyph, not 📎 in one chat and an SVG in another. */
|
|
594
662
|
export function PaperclipIcon() {
|
|
595
663
|
return (
|
|
@@ -635,6 +703,9 @@ export interface ChatComposerProps {
|
|
|
635
703
|
* image), an upload still running is not. The text box stays editable either way; `disabled` is for the whole box. */
|
|
636
704
|
canSend?: boolean;
|
|
637
705
|
placeholder?: string;
|
|
706
|
+
/** Said in the box instead of `placeholder` when that one does not fit the field (12/11/2026: "How's my stor" at 390 under a finger):
|
|
707
|
+
* measured against the words' width in the box's own font, so a narrow panel on a desktop gets it too, not by the window's width. */
|
|
708
|
+
shortPlaceholder?: string;
|
|
638
709
|
/** The text box's accessible name (default "Message"). */
|
|
639
710
|
label?: string;
|
|
640
711
|
/**
|
|
@@ -741,25 +812,53 @@ export function ChatComposer(p: ChatComposerProps) {
|
|
|
741
812
|
}, []);
|
|
742
813
|
|
|
743
814
|
// Grow from one line to the box's max-height (chat.css: 84px), then scroll inside. Hidden (a closed tab): skip, the
|
|
744
|
-
// observer fits it when it gets a size.
|
|
815
|
+
// observer fits it when it gets a size. Before paint, so the row it picks (`composerRows`) is the first one seen.
|
|
816
|
+
// The words the row was last decided for: on two rows, words that only GREW at the end cannot fit one line again; on one row, words
|
|
817
|
+
// that only SHRANK at the end cannot need two. Anything else (a paste over a selection, an edit in the middle) is measured (review of
|
|
818
|
+
// #7341: a forced layout on every key, and a length alone misread a paste).
|
|
819
|
+
const decided = useRef("");
|
|
820
|
+
// The full placeholder fits the field, measured against the words' width (`shortPlaceholder`).
|
|
821
|
+
const [placeholderFits, setPlaceholderFits] = useState(true);
|
|
822
|
+
const fitRef = useRef<(force?: boolean) => void>(() => {});
|
|
823
|
+
fitRef.current = (force = false) => {
|
|
824
|
+
const el = ref.current;
|
|
825
|
+
if (!el || el.offsetParent === null || el.scrollHeight === 0) return;
|
|
826
|
+
const box = boxRef.current;
|
|
827
|
+
const prev = decided.current, now = el.value;
|
|
828
|
+
decided.current = now;
|
|
829
|
+
const was = box?.dataset.rows;
|
|
830
|
+
// Emptied on one row: measured, the placeholder may not fit there (`shortPlaceholder`). The other way, on purpose: an empty box on
|
|
831
|
+
// two rows because even its short placeholder did not fit one row stays two as words start ("" starts every word). Its one-row
|
|
832
|
+
// field is narrower than "Ask Gem…" (34px at 320 under a finger), so the first word would bring one row and the second take it
|
|
833
|
+
// away (review of #7350 asked; kept).
|
|
834
|
+
const kept = !force && ((was === "2" && now.startsWith(prev)) || (was === "1" && now !== "" && prev.startsWith(now))) ? was : null;
|
|
835
|
+
const rows = !box ? null : kept ?? composerRows(box, el, p.shortPlaceholder);
|
|
836
|
+
// The density steps were measured on the other layout: step again from full on this one (a chip has more room on two rows).
|
|
837
|
+
if (box && (box.dataset.rows ?? null) !== rows) {
|
|
838
|
+
if (rows) box.dataset.rows = rows; else delete box.dataset.rows;
|
|
839
|
+
setDensity("full"); setRemeasure((n) => n + 1);
|
|
840
|
+
}
|
|
841
|
+
const cs = getComputedStyle(el);
|
|
842
|
+
const max = parseFloat(cs.maxHeight) || 84;
|
|
843
|
+
el.style.height = "auto";
|
|
844
|
+
const want = el.scrollHeight + (el.offsetHeight - el.clientHeight); // border-box: add the 1px borders back
|
|
845
|
+
el.style.height = `${Math.min(want, max)}px`;
|
|
846
|
+
el.style.overflowY = want > max ? "auto" : "hidden";
|
|
847
|
+
if (p.shortPlaceholder && p.placeholder) setPlaceholderFits(textWidth(p.placeholder, cs) <= fieldWidth(el, cs));
|
|
848
|
+
};
|
|
849
|
+
useBeforePaint(() => { fitRef.current(); }, [p.value, p.placeholder, p.shortPlaceholder]);
|
|
850
|
+
// Once, not on every key: a new width, or a change in the lead ("+" arrived, a chip narrowed to its mark), decides again.
|
|
745
851
|
useEffect(() => {
|
|
746
852
|
const el = ref.current;
|
|
747
|
-
if (!el) return undefined;
|
|
748
|
-
const fit = () => {
|
|
749
|
-
if (el.offsetParent === null || el.scrollHeight === 0) return;
|
|
750
|
-
const max = parseFloat(getComputedStyle(el).maxHeight) || 84;
|
|
751
|
-
el.style.height = "auto";
|
|
752
|
-
const want = el.scrollHeight + (el.offsetHeight - el.clientHeight); // border-box: add the 1px borders back
|
|
753
|
-
el.style.height = `${Math.min(want, max)}px`;
|
|
754
|
-
el.style.overflowY = want > max ? "auto" : "hidden";
|
|
755
|
-
};
|
|
756
|
-
fit();
|
|
757
|
-
if (typeof ResizeObserver === "undefined") return undefined;
|
|
853
|
+
if (!el || typeof ResizeObserver === "undefined") return undefined;
|
|
758
854
|
let width = el.clientWidth;
|
|
759
|
-
const ro = new ResizeObserver(() => { if (el.clientWidth === width) return; width = el.clientWidth;
|
|
855
|
+
const ro = new ResizeObserver(() => { if (el.clientWidth === width) return; width = el.clientWidth; fitRef.current(true); });
|
|
760
856
|
ro.observe(el);
|
|
761
|
-
|
|
762
|
-
|
|
857
|
+
const lead = boxRef.current?.querySelector(".gemboss-ec-toolbar-lead");
|
|
858
|
+
const mo = lead ? new MutationObserver(() => fitRef.current(true)) : null;
|
|
859
|
+
mo?.observe(lead!, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-label", "title", "aria-label"] });
|
|
860
|
+
return () => { ro.disconnect(); mo?.disconnect(); };
|
|
861
|
+
}, [ref]);
|
|
763
862
|
|
|
764
863
|
// What is sent is what the box shows: a session still listening stops first, so nothing lands after the message left.
|
|
765
864
|
const send = () => { if (canSend) { cancelVoice(); p.onSend(p.value); } };
|
|
@@ -806,7 +905,10 @@ export function ChatComposer(p: ChatComposerProps) {
|
|
|
806
905
|
disabled={p.disabled}
|
|
807
906
|
autoFocus={p.autoFocus}
|
|
808
907
|
aria-label={p.label ?? L.message}
|
|
809
|
-
placeholder={p.placeholder}
|
|
908
|
+
placeholder={p.shortPlaceholder && !placeholderFits ? p.shortPlaceholder : p.placeholder}
|
|
909
|
+
// The shortest text the empty box shows: a box is two rows when even this does not fit one row (`composerRows`), and the
|
|
910
|
+
// admin's composer gate reads it to tell that from a box that wrapped for nothing.
|
|
911
|
+
data-short-placeholder={p.shortPlaceholder}
|
|
810
912
|
// The seller typing while it listens stops it at once (their edit is the box; nothing more lands in it).
|
|
811
913
|
onChange={(e) => { cancelVoice(); if (addNote) setAddNote(null); if (aiProblem) setProblemRead(aiProblem); p.onChange(e.target.value); }}
|
|
812
914
|
onPaste={p.onPaste}
|
|
@@ -46,8 +46,11 @@ export interface ChatAddItem {
|
|
|
46
46
|
disabled?: boolean;
|
|
47
47
|
/** Why it is off, or more about it: its tooltip. */
|
|
48
48
|
title?: string;
|
|
49
|
+
/** A switch, not an action (12/11/2026, Gem's "Use this screen"): `menuitemcheckbox`, the kit's check before it while on.
|
|
50
|
+
* Its `onSelect` turns it over. Left out: a plain row. */
|
|
51
|
+
checked?: boolean;
|
|
49
52
|
}
|
|
50
|
-
export type ChatAddIcon = "image" | "file" | "media" | "screenshot" | "mention" | "link";
|
|
53
|
+
export type ChatAddIcon = "image" | "file" | "media" | "screenshot" | "mention" | "link" | "screen" | "document";
|
|
51
54
|
|
|
52
55
|
export interface ChatComposerAdd {
|
|
53
56
|
items: readonly ChatAddItem[];
|
|
@@ -88,7 +91,7 @@ export interface ChatComposerAi {
|
|
|
88
91
|
export function PlusGlyph() { return <Icon name="plus" />; }
|
|
89
92
|
export function SparkleGlyph() { return <Icon name="sparkle" />; }
|
|
90
93
|
const ROW_GLYPH: Record<ChatAddIcon, IconName> = {
|
|
91
|
-
image: "image", file: "paperclip", media: "media", screenshot: "screenshot", mention: "at", link: "link",
|
|
94
|
+
image: "image", file: "paperclip", media: "media", screenshot: "screenshot", mention: "at", link: "link", screen: "eye", document: "document",
|
|
92
95
|
};
|
|
93
96
|
const iconOf = (it: ChatAddItem): ChatAddIcon =>
|
|
94
97
|
it.icon ?? (it.paste ? "screenshot" : it.onFiles ? (/^\s*image\/[^,]*(\s*,\s*image\/[^,]*)*\s*$/.test(it.accept ?? "") ? "image" : "file") : "media");
|
|
@@ -148,6 +151,8 @@ export function useComposerAdd(add: ChatComposerAdd | null | undefined, disabled
|
|
|
148
151
|
<Menu label={label} icon={<PlusGlyph />} className="gemboss-ec-add" disabled={disabled} loading={add.busy}>
|
|
149
152
|
{items.map((it, i) => (
|
|
150
153
|
<MenuItem key={`${i}:${it.label}`} icon={<Icon name={ROW_GLYPH[iconOf(it)]} size={16} />} description={it.description} disabled={it.disabled} title={it.title}
|
|
154
|
+
// A switch row: the check and `aria-checked` are MenuItem's choice; the role says it turns on and off on its own.
|
|
155
|
+
checked={it.checked} {...(it.checked === undefined ? {} : { role: "menuitemcheckbox" })}
|
|
151
156
|
onClick={() => {
|
|
152
157
|
onNote(null);
|
|
153
158
|
if (it.onFiles) inputs.current[i]?.click();
|
package/src/assistant/dock.ts
CHANGED
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
* being spread over three components' effects.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
// NO IMPORTS in this file: the admin's tests load it straight with Node's type stripping (lib/assistant-dock.ts re-exports it), and
|
|
20
|
+
// Node does not resolve an extensionless sibling (`./window` broke assistant-dock.test.ts, 12/11/2026). The floating window's geometry
|
|
21
|
+
// is window.ts, which nothing Node loads imports.
|
|
22
|
+
|
|
19
23
|
/**
|
|
20
24
|
* Where the assistant is drawn. `hidden` still means MOUNTED — the run keeps going.
|
|
21
25
|
*
|
|
@@ -24,9 +28,25 @@
|
|
|
24
28
|
* popup, full width height" — and content-radar / partner-radar / GemCommunity each built their own right-side panel.
|
|
25
29
|
* A surface opts in (`AssistantHost allowSide`); without it nothing here ever produces `side`.
|
|
26
30
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
/**
|
|
32
|
+
* `left` (12/11/2026, Chris: "ai chat mặc định mở, nằm ở bên trái, sidebar menu sẽ collapse lại; tắt ai chat thì menu tự động expand
|
|
33
|
+
* ra… thêm một kiểu hiển thị"): the same full-height panel, on the LEFT of the page (beside the rail, under the topbar), resized on
|
|
34
|
+
* its right edge. A surface opts in (`AssistantHost allowLeft`) and may fold its rail while it is up (the admin does, reading
|
|
35
|
+
* `useAssistantPresentation`); the kit does not touch the rail.
|
|
36
|
+
*/
|
|
37
|
+
export type AssistantPresentation = "hidden" | "mini" | "dock" | "side" | "left" | "full";
|
|
38
|
+
/** The shapes a seller WORKS in on top of a screen. The chat button (`mini`) reopens into whichever they last used. */
|
|
39
|
+
export type AssistantFloatShape = "dock" | "side" | "left";
|
|
40
|
+
|
|
41
|
+
/** A shape the person works in over a screen: the popup or a panel (12/11/2026). Every "is Gem beside the page" check asks this, so
|
|
42
|
+
* a shape added later is counted everywhere at once (the left panel had to be added by hand to nine checks, and a tenth was missed). */
|
|
43
|
+
export function isPanelShape(p: AssistantPresentation): boolean {
|
|
44
|
+
return p === "dock" || p === "side" || p === "left";
|
|
45
|
+
}
|
|
46
|
+
/** On screen and worked in: a panel shape or the full page. Not `mini` (folded into its button) nor `hidden`. */
|
|
47
|
+
export function isOpenShape(p: AssistantPresentation): boolean {
|
|
48
|
+
return isPanelShape(p) || p === "full";
|
|
49
|
+
}
|
|
30
50
|
|
|
31
51
|
export interface AssistantDockState {
|
|
32
52
|
presentation: AssistantPresentation;
|
|
@@ -44,7 +64,8 @@ export interface AssistantDockState {
|
|
|
44
64
|
/** Bumped every time the assistant is brought back on screen. Lets a mount that already exists
|
|
45
65
|
* pick up a question handed over from ⌘K, which a mount-time read would only ever see once. */
|
|
46
66
|
openNonce: number;
|
|
47
|
-
/** Width of the `side` panel in px (seller-resizable, persisted).
|
|
67
|
+
/** Width of the `side` panel in px (seller-resizable, persisted). The `left` panel is the same column on the other side of
|
|
68
|
+
* the page and wears the same width: one number for "how wide I want Gem's column", whichever side it stands on. */
|
|
48
69
|
sideWidth: number;
|
|
49
70
|
/**
|
|
50
71
|
* The last shape the seller worked in over a screen. The status bar's "reopen", × on a busy bar and leaving full
|
|
@@ -59,6 +80,16 @@ export interface AssistantDockState {
|
|
|
59
80
|
* build. Review of #(this PR): the rail link dispatched a stored "side" straight past the host's opt-in.
|
|
60
81
|
*/
|
|
61
82
|
sideAllowed: boolean;
|
|
83
|
+
/** Whether the mounted host offers the LEFT panel (`AssistantHost allowLeft`, and a window that fits it). Same rule as
|
|
84
|
+
* `sideAllowed`: every way into `left` goes through it. */
|
|
85
|
+
leftAllowed: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* The app loaded for a person whose place is the left panel ("mặc định mở"): mounted and waiting for the host to say whether the left
|
|
88
|
+
* panel is offered here (12/11/2026). The host's first word decides: offered, it opens as the left panel; not offered (a narrow
|
|
89
|
+
* window, a page an editor covers, a host without it), it stays closed. Never a stand-in popup opened over a screen nobody opened
|
|
90
|
+
* the assistant on (/code-review of #7303). Any other way of opening or closing it clears this.
|
|
91
|
+
*/
|
|
92
|
+
opensLeft: boolean;
|
|
62
93
|
}
|
|
63
94
|
|
|
64
95
|
export type AssistantDockEvent =
|
|
@@ -68,18 +99,24 @@ export type AssistantDockEvent =
|
|
|
68
99
|
| { type: "leave-full" }
|
|
69
100
|
/** show the floating popup (restore from mini, or open it from anywhere) */
|
|
70
101
|
| { type: "dock" }
|
|
71
|
-
/**
|
|
102
|
+
/** fold into the chat button (12/11/2026; a small status bar until then) */
|
|
72
103
|
| { type: "minimize" }
|
|
73
104
|
/** the popup's × */
|
|
74
105
|
| { type: "dismiss" }
|
|
75
106
|
/** pin to the side panel (only surfaces that allow it send this) */
|
|
76
107
|
| { type: "side" }
|
|
77
|
-
/**
|
|
108
|
+
/** pin to the left panel (only surfaces that allow it send this) */
|
|
109
|
+
| { type: "left" }
|
|
110
|
+
/** bring it back in the last working shape (`floatShape`) — the chat button's click */
|
|
78
111
|
| { type: "reopen" }
|
|
79
112
|
/** `available` = the width of the content area the panel sits in (window minus the rail) */
|
|
80
113
|
| { type: "side-resize"; width: number; available: number }
|
|
81
114
|
/** the host says whether it offers the side panel */
|
|
82
115
|
| { type: "side-allowed"; allowed: boolean }
|
|
116
|
+
/** the host says whether it offers the left panel */
|
|
117
|
+
| { type: "left-allowed"; allowed: boolean }
|
|
118
|
+
/** the app loaded for a person whose place is the left panel: open it when the host says it is offered (`opensLeft`) */
|
|
119
|
+
| { type: "open-left-on-load" }
|
|
83
120
|
/** the last working shape, read back from storage on load */
|
|
84
121
|
| { type: "restore-float"; shape: AssistantFloatShape }
|
|
85
122
|
| { type: "busy"; busy: boolean }
|
|
@@ -112,6 +149,12 @@ export const SIDE_MAX_WIDTH = 720;
|
|
|
112
149
|
/** The page beside the panel never gets narrower than this — a cap only exists when it is smaller than the room
|
|
113
150
|
* there really is (§9.1), so the ceiling is taken from the content area, not from SIDE_MAX_WIDTH alone. */
|
|
114
151
|
export const SIDE_PAGE_MIN = 480;
|
|
152
|
+
/** The mark on <html> while the LEFT panel's place is held from the first paint (assistant/hold.ts), until the load's open is decided. */
|
|
153
|
+
export const ASSISTANT_HOLD_ATTR = "data-gb-assistant-hold";
|
|
154
|
+
|
|
155
|
+
/** Where a panel (side or left) stands BESIDE the page: rail 240 + SIDE_MIN_WIDTH + SIDE_PAGE_MIN. host.tsx says why below it the
|
|
156
|
+
* popup stands in; the provider reads it too (a seller whose place is the left panel finds it open on load only where it fits). */
|
|
157
|
+
export const SIDE_FITS_QUERY = "(min-width: 1100px)";
|
|
115
158
|
|
|
116
159
|
export function clampSideWidth(width: number, available: number): number {
|
|
117
160
|
const max = Number.isFinite(available) && available > 0
|
|
@@ -160,15 +203,33 @@ export const initialAssistantDockState: AssistantDockState = {
|
|
|
160
203
|
// (`backTo`), and a seller who floats it as a popup is remembered as such.
|
|
161
204
|
floatShape: "side",
|
|
162
205
|
sideAllowed: false,
|
|
206
|
+
leftAllowed: false,
|
|
207
|
+
opensLeft: false,
|
|
163
208
|
};
|
|
164
209
|
|
|
165
|
-
/** The shape to come back to: the last one worked in, unless this host does not offer
|
|
210
|
+
/** The shape to come back to: the last one worked in, unless this host (or this window) does not offer that panel. A left panel not
|
|
211
|
+
* offered here stands in as the side panel where that one is (an editor covers the page: it makes room on the right, editor-gem.css),
|
|
212
|
+
* else as the popup (review of #7303: with the left panel the admin's default, every editor otherwise got a popup over it). */
|
|
166
213
|
function backTo(state: AssistantDockState): AssistantFloatShape {
|
|
167
|
-
return state.sideAllowed ?
|
|
214
|
+
if (state.floatShape === "side") return state.sideAllowed ? "side" : "dock";
|
|
215
|
+
if (state.floatShape === "left") return state.leftAllowed ? "left" : state.sideAllowed ? "side" : "dock";
|
|
216
|
+
return "dock";
|
|
168
217
|
}
|
|
169
218
|
|
|
170
219
|
export function assistantDockReducer(state: AssistantDockState, event: AssistantDockEvent): AssistantDockState {
|
|
220
|
+
// A way in or out the person (or a screen) chose replaces the load's wish to open the left panel.
|
|
221
|
+
if (state.opensLeft && event.type !== "left-allowed" && event.type !== "side-allowed" && event.type !== "busy"
|
|
222
|
+
&& event.type !== "resize" && event.type !== "slide" && event.type !== "side-resize" && event.type !== "restore-float"
|
|
223
|
+
&& event.type !== "open-left-on-load") {
|
|
224
|
+
return assistantDockReducer({ ...state, opensLeft: false }, event);
|
|
225
|
+
}
|
|
171
226
|
switch (event.type) {
|
|
227
|
+
case "open-left-on-load":
|
|
228
|
+
// Only from a closed assistant, and only for a person whose place is the left panel.
|
|
229
|
+
if (state.presentation !== "hidden" || state.floatShape !== "left") return state;
|
|
230
|
+
if (state.leftAllowed) return { ...state, presentation: "left", mounted: true, unread: false, openNonce: state.openNonce + 1 };
|
|
231
|
+
return { ...state, mounted: true, opensLeft: true };
|
|
232
|
+
|
|
172
233
|
case "enter-full":
|
|
173
234
|
return { ...state, presentation: "full", mounted: true, unread: false, openNonce: state.openNonce + 1 };
|
|
174
235
|
|
|
@@ -194,18 +255,44 @@ export function assistantDockReducer(state: AssistantDockState, event: Assistant
|
|
|
194
255
|
if (!state.sideAllowed) return { ...state, presentation: "dock", floatShape: "dock", mounted: true, unread: false, openNonce: state.openNonce + 1 };
|
|
195
256
|
return { ...state, presentation: "side", floatShape: "side", mounted: true, unread: false, openNonce: state.openNonce + 1 };
|
|
196
257
|
|
|
258
|
+
case "left":
|
|
259
|
+
// Not offered (a host without it, a window under 1100px, a covered page): the popup, as `side` does, and recorded as the
|
|
260
|
+
// popup, as a refused `side` is: it was asked for now. A caller that means "the person's own place, when it can" sends
|
|
261
|
+
// `reopen`, which keeps `floatShape` and lets `left-allowed` put the panel back (the admin's Ask Gem does).
|
|
262
|
+
if (!state.leftAllowed) return { ...state, presentation: "dock", floatShape: "dock", mounted: true, unread: false, openNonce: state.openNonce + 1 };
|
|
263
|
+
return { ...state, presentation: "left", floatShape: "left", mounted: true, unread: false, openNonce: state.openNonce + 1 };
|
|
264
|
+
|
|
197
265
|
case "reopen":
|
|
198
266
|
return { ...state, presentation: backTo(state), mounted: true, unread: false, openNonce: state.openNonce + 1 };
|
|
199
267
|
|
|
200
268
|
case "side-allowed":
|
|
201
269
|
if (event.allowed === state.sideAllowed) return state;
|
|
202
|
-
// Withdrawn while the panel is up: it becomes the popup rather than a shape the host no longer draws for
|
|
270
|
+
// Withdrawn while the panel is up: it becomes the popup rather than a shape the host no longer draws for (also when it stood in for
|
|
271
|
+
// the left panel).
|
|
203
272
|
if (!event.allowed) return { ...state, sideAllowed: false, presentation: state.presentation === "side" ? "dock" : state.presentation };
|
|
204
273
|
// Allowed (again): a popup that is only there because the panel was not allowed a moment ago — the working shape
|
|
205
274
|
// is still "side" — goes back to the panel. Two ways that happens (review #3744): the admin mounts its host only
|
|
206
275
|
// after the first open, so that first open arrived before the host said yes; and a window that dipped below
|
|
207
276
|
// 1100px (DevTools docked, a snap) and came back. A popup the person CHOSE has floatShape "dock" and stays.
|
|
208
|
-
|
|
277
|
+
// A popup standing in for a LEFT panel not offered here becomes the side panel too (backTo's order: left, side, popup).
|
|
278
|
+
const standIn = state.floatShape === "side" || (state.floatShape === "left" && !state.leftAllowed);
|
|
279
|
+
return { ...state, sideAllowed: true, presentation: state.presentation === "dock" && standIn ? "side" : state.presentation };
|
|
280
|
+
|
|
281
|
+
case "left-allowed":
|
|
282
|
+
// Waiting on the load's open (`opensLeft`): this word decides it, even when it is the same word as before (a host that does
|
|
283
|
+
// not offer it says "no" to a "no"); offered, the left panel opens; not offered, nothing opens.
|
|
284
|
+
if (state.opensLeft) {
|
|
285
|
+
const open = event.allowed && state.presentation === "hidden";
|
|
286
|
+
return { ...state, leftAllowed: event.allowed, opensLeft: false,
|
|
287
|
+
...(open ? { presentation: "left" as const, unread: false, openNonce: state.openNonce + 1 } : {}) };
|
|
288
|
+
}
|
|
289
|
+
// The same two rules as the side panel: withdrawn, the panel becomes the popup; allowed (again), a popup that only stood in
|
|
290
|
+
// for it (the working shape is still "left") goes back to the left panel.
|
|
291
|
+
if (event.allowed === state.leftAllowed) return state;
|
|
292
|
+
if (!event.allowed) return { ...state, leftAllowed: false, presentation: state.presentation === "left" ? (state.sideAllowed ? "side" : "dock") : state.presentation };
|
|
293
|
+
// Back: the stand-in (the popup, or the side panel standing in for the left one) gives way to the left panel.
|
|
294
|
+
return { ...state, leftAllowed: true,
|
|
295
|
+
presentation: (state.presentation === "dock" || state.presentation === "side") && state.floatShape === "left" ? "left" : state.presentation };
|
|
209
296
|
|
|
210
297
|
case "restore-float":
|
|
211
298
|
return { ...state, floatShape: event.shape };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE LEFT PANEL'S PLACE, HELD FROM THE FIRST PAINT (12/11/2026, review of gemboss #7303).
|
|
3
|
+
*
|
|
4
|
+
* A surface whose person finds the left panel open on load (`defaultShape: "left"`, or "left" chosen) opened it only once the provider
|
|
5
|
+
* had read storage and the dock's code had arrived, after the page had painted: the rail folded 240 → 56 and the page moved over by the
|
|
6
|
+
* panel, every load. Measured on the admin rig at 1440: CLS 0.119, against 0.0001 for a person who keeps the popup (§9.4's cap is 0.1).
|
|
7
|
+
*
|
|
8
|
+
* `assistantLeftHoldScript(...)` is a script for the page's markup BEFORE the shell (like `themeScript`): it asks what the provider will
|
|
9
|
+
* ask (a window that fits, not the full page, not closed or folded in this tab, the place chosen or the surface's default), and if the
|
|
10
|
+
* left panel will open, marks <html> (`ASSISTANT_HOLD_ATTR`) with the panel's width. assistant-hold.css, which this module brings, then
|
|
11
|
+
* draws the folded rail, the page beside the panel and an empty panel from the first frame. The provider takes the mark away once the
|
|
12
|
+
* load's open is decided (the panel up, or not opened): the real rules then hold the same geometry.
|
|
13
|
+
*/
|
|
14
|
+
import "../assistant-hold.css";
|
|
15
|
+
import { ASSISTANT_HOLD_ATTR, SIDE_DEFAULT_WIDTH, SIDE_FITS_QUERY, SIDE_MAX_WIDTH, SIDE_MIN_WIDTH, SIDE_PAGE_MIN, type AssistantFloatShape } from "./dock";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* How long a hold may stand at most, from the first paint. The provider gives it back once the load's open is decided (the host's word,
|
|
19
|
+
* `opensLeft`); a host that never mounts (the dock's code failed to load) never says it, and the empty column would stay for good. So
|
|
20
|
+
* the script that set the mark takes it away by itself this long after (12/11/2026). Here, not in the provider: the script is the
|
|
21
|
+
* page's markup, while the provider is in every admin screen's first-load JS, at its budget (#7320). The panel still opens if the host
|
|
22
|
+
* comes later.
|
|
23
|
+
*/
|
|
24
|
+
export const ASSISTANT_HOLD_GIVE_UP_MS = 5000;
|
|
25
|
+
|
|
26
|
+
/** The folded rail's width (rail-fold.css, rail-mini.css): the panel stands right of it. */
|
|
27
|
+
const FOLDED_RAIL = 56;
|
|
28
|
+
|
|
29
|
+
export function assistantLeftHoldScript({ storagePrefix = "gemboss.assistant", defaultShape = "side", fullPath = "" }: {
|
|
30
|
+
/** The provider's `storagePrefix`. */
|
|
31
|
+
storagePrefix?: string;
|
|
32
|
+
/** The provider's `defaultShape`. */
|
|
33
|
+
defaultShape?: AssistantFloatShape;
|
|
34
|
+
/** The assistant's own page: the provider's `isOnFullPage` as a path prefix ("/app/assistant" in the admin). Nothing is held there. */
|
|
35
|
+
fullPath?: string;
|
|
36
|
+
} = {}): string {
|
|
37
|
+
const j = JSON.stringify;
|
|
38
|
+
return `(function(){try{var d=document.documentElement,P=${j(storagePrefix)};`
|
|
39
|
+
+ `if(!matchMedia(${j(SIDE_FITS_QUERY)}).matches)return;`
|
|
40
|
+
+ (fullPath ? `if(location.pathname.indexOf(${j(fullPath)})===0)return;` : "")
|
|
41
|
+
+ `var s=sessionStorage.getItem(P+".presentation");if(s==="hidden"||s==="mini")return;`
|
|
42
|
+
// The provider's reading of the stored place (provider.tsx): `place`, else the old key's "dock" (a choice), else the default.
|
|
43
|
+
+ `var c=localStorage.getItem(P+".place");if(c===null&&localStorage.getItem(P+".shape")==="dock")c="dock";`
|
|
44
|
+
+ `if((c==="side"||c==="dock"||c==="left"?c:${j(defaultShape)})!=="left")return;`
|
|
45
|
+
// dock.ts clampSideWidth against the content area beside the folded rail (provider.tsx sideAvailable(true)).
|
|
46
|
+
+ `var w=Number(localStorage.getItem(P+".sideWidth"))||${SIDE_DEFAULT_WIDTH},a=(d.clientWidth||innerWidth)-${FOLDED_RAIL};`
|
|
47
|
+
+ `var m=Math.max(${SIDE_MIN_WIDTH},Math.min(${SIDE_MAX_WIDTH},a-${SIDE_PAGE_MIN}));w=Math.min(Math.max(Math.round(w),${SIDE_MIN_WIDTH}),m);`
|
|
48
|
+
+ `d.setAttribute(${j(ASSISTANT_HOLD_ATTR)},"left");d.style.setProperty("--gb-assistant-left-w",w+"px");`
|
|
49
|
+
+ `setTimeout(function(){if(d.hasAttribute(${j(ASSISTANT_HOLD_ATTR)})){d.removeAttribute(${j(ASSISTANT_HOLD_ATTR)});`
|
|
50
|
+
+ `d.style.removeProperty("--gb-assistant-left-w")}},${ASSISTANT_HOLD_GIVE_UP_MS})}catch(e){}})();`;
|
|
51
|
+
}
|