Repository navigation
[backport core/1.54] fix(agent): report an approval ask the panel never delivered (#18952) #19337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
70df068
fix(agent): report an approval ask the panel never delivered (#18952)
christian-byrne 5102d59
[automated] Apply ESLint and Oxfmt fixes
actions-user 282ef4c
test(core/1.54): restore auth config fixture state
christian-byrne b647c8d
fix(agent): harden approval ask telemetry lifecycle
christian-byrne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
browser_tests/tests/agent/agentApprovalSurvivesSocketDrop.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| import enMessages from '@/locales/en/main.json' with { type: 'json' } | ||
| import { | ||
| RUN_APPROVAL_EVENT, | ||
| agentTurnLockTest as test | ||
| } from '@e2e/fixtures/agentTurnLockFixture' | ||
|
|
||
| // The worst shape a stall can take, from a real user report: they asked for an | ||
| // img2img workflow, then for img2video, and the panel went dead. They restarted | ||
| // the agent tab to get out of it. | ||
| // | ||
| // A session-id trace said the backend never hung. The turn was alive the whole | ||
| // time, parked waiting for the user to approve a tool call — and the approval | ||
| // prompt never made it into the panel. The product was working and waiting on | ||
| // the user; the user had no way to answer. | ||
| // | ||
| // The mechanism is the socket blip. `useAgentSession.onStatus(false)` answers a | ||
| // transient close with `abortActiveTurn()` + `dropBackgroundTurns()`, so the | ||
| // transport slot is null and the background map is empty. The server, which | ||
| // never learned the socket went away, then emits `agent_ask` for the approval | ||
| // it is parked on, and `agentConversationStore.ingest` has nothing to route it | ||
| // to: `ingestBackgroundTurnEvent` returns at `!entry` and the frame is gone. | ||
| // Nothing errors, the panel looks idle, the server looks healthy. | ||
| // | ||
| // Deliberately not a refresh: on a refresh the ask comes back, because the | ||
| // persisted row carries `pending_ask` and `normalizeAgentTranscript` restores | ||
| // the card. That asymmetry is why restarting the tab "fixed" it for the user | ||
| // and why this only ever showed up through a feedback form. | ||
| test.describe.configure({ timeout: 120_000 }) | ||
| test.use({ connectWebSocketToServer: false }) | ||
|
|
||
| test.describe( | ||
| 'an approval ask survives a socket drop', | ||
| { tag: ['@cloud', '@ui'] }, | ||
| () => { | ||
| const PROMPT = 'turn this image into a video' | ||
|
|
||
| test.beforeEach(async ({ turnLock }) => { | ||
| await turnLock.openOnBlankWorkflow() | ||
| await turnLock.startTurn(PROMPT) | ||
| }) | ||
|
|
||
| test('the approval card reaches the panel after a reconnect', async ({ | ||
| turnLock | ||
| }) => { | ||
| const reconnected = await turnLock.dropSocket() | ||
|
|
||
| // Preconditions stay above the marker so a wiped thread or a lost prompt | ||
| // reads as a real failure rather than the expected one. | ||
| await expect(turnLock.userBubbles).toHaveText([PROMPT]) | ||
|
|
||
| // The server is parked on this ask and will not proceed without an | ||
| // answer. `ws.send()` throws on a dead route, so pushing stays above | ||
| // test.fail() too. | ||
| turnLock.push(reconnected, RUN_APPROVAL_EVENT) | ||
| expect(turnLock.pendingAskIsPrimed()).toBe(false) | ||
|
|
||
| test.fail() | ||
| await expect( | ||
| turnLock.panel.getByText(enMessages.agent.runApproval.question) | ||
| ).toBeVisible() | ||
| await expect( | ||
| turnLock.panel.getByRole('button', { | ||
| name: enMessages.agent.runApproval.run, | ||
| exact: true | ||
| }) | ||
| ).toBeVisible() | ||
| }) | ||
|
|
||
| test('the user can answer the ask that arrived after the reconnect', async ({ | ||
| turnLock | ||
| }) => { | ||
| const reconnected = await turnLock.dropSocket() | ||
| await expect(turnLock.userBubbles).toHaveText([PROMPT]) | ||
| turnLock.push(reconnected, RUN_APPROVAL_EVENT) | ||
| expect(turnLock.pendingAskIsPrimed()).toBe(false) | ||
|
|
||
| test.fail() | ||
| // Recovery must restore both the card and its active turn identity; | ||
| // `answerAsk` deliberately refuses to POST without `activeTurnId`. | ||
| await turnLock.panel | ||
| .getByRole('button', { | ||
| name: enMessages.agent.runApproval.run, | ||
| exact: true | ||
| }) | ||
| .click({ timeout: 10_000 }) | ||
| await expect.poll(() => turnLock.answeredAsks()).toEqual(['run']) | ||
| }) | ||
|
|
||
| // Keeps the locators above honest. If the approval card never renders under | ||
| // this fixture at all — a changed testid, a gate, reworded copy — this case | ||
| // reddens and the two expected failures above stop being evidence of the | ||
| // defect they name. | ||
| test('the same ask renders when the socket never drops', async ({ | ||
| turnLock | ||
| }) => { | ||
| const live = await turnLock.liveSocket() | ||
|
|
||
| turnLock.push(live, RUN_APPROVAL_EVENT) | ||
| expect(turnLock.pendingAskIsPrimed()).toBe(false) | ||
|
|
||
| await expect( | ||
| turnLock.panel.getByText(enMessages.agent.runApproval.question) | ||
| ).toBeVisible() | ||
| await turnLock.panel | ||
| .getByRole('button', { | ||
| name: enMessages.agent.runApproval.run, | ||
| exact: true | ||
| }) | ||
| .click() | ||
| await expect.poll(() => turnLock.answeredAsks()).toEqual(['run']) | ||
| }) | ||
| } | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.