Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): target assistant-ui chat composer

Steven Enamakel40de40145553
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index 61c9283044..23410b6095 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -341,7 +341,9 @@ const Composer: FC<{
return (
<ComposerPrimitive.Unstable_TriggerPopoverRoot>
- <ComposerPrimitive.Root className="aui-composer-root relative flex w-full flex-col">
+ <ComposerPrimitive.Root
+ className="aui-composer-root relative flex w-full flex-col"
+ data-walkthrough="chat-agent-panel">
{ComposerHeader ? <ComposerHeader /> : null}
<ComposerPrimitive.AttachmentDropzone asChild>
<div
diff --git a/app/test/e2e/helpers/chat-harness.ts b/app/test/e2e/helpers/chat-harness.ts
index 19e325c119..d983c54e0f 100644
--- a/app/test/e2e/helpers/chat-harness.ts
+++ b/app/test/e2e/helpers/chat-harness.ts
@@ -57,7 +57,12 @@ export async function clickByTitle(title: string, timeoutMs = 6_000): Promise<bo
return false;
}
-const COMPOSER_SELECTOR = 'textarea[placeholder="Send a message..."]';
+// Chat now uses assistant-ui's Lexical contenteditable surface. Keep the
+// former textarea selector as a fallback for the voice/legacy embed, but make
+// all harness flows target the stable semantic textbox rather than a specific
+// editor implementation.
+const COMPOSER_SELECTOR =
+ 'textarea[placeholder="Send a message..."], [contenteditable="true"][role="textbox"][aria-label="Message input"]';
/** True once the Conversations page has mounted its composer/header.
*
@@ -80,7 +85,7 @@ export async function chatMounted(): Promise<boolean> {
export async function typeIntoComposer(text: string): Promise<void> {
let actual = '';
for (let attempt = 1; attempt <= 3; attempt += 1) {
- // Creating a thread can replace the controlled textarea after the selected
+ // Creating a thread can replace the controlled composer after the selected
// thread id changes. Resolve it afresh on every attempt so a late React
// commit cannot leave WebDriver typing into a detached element.
const composer = await browser.$(COMPOSER_SELECTOR);
@@ -98,20 +103,25 @@ export async function typeIntoComposer(text: string): Promise<void> {
}, COMPOSER_SELECTOR);
if (!focused) continue;
- // WebKitWebDriver drops trailing key events even when they are paced.
- // Use the native textarea setter and the bubbling input event React
- // listens to, so the controlled composer state receives the full value.
+ // WebKitWebDriver drops trailing key events even when they are paced. Use
+ // the native textarea setter for the legacy field or textContent for the
+ // assistant-ui Lexical field, then emit the bubbling input event each
+ // surface observes.
const typed = await browser.execute(
(sel: string, nextValue: string) => {
- const el = document.querySelector(sel) as HTMLTextAreaElement | null;
+ const el = document.querySelector(sel) as HTMLElement | null;
if (!el) return false;
- const setter = Object.getOwnPropertyDescriptor(
- window.HTMLTextAreaElement.prototype,
- 'value'
- )?.set;
- if (setter) setter.call(el, nextValue);
- else el.value = nextValue;
- el.dispatchEvent(new Event('input', { bubbles: true }));
+ if (el instanceof HTMLTextAreaElement) {
+ const setter = Object.getOwnPropertyDescriptor(
+ window.HTMLTextAreaElement.prototype,
+ 'value'
+ )?.set;
+ if (setter) setter.call(el, nextValue);
+ else el.value = nextValue;
+ } else {
+ el.textContent = nextValue;
+ }
+ el.dispatchEvent(new InputEvent('input', { bubbles: true, data: nextValue }));
el.dispatchEvent(new Event('change', { bubbles: true }));
return true;
},
@@ -120,7 +130,11 @@ export async function typeIntoComposer(text: string): Promise<void> {
);
if (!typed) continue;
await browser.pause(200);
- actual = String(await composer.getValue());
+ actual = (await browser.execute((sel: string) => {
+ const el = document.querySelector(sel) as HTMLTextAreaElement | HTMLElement | null;
+ if (!el) return '';
+ return el instanceof HTMLTextAreaElement ? el.value : (el.textContent ?? '');
+ }, COMPOSER_SELECTOR)) as string;
if (actual === text) return;
}