Skip to content

The agent that grows with you

test(desktop): the core reload step checks the reply is one bubble before the turn completes

Teknium0ab6e17dee38
diff --git a/apps/desktop/e2e/core/provider.ts b/apps/desktop/e2e/core/provider.ts
index 5258a0d3f35..171b9f00284 100644
--- a/apps/desktop/e2e/core/provider.ts
+++ b/apps/desktop/e2e/core/provider.ts
@@ -42,6 +42,8 @@ export interface Step {
toolCalls?: ToolCallSpec[]
/** Hold the stream after the first text (or reasoning) chunk until the gate opens. */
holdAfterFirstChunk?: Gate
+ /** Hold the stream after its last text chunk, before tool calls and the finish, until the gate opens. */
+ holdBeforeFinish?: Gate
}
export interface RecordedCompletion {
@@ -180,6 +182,10 @@ export function startScriptedProvider(): Promise<ScriptedProvider> {
await afterChunk()
}
+ if (step.holdBeforeFinish) {
+ await step.holdBeforeFinish.opened
+ }
+
const calls = step.toolCalls ?? []
if (rec.aborted) {
diff --git a/apps/desktop/e2e/core/reattach-running-turn.spec.ts b/apps/desktop/e2e/core/reattach-running-turn.spec.ts
index 1781f1f8cb7..2e04b440c0c 100644
--- a/apps/desktop/e2e/core/reattach-running-turn.spec.ts
+++ b/apps/desktop/e2e/core/reattach-running-turn.spec.ts
@@ -160,9 +160,10 @@ test('re-attaching to a running tool turn renders each segment once', async () =
await test.step('reload while the answer after a tool streams', async () => {
const hold = gate()
+ const finish = gate()
provider.script(U(4), [
{ text: words(AI(4), 'narrating', 'again'), toolCalls: [echo('reattach-c')] },
- { text: words(A(4), 'answer', 'across', 'a', 'reload'), holdAfterFirstChunk: hold }
+ { text: words(A(4), 'answer', 'across', 'a', 'reload'), holdAfterFirstChunk: hold, holdBeforeFinish: finish }
])
await send(page, `${U(4)} reload mid answer`, 'Enter', ws)
await provider.streamStarted(U(4), 1)
@@ -172,6 +173,17 @@ test('re-attaching to a running tool turn renders each segment once', async () =
await expect(viewport(page)).toContainText(AI(4), { timeout: 60_000 })
await installDuplicateSampler(page)
hold.open()
+
+ // Before the turn completes, the rest of the answer extends the reply the
+ // reloaded window restored: one bubble, not a second one beside it.
+ const answer = viewport(page)
+ .locator('[data-slot="aui_assistant-message-root"]')
+ .filter({ hasText: 'across a reload' })
+
+ await expect(answer).toHaveCount(1, { timeout: 60_000 })
+ await page.screenshot({ path: test.info().outputPath('reload-mid-turn.png') })
+ await expect(answer).toContainText(A(4))
+ finish.open()
await settled(page, ws, A(4))
await assertTranscriptOracle(page, ws, provider, session, 're-attach after a reload')
})