fix(ui/chat): wrap TokenInput children in flex row and fix placeholder
This commit is contained in:
3 files changed
+81
-52
No files matched your search
@@ -250,32 +250,52 @@ function menuHeading(trigger: string | null): string {
|
||||
</li>
|
||||
</ul>
|
||||
<ChatSuggestions v-if="!flat && messages.length" />
|
||||
<TokenInput
|
||||
:controller="prompt"
|
||||
submit-shortcut="enter"
|
||||
:class="
|
||||
cn(
|
||||
'relative flex gap-2 rounded-xl border transition-colors duration-200',
|
||||
flat ? 'items-center border-transparent px-2 py-1.5' : 'items-end border-border-strong bg-muted px-3 py-2.5',
|
||||
)
|
||||
"
|
||||
@value-change="onValueChange"
|
||||
@submit="onSubmit"
|
||||
>
|
||||
<div v-if="$slots.start" :class="cn('flex flex-none items-center', !flat && 'mb-1.5')">
|
||||
<slot name="start" />
|
||||
</div>
|
||||
|
||||
<TokenInputEditor
|
||||
aria-label="Message Archie"
|
||||
:placeholder="placeholderHint || 'Message Archie (@ workflow, # task, / command)'"
|
||||
<TokenInput :controller="prompt" submit-shortcut="enter" @value-change="onValueChange" @submit="onSubmit">
|
||||
<div
|
||||
:class="
|
||||
cn(
|
||||
'max-h-40 min-w-0 flex-1 overflow-y-auto bg-transparent text-label pointer-coarse:text-base outline-none',
|
||||
flat ? 'min-h-10 py-2.5 text-base leading-5' : 'min-h-11 py-1 leading-6',
|
||||
'relative flex gap-2 rounded-xl border transition-colors duration-200',
|
||||
flat ? 'items-center border-transparent px-2 py-1.5' : 'items-end border-border-strong bg-muted px-3 py-2.5',
|
||||
)
|
||||
"
|
||||
/>
|
||||
>
|
||||
<div v-if="$slots.start" :class="cn('flex flex-none items-center', !flat && 'mb-1.5')">
|
||||
<slot name="start" />
|
||||
</div>
|
||||
|
||||
<TokenInputEditor
|
||||
aria-label="Message Archie"
|
||||
:placeholder="placeholderHint || 'Message Archie (@ workflow, # task, / command)'"
|
||||
:class="
|
||||
cn(
|
||||
'max-h-40 min-w-0 flex-1 overflow-y-auto bg-transparent text-label pointer-coarse:text-base outline-none',
|
||||
flat ? 'min-h-10 py-2.5 text-base leading-5' : 'min-h-11 py-1 leading-6',
|
||||
)
|
||||
"
|
||||
/>
|
||||
|
||||
<div :class="cn('flex flex-none items-center gap-2', !flat && 'mb-1.5')">
|
||||
<slot name="actions" />
|
||||
<Button v-if="isSending" variant="outline" size="sm" @click="stopTurn">Stop</Button>
|
||||
<Button
|
||||
v-if="canRecord && !composerText.trim()"
|
||||
size="sm"
|
||||
:variant="recording ? 'destructive' : 'outline'"
|
||||
:disabled="isSending && !recording"
|
||||
:aria-label="recording ? 'Stop recording and send' : 'Record a voice message'"
|
||||
@click="toggleRecording"
|
||||
><Mic data-icon="inline-start" />{{ recording ? "Send" : "" }}</Button
|
||||
>
|
||||
<p v-if="recordError" class="px-1 text-caption text-danger" role="alert">{{ recordError }}</p>
|
||||
<Button
|
||||
size="sm"
|
||||
:variant="composerText.trim() ? 'default' : 'secondary'"
|
||||
:disabled="!composerText.trim()"
|
||||
@click="sendMessage()"
|
||||
>{{ isSending ? "Queue" : "Send" }}</Button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TriggerMenu :triggers="triggers">
|
||||
<TriggerMenuContent
|
||||
@@ -315,28 +335,6 @@ function menuHeading(trigger: string | null): string {
|
||||
</TokenInputTokenRemove>
|
||||
</TokenInputToken>
|
||||
</template>
|
||||
|
||||
<div :class="cn('flex flex-none items-center gap-2', !flat && 'mb-1.5')">
|
||||
<slot name="actions" />
|
||||
<Button v-if="isSending" variant="outline" size="sm" @click="stopTurn">Stop</Button>
|
||||
<Button
|
||||
v-if="canRecord && !composerText.trim()"
|
||||
size="sm"
|
||||
:variant="recording ? 'destructive' : 'outline'"
|
||||
:disabled="isSending && !recording"
|
||||
:aria-label="recording ? 'Stop recording and send' : 'Record a voice message'"
|
||||
@click="toggleRecording"
|
||||
><Mic data-icon="inline-start" />{{ recording ? "Send" : "" }}</Button
|
||||
>
|
||||
<p v-if="recordError" class="px-1 text-caption text-danger" role="alert">{{ recordError }}</p>
|
||||
<Button
|
||||
size="sm"
|
||||
:variant="composerText.trim() ? 'default' : 'secondary'"
|
||||
:disabled="!composerText.trim()"
|
||||
@click="sendMessage()"
|
||||
>{{ isSending ? "Queue" : "Send" }}</Button
|
||||
>
|
||||
</div>
|
||||
</TokenInput>
|
||||
</div>
|
||||
</template>
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user