A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Anchor floating layers to the visible viewport
Fei24111ca28bc1165c
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex a3f5ab8d..4f36c935 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -1966,6 +1966,22 @@ function runStatsOf(values) {var import_react = require("react");var reducedMotion = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;var noHover = () => window.matchMedia?.("(hover: none)").matches === true;+var viewBottom = () => window.visualViewport ? window.visualViewport.height + window.visualViewport.offsetTop : window.innerHeight;+function useViewport() {+ const [tick, setTick] = (0, import_react.useState)(0);+ (0, import_react.useEffect)(() => {+ const viewport = window.visualViewport;+ if (!viewport) return void 0;+ const bump = () => setTick((value) => value + 1);+ viewport.addEventListener("resize", bump);+ viewport.addEventListener("scroll", bump);+ return () => {+ viewport.removeEventListener("resize", bump);+ viewport.removeEventListener("scroll", bump);+ };+ }, []);+ return tick;+}function springEasing(stiffness, damping) {const w0 = Math.sqrt(stiffness);const zeta = damping / (2 * w0);@@ -2174,7 +2190,9 @@ function useLinger(value, ms) {// src/client/styles.jsvar SKIN_FOOT = ':is(div,footer):not([class*="_footArea"]):has(> div > [data-slot="sidebar.footer.action"] > .bt-connect-wrap)';var SHELL_CSS = `-body{--bt-ink:#141414;--bt-danger:#e02135;--bt-ink-2:rgba(20,20,20,.6);--bt-ink-3:rgba(20,20,20,.36);--bt-bubble:#eeeeee;--bt-sidebar:#f7f7f7;--bt-main:#fcfcfc;--bt-line:rgba(20,20,20,.08);--bt-line-2:rgba(20,20,20,.15);--bt-line-weak:rgba(20,20,20,.1);--bt-hover:rgba(119,119,119,.09);--bt-active:rgba(119,119,119,.17);--bt-card:#ffffff;--bt-accent:#4d6bfe;--bt-green:#00c972;--bt-star:#ff9800;--bt-user:#070707;--bt-user-ink:#fcfcfc;--bt-tag-bg:rgba(20,20,20,.06);--bt-tag-ink:rgba(20,20,20,.56)}+body{--bt-ink:#141414;--bt-danger:#e02135;--bt-ink-2:rgba(20,20,20,.6);--bt-ink-3:rgba(20,20,20,.36);--bt-bubble:#eeeeee;--bt-sidebar:#f7f7f7;--bt-main:#fcfcfc;--bt-line:rgba(20,20,20,.08);--bt-line-2:rgba(20,20,20,.15);--bt-line-weak:rgba(20,20,20,.1);--bt-hover:rgba(119,119,119,.09);--bt-active:rgba(119,119,119,.17);--bt-card:#ffffff;--bt-accent:#4d6bfe;--bt-green:#00c972;--bt-star:#ff9800;--bt-user:#070707;--bt-user-ink:#fcfcfc;--bt-tag-bg:rgba(20,20,20,.06);--bt-tag-ink:rgba(20,20,20,.56);-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:100%}+/* iOS waits out a double-tap zoom on buttons; the plugin's own controls never zoom. */+:is(.bt-tool,.bt-uaction,.bt-menu button,.bt-menu-item,.bt-icon-btn,.bt-round,.bt-pill,.bt-account,.bt-set-row,.bt-settings-item,.bt-react-strip button,.bt-palette-row,.bt-palette-clear,.bt-tab,.bt-ptab,.bt-ptab-x,.bt-bcard-x,.bt-plus,.bt-q-btn,.bt-q-x,.bt-x,.bt-nc-send,.bt-send,.bt-soft,.bt-mini,.bt-shape,.bt-swatch,.bt-color,.bt-newchat,.bt-task-day,.bt-task-remove,.bt-fb-btn){touch-action:manipulation}body[data-ds-dark-theme]{--bt-ink:#f2f2f2;--bt-ink-2:rgba(242,242,242,.6);--bt-ink-3:rgba(242,242,242,.36);--bt-bubble:#262626;--bt-sidebar:#1b1b1b;--bt-main:#141414;--bt-line:rgba(255,255,255,.08);--bt-line-2:rgba(255,255,255,.15);--bt-line-weak:rgba(255,255,255,.1);--bt-hover:rgba(160,160,160,.12);--bt-active:rgba(160,160,160,.2);--bt-card:#1f1f1f;--bt-user:#f2f2f2;--bt-user-ink:#141414;--bt-tag-bg:rgba(255,255,255,.09);--bt-tag-ink:rgba(242,242,242,.62)}${Object.entries(INKS).map(([name, [light]]) => `body{--bt-ink-${name}:${light}}`).join("")}${Object.entries(INKS).map(([name, [, dark]]) => `body[data-ds-dark-theme]{--bt-ink-${name}:${dark}}`).join("")}@@ -2782,7 +2800,7 @@ button:hover .bt-you{background:color-mix(in srgb,var(--bt-ink) 9%,var(--bt-side.bt-palette-clear{width:18px;height:18px;border:0;padding:0;border-radius:6px;background:none;color:var(--bt-ink-3);display:inline-flex;align-items:center;justify-content:center;cursor:pointer}.bt-palette-clear:hover{color:var(--bt-ink)}.bt-palette-clear svg{width:12px;height:12px}-.bt-palette-list{position:relative;height:402px;overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:2px;box-sizing:border-box}+.bt-palette-list{position:relative;height:402px;height:min(402px,54vh);height:min(402px,54dvh);overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:2px;box-sizing:border-box}.bt-palette-list>.bt-thumb,.bt-drop-list>.bt-thumb{left:0;right:0;border-radius:8px;background:var(--bt-active)}.bt-palette-list>.bt-thumb{left:8px;right:8px}:is(.bt-palette-list,.bt-drop-list)[data-glide] [aria-selected=true]{background:transparent}@@ -2922,7 +2940,7 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}@media (hover:none){.bt-mem-remove{opacity:1}}.bt-mem-none{font-size:13px;line-height:18px;color:var(--bt-ink-3);padding:8px 4px}.bt-mem-foot{flex:none;padding:8px 20px 20px;display:flex;flex-direction:column;gap:10px}-.bt-mem-reply{border-radius:16px;background:var(--bt-hover);padding:8px 8px 12px 16px;display:flex;flex-direction:column;gap:6px;max-height:36vh;overflow-y:auto;scrollbar-width:thin;transform-origin:50% 100%;animation:bt-pop-lift ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},bt-veil-in .2s ease-out}+.bt-mem-reply{border-radius:16px;background:var(--bt-hover);padding:8px 8px 12px 16px;display:flex;flex-direction:column;gap:6px;max-height:36vh;max-height:36dvh;overflow-y:auto;scrollbar-width:thin;transform-origin:50% 100%;animation:bt-pop-lift ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},bt-veil-in .2s ease-out}.bt-mem-reply-head{display:flex;align-items:center;gap:8px;min-height:24px}.bt-mem-reply-asked{flex:1;min-width:0;font-size:12px;line-height:16px;color:var(--bt-ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.bt-mem-reply .bt-icon-btn{width:24px;height:24px;flex:none}@@ -2984,6 +3002,20 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}.bt-avedit{width:min(300px,calc(100vw - 32px))}.bt-shape-row{grid-template-columns:repeat(4,1fr)}}+/* Follow the visible viewport, not the layout one: dvh where the browser knows+ it (the earlier vh value is the fallback), and safe-area padding where+ full-screen layers and bottom regions meet the device's own bars. */+.bt-settings{--bt-set-h:min(780px,calc(100dvh - 2*max(32px,var(--dsh-frame-overlay-top,32px))))}+.bt-mem{height:min(760px,calc(100dvh - 2*max(32px,var(--dsh-frame-overlay-top,32px))))}+.bt-settings-layer,.bt-mem-layer,.bt-palette-layer{padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)}+.bt-panel{padding-bottom:env(safe-area-inset-bottom,0px)}+.bt-settings-scroll{padding-bottom:calc(24px + env(safe-area-inset-bottom,0px))}+.bt-voice-bar{padding-bottom:calc(32px + env(safe-area-inset-bottom,0px))}+.bt-exchange .bt-dialog-foot{padding-bottom:calc(28px + env(safe-area-inset-bottom,0px))}+/* iOS zooms the whole page on focused inputs under 16px. */+@media (max-width:640px) and (pointer:coarse){+ .bt-input,.bt-bs-input,.bt-browser-address input,.bt-folder-input,.bt-secret-input,.bt-q-input,.bt-to input,.bt-palette-head input,.bt-mem-input{font-size:16px}+}`;var CONVERSATION_CSS = `.bt-think{font-size:13px;line-height:18px;color:var(--bt-ink-2);margin:2px 0 4px;max-width:min(560px,78%)}@@ -3021,7 +3053,7 @@ var CONVERSATION_CSS = `[class*="_header"]:has(.bt-head){border-bottom-color:transparent!important;box-shadow:none!important}/* The transcript runs under a floating header pill. */header[class*="_header"]:has(.bt-head){position:absolute!important;top:0;left:0;right:0;z-index:8;display:flex!important;padding:10px 0 0!important;background:transparent!important;pointer-events:none;justify-content:center}-header[class*="_header"]:has(.bt-head)::before{content:"";position:absolute;inset:0 0 auto;height:60px;background:linear-gradient(to bottom,var(--bt-main),color-mix(in srgb,var(--bt-main) 0%,transparent));pointer-events:none;z-index:-1}+header[class*="_header"]:has(.bt-head)::before{content:"";position:absolute;inset:0 0 auto;height:calc(60px + env(safe-area-inset-top,0px));background:linear-gradient(to bottom,var(--bt-main),color-mix(in srgb,var(--bt-main) 0%,transparent));pointer-events:none;z-index:-1}header[class*="_header"]:has(.bt-head)>[class*="_headerLeading"]{position:absolute;left:12px;top:10px;pointer-events:auto}header[class*="_header"] .bt-head{flex:1 1 auto;width:100%}[class*="_body"]:has(> [class*="_scrollBody"]){--dsh-chat-content-width:min(960px,100%)}@@ -3043,7 +3075,7 @@ header[class*="_header"] .bt-head{flex:1 1 auto;width:100%}[data-content-phase=hero] [class*="_composerHero"]>[class$="_root"],[data-content-phase=hero] [class*="_heroWorkspaceRow"]{display:none!important}[data-content-phase=hero] [class*="_composerHero"] [class*="_input"]{min-height:0!important}/* The right sides give back the scrollbar gutter so both edges sit 16px from the column. */-[class*="_scroll"]:has(> [class*="_column"]){padding:60px 11px 16px 16px!important}+[class*="_scroll"]:has(> [class*="_column"]){padding:calc(60px + env(safe-area-inset-top,0px)) calc(11px + env(safe-area-inset-right,0px)) calc(16px + env(safe-area-inset-bottom,0px)) calc(16px + env(safe-area-inset-left,0px))!important}/* The shell's running status only hosts the activity row (.bt-typing). */[data-chat-running]{display:block!important;width:100%;min-height:0!important;margin:0!important;padding:0!important}[data-chat-running]>span:not([role=status]){display:none!important}@@ -5020,6 +5052,7 @@ function Bubble({ text, index, roster, selfId, actions, sessionId, msgKey, menti);}var REACTIONS = ["๐", "โค๏ธ", "๐", "๐ฎ", "๐ข", "๐"];+var STRIP_HALF = (REACTIONS.length * 34 + 10) / 2 + 8;function useDismiss(open, close, refs) {(0, import_react9.useEffect)(() => {if (!open) return void 0;@@ -5045,22 +5078,25 @@ function useDismiss(open, close, refs) {}function MessageTools({ text, name, sessionId, react, actions, open: tapped }) {const [panel, setPanel] = (0, import_react9.useState)(null);- const [place, setPlace] = (0, import_react9.useState)(null);const [copied, setCopied] = (0, import_react9.useState)(false);const tools = (0, import_react9.useRef)(null);const pop = (0, import_react9.useRef)(null);+ const tick = useViewport();const close = () => setPanel(null);useDismiss(panel !== null, close, [tools, pop]);const open = (kind, event) => {- if (panel === kind) {+ if (panel?.kind === kind) {close();return;}- const rect = event.currentTarget.getBoundingClientRect();- const below = rect.bottom + 220 < window.innerHeight;- setPlace(kind === "react" ? { left: rect.left + rect.width / 2, top: rect.top - 6, "--bt-origin": "bottom center" } : { left: Math.min(rect.left, window.innerWidth - 208), ...below ? { top: rect.bottom + 4 } : { bottom: window.innerHeight - rect.top + 4, "--bt-origin": "bottom left" } });- setPanel(kind);+ setPanel({ kind, node: event.currentTarget });};+ const place = (0, import_react9.useMemo)(() => {+ if (!panel) return null;+ const rect = panel.node.getBoundingClientRect();+ const below = rect.bottom + 220 < viewBottom();+ return panel.kind === "react" ? { left: Math.min(Math.max(rect.left + rect.width / 2, STRIP_HALF), window.innerWidth - STRIP_HALF), top: rect.top - 6, "--bt-origin": "bottom center" } : { left: Math.min(rect.left, window.innerWidth - 208), ...below ? { top: rect.bottom + 4 } : { bottom: viewBottom() - rect.top + 4, "--bt-origin": "bottom left" } };+ }, [panel, tick]);const copy2 = () => {void navigator.clipboard?.writeText(text).then(() => {setCopied(true);@@ -5080,10 +5116,10 @@ function MessageTools({ text, name, sessionId, react, actions, open: tapped }) {return (0, import_react9.createElement)("div",{ ref: tools, className: "bt-tools", "data-open": panel !== null || tapped || void 0 },- react ? (0, import_react9.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("Add reaction"), title: t("Add reaction"), "aria-expanded": panel === "react", onClick: (event) => open("react", event) }, (0, import_react9.createElement)(SmileIcon)) : null,+ react ? (0, import_react9.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("Add reaction"), title: t("Add reaction"), "aria-expanded": panel?.kind === "react", onClick: (event) => open("react", event) }, (0, import_react9.createElement)(SmileIcon)) : null,sessionId ? (0, import_react9.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("Reply"), title: t("Reply"), onClick: () => actions.quote(sessionId, text) }, (0, import_react9.createElement)(ReplyIcon)) : null,- (0, import_react9.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("More message actions"), title: t("More"), "aria-haspopup": "menu", "aria-expanded": panel === "more", onClick: (event) => open("more", event) }, copied ? (0, import_react9.createElement)(CheckIcon) : (0, import_react9.createElement)(DotsIcon)),- panel === "react" ? (0, import_react_dom.createPortal)((0, import_react9.createElement)(+ (0, import_react9.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("More message actions"), title: t("More"), "aria-haspopup": "menu", "aria-expanded": panel?.kind === "more", onClick: (event) => open("more", event) }, copied ? (0, import_react9.createElement)(CheckIcon) : (0, import_react9.createElement)(DotsIcon)),+ panel?.kind === "react" ? (0, import_react_dom.createPortal)((0, import_react9.createElement)("div",{ ref: pop, className: "bt-react-strip", role: "menu", "aria-label": t("Reactions"), style: place },REACTIONS.map((emoji) => (0, import_react9.createElement)("button", { key: emoji, type: "button", role: "menuitem", "aria-label": emoji, onClick: () => {@@ -5091,7 +5127,7 @@ function MessageTools({ text, name, sessionId, react, actions, open: tapped }) {react(emoji);} }, emoji))), document.body) : null,- panel === "more" ? (0, import_react_dom.createPortal)((0, import_react9.createElement)(+ panel?.kind === "more" ? (0, import_react_dom.createPortal)((0, import_react9.createElement)("div",{ ref: pop, className: "bt-menu", role: "menu", "aria-label": t("Message actions"), style: place },item(t("Copy"), CopyIcon, copy2),@@ -6458,11 +6494,13 @@ function UpdateButton({ useUpdate, actions }) {const dshRow = showsDshRow(dsh, update?.app);if (!update?.available && !dshRow && phase === "idle" && dshPhase === "idle") return null;const cloudPhase = phase === "installing" || dshPhase === "installing" ? "installing" : phase !== "idle" ? phase : dshPhase;- const toggle = () => {+ const tick = useViewport();+ (0, import_react11.useLayoutEffect)(() => {+ if (!open) return;const rect = button.current?.getBoundingClientRect();if (rect) setBox({ left: Math.max(8, Math.min(rect.left, window.innerWidth - 288)), top: rect.bottom + 6 });- setOpen((value) => !value);- };+ }, [open, tick]);+ const toggle = () => setOpen((value) => !value);const start = () => {setError("");void actions.installUpdate().catch((failure) => setError(hostText(failure?.message ?? String(failure))));@@ -6656,11 +6694,13 @@ function AccountLauncher({ seat = true, settingsOpen, openSettings, openOnboardiwindow.removeEventListener("keydown", onKey, true);};}, [open]);- const toggle = () => {+ const tick = useViewport();+ (0, import_react11.useLayoutEffect)(() => {+ if (!open) return;const rect = button.current?.getBoundingClientRect();- if (rect) setBox({ left: rect.left, bottom: window.innerHeight - rect.top + 5 });- setOpen((value) => !value);- };+ if (rect) setBox({ left: rect.left, bottom: viewBottom() - rect.top + 5 });+ }, [open, tick]);+ const toggle = () => setOpen((value) => !value);const groups = [[[t("Usage"), GaugeIcon, () => actions.openSettings("usage")],@@ -6950,7 +6990,7 @@ function useTranscriptView() {divider,center: Math.round(box.left + box.width / 2),top: Math.round(headerBottom + 8),- bottom: Math.round(window.innerHeight - box.bottom + composer + 8)+ bottom: Math.round(viewBottom() - box.bottom + composer + 8)};setView((prev) => prev && Object.keys(next).every((key) => prev[key] === next[key]) ? prev : next);};@@ -6959,12 +6999,16 @@ function useTranscriptView() {};document.addEventListener("scroll", schedule, true);window.addEventListener("resize", schedule);+ window.visualViewport?.addEventListener("resize", schedule);+ window.visualViewport?.addEventListener("scroll", schedule);schedule();return () => {cancelAnimationFrame(frame);observer.disconnect();document.removeEventListener("scroll", schedule, true);window.removeEventListener("resize", schedule);+ window.visualViewport?.removeEventListener("resize", schedule);+ window.visualViewport?.removeEventListener("scroll", schedule);};}, []);return view;@@ -7162,6 +7206,7 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {const [shown, leaving] = useLinger(open, 120);const button = (0, import_react13.useRef)(null);const menu = (0, import_react13.useRef)(null);+ const tick = useViewport();(0, import_react13.useEffect)(() => {if (!open) return void 0;const onDown = (event) => {@@ -7188,8 +7233,7 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {setOpen(null);return;}- const rect = button.current.getBoundingClientRect();- setOpen({ left: rect.left, bottom: window.innerHeight - rect.top + 8, files: Boolean(fileInput()) });+ setOpen({ files: Boolean(fileInput()) });};const attach = () => {setOpen(null);@@ -7204,6 +7248,11 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {actions.referenceChat(sessionId, inputActions?.captureInsertion?.());};const canReference = typeof inputActions?.captureInsertion === "function" && actions.canReferenceChat();+ const place = (0, import_react13.useMemo)(() => {+ if (!shown || !button.current) return null;+ const rect = button.current.getBoundingClientRect();+ return { left: rect.left, bottom: viewBottom() - rect.top + 8 };+ }, [shown, open, tick]);return (0, import_react13.createElement)(import_react13.Fragment,null,@@ -7225,7 +7274,7 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {className: "bt-menu bt-menu-up bt-plus-menu",role: "menu","aria-label": t("Add"),- style: { left: shown.left, bottom: shown.bottom },+ style: place ?? {},"data-leaving": leaving || void 0},shown.files ? (0, import_react13.createElement)("button", { type: "button", role: "menuitem", onClick: attach }, (0, import_react13.createElement)(PaperclipIcon), (0, import_react13.createElement)("span", { className: "bt-menu-label" }, t("Add files"))) : null,@@ -7936,11 +7985,16 @@ function ModelRows({ roster, current, onPick }) {}var Caret = () => (0, import_react16.createElement)("svg", { className: "bt-model-caret", width: 12, height: 12, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true }, (0, import_react16.createElement)("path", { d: "M5.5 8l4.5 4.5L14.5 8" }));function useAnchoredMenu() {+ const [anchor, setAnchor] = (0, import_react16.useState)(null);const [place, setPlace] = (0, import_react16.useState)(null);const [shownPlace, leaving] = useLinger(place, MENU_EXIT_MS);const button = (0, import_react16.useRef)(null);const menu = (0, import_react16.useRef)(null);- const close = () => setPlace(null);+ const tick = useViewport();+ const close = () => {+ setAnchor(null);+ setPlace(null);+ };(0, import_react16.useEffect)(() => {if (place === null) return void 0;const onDown = (event) => {@@ -7966,13 +8020,15 @@ function useAnchoredMenu() {window.removeEventListener("scroll", onScroll, true);};}, [place]);- const open = () => {+ const open = () => setAnchor({});+ (0, import_react16.useLayoutEffect)(() => {+ if (anchor === null || !button.current) return;const rect = button.current.getBoundingClientRect();const width = Math.max(240, rect.width);const left = Math.max(8, Math.min(rect.right - width, window.innerWidth - width - 8));- const below = window.innerHeight - rect.bottom;- setPlace(below >= 260 || below >= rect.top ? { left, width, top: rect.bottom + 4, maxHeight: below - 16, "--bt-origin": "top right" } : { left, width, bottom: window.innerHeight - rect.top + 4, maxHeight: rect.top - 16, "--bt-origin": "bottom right" });- };+ const below = viewBottom() - rect.bottom;+ setPlace(below >= 260 || below >= rect.top ? { left, width, top: rect.bottom + 4, maxHeight: below - 16, "--bt-origin": "top right" } : { left, width, bottom: viewBottom() - rect.top + 4, maxHeight: rect.top - 16, "--bt-origin": "bottom right" });+ }, [anchor, tick]);return { isOpen: place !== null, shownPlace, leaving, button, menu, open, close };}function ModelMenu({ bot, roster, actions, run, wide = false, onPick, onPickEffort }) {@@ -8180,7 +8236,7 @@ var MODEL_CSS = `.bt-model-tick svg{animation:bt-check-pop ${SPRING_POP.duration}ms ${SPRING_POP.easing} 60ms backwards}.bt-model-none{padding:8px;font-size:13px;line-height:18px;color:var(--bt-ink-2)}.bt-model-dock{width:100%;max-width:var(--dsh-chat-content-width,748px);margin:0 auto;display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding:0 0 10px;box-sizing:border-box;animation:bt-model-in ${SPRING_POP.duration}ms ${SPRING_POP.easing} backwards}-.bt-model-chips{display:flex;flex-wrap:wrap;gap:6px;margin-left:30px;max-width:min(560px,calc(100% - 30px));max-height:min(240px,36vh);overflow-y:auto;scrollbar-width:thin}+.bt-model-chips{display:flex;flex-wrap:wrap;gap:6px;margin-left:30px;max-width:min(560px,calc(100% - 30px));max-height:min(240px,36vh);max-height:min(240px,36dvh);overflow-y:auto;scrollbar-width:thin}.bt-model-choice-group{display:flex;flex-direction:column;gap:6px;width:100%;min-width:0}.bt-model-choice-provider{padding-top:4px;font-size:12px;line-height:16px;font-weight:500;color:var(--bt-ink-2);overflow-wrap:anywhere}.bt-model-choice-chips{display:flex;flex-wrap:wrap;gap:6px}@@ -12059,6 +12115,7 @@ var FEEDBACK_CSS = `.bt-fb-code{flex:none;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}.bt-event-error{color:var(--bt-danger,#e02135)}.bt-toast{position:fixed;left:50%;bottom:28px;z-index:1000;display:flex;align-items:center;gap:8px;max-width:min(560px,calc(100vw - 32px));padding:8px 8px 8px 14px;border-radius:12px;background:var(--bt-card,#fff);color:var(--bt-ink,#141414);border:1px solid var(--bt-line-2,rgba(0,0,0,.15));box-shadow:0 8px 28px rgba(0,0,0,.14);font-size:13px;line-height:18px;transform:translateX(-50%);animation:bt-toast-in ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},bt-veil-in .2s ease-out}+.bt-toast{bottom:calc(28px + env(safe-area-inset-bottom,0px))}.bt-toast[data-leaving]{opacity:0;transform:translate(-50%,6px) scale(.98);filter:blur(3px);transition:opacity .18s ease-in,transform .18s ease-in,filter .18s ease-in}.bt-toast-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical}.bt-toast-text::before{content:'';display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--bt-danger,#e02135);margin:0 8px 1px 0}@@ -12835,11 +12892,12 @@ function ContextMenu({ menu, roster, actions, leaving = false }) {}, []);const ref = (0, import_react34.useRef)(null);const [place, setPlace] = (0, import_react34.useState)({ left: menu.x, top: menu.y });+ const tick = useViewport();(0, import_react34.useLayoutEffect)(() => {const box = ref.current?.getBoundingClientRect();if (!box) return;- setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, window.innerHeight - box.height - 8)) });- }, [menu.x, menu.y]);+ setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, viewBottom() - box.height - 8)) });+ }, [menu.x, menu.y, tick]);if (menu.kind === "agent" || menu.kind === "agent-session") return (0, import_react34.createElement)(AgentMenu, { menu, roster, actions, leaving });const bot = roster.byId[menu.id];const room2 = roster.roomsById[menu.id];@@ -12894,11 +12952,12 @@ function ContextMenu({ menu, roster, actions, leaving = false }) {function AgentMenu({ menu, roster, actions, leaving }) {const ref = (0, import_react34.useRef)(null);const [place, setPlace] = (0, import_react34.useState)({ left: menu.x, top: menu.y });+ const tick = useViewport();(0, import_react34.useLayoutEffect)(() => {const box = ref.current?.getBoundingClientRect();if (!box) return;- setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, window.innerHeight - box.height - 8)) });- }, [menu.x, menu.y]);+ setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, viewBottom() - box.height - 8)) });+ }, [menu.x, menu.y, tick]);const agent = roster.agentsById[menu.kind === "agent" ? menu.id : menu.agentId];if (agent === void 0) return null;const groups = menu.kind === "agent" ? [diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.jsindex 19f7c705..202da09c 100644--- a/ds-bot/src/client/cells.js+++ b/ds-bot/src/client/cells.js@@ -13,7 +13,7 @@ import { call } from './api.js'import { failureLabel } from './diagnostics.js'import { turnReasoning, thinkingStep } from './turn-reasoning.js'import { FOLD_AT, FOLD_HUGE, stripLongNote, useFold } from './fold.js'-import { noHover } from './motion.js'+import { noHover, useViewport, viewBottom } from './motion.js'import { heldCardKey } from './sources.js'export { clockLabel }@@ -75,6 +75,9 @@ function Bubble({ text, index, roster, selfId, actions, sessionId, msgKey, menti}const REACTIONS = ['๐', 'โค๏ธ', '๐', '๐ฎ', '๐ข', '๐']+// Half the reaction strip: six 32px buttons at 2px gaps plus its own padding and+// the 8px margin it keeps from the screen edge.+const STRIP_HALF = (REACTIONS.length * 34 + 10) / 2 + 8// Closes a popover on a press outside the given elements or on Escape.function useDismiss(open, close, refs) {@@ -95,22 +98,26 @@ function useDismiss(open, close, refs) {// The hover toolbar beside a reply bubble: Add reaction, Reply, More. `open` is// the touch fallback: a tap on the bubble toggles it (see Bubble).function MessageTools({ text, name, sessionId, react, actions, open: tapped }) {+ // The anchor element is kept, not its rect: the visible viewport can move+ // (on-screen keyboard) while the popover is open.const [panel, setPanel] = useState(null)- const [place, setPlace] = useState(null)const [copied, setCopied] = useState(false)const tools = useRef(null)const pop = useRef(null)+ const tick = useViewport()const close = () => setPanel(null)useDismiss(panel !== null, close, [tools, pop])- const open = (kind, event) => {- if (panel === kind) { close(); return }- const rect = event.currentTarget.getBoundingClientRect()- const below = rect.bottom + 220 < window.innerHeight- setPlace(kind === 'react'- ? { left: rect.left + rect.width / 2, top: rect.top - 6, '--bt-origin': 'bottom center' }- : { left: Math.min(rect.left, window.innerWidth - 208), ...(below ? { top: rect.bottom + 4 } : { bottom: window.innerHeight - rect.top + 4, '--bt-origin': 'bottom left' }) })- setPanel(kind)- }+ const open = (kind, event) => { if (panel?.kind === kind) { close(); return } setPanel({ kind, node: event.currentTarget }) }+ const place = useMemo(() => {+ if (!panel) return null+ const rect = panel.node.getBoundingClientRect()+ const below = rect.bottom + 220 < viewBottom()+ return panel.kind === 'react'+ // The strip hangs off its center anchor: clamp the center so the strip+ // itself stays inside the viewport.+ ? { left: Math.min(Math.max(rect.left + rect.width / 2, STRIP_HALF), window.innerWidth - STRIP_HALF), top: rect.top - 6, '--bt-origin': 'bottom center' }+ : { left: Math.min(rect.left, window.innerWidth - 208), ...(below ? { top: rect.bottom + 4 } : { bottom: viewBottom() - rect.top + 4, '--bt-origin': 'bottom left' }) }+ }, [panel, tick])const copy = () => {void navigator.clipboard?.writeText(text).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1000) })}@@ -122,12 +129,12 @@ function MessageTools({ text, name, sessionId, react, actions, open: tapped }) {}const item = (label, Icon, run) => h('button', { key: label, type: 'button', role: 'menuitem', onClick: () => { close(); run() } }, h(Icon), label)return h('div', { ref: tools, className: 'bt-tools', 'data-open': panel !== null || tapped || undefined },- react ? h('button', { type: 'button', className: 'bt-tool', 'aria-label': t('Add reaction'), title: t('Add reaction'), 'aria-expanded': panel === 'react', onClick: event => open('react', event) }, h(SmileIcon)) : null,+ react ? h('button', { type: 'button', className: 'bt-tool', 'aria-label': t('Add reaction'), title: t('Add reaction'), 'aria-expanded': panel?.kind === 'react', onClick: event => open('react', event) }, h(SmileIcon)) : null,sessionId ? h('button', { type: 'button', className: 'bt-tool', 'aria-label': t('Reply'), title: t('Reply'), onClick: () => actions.quote(sessionId, text) }, h(ReplyIcon)) : null,- h('button', { type: 'button', className: 'bt-tool', 'aria-label': t('More message actions'), title: t('More'), 'aria-haspopup': 'menu', 'aria-expanded': panel === 'more', onClick: event => open('more', event) }, copied ? h(CheckIcon) : h(DotsIcon)),- panel === 'react' ? createPortal(h('div', { ref: pop, className: 'bt-react-strip', role: 'menu', 'aria-label': t('Reactions'), style: place },+ h('button', { type: 'button', className: 'bt-tool', 'aria-label': t('More message actions'), title: t('More'), 'aria-haspopup': 'menu', 'aria-expanded': panel?.kind === 'more', onClick: event => open('more', event) }, copied ? h(CheckIcon) : h(DotsIcon)),+ panel?.kind === 'react' ? createPortal(h('div', { ref: pop, className: 'bt-react-strip', role: 'menu', 'aria-label': t('Reactions'), style: place },REACTIONS.map(emoji => h('button', { key: emoji, type: 'button', role: 'menuitem', 'aria-label': emoji, onClick: () => { close(); react(emoji) } }, emoji))), document.body) : null,- panel === 'more' ? createPortal(h('div', { ref: pop, className: 'bt-menu', role: 'menu', 'aria-label': t('Message actions'), style: place },+ panel?.kind === 'more' ? createPortal(h('div', { ref: pop, className: 'bt-menu', role: 'menu', 'aria-label': t('Message actions'), style: place },item(t('Copy'), CopyIcon, copy), item(t('Download'), DownloadIcon, download)), document.body) : null)}diff --git a/ds-bot/src/client/composer.js b/ds-bot/src/client/composer.jsindex ce361e08..08d3b669 100644--- a/ds-bot/src/client/composer.js+++ b/ds-bot/src/client/composer.js@@ -1,8 +1,8 @@-import { createElement as h, Fragment, useEffect, useRef, useState } from 'react'+import { createElement as h, Fragment, useEffect, useMemo, useRef, useState } from 'react'import { createPortal } from 'react-dom'import { ChatsIcon, ClockIcon, MicIcon, PaperclipIcon, PeopleIcon, PlusIcon, WaveIcon } from './icons.js'import { BotMark } from './mark.js'-import { useLinger } from './motion.js'+import { useLinger, useViewport, viewBottom } from './motion.js'import { t } from './i18n.js'// -------------------------------------------------------------------------@@ -112,6 +112,7 @@ export function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {const [shown, leaving] = useLinger(open, 120)const button = useRef(null)const menu = useRef(null)+ const tick = useViewport()useEffect(() => {if (!open) return undefinedconst onDown = (event) => { if (![button.current, menu.current].some(node => node?.contains(event.target))) setOpen(null) }@@ -125,9 +126,8 @@ export function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {const fileInput = () => button.current?.closest('[data-composer-card]')?.querySelector('input[type=file]')const toggle = () => {if (open) { setOpen(null); return }- const rect = button.current.getBoundingClientRect()// Files go through the composer's own file input; a composer without one takes none.- setOpen({ left: rect.left, bottom: window.innerHeight - rect.top + 8, files: Boolean(fileInput()) })+ setOpen({ files: Boolean(fileInput()) })}const attach = () => {setOpen(null)@@ -144,6 +144,13 @@ export function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {actions.referenceChat(sessionId, inputActions?.captureInsertion?.())}const canReference = typeof inputActions?.captureInsertion === 'function' && actions.canReferenceChat()+ // Anchored to the "+" each render: the visible viewport can move (on-screen+ // keyboard) while the menu is open.+ const place = useMemo(() => {+ if (!shown || !button.current) return null+ const rect = button.current.getBoundingClientRect()+ return { left: rect.left, bottom: viewBottom() - rect.top + 8 }+ }, [shown, open, tick])return h(Fragment, null,h('button', {ref: button, type: 'button', className: 'bt-plus', 'aria-label': t('Add'), title: t('Add'),@@ -151,7 +158,7 @@ export function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {}, h(PlusIcon)),shown ? createPortal(h('div', {ref: menu, className: 'bt-menu bt-menu-up bt-plus-menu', role: 'menu', 'aria-label': t('Add'),- style: { left: shown.left, bottom: shown.bottom }, 'data-leaving': leaving || undefined,+ style: place ?? {}, 'data-leaving': leaving || undefined,},shown.files ? h('button', { type: 'button', role: 'menuitem', onClick: attach }, h(PaperclipIcon), h('span', { className: 'bt-menu-label' }, t('Add files'))) : null,canReference ? h('button', { type: 'button', role: 'menuitem', onMouseDown: keepComposerFocus, onClick: reference }, h(ChatsIcon), h('span', { className: 'bt-menu-label' }, t('Reference a chat'))) : null,diff --git a/ds-bot/src/client/context-menu.js b/ds-bot/src/client/context-menu.jsindex 48b00189..dc5fd1b8 100644--- a/ds-bot/src/client/context-menu.js+++ b/ds-bot/src/client/context-menu.js@@ -3,6 +3,7 @@ import { isMainOf } from './sources.js'import { currentPart } from './text.js'import { GearIcon, PinIcon, UnreadIcon, PencilIcon, StarLineIcon, CopyIcon, HideIcon, TrashIcon, DuplicateIcon } from './icons.js'import { useEscape } from './overlay-hooks.js'+import { useViewport, viewBottom } from './motion.js'import { t } from './i18n.js'export function ContextMenu({ menu, roster, actions, leaving = false }) {@@ -14,11 +15,12 @@ export function ContextMenu({ menu, roster, actions, leaving = false }) {}, [])const ref = useRef(null)const [place, setPlace] = useState({ left: menu.x, top: menu.y })+ const tick = useViewport()useLayoutEffect(() => {const box = ref.current?.getBoundingClientRect()if (!box) return- setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, window.innerHeight - box.height - 8)) })- }, [menu.x, menu.y])+ setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, viewBottom() - box.height - 8)) })+ }, [menu.x, menu.y, tick])if (menu.kind === 'agent' || menu.kind === 'agent-session') return h(AgentMenu, { menu, roster, actions, leaving })const bot = roster.byId[menu.id]const room = roster.roomsById[menu.id]@@ -60,11 +62,12 @@ export function ContextMenu({ menu, roster, actions, leaving = false }) {function AgentMenu({ menu, roster, actions, leaving }) {const ref = useRef(null)const [place, setPlace] = useState({ left: menu.x, top: menu.y })+ const tick = useViewport()useLayoutEffect(() => {const box = ref.current?.getBoundingClientRect()if (!box) return- setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, window.innerHeight - box.height - 8)) })- }, [menu.x, menu.y])+ setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, viewBottom() - box.height - 8)) })+ }, [menu.x, menu.y, tick])const agent = roster.agentsById[menu.kind === 'agent' ? menu.id : menu.agentId]if (agent === undefined) return nullconst groups = menu.kind === 'agent'diff --git a/ds-bot/src/client/feedback.js b/ds-bot/src/client/feedback.jsindex e05d18cd..a296b927 100644--- a/ds-bot/src/client/feedback.js+++ b/ds-bot/src/client/feedback.js@@ -170,6 +170,7 @@ export const FEEDBACK_CSS = `.bt-fb-code{flex:none;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}.bt-event-error{color:var(--bt-danger,#e02135)}.bt-toast{position:fixed;left:50%;bottom:28px;z-index:1000;display:flex;align-items:center;gap:8px;max-width:min(560px,calc(100vw - 32px));padding:8px 8px 8px 14px;border-radius:12px;background:var(--bt-card,#fff);color:var(--bt-ink,#141414);border:1px solid var(--bt-line-2,rgba(0,0,0,.15));box-shadow:0 8px 28px rgba(0,0,0,.14);font-size:13px;line-height:18px;transform:translateX(-50%);animation:bt-toast-in ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},bt-veil-in .2s ease-out}+.bt-toast{bottom:calc(28px + env(safe-area-inset-bottom,0px))}.bt-toast[data-leaving]{opacity:0;transform:translate(-50%,6px) scale(.98);filter:blur(3px);transition:opacity .18s ease-in,transform .18s ease-in,filter .18s ease-in}.bt-toast-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical}.bt-toast-text::before{content:'';display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--bt-danger,#e02135);margin:0 8px 1px 0}diff --git a/ds-bot/src/client/header.js b/ds-bot/src/client/header.jsindex a46333e1..239f4fef 100644--- a/ds-bot/src/client/header.js+++ b/ds-bot/src/client/header.js@@ -5,6 +5,7 @@ import { ArrowUpIcon, CloseIcon, ArrowDownIcon, MemoryIcon, SidePanelIcon } fromimport { botState, BotAvatar, RoomAvatar } from './mark.js'import { ActivityIndicator } from './activity-row.js'import { clockLabel, openingTurn, unseenSince } from './cells.js'+import { viewBottom } from './motion.js'import { t } from './i18n.js'// -------------------------------------------------------------------------@@ -146,19 +147,23 @@ function useTranscriptView() {divider,center: Math.round(box.left + box.width / 2),top: Math.round(headerBottom + 8),- bottom: Math.round(window.innerHeight - box.bottom + composer + 8),+ bottom: Math.round(viewBottom() - box.bottom + composer + 8),}setView(prev => (prev && Object.keys(next).every(key => prev[key] === next[key]) ? prev : next))}const schedule = () => { if (!frame) frame = requestAnimationFrame(measure) }document.addEventListener('scroll', schedule, true)window.addEventListener('resize', schedule)+ window.visualViewport?.addEventListener('resize', schedule)+ window.visualViewport?.addEventListener('scroll', schedule)schedule()return () => {cancelAnimationFrame(frame)observer.disconnect()document.removeEventListener('scroll', schedule, true)window.removeEventListener('resize', schedule)+ window.visualViewport?.removeEventListener('resize', schedule)+ window.visualViewport?.removeEventListener('scroll', schedule)}}, [])return viewdiff --git a/ds-bot/src/client/model-menu.js b/ds-bot/src/client/model-menu.jsindex 1a1e8460..6980767a 100644--- a/ds-bot/src/client/model-menu.js+++ b/ds-bot/src/client/model-menu.js@@ -1,10 +1,10 @@-import { createElement as h, Fragment, useEffect, useRef, useState, useSyncExternalStore } from 'react'+import { createElement as h, Fragment, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react'import { createPortal } from 'react-dom'import { currentPart } from './text.js'import { CheckIcon, SlidersIcon } from './icons.js'import { BotMark } from './mark.js'import { KeyIcon, MaskedInput } from './secret-card.js'-import { SPRING_POP, SPRING_SHAPE, spring, useLinger } from './motion.js'+import { SPRING_POP, SPRING_SHAPE, spring, useLinger, useViewport, viewBottom } from './motion.js'import { hostText, t } from './i18n.js'const MENU_EXIT_MS = 120@@ -101,11 +101,13 @@ export const Caret = () => h('svg', { className: 'bt-model-caret', width: 12, he// A menu that opens under its trigger, or above when the window has no room below. A// click outside, Escape, or a scroll outside it closes it.export function useAnchoredMenu() {+ const [anchor, setAnchor] = useState(null)const [place, setPlace] = useState(null)const [shownPlace, leaving] = useLinger(place, MENU_EXIT_MS)const button = useRef(null)const menu = useRef(null)- const close = () => setPlace(null)+ const tick = useViewport()+ const close = () => { setAnchor(null); setPlace(null) }useEffect(() => {if (place === null) return undefinedconst onDown = (event) => {@@ -123,15 +125,19 @@ export function useAnchoredMenu() {window.removeEventListener('scroll', onScroll, true)}}, [place])- const open = () => {+ const open = () => setAnchor({})+ // Re-reads the trigger's rect whenever the visible viewport moves: the menu+ // tracks its anchor through the on-screen keyboard, not past it.+ useLayoutEffect(() => {+ if (anchor === null || !button.current) returnconst rect = button.current.getBoundingClientRect()const width = Math.max(240, rect.width)const left = Math.max(8, Math.min(rect.right - width, window.innerWidth - width - 8))- const below = window.innerHeight - rect.bottom+ const below = viewBottom() - rect.bottomsetPlace(below >= 260 || below >= rect.top? { left, width, top: rect.bottom + 4, maxHeight: below - 16, '--bt-origin': 'top right' }- : { left, width, bottom: window.innerHeight - rect.top + 4, maxHeight: rect.top - 16, '--bt-origin': 'bottom right' })- }+ : { left, width, bottom: viewBottom() - rect.top + 4, maxHeight: rect.top - 16, '--bt-origin': 'bottom right' })+ }, [anchor, tick])return { isOpen: place !== null, shownPlace, leaving, button, menu, open, close }}@@ -328,7 +334,7 @@ export const MODEL_CSS = `.bt-model-tick svg{animation:bt-check-pop ${SPRING_POP.duration}ms ${SPRING_POP.easing} 60ms backwards}.bt-model-none{padding:8px;font-size:13px;line-height:18px;color:var(--bt-ink-2)}.bt-model-dock{width:100%;max-width:var(--dsh-chat-content-width,748px);margin:0 auto;display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding:0 0 10px;box-sizing:border-box;animation:bt-model-in ${SPRING_POP.duration}ms ${SPRING_POP.easing} backwards}-.bt-model-chips{display:flex;flex-wrap:wrap;gap:6px;margin-left:30px;max-width:min(560px,calc(100% - 30px));max-height:min(240px,36vh);overflow-y:auto;scrollbar-width:thin}+.bt-model-chips{display:flex;flex-wrap:wrap;gap:6px;margin-left:30px;max-width:min(560px,calc(100% - 30px));max-height:min(240px,36vh);max-height:min(240px,36dvh);overflow-y:auto;scrollbar-width:thin}.bt-model-choice-group{display:flex;flex-direction:column;gap:6px;width:100%;min-width:0}.bt-model-choice-provider{padding-top:4px;font-size:12px;line-height:16px;font-weight:500;color:var(--bt-ink-2);overflow-wrap:anywhere}.bt-model-choice-chips{display:flex;flex-wrap:wrap;gap:6px}diff --git a/ds-bot/src/client/motion.js b/ds-bot/src/client/motion.jsindex a7adc1dc..66723a80 100644--- a/ds-bot/src/client/motion.js+++ b/ds-bot/src/client/motion.js@@ -4,6 +4,26 @@ export const reducedMotion = () => window.matchMedia?.('(prefers-reduced-motion:// Touch devices never hover: controls revealed on hover need a tap path instead.export const noHover = () => window.matchMedia?.('(hover: none)').matches === true+// The bottom edge of what the user can see: window.innerHeight, or the visible+// region the visual viewport reports while the on-screen keyboard is open โ+// innerHeight does not shrink for it.+export const viewBottom = () => (window.visualViewport ? window.visualViewport.height + window.visualViewport.offsetTop : window.innerHeight)++// Re-renders whenever the visual viewport moves or resizes (keyboard opens, the+// URL bar collapses), so anchored layers can re-read their anchor's rect.+export function useViewport() {+ const [tick, setTick] = useState(0)+ useEffect(() => {+ const viewport = window.visualViewport+ if (!viewport) return undefined+ const bump = () => setTick(value => value + 1)+ viewport.addEventListener('resize', bump)+ viewport.addEventListener('scroll', bump)+ return () => { viewport.removeEventListener('resize', bump); viewport.removeEventListener('scroll', bump) }+ }, [])+ return tick+}+// A damped spring (mass 1) sampled into a CSS linear() easing, for WAAPI glides// and CSS transitions alike.export function springEasing(stiffness, damping) {diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.jsindex 5b0e1933..a45ee990 100644--- a/ds-bot/src/client/sidebar.js+++ b/ds-bot/src/client/sidebar.js@@ -8,7 +8,7 @@ import { MAIN_LOOK } from './characters.js'import { botState, BotMark, BotAvatar, RoomAvatar } from './mark.js'import { reducedMotion } from './activity-row.js'import { Shimmer, workPhrase } from './cells.js'-import { springEasing, SPRING_SHAPE } from './motion.js'+import { springEasing, SPRING_SHAPE, useViewport, viewBottom } from './motion.js'import { hostText, t } from './i18n.js'import { showsDshRow } from './dsh-offer.js'@@ -344,11 +344,13 @@ function UpdateButton({ useUpdate, actions }) {const dshRow = showsDshRow(dsh, update?.app)if (!update?.available && !dshRow && phase === 'idle' && dshPhase === 'idle') return nullconst cloudPhase = phase === 'installing' || dshPhase === 'installing' ? 'installing' : phase !== 'idle' ? phase : dshPhase- const toggle = () => {+ const tick = useViewport()+ useLayoutEffect(() => {+ if (!open) returnconst rect = button.current?.getBoundingClientRect()if (rect) setBox({ left: Math.max(8, Math.min(rect.left, window.innerWidth - 288)), top: rect.bottom + 6 })- setOpen(value => !value)- }+ }, [open, tick])+ const toggle = () => setOpen(value => !value)const start = () => {setError('')void actions.installUpdate().catch(failure => setError(hostText(failure?.message ?? String(failure))))@@ -512,11 +514,13 @@ export function AccountLauncher({ seat = true, settingsOpen, openSettings, openOwindow.addEventListener('keydown', onKey, true)return () => { window.removeEventListener('mousedown', onDown); window.removeEventListener('keydown', onKey, true) }}, [open])- const toggle = () => {+ const tick = useViewport()+ useLayoutEffect(() => {+ if (!open) returnconst rect = button.current?.getBoundingClientRect()- if (rect) setBox({ left: rect.left, bottom: window.innerHeight - rect.top + 5 })- setOpen(value => !value)- }+ if (rect) setBox({ left: rect.left, bottom: viewBottom() - rect.top + 5 })+ }, [open, tick])+ const toggle = () => setOpen(value => !value)const groups = [[[t('Usage'), GaugeIcon, () => actions.openSettings('usage')],diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.jsindex aae4c145..0c2432bb 100644--- a/ds-bot/src/client/styles.js+++ b/ds-bot/src/client/styles.js@@ -18,7 +18,9 @@ const SKIN_FOOT = ':is(div,footer):not([class*="_footArea"]):has(> div > [data-s// CONVERSATION_CSS re-skins the shell's own conversation DOM and styles what only// the conversation renders.export const SHELL_CSS = `-body{--bt-ink:#141414;--bt-danger:#e02135;--bt-ink-2:rgba(20,20,20,.6);--bt-ink-3:rgba(20,20,20,.36);--bt-bubble:#eeeeee;--bt-sidebar:#f7f7f7;--bt-main:#fcfcfc;--bt-line:rgba(20,20,20,.08);--bt-line-2:rgba(20,20,20,.15);--bt-line-weak:rgba(20,20,20,.1);--bt-hover:rgba(119,119,119,.09);--bt-active:rgba(119,119,119,.17);--bt-card:#ffffff;--bt-accent:#4d6bfe;--bt-green:#00c972;--bt-star:#ff9800;--bt-user:#070707;--bt-user-ink:#fcfcfc;--bt-tag-bg:rgba(20,20,20,.06);--bt-tag-ink:rgba(20,20,20,.56)}+body{--bt-ink:#141414;--bt-danger:#e02135;--bt-ink-2:rgba(20,20,20,.6);--bt-ink-3:rgba(20,20,20,.36);--bt-bubble:#eeeeee;--bt-sidebar:#f7f7f7;--bt-main:#fcfcfc;--bt-line:rgba(20,20,20,.08);--bt-line-2:rgba(20,20,20,.15);--bt-line-weak:rgba(20,20,20,.1);--bt-hover:rgba(119,119,119,.09);--bt-active:rgba(119,119,119,.17);--bt-card:#ffffff;--bt-accent:#4d6bfe;--bt-green:#00c972;--bt-star:#ff9800;--bt-user:#070707;--bt-user-ink:#fcfcfc;--bt-tag-bg:rgba(20,20,20,.06);--bt-tag-ink:rgba(20,20,20,.56);-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:100%}+/* iOS waits out a double-tap zoom on buttons; the plugin's own controls never zoom. */+:is(.bt-tool,.bt-uaction,.bt-menu button,.bt-menu-item,.bt-icon-btn,.bt-round,.bt-pill,.bt-account,.bt-set-row,.bt-settings-item,.bt-react-strip button,.bt-palette-row,.bt-palette-clear,.bt-tab,.bt-ptab,.bt-ptab-x,.bt-bcard-x,.bt-plus,.bt-q-btn,.bt-q-x,.bt-x,.bt-nc-send,.bt-send,.bt-soft,.bt-mini,.bt-shape,.bt-swatch,.bt-color,.bt-newchat,.bt-task-day,.bt-task-remove,.bt-fb-btn){touch-action:manipulation}body[data-ds-dark-theme]{--bt-ink:#f2f2f2;--bt-ink-2:rgba(242,242,242,.6);--bt-ink-3:rgba(242,242,242,.36);--bt-bubble:#262626;--bt-sidebar:#1b1b1b;--bt-main:#141414;--bt-line:rgba(255,255,255,.08);--bt-line-2:rgba(255,255,255,.15);--bt-line-weak:rgba(255,255,255,.1);--bt-hover:rgba(160,160,160,.12);--bt-active:rgba(160,160,160,.2);--bt-card:#1f1f1f;--bt-user:#f2f2f2;--bt-user-ink:#141414;--bt-tag-bg:rgba(255,255,255,.09);--bt-tag-ink:rgba(242,242,242,.62)}${Object.entries(INKS).map(([name, [light]]) => `body{--bt-ink-${name}:${light}}`).join('')}${Object.entries(INKS).map(([name, [, dark]]) => `body[data-ds-dark-theme]{--bt-ink-${name}:${dark}}`).join('')}@@ -626,7 +628,7 @@ button:hover .bt-you{background:color-mix(in srgb,var(--bt-ink) 9%,var(--bt-side.bt-palette-clear{width:18px;height:18px;border:0;padding:0;border-radius:6px;background:none;color:var(--bt-ink-3);display:inline-flex;align-items:center;justify-content:center;cursor:pointer}.bt-palette-clear:hover{color:var(--bt-ink)}.bt-palette-clear svg{width:12px;height:12px}-.bt-palette-list{position:relative;height:402px;overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:2px;box-sizing:border-box}+.bt-palette-list{position:relative;height:402px;height:min(402px,54vh);height:min(402px,54dvh);overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:2px;box-sizing:border-box}.bt-palette-list>.bt-thumb,.bt-drop-list>.bt-thumb{left:0;right:0;border-radius:8px;background:var(--bt-active)}.bt-palette-list>.bt-thumb{left:8px;right:8px}:is(.bt-palette-list,.bt-drop-list)[data-glide] [aria-selected=true]{background:transparent}@@ -766,7 +768,7 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}@media (hover:none){.bt-mem-remove{opacity:1}}.bt-mem-none{font-size:13px;line-height:18px;color:var(--bt-ink-3);padding:8px 4px}.bt-mem-foot{flex:none;padding:8px 20px 20px;display:flex;flex-direction:column;gap:10px}-.bt-mem-reply{border-radius:16px;background:var(--bt-hover);padding:8px 8px 12px 16px;display:flex;flex-direction:column;gap:6px;max-height:36vh;overflow-y:auto;scrollbar-width:thin;transform-origin:50% 100%;animation:bt-pop-lift ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},bt-veil-in .2s ease-out}+.bt-mem-reply{border-radius:16px;background:var(--bt-hover);padding:8px 8px 12px 16px;display:flex;flex-direction:column;gap:6px;max-height:36vh;max-height:36dvh;overflow-y:auto;scrollbar-width:thin;transform-origin:50% 100%;animation:bt-pop-lift ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},bt-veil-in .2s ease-out}.bt-mem-reply-head{display:flex;align-items:center;gap:8px;min-height:24px}.bt-mem-reply-asked{flex:1;min-width:0;font-size:12px;line-height:16px;color:var(--bt-ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.bt-mem-reply .bt-icon-btn{width:24px;height:24px;flex:none}@@ -828,6 +830,20 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}.bt-avedit{width:min(300px,calc(100vw - 32px))}.bt-shape-row{grid-template-columns:repeat(4,1fr)}}+/* Follow the visible viewport, not the layout one: dvh where the browser knows+ it (the earlier vh value is the fallback), and safe-area padding where+ full-screen layers and bottom regions meet the device's own bars. */+.bt-settings{--bt-set-h:min(780px,calc(100dvh - 2*max(32px,var(--dsh-frame-overlay-top,32px))))}+.bt-mem{height:min(760px,calc(100dvh - 2*max(32px,var(--dsh-frame-overlay-top,32px))))}+.bt-settings-layer,.bt-mem-layer,.bt-palette-layer{padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)}+.bt-panel{padding-bottom:env(safe-area-inset-bottom,0px)}+.bt-settings-scroll{padding-bottom:calc(24px + env(safe-area-inset-bottom,0px))}+.bt-voice-bar{padding-bottom:calc(32px + env(safe-area-inset-bottom,0px))}+.bt-exchange .bt-dialog-foot{padding-bottom:calc(28px + env(safe-area-inset-bottom,0px))}+/* iOS zooms the whole page on focused inputs under 16px. */+@media (max-width:640px) and (pointer:coarse){+ .bt-input,.bt-bs-input,.bt-browser-address input,.bt-folder-input,.bt-secret-input,.bt-q-input,.bt-to input,.bt-palette-head input,.bt-mem-input{font-size:16px}+}`export const CONVERSATION_CSS = `@@ -866,7 +882,7 @@ export const CONVERSATION_CSS = `[class*="_header"]:has(.bt-head){border-bottom-color:transparent!important;box-shadow:none!important}/* The transcript runs under a floating header pill. */header[class*="_header"]:has(.bt-head){position:absolute!important;top:0;left:0;right:0;z-index:8;display:flex!important;padding:10px 0 0!important;background:transparent!important;pointer-events:none;justify-content:center}-header[class*="_header"]:has(.bt-head)::before{content:"";position:absolute;inset:0 0 auto;height:60px;background:linear-gradient(to bottom,var(--bt-main),color-mix(in srgb,var(--bt-main) 0%,transparent));pointer-events:none;z-index:-1}+header[class*="_header"]:has(.bt-head)::before{content:"";position:absolute;inset:0 0 auto;height:calc(60px + env(safe-area-inset-top,0px));background:linear-gradient(to bottom,var(--bt-main),color-mix(in srgb,var(--bt-main) 0%,transparent));pointer-events:none;z-index:-1}header[class*="_header"]:has(.bt-head)>[class*="_headerLeading"]{position:absolute;left:12px;top:10px;pointer-events:auto}header[class*="_header"] .bt-head{flex:1 1 auto;width:100%}[class*="_body"]:has(> [class*="_scrollBody"]){--dsh-chat-content-width:min(960px,100%)}@@ -888,7 +904,7 @@ header[class*="_header"] .bt-head{flex:1 1 auto;width:100%}[data-content-phase=hero] [class*="_composerHero"]>[class$="_root"],[data-content-phase=hero] [class*="_heroWorkspaceRow"]{display:none!important}[data-content-phase=hero] [class*="_composerHero"] [class*="_input"]{min-height:0!important}/* The right sides give back the scrollbar gutter so both edges sit 16px from the column. */-[class*="_scroll"]:has(> [class*="_column"]){padding:60px 11px 16px 16px!important}+[class*="_scroll"]:has(> [class*="_column"]){padding:calc(60px + env(safe-area-inset-top,0px)) calc(11px + env(safe-area-inset-right,0px)) calc(16px + env(safe-area-inset-bottom,0px)) calc(16px + env(safe-area-inset-left,0px))!important}/* The shell's running status only hosts the activity row (.bt-typing). */[data-chat-running]{display:block!important;width:100%;min-height:0!important;margin:0!important;padding:0!important}[data-chat-running]>span:not([role=status]){display:none!important}