From 8cc64acd5df444061c1966827bd6c3b28ea4db06 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sat, 14 Nov 2026 07:33:39 -0500 Subject: [PATCH] feat(web): expand the mobile composer on focus --- robot-docs/web.md | 6 +++ web/src/lib/chat/Composer.svelte | 75 +++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/robot-docs/web.md b/robot-docs/web.md index 9ab8e74ba..5da27100e 100644 --- a/robot-docs/web.md +++ b/robot-docs/web.md @@ -63,6 +63,12 @@ editor. Other files appear as removable cards with a name and size. [`Composer.svelte`](../web/src/lib/chat/Composer.svelte) and [`Chat.svelte`](../web/src/lib/chat/Chat.svelte) own this presentation. +On phones, an empty unfocused composer shows one row with the attachment button, +message field, and Send or Stop controls. Focusing the field expands it to show +model and reasoning controls. Drafts, attachments, pending reads, notices, and +edits keep it expanded. Moving focus into its toolbar or picker does not +collapse it. Desktop composers keep their existing layout. + [`attachments.ts`](../web/src/lib/chat/attachments.ts) reads files and checks the browser limits in `attachmentProblem`: ten images, ten other files, and 20 MiB of decoded bytes for both kinds together. These limits keep a send inside diff --git a/web/src/lib/chat/Composer.svelte b/web/src/lib/chat/Composer.svelte index c2a83c8d9..f050a4169 100644 --- a/web/src/lib/chat/Composer.svelte +++ b/web/src/lib/chat/Composer.svelte @@ -82,6 +82,8 @@ } = $props(); let stopping = $state(false); let toolsWidth = $state(0); + let composing = $state(false); + let pointerInside = false; async function stop() { const stopTurn = onstop; @@ -742,13 +744,41 @@ renderToDom(text, false); } }); + const expanded = $derived( + !compact || + composing || + !!text || + attachmentCount > 0 || + attached > 0 || + reading > 0 || + editing || + dragging || + !!feedback, + ); + + function leaveComposer(event: FocusEvent) { + if (pointerInside) return; + const form = event.currentTarget as HTMLFormElement; + // A picker or toolbar button is part of the same composing interaction. + queueMicrotask(() => { + if (mounted && !form.contains(document.activeElement)) composing = false; + }); + } + (pointerInside = false)} + onpointercancel={() => (pointerInside = false)} +/> +
(pointerInside = true)} class="composer" class:locked={!!locked} class:compact class:stacked={!!tools} + class:resting={compact && !expanded} + onfocusout={leaveComposer} class:dragging onsubmit={(event) => (event.preventDefault(), send())} use:fileDrops @@ -884,7 +914,10 @@ spellcheck="true" tabindex="0" oninput={onInput} - onfocus={() => completing && oncommands?.()} + onfocus={() => { + composing = true; + if (completing) oncommands?.(); + }} onkeydown={keydown} onpaste={paste} > @@ -1444,6 +1477,46 @@ opacity: 1; transition-duration: 120ms; } + .composer.compact.resting { + display: grid; + grid-template-columns: 44px minmax(0, 1fr) auto auto; + align-items: center; + gap: 4px; + padding: 6px; + border-radius: 30px; + } + .resting .editor { + grid-area: 1 / 2; + min-width: 0; + min-height: 24px; + max-height: 24px; + padding: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + .resting .actions { + display: contents; + } + .resting .tools { + display: none; + } + .resting .tool, + .resting .stop, + .resting .send { + min-width: 44px; + height: 44px; + border-radius: 50%; + } + .resting .tool { + grid-area: 1 / 1; + } + .resting .stop { + grid-area: 1 / 3; + } + .resting .send { + grid-area: 1 / 4; + } .hint { display: block; margin: 2px 0 7px; -- knotmirror 0.0.1