From 7e9b6771efa8875dd821af0f087e5f8dc706fb44 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Tue, 20 Oct 2026 18:47:56 +0100 Subject: [PATCH] fix(web): align chat composer and stabilize running controls --- web/PARITY.md | 16 +++++ web/chat.css | 84 +++++++++++++++++----- web/test/composer-fit-browser.mjs | 115 ++++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+), 18 deletions(-) create mode 100644 web/test/composer-fit-browser.mjs diff --git a/web/PARITY.md b/web/PARITY.md index 98fa88a6..d84ee44e 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -65,6 +65,22 @@ restoration. No deployed service, live workflow or device was used. ### Chat audit follow-up (2026-10-20, partial — fresh UI captures pending) +Composer fit follow-up (2026-10-20): CSS-only alignment of attachment, Send and +Stop controls (44px square; 48px with a coarse pointer), a matching single-line +input, and six complete auto-grown text lines before scrolling. Send remains +available while running; its adjacent Stop slot is reserved even while idle so +state changes do not rewrap a draft. Monochrome CSS SVG masks replace the +platform-dependent button glyph rendering, preserving existing accessible names. +Back/title, chat view/protocol code and keyboard geometry are untouched. +`node test/composer-fit-browser.mjs ../.ui-composer-fit-after` verifies the real +chat view and input handlers using deterministic fixtures at 390/420/1100px: +empty, single/multiline, running, six/ten-line drafts, attachments and simulated +keyboard geometry. `--before` serves HEAD's CSS for comparison (run before +committing, or on the parent revision). Captures and `geometry.json` are in +`.ui-composer-fit-before/` and `.ui-composer-fit-after/` in the isolated composer +worktree. This is scratch-browser evidence, not a live-server parity upgrade; +real iOS/Android keyboards and deployed services were not tested. + Codex model follow-up (partial, fixture-tested; fresh UI captures pending): model controls now include Codex, using the app-server `model/list` catalog and current `thread/read`/`thread/list` model metadata. Selecting a model saves a diff --git a/web/chat.css b/web/chat.css index 85ede400..81d84e88 100644 --- a/web/chat.css +++ b/web/chat.css @@ -844,8 +844,18 @@ } /* The composer at the foot of a conversation (C8/C9). The field grows 1–6 rows; - the primary control turns from Send to Stop while a turn is in flight. */ -.chat-composer { flex: 0 0 auto; display: grid; gap: var(--space-xs); padding-top: var(--space-xs); border-top: 1px solid var(--color-divider); } + Stop joins Send while a turn is in flight. */ +.chat-composer { + --composer-control: 44px; + --composer-line: 22px; + --composer-padding: 10px; + flex: 0 0 auto; + min-width: 0; + display: grid; + gap: var(--space-xs); + padding-top: var(--space-xs); + border-top: 1px solid var(--color-divider); +} .chat-queued { font-size: 12px; color: var(--muted); } .chat-attachment-strip { display: flex; flex-wrap: wrap; gap: 8px; } @@ -853,6 +863,7 @@ display: inline-flex; align-items: center; gap: 8px; + max-width: 100%; padding: 4px 6px 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-control); @@ -865,7 +876,7 @@ .chat-attachment-thumb { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; } .chat-attachment-glyph { width: 28px; text-align: center; font-size: 18px; line-height: 1; } .chat-attachment-body { display: grid; gap: 1px; min-width: 0; max-width: 220px; } -.chat-attachment-name { font-size: 12px; } +.chat-attachment-name { font-size: 12px; overflow-wrap: anywhere; } .chat-attachment-meta { font-size: 11px; color: var(--muted); } .chat-attachment-error { color: var(--bad); } .chat-attachment-remove { padding: 1px 6px; font-size: 12px; line-height: 1; } @@ -915,29 +926,69 @@ .chat-command-notice-actions { display: flex; gap: 8px; } .chat-command-notice-actions button { padding: 3px 10px; font-size: 12px; } -.chat-composer-row { display: flex; gap: 8px; align-items: flex-end; } +.chat-composer-row { display: flex; gap: 8px; align-items: flex-end; min-width: 0; } .chat-file-input { display: none; } -.chat-attach { padding: 6px 10px; font-size: 16px; line-height: 1; } +.chat-attach { color: var(--muted); } .chat-composer-input { flex: 1 1 auto; min-width: 0; + min-height: var(--composer-control); resize: none; - padding: 8px 12px; + padding: var(--composer-padding) 12px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-control); font: inherit; - line-height: 20px; - max-height: 132px; - overflow-y: hidden; -} -.chat-composer-input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; } -.chat-composer-primary { display: inline-flex; align-items: flex-end; gap: 6px; } -.chat-send, .chat-stop { - padding: 8px 12px; font-size: 16px; + line-height: var(--composer-line); + /* Match growComposerTextarea's six full lines, padding and border. */ + max-height: calc(6 * var(--composer-line) + 2 * var(--composer-padding) + 2px); + overflow-y: hidden; + overflow-wrap: anywhere; +} +.chat-composer-input::placeholder { color: var(--muted); opacity: 1; } +.chat-composer-input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; } +.chat-composer-primary { + /* Stop is added beside Send, not instead of it. Keep both slots reserved so + a running-state update cannot rewrap a draft or move the caret vertically. */ + display: inline-flex; + flex: 0 0 calc(2 * var(--composer-control) + 8px); + align-items: flex-end; + gap: 8px; +} +.chat-attach, .chat-send, .chat-stop { + display: inline-flex; + flex: 0 0 var(--composer-control); + align-items: center; + justify-content: center; + width: var(--composer-control); + height: var(--composer-control); + min-width: var(--composer-control); + min-height: var(--composer-control); + padding: 0; + /* Use monochrome masks rather than platform-dependent emoji/glyph metrics. + The existing button aria-labels and titles remain the accessible names. */ + font-size: 0; line-height: 1; +} +.chat-attach::before, .chat-send::before, .chat-stop::before { + content: ""; + width: 20px; + height: 20px; + background: currentColor; + mask: var(--composer-icon) center / contain no-repeat; +} +.chat-attach { + --composer-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m8 13 6-6a3 3 0 0 1 4 4l-8 8a5 5 0 0 1-7-7l9-9a1 1 0 0 1 1.4 1.4l-9 9a3 3 0 0 0 4.2 4.2l8-8a1 1 0 0 0-1.4-1.4l-6 6a1 1 0 0 0 1.4 1.4l5-5 1.4 1.4-5 5a3 3 0 0 1-4.2-4.2Z'/%3E%3C/svg%3E"); +} +.chat-send { + --composer-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m3 3 19 9-19 9 3-8 9-1-9-1Z'/%3E%3C/svg%3E"); +} +.chat-stop { + --composer-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='5' y='5' width='14' height='14' rx='2'/%3E%3C/svg%3E"); +} +.chat-send, .chat-stop { border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-2); @@ -1139,10 +1190,6 @@ .chat-bar-title { font-size: 18px; } .chat-model-button { max-width: 118px; min-height: 36px; } .chat-activity { font-size: 12px; } - .chat-send, - .chat-stop { min-width: 44px; min-height: 44px; font-size: 18px; } - .chat-attach { min-width: 44px; min-height: 44px; } - .chat-composer-input { padding: 10px 12px; font-size: 16px; } .chat-turn { font-size: 15px; } } @@ -1193,6 +1240,7 @@ /* Input capability, not just screen width, selects touch-sized controls. */ @media (any-pointer: coarse) { + .chat-composer { --composer-control: 48px; --composer-padding: 12px; } .chat-reasoning-toggle, .chat-tool-chip, .chat-group-toggle, .chat-send, .chat-stop, .chat-attach, .chat-model-button, .chat-model-option, .chat-new { min-height: 48px; } diff --git a/web/test/composer-fit-browser.mjs b/web/test/composer-fit-browser.mjs new file mode 100644 index 00000000..0352672f --- /dev/null +++ b/web/test/composer-fit-browser.mjs @@ -0,0 +1,115 @@ +// Scratch-only ui-smoke extension: real chat view/input handlers, no backend, +// workflows, services or devices. --before serves HEAD's CSS for comparison. +import assert from 'node:assert/strict'; +import { createServer } from 'node:http'; +import { readFile, mkdir, writeFile } from 'node:fs/promises'; +import { execFileSync } from 'node:child_process'; +import { resolve, extname } from 'node:path'; +import { launchChrome } from './browser.mjs'; + +const root = resolve(import.meta.dirname, '..'); +const out = resolve(process.argv[2] || '.ui-composer-fit'); +const before = process.argv.includes('--before'); +await mkdir(out, { recursive: true }); +const html = ` +${['design/tokens/tokens','base','shell','lists','run-detail','chat','dialogs'].map(n => ``).join('')} +
+`; +const server = createServer(async (req, res) => { + try { + if (req.url === '/') { res.setHeader('content-type','text/html'); res.end(html); return; } + const path = resolve(root, `.${new URL(req.url,'http://scratch').pathname}`); + if (!path.startsWith(root + '/')) throw new Error('outside root'); + res.setHeader('content-type',extname(path)==='.css'?'text/css':'text/javascript'); + res.end(before && path===resolve(root,'chat.css') ? execFileSync('git',['show','HEAD:web/chat.css'],{cwd:root}) : await readFile(path)); + } catch { res.writeHead(404); res.end(); } +}); +await new Promise(r=>server.listen(0,'127.0.0.1',r)); +let browser; +const measurements=[]; +try { + browser=await launchChrome(); + const page=await browser.openPage(`http://127.0.0.1:${server.address().port}/`); + await page.waitForSelector('#chatInput'); + const measure=()=>page.evaluate(`(() => { + const rect=s=>{const e=document.querySelector(s);if(!e)return null;const r=e.getBoundingClientRect();return {x:r.x,y:r.y,width:r.width,height:r.height,bottom:r.bottom,right:r.right};}; + const input=document.querySelector('#chatInput'),s=getComputedStyle(input); + return {input:rect('#chatInput'),attach:rect('#chatAttach'),send:rect('#chatSend'),stop:rect('#chatStop'), + header:rect('.chat-bar'),composer:rect('#chatComposer'),scroll:input.scrollHeight,client:input.clientHeight, + line:parseFloat(s.lineHeight),padding:parseFloat(s.paddingTop)+parseFloat(s.paddingBottom), + overflow:s.overflowY,documentWidth:document.documentElement.scrollWidth,viewport:innerWidth}; + })()`); + const capture=async(name)=>{ + await page.evaluate('new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r)))'); + const m=await measure(); measurements.push({name,...m}); + await page.screenshot(resolve(out,name+'.png')); + if (!before) { + assert.ok(m.documentWidth<=m.viewport,`${name}: document overflow`); + for(const b of [m.attach,m.send,m.stop].filter(Boolean)) { + assert.ok(b.width>=44 && b.height>=44,`${name}: touch target`); + assert.equal(b.bottom,m.input.bottom,`${name}: bottom alignment`); + } + assert.equal(m.send.width,m.attach.width); + assert.ok(m.input.right+8<=m.send.x,`${name}: input/action overlap`); + assert.ok(m.composer.bottom<= (name.includes('keyboard') && m.viewport<600?500:900),`${name}: visible composer`); + } + return m; + }; + for(const width of [390,420,1100]) { + await page.resize(width,900); + await page.goto(`http://127.0.0.1:${server.address().port}/`); + await page.waitForSelector('#chatInput'); + await capture(`empty-${width}`); + await page.fill('#chatInput','Review this draft'); + await capture(`single-${width}`); + await page.fill('#chatInput','First draft line\nSecond draft line\nThird draft line'); + const idle=await capture(`multiline-${width}`); + await page.evaluate('setRunning(true)'); + const running=await capture(`running-${width}`); + if(!before) { + assert.deepEqual(running.input,idle.input,'running must not rewrap or move draft'); + assert.equal(running.stop.width,running.send.width); + assert.deepEqual(running.header,idle.header,'header unchanged'); + assert.ok(running.scroll<=running.client,'three full lines fit'); + } + await page.evaluate('setRunning(false)'); + const settled=await measure(); + if(!before) { + assert.deepEqual(settled.input,idle.input,'settling must not move draft'); + assert.equal(settled.stop,null); + assert.equal(await page.evaluate('document.activeElement.id'),'chatInput'); + } + await page.evaluate('setRunning(true)'); + await page.fill('#chatInput','Line one\nLine two\nLine three\nLine four\nLine five\nLine six'); + const six=await capture(`six-lines-${width}`); + if(!before) assert.equal(six.input.height,6*six.line+six.padding+2,'six complete lines fit'); + await page.fill('#chatInput',Array(10).fill('Long draft line').join('\n')); + const long=await capture(`long-draft-${width}`); + if(!before) { assert.equal(long.overflow,'auto');assert.equal(long.input.height,six.input.height); } + await page.fill('#chatInput','First draft line\nSecond draft line'); + { + // Deterministic existing keyboard CSS geometry, not a real OS keyboard. + await page.evaluate(`document.documentElement.classList.add('keyboard-open');document.documentElement.style.setProperty('--keyboard-visible-height','500px');document.documentElement.style.setProperty('--keyboard-viewport-top','0px')`); + await capture(`keyboard-${width}`); + await page.evaluate(`document.documentElement.classList.remove('keyboard-open')`); + } + await page.evaluate('setAttachment()'); + await capture(`attachment-${width}`); + } + await writeFile(resolve(out,'geometry.json'),JSON.stringify(measurements,null,2)); + console.log(`${measurements.length} scratch captures and geometry: ${out}`); +} finally { + if(browser) await browser.close(); + await new Promise(r=>server.close(r)); +}