From 7904ccdfe0201ad0d543e330ad2fd8a74bb121a4 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 25 Nov 2026 23:06:46 +1100 Subject: [PATCH] fix(ui/chat): wrap TokenInput children in flex row and fix placeholder --- ui/src/chat/ChatComposer.vue | 86 +++++++++++++++++----------------- ui/src/style.css | 2 +- ui/test/chat-more-menu.test.ts | 45 +++++++++++++++--- 3 files changed, 81 insertions(+), 52 deletions(-) diff --git a/ui/src/chat/ChatComposer.vue b/ui/src/chat/ChatComposer.vue index f2f4e5105..bad346c83 100644 --- a/ui/src/chat/ChatComposer.vue +++ b/ui/src/chat/ChatComposer.vue @@ -250,32 +250,52 @@ function menuHeading(trigger: string | null): string { - -
- -
- - +
+ > +
+ +
+ + + +
+ + + + + +
+
- -
- - - - - -
diff --git a/ui/src/style.css b/ui/src/style.css index e075e3288..ec24c52c5 100644 --- a/ui/src/style.css +++ b/ui/src/style.css @@ -354,7 +354,7 @@ } [data-slot="token-input-editor"][data-empty]::before { - content: attr(data-placeholder); + content: attr(aria-placeholder); color: var(--muted-foreground); pointer-events: none; } diff --git a/ui/test/chat-more-menu.test.ts b/ui/test/chat-more-menu.test.ts index fd8c5d126..0c6d8c311 100644 --- a/ui/test/chat-more-menu.test.ts +++ b/ui/test/chat-more-menu.test.ts @@ -186,18 +186,49 @@ test("chat More menu opens on screen and its items run", { timeout: 90000 }, asy await cdp.send("Emulation.setDeviceMetricsOverride", { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false }); await cdp.send("Page.navigate", { url: `http://127.0.0.1:${vitePort}/` }); - // Wait for the app shell and the collapsed dock, then expand it. - await cdp.evaluate(`(async () => { + // Wait for the app shell and the collapsed dock, verify the minimised + // composer stays on one horizontal row with its placeholder, then expand it. + const collapsed = await cdp.evaluate(`(async () => { const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); for (let i = 0; i < 60; i++) { - if (document.querySelector('button[aria-label="Show conversation"]')) { - document.querySelector('button[aria-label="Show conversation"]').click(); - for (let j = 0; j < 40 && !document.querySelector('button[aria-label="More"]'); j++) await sleep(250); - return !!document.querySelector('button[aria-label="More"]'); + const show = document.querySelector('button[aria-label="Show conversation"]'); + if (show) { + const handle = document.querySelector('[data-move-handle]'); + const editor = document.querySelector('[data-slot="token-input-editor"]'); + if (!handle || !editor) return { ready: false }; + const hr = handle.getBoundingClientRect(); + const er = editor.getBoundingClientRect(); + const sr = show.getBoundingClientRect(); + const placeholder = getComputedStyle(editor, "::before").content; + return { + ready: true, + handleMidY: hr.y + hr.height / 2, + editorMidY: er.y + er.height / 2, + showMidY: sr.y + sr.height / 2, + horizontalOrder: hr.right <= er.left + 1 && er.right <= sr.left + 1, + placeholder, + }; } await sleep(250); } - return false; + return { ready: false }; + })()`); + assert.equal(collapsed.ready, true, "the collapsed chat dock rendered"); + assert.equal(collapsed.horizontalOrder, true, `minimised composer controls stay on one horizontal row, got ${JSON.stringify(collapsed)}`); + assert.ok( + Math.abs(collapsed.handleMidY - collapsed.editorMidY) < 8 && Math.abs(collapsed.showMidY - collapsed.editorMidY) < 8, + `minimised composer controls align vertically on one row, got ${JSON.stringify(collapsed)}`, + ); + assert.ok( + typeof collapsed.placeholder === "string" && collapsed.placeholder.includes("Message Archie"), + `empty composer shows its placeholder, got ${JSON.stringify(collapsed.placeholder)}`, + ); + + await cdp.evaluate(`(async () => { + const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); + document.querySelector('button[aria-label="Show conversation"]').click(); + for (let j = 0; j < 40 && !document.querySelector('button[aria-label="More"]'); j++) await sleep(250); + return !!document.querySelector('button[aria-label="More"]'); })()`).then((expanded: unknown) => assert.equal(expanded, true, "the chat dock expanded and rendered the More button")); // Pick the open conversation first, so the menu's actions have a