Repository navigation
fix(agent): report why a history chat's workflow could not be restored #21339
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8c14eef
fix(agent): report why a history chat's workflow could not be restored
christian-byrne 1dd5eb6
test(agent): assert the thrown restore error reaches reportError
christian-byrne 96dc18b
test(agent): match the thread list request with its query string
christian-byrne ef7a75b
Merge remote-tracking branch 'origin/main' into fix/qa157-agent-histo…
christian-byrne d1166fa
test(agent): assert restore failure reasons and move spec setup to be…
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
165 changes: 165 additions & 0 deletions
165
browser_tests/tests/agent/agentHistoryUnresolvedWorkflowReported.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,165 @@ | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| import type { | ||
| AgentMessage, | ||
| AgentThreadListResponse, | ||
| WorkflowListResponse | ||
| } from '@comfyorg/ingest-types' | ||
| import { REPORTED_ERROR_PREFIX } from '@comfyorg/shared-frontend-utils/telemetry' | ||
|
|
||
| import enMessages from '@/locales/en/main.json' with { type: 'json' } | ||
| import type { UserDataFullInfo } from '@/platform/remote/comfyui/types' | ||
|
|
||
| import { | ||
| agentTest as test, | ||
| bootAgentApp | ||
| } from '@e2e/fixtures/agentPanelFixture' | ||
| import { AgentPanel } from '@e2e/fixtures/components/AgentPanel' | ||
| import { collectConsoleErrors } from '@e2e/fixtures/utils/consoleErrorCollector' | ||
| import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute' | ||
|
|
||
| const THREAD_ID = '3b7e2d1c-9a4f-4e6b-8c5d-1f2a3b4c5d6e' | ||
| const TURN_ID = '6c5d4e3f-2a1b-4c9d-8e7f-0a1b2c3d4e5f' | ||
| const WORKFLOW_ID = '0d9c8b7a-6f5e-4d3c-b2a1-f0e9d8c7b6a5' | ||
| const TWIN_WORKFLOW_ID = '1e0d9c8b-7a6f-4e5d-c3b2-a1f0e9d8c7b6' | ||
| const WORKFLOW_NAME = 'Image and video' | ||
| const THREAD_TITLE = 'Lighthouse clip' | ||
| const USER_REQUEST = 'Make a lighthouse image, then a short video of it' | ||
| const IMAGE_URL = | ||
| 'https://cloud.comfy.org/api/view?filename=lighthouse_00001_.png&subfolder=agent%2Foutputs&type=output' | ||
| const VIDEO_URL = | ||
| 'https://cloud.comfy.org/api/view?filename=lighthouse_00001_.mp4&subfolder=agent%2Foutputs&type=output' | ||
| const ASSISTANT_REPLY = `Here is the image: [lighthouse_00001_.png](${IMAGE_URL}) and the video: [lighthouse_00001_.mp4](${VIDEO_URL})` | ||
| const SAVED_AT = '2026-10-15T10:00:00Z' | ||
|
|
||
| const THREADS: AgentThreadListResponse = { | ||
| threads: [ | ||
| { | ||
| id: THREAD_ID, | ||
| title: THREAD_TITLE, | ||
| preview: USER_REQUEST, | ||
| workflow_id: WORKFLOW_ID, | ||
| status: 'active', | ||
| message_count: 2, | ||
| created_at: SAVED_AT, | ||
| updated_at: SAVED_AT, | ||
| last_message_at: SAVED_AT | ||
| } | ||
| ], | ||
| pagination: { offset: 0, limit: 100, total: 1, has_more: false } | ||
| } | ||
| const TRANSCRIPT: AgentMessage[] = [ | ||
| { | ||
| id: 'lighthouse-user', | ||
| thread_id: THREAD_ID, | ||
| turn_id: TURN_ID, | ||
| seq: 1, | ||
| role: 'user', | ||
| status: 'complete', | ||
| workflow_id: WORKFLOW_ID, | ||
| content: { text: USER_REQUEST } | ||
| }, | ||
| { | ||
| id: TURN_ID, | ||
| thread_id: THREAD_ID, | ||
| turn_id: TURN_ID, | ||
| seq: 2, | ||
| role: 'assistant', | ||
| status: 'complete', | ||
| workflow_id: WORKFLOW_ID, | ||
| content: { | ||
| text: ASSISTANT_REPLY, | ||
| tool_calls: [ | ||
| { | ||
| id: 'call-image', | ||
| tool_call_id: 'toolu_image', | ||
| tool_name: 'run_workflow', | ||
| status: 'success', | ||
| duration_ms: 4200 | ||
| }, | ||
| { | ||
| id: 'call-video', | ||
| tool_call_id: 'toolu_video', | ||
| tool_name: 'run_workflow', | ||
| status: 'success', | ||
| duration_ms: 18400 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| const CLOUD_WORKFLOWS: WorkflowListResponse = { | ||
| data: [WORKFLOW_ID, TWIN_WORKFLOW_ID].map((id) => ({ | ||
| id, | ||
| name: WORKFLOW_NAME, | ||
| created_at: SAVED_AT, | ||
| updated_at: SAVED_AT, | ||
| created_by: 'test-user-e2e', | ||
| latest_version: 1 | ||
| })), | ||
| pagination: { offset: 0, limit: 100, total: 2, has_more: false } | ||
| } | ||
| const SAVED_FILES: UserDataFullInfo[] = [ | ||
| `${WORKFLOW_NAME}.json`, | ||
| `drafts/${WORKFLOW_NAME}.json` | ||
| ].map((path) => ({ path, modified: Date.parse(SAVED_AT), size: 64 })) | ||
|
|
||
| test.describe( | ||
| 'Agent history reports an unresolvable chat workflow', | ||
| { tag: ['@cloud', '@agent'] }, | ||
| () => { | ||
| test.beforeEach(async ({ page, agentFlagEnabled }) => { | ||
| await bootAgentApp(page, agentFlagEnabled, { | ||
| beforeNavigate: async (page) => { | ||
| await page.route('**/api/agent/threads?*', (route) => | ||
| route.fulfill(jsonRoute(THREADS)) | ||
| ) | ||
| await page.route('**/api/agent/threads/*/messages', (route) => | ||
| route.request().method() === 'GET' | ||
| ? route.fulfill(jsonRoute(TRANSCRIPT)) | ||
| : route.fallback() | ||
| ) | ||
| await page.route('**/api/workflows?*', (route) => | ||
| route.fulfill(jsonRoute(CLOUD_WORKFLOWS)) | ||
| ) | ||
| await page.route('**/api/userdata?*', (route) => { | ||
| const dir = new URL(route.request().url()).searchParams.get('dir') | ||
| if (dir !== 'workflows') return route.fallback() | ||
| return route.fulfill(jsonRoute(SAVED_FILES)) | ||
| }) | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| test('logs why a chat whose workflow cannot be resolved does not open', async ({ | ||
| page | ||
| }) => { | ||
| const agentPanel = new AgentPanel(page) | ||
| const panel = agentPanel.root | ||
| const historyRow = panel.getByRole('button', { | ||
| name: THREAD_TITLE, | ||
| exact: true | ||
| }) | ||
| using consoleErrors = collectConsoleErrors(page) | ||
|
|
||
| await agentPanel.open() | ||
| await panel | ||
| .getByRole('button', { name: enMessages.agent.showChatHistory }) | ||
| .click() | ||
| await historyRow.click() | ||
|
|
||
| await expect(panel.getByRole('alert')).toHaveText( | ||
| enMessages.agent.historyOpenFailed | ||
| ) | ||
| await expect | ||
| .poll(() => | ||
| consoleErrors.errors.filter((error) => | ||
| error.startsWith( | ||
| `${REPORTED_ERROR_PREFIX}agent_workflow_restore_failed` | ||
| ) | ||
| ) | ||
| ) | ||
| .toHaveLength(1) | ||
| }) | ||
| } | ||
| ) | ||
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
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
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.
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.