Skip to content

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

test(e2e): close a mount race in the attachment spec's attach helper\n\nThe confirmation run on restored source came back 14/15, failing `the\npicker attaches a file and the chip names it` — a case that had passed in\ntwo earlier runs, and whose immediate neighbour performs the same attach\nand passed in the same run.\n\nThe race is in the test, not the app. `ComposerAddAttachment` is a\nuseCallback whose identity changes with attachmentInteractionBlocked,\nattachments.length and maxAttachments (AssistantUiChat.tsx:160-185), so\nearly on a fresh page the hidden input can be replaced between\nsetInputFiles and React binding its onChange, and the change event lands\non a detached node. The failure screenshot shows a fully rendered, idle\ncomposer with [+] enabled and no chip. Seen once in ~15 runs, always on\nthe first case of the file.\n\n`attach()` now polls, re-issuing setInputFiles until the chip appears,\nbounded at 15s.\n\nA retry needs a higher bar than "the test passes now", because that is\nalso what a broken test does: the case must still fail when the behaviour\nis broken. Verified rather than assumed — re-ran fault A3 (onAttachFiles\nhanded an empty FileList) against the hardened helper:\n\n ✘ the picker attaches a file and the chip names it (16.0s)\n ✘ an attached file can be removed again (15.5s)\n ✘ an attachment keeps the Send affordance (11.2s)\n ✓ the [+] button is disabled while a turn streams (1.1s)\n ✓ the [+] button becomes usable again once stopped (1.2s)\n\nThe three ingest cases fail at the poll timeout — exhausting, not\npassing — while the two gate cases, which never ingest, correctly stay\ngreen. Restored and rebuilt clean: 15/15.\n\nWorth noting for whoever writes the next spec in this lane: this was\ncaught only by the "restore and re-confirm green" step at the end of the\nfault-injection loop. That run is the one most likely to execute under\ndifferent timing than the original green, so it is not ceremony.\n

M3gA-Mind4f6ac25c8eb1
diff --git a/app/test/playwright/specs/chat-composer-attachment-gate.spec.ts b/app/test/playwright/specs/chat-composer-attachment-gate.spec.ts
index 8488e000e5..80adb6c3cd 100644
--- a/app/test/playwright/specs/chat-composer-attachment-gate.spec.ts
+++ b/app/test/playwright/specs/chat-composer-attachment-gate.spec.ts
@@ -72,10 +72,47 @@ const stopButton = (page: Page): Locator => page.getByTestId('stop-generation-bu
const attachButton = (page: Page): Locator => page.getByRole('button', { name: 'Attach file' });
const fileInput = (page: Page): Locator => page.locator('input[type="file"]');
+/**
+ * Attach a file through the app's own hidden `input[type=file]`, retrying until
+ * the chip appears.
+ *
+ * The retry closes a race in the TEST, not a product bug.
+ * `ComposerAddAttachment` is a `useCallback` whose identity changes with
+ * `attachmentInteractionBlocked`, `attachments.length` and `maxAttachments`
+ * (`AssistantUiChat.tsx:160-185`), so early on a fresh page the input can be
+ * replaced between `setInputFiles` and React binding its `onChange`, and the
+ * change event lands on a detached node. Seen once in fifteen runs, always on
+ * the first case of the file; the screenshot showed a fully rendered, idle
+ * composer with `[+]` enabled and no chip.
+ *
+ * A retry is only acceptable if the case still dies under fault injection —
+ * otherwise it is a way of passing regardless. If ingest is genuinely broken
+ * the chip never appears and this poll exhausts. Re-verified against fault A3
+ * (`onAttachFiles` handed an empty `FileList`): the cases still fail.
+ */
async function attach(page: Page, name: string, body = 'attached by the picker'): Promise<void> {
- await fileInput(page)
- .first()
- .setInputFiles({ name, mimeType: 'text/plain', buffer: Buffer.from(body) });
+ await expect
+ .poll(
+ async () => {
+ if (
+ await page
+ .getByText(name)
+ .isVisible()
+ .catch(() => false)
+ ) {
+ return true;
+ }
+ await fileInput(page)
+ .first()
+ .setInputFiles({ name, mimeType: 'text/plain', buffer: Buffer.from(body) });
+ return page
+ .getByText(name)
+ .isVisible({ timeout: 2_000 })
+ .catch(() => false);
+ },
+ { timeout: 15_000, message: `attachment chip for ${name} never appeared` }
+ )
+ .toBe(true);
}
async function beginStreamingTurn(page: Page, prompt: string): Promise<void> {
@@ -101,7 +138,9 @@ test.describe('Chat composer attachment gate', () => {
await attach(page, 'picker-notes.txt');
- await expect(page.getByText('picker-notes.txt')).toBeVisible({ timeout: 10_000 });
+ // `attach` already waits for the chip; assert it here too so this case
+ // fails on its own terms rather than inside a helper.
+ await expect(page.getByText('picker-notes.txt')).toBeVisible();
});
test('an attached file can be removed again', async ({ page }) => {