From 95ece0bcd210c673c2c61ac993da990dae36ce8e Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sun, 18 Oct 2026 20:49:29 +0200 Subject: [PATCH] Chat: the message box stops at 30% of the window height and scrolls inside, so Send and the toolbar stay in view in a small window --- apps/host/src/lib/responsive.ts | 5 +++++ apps/host/src/screens/Chat.tsx | 18 ++++++++++++------ apps/host/src/styles/annotation-fixes.css | 1 + apps/host/tests/split-qa2-fields.test.mjs | 8 ++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/apps/host/src/lib/responsive.ts b/apps/host/src/lib/responsive.ts index 714551e5..596b072f 100644 --- a/apps/host/src/lib/responsive.ts +++ b/apps/host/src/lib/responsive.ts @@ -16,3 +16,8 @@ export function scrollBehavior(): ScrollBehavior { const override = document.documentElement.dataset.motion; return override === 'reduced' || (override !== 'full' && window.matchMedia('(prefers-reduced-motion: reduce)').matches) ? 'instant' : 'smooth'; } + +/** The tallest the message box may grow: 30% of the window, between 44 and 180 pixels (the rest of the window keeps the toolbar and Send in view). */ +export function composerCap(windowHeight: number): number { + return Math.max(44, Math.min(180, Math.floor(windowHeight * 0.3))); +} diff --git a/apps/host/src/screens/Chat.tsx b/apps/host/src/screens/Chat.tsx index e152ec73..b869be7c 100644 --- a/apps/host/src/screens/Chat.tsx +++ b/apps/host/src/screens/Chat.tsx @@ -33,7 +33,7 @@ import { artifactFromUrl, type PreviewArtifact } from '../lib/artifacts'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Markdown } from '../components/Markdown'; import { Btn, Icon, IconBtn, ErrorNotice, type IconName } from '../components/ui'; -import { scrollBehavior } from '../lib/responsive'; +import { composerCap, scrollBehavior } from '../lib/responsive'; import { relTime, cx, duration, tokens, tps } from '../lib/format'; import { createSubagentExample, pushToast, setPreviewTabClosed, branchFrom, continueLast, markRead, resolveTool, retryLast, selectSession, rewindTo, sendMessage, stopStreaming, useStore, } from '../lib/store'; import { getSlashCommands } from '../lib/commands'; @@ -265,12 +265,18 @@ export function ChatScreen() { // would fight the follow-the-stream effect above. // eslint-disable-next-line react-hooks/exhaustive-deps }, [session?.id]); + // The box grows with the draft but never past 30% of the window, and scrolls inside after that, so Send and the toolbar stay on screen (QA F08). useEffect(() => { - const el = textarea.current; - if (!el) - return; - el.style.height = 'auto'; - el.style.height = `${Math.min(200, el.scrollHeight)}px`; + const fit = () => { + const el = textarea.current; + if (!el) + return; + el.style.height = 'auto'; + el.style.height = `${Math.min(composerCap(window.innerHeight), el.scrollHeight)}px`; + }; + fit(); + window.addEventListener('resize', fit); + return () => window.removeEventListener('resize', fit); }, [draft]); /** Hands a rewound prompt back to the composer so it can be changed. */ function editPrompt(text: string) { diff --git a/apps/host/src/styles/annotation-fixes.css b/apps/host/src/styles/annotation-fixes.css index 5f35e31d..020e6280 100644 --- a/apps/host/src/styles/annotation-fixes.css +++ b/apps/host/src/styles/annotation-fixes.css @@ -57,6 +57,7 @@ input:focus, textarea:focus, [contenteditable]:focus { outline: none; box-shadow .sampling-field p { margin: 1px 0 0; } #response-panel-sampling > .stack { gap: 12px; } .sampling-number-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } +.composer .st-composer textarea { max-height: clamp(44px, 30dvh, 180px); overflow-y: auto; } .field-problem { color: var(--st-danger-text); font-size: var(--st-fs-sm); } .input-field input[aria-invalid="true"] { border-color: var(--st-danger); } .response-projection { display: flex; align-items: center; gap: 20px; } diff --git a/apps/host/tests/split-qa2-fields.test.mjs b/apps/host/tests/split-qa2-fields.test.mjs index 30548f66..7822e870 100644 --- a/apps/host/tests/split-qa2-fields.test.mjs +++ b/apps/host/tests/split-qa2-fields.test.mjs @@ -49,3 +49,11 @@ test('F07: a page opened from another computer says why Add skill cannot work in assert.match(skills, /pageIsOnThisComputer\(window\.location\.hostname\)/); void pick; }); + +test('F08: the message box stops at 30% of the window height (44 to 180 px) and scrolls inside', async () => { + const { composerCap } = await loadTs('../src/lib/responsive.ts'); + assert.equal(composerCap(400), 120); assert.equal(composerCap(500), 150); assert.equal(composerCap(720), 180); assert.equal(composerCap(2000), 180); assert.equal(composerCap(100), 44); + const css = await readFile(new URL('../src/styles/annotation-fixes.css', import.meta.url), 'utf8'); + assert.match(css, /\.composer \.st-composer textarea \{ max-height: clamp\(44px, 30dvh, 180px\); overflow-y: auto; \}/); + assert.match(await readFile(new URL('../src/screens/Chat.tsx', import.meta.url), 'utf8'), /composerCap\(window\.innerHeight\)/); +});