Skip to content

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

test(chat): enhance error recovery tests with thread key checks

Steven Enamakel9ad1686367c6
diff --git a/app/test/playwright/specs/chat-tool-error-recovery.spec.ts b/app/test/playwright/specs/chat-tool-error-recovery.spec.ts
index dae45cd9b2..0d8a785ee8 100644
--- a/app/test/playwright/specs/chat-tool-error-recovery.spec.ts
+++ b/app/test/playwright/specs/chat-tool-error-recovery.spec.ts
@@ -5,6 +5,7 @@ import {
dismissWalkthroughIfPresent,
waitForAppReady,
} from '../helpers/core-rpc';
+import { inFlightThreadKey } from '../helpers/chat-transcript';
const MOCK_ADMIN_BASE = `http://127.0.0.1:${process.env.E2E_MOCK_PORT || '18473'}`;
const USER_ID = 'pw-chat-error-recovery';
@@ -117,7 +118,10 @@ test.describe('Chat Tool Error Recovery', () => {
JSON.stringify([
{
keyword: 'Please try again with a fresh answer.',
- streamScript: [{ text: `Recovery successful: ${RECOVERY_CANARY}` }, { finish: 'stop' }],
+ streamScript: [
+ { text: `Recovery successful: ${RECOVERY_CANARY}`, delayMs: 500 },
+ { finish: 'stop' },
+ ],
},
{
keyword: 'Tell me something important.',
@@ -129,6 +133,7 @@ test.describe('Chat Tool Error Recovery', () => {
await openChat(page);
const threadId = await createNewThread(page);
await sendMessage(page, 'Tell me something important.');
+ await expect.poll(() => inFlightThreadKey(threadId)).toBeTruthy();
// A new thread starts with a null lifecycle too. Waiting only for null can
// therefore race ahead of the first turn and let the retry overlap it.
@@ -154,11 +159,14 @@ test.describe('Chat Tool Error Recovery', () => {
return lifecycle;
})
.toBeNull();
+ await expect.poll(() => inFlightThreadKey(threadId)).toBeUndefined();
const composer = page.getByTestId('chat-message-input');
await expect(composer).toBeEnabled();
await sendMessage(page, 'Please try again with a fresh answer.');
+ await expect.poll(() => inFlightThreadKey(threadId)).toBeTruthy();
await expect(page.getByText(RECOVERY_CANARY)).toBeVisible({ timeout: 30_000 });
+ await expect.poll(() => inFlightThreadKey(threadId)).toBeUndefined();
});
});