Repository navigation
fix(agent): bind the workflow a followed chat opens (FRONT-3804) #22792
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
9 commits
Select commit
Hold shift + click to select a range
c9b47b9
fix(agent): bind the workflow a followed chat opens (FRONT-3804)
christian-byrne aab621e
test(agent): drop the comment on applyOpsOnHostUnsent
christian-byrne ce05465
test(agent): move the background-tab spec rationale to the PR
christian-byrne 29e0d26
refactor(agent): drop the comments on the followed-workflow bind
christian-byrne 7d3bd31
test(agent): move the background-tab chats into a data file and the c…
christian-byrne 2e1e1c4
fix(agent): record unbound edits to the visible workflow before a fol…
christian-byrne 282bf44
refactor(agent): extract intentRootGraphId from noteUnboundLocalIntent
christian-byrne b8319d6
test(agent): hold only transcript reads in holdTranscript
christian-byrne 77289cf
test(agent): prove B was not re-subscribed with a later subscribe to A
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
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,99 @@ | ||
| import type { ComfyWorkflowJSON } from '@comfyorg/graph-model/workflowSchema' | ||
|
|
||
| import type { RecordedGraphOperation } from '@e2e/fixtures/data/agent/agentConversation' | ||
| import { | ||
| agentThreadSummary, | ||
| agentUserTranscript | ||
| } from '@e2e/fixtures/data/agent/agentThreadList' | ||
| import type { AgentWorkflowChatsMock } from '@e2e/fixtures/helpers/agentWorkflowChats' | ||
|
|
||
| type WorkflowChats = ConstructorParameters<typeof AgentWorkflowChatsMock>[0] | ||
|
|
||
| interface ChatWorkflow { | ||
| id: string | ||
| name: string | ||
| threadId: string | ||
| request: string | ||
| } | ||
|
|
||
| export const BACKGROUND_TAB_CASE = 'agent-rec-set-widget-existing' | ||
| export const FOREGROUND_NAME = 'Unsaved Workflow' | ||
| export const BACKGROUND: ChatWorkflow = { | ||
| id: '3c1e5b7a-9d2f-4e8b-a6c4-0f1e2d3c4b5a', | ||
| name: 'Other Study', | ||
| threadId: '7a2b4c6d-8e0f-4a1b-9c3d-5e7f9a1b3c5d', | ||
| request: 'Tidy up the other study' | ||
| } | ||
| export const BACKGROUND_NODES = [ | ||
| { id: 801, title: 'b1', x: 1400 }, | ||
| { id: 802, title: 'b2', x: 1700 }, | ||
| { id: 803, title: 'b3', x: 2000 } | ||
| ] | ||
|
|
||
| const EMPTY_GRAPH: ComfyWorkflowJSON = { | ||
| last_node_id: 0, | ||
| last_link_id: 0, | ||
| nodes: [], | ||
| links: [], | ||
| groups: [], | ||
| config: {}, | ||
| extra: {}, | ||
| version: 0.4 | ||
| } | ||
|
|
||
| export function backgroundEdits(): RecordedGraphOperation[] { | ||
| const type = 'EmptyLatentImage' | ||
| return BACKGROUND_NODES.flatMap(({ id, title, x }) => [ | ||
| { | ||
| op: 'add_node', | ||
| node_id: id, | ||
| class_type: type, | ||
| pos: [x, 600], | ||
| node: { | ||
| id, | ||
| type, | ||
| pos: [x, 600], | ||
| size: [240, 134], | ||
| flags: {}, | ||
| order: 0, | ||
| mode: 0, | ||
| inputs: [], | ||
| outputs: [{ name: 'LATENT', type: 'LATENT', links: [] }], | ||
| properties: {}, | ||
| widgets_values: [512, 512, 1] | ||
| } | ||
| }, | ||
| { op: 'set_node_field', node_id: id, field: 'title', value: title } | ||
| ]) | ||
| } | ||
|
|
||
| export function backgroundTabChats( | ||
| foreground: Omit<ChatWorkflow, 'name'> | ||
| ): WorkflowChats { | ||
| const chats = [ | ||
| { ...foreground, name: FOREGROUND_NAME, at: '2026-11-02T09:00:00Z' }, | ||
| { ...BACKGROUND, at: '2026-11-02T10:00:00Z' } | ||
| ] | ||
| return { | ||
| workflows: chats.map(({ id, name }) => ({ | ||
| id, | ||
| name, | ||
| content: EMPTY_GRAPH | ||
| })), | ||
| threads: chats.map(({ id, name, threadId, request, at }) => | ||
| agentThreadSummary(threadId, `${name} chat`, { | ||
| preview: request, | ||
| workflow_id: id, | ||
| last_message_at: at | ||
| }) | ||
| ), | ||
| transcripts: Object.fromEntries( | ||
| chats.map(({ id, threadId, request }) => [ | ||
| threadId, | ||
| agentUserTranscript(threadId, id, request) | ||
| ]) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| export const USER_NOTE_POSITION: [number, number] = [400, 400] |
146 changes: 146 additions & 0 deletions
146
browser_tests/tests/agent/agentBackgroundTabEditsLand.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,146 @@ | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| import { | ||
| agentConversationTest as test, | ||
| THREAD_ID | ||
| } from '@e2e/fixtures/agentConversationFixture' | ||
| import { AgentPanel } from '@e2e/fixtures/components/AgentPanel' | ||
| import { | ||
| BACKGROUND, | ||
| BACKGROUND_NODES, | ||
| BACKGROUND_TAB_CASE, | ||
| backgroundEdits, | ||
| backgroundTabChats, | ||
| FOREGROUND_NAME, | ||
| USER_NOTE_POSITION | ||
| } from '@e2e/fixtures/data/agent/backgroundTabEdits' | ||
| import { AgentWorkflowChatsMock } from '@e2e/fixtures/helpers/agentWorkflowChats' | ||
|
|
||
| test.describe( | ||
| 'Agent edits to a background workflow tab', | ||
| { tag: ['@cloud', '@agent', '@vue-nodes'] }, | ||
| () => { | ||
| test.use({ conversationCase: BACKGROUND_TAB_CASE }) | ||
|
|
||
| test.beforeEach(async ({ agentConversation, page }) => { | ||
| test.setTimeout(120_000) | ||
| const panel = new AgentPanel(page) | ||
| const topbar = agentConversation.topbar | ||
| const aRequest = agentConversation.conversation.turns[0].request.content | ||
|
|
||
| await test.step('agent edits workflow A', () => | ||
| agentConversation.runTurns()) | ||
|
|
||
| await test.step('workflow B has a saved chat of its own', async () => { | ||
| agentConversation.serveWorkflow(BACKGROUND.id, { | ||
| ...agentConversation.conversation.workflow.seed, | ||
| nodes: [], | ||
| links: [] | ||
| }) | ||
| await new AgentWorkflowChatsMock( | ||
| backgroundTabChats({ | ||
| id: agentConversation.conversation.workflow.id, | ||
| threadId: THREAD_ID, | ||
| request: aRequest | ||
| }) | ||
| ).route(page) | ||
| }) | ||
|
|
||
| await test.step('user opens workflow B and its chat', async () => { | ||
| await panel.historyButton.click() | ||
| await panel.root | ||
| .getByRole('button', { name: `${BACKGROUND.name} chat`, exact: true }) | ||
| .click() | ||
| await expect(panel.userMessageBubbles).toHaveText([BACKGROUND.request]) | ||
| await expect( | ||
| topbar.getWorkflowTab(BACKGROUND.name).and(topbar.getActiveTab()) | ||
| ).toBeVisible() | ||
| }) | ||
|
|
||
| await test.step('user returns to A by its tab', async () => { | ||
| await topbar.getWorkflowTab(FOREGROUND_NAME).click() | ||
| await expect(panel.userMessageBubbles).toHaveText([aRequest]) | ||
| }) | ||
| }) | ||
|
|
||
| test('are on the canvas when the user returns to that tab', async ({ | ||
| agentConversation, | ||
| page | ||
| }) => { | ||
| const panel = new AgentPanel(page) | ||
| const topbar = agentConversation.topbar | ||
| const aRequest = agentConversation.conversation.turns[0].request.content | ||
|
|
||
| await test.step('user switches to B by its tab', async () => { | ||
| await topbar.getWorkflowTab(BACKGROUND.name).click() | ||
| await expect(panel.userMessageBubbles).toHaveText([BACKGROUND.request]) | ||
| await expect( | ||
| topbar.getWorkflowTab(BACKGROUND.name).and(topbar.getActiveTab()) | ||
| ).toBeVisible() | ||
| }) | ||
|
|
||
| await test.step('agent adds three titled nodes to A while B is shown', () => | ||
| agentConversation.applyOpsOnHostUnsent(backgroundEdits())) | ||
|
|
||
| await test.step('returning to A shows every background edit', async () => { | ||
| await topbar.getWorkflowTab(FOREGROUND_NAME).click() | ||
| await expect( | ||
| topbar.getWorkflowTab(FOREGROUND_NAME).and(topbar.getActiveTab()) | ||
| ).toBeVisible() | ||
| await expect(panel.userMessageBubbles).toHaveText([aRequest]) | ||
| for (const { id, title } of BACKGROUND_NODES) | ||
| await expect( | ||
| agentConversation.vueNodes | ||
| .getNodeLocator(String(id)) | ||
| .getByTestId('node-title') | ||
| ).toHaveText(title) | ||
| }) | ||
| }) | ||
|
|
||
| test('do not rebind a tab the user edited while its chat was loading', async ({ | ||
| agentConversation, | ||
| page | ||
| }) => { | ||
| const panel = new AgentPanel(page) | ||
| const topbar = agentConversation.topbar | ||
| const subscribesBefore = agentConversation.subscribeCount(BACKGROUND.id) | ||
| const transcript = await agentConversation.holdTranscript( | ||
| BACKGROUND.threadId | ||
| ) | ||
|
|
||
| const noteId = | ||
| await test.step('user edits B before its chat loads', async () => { | ||
| await topbar.getWorkflowTab(BACKGROUND.name).click() | ||
| await transcript.requested | ||
| const id = await agentConversation.addNoteThroughSearchBox({ | ||
| x: USER_NOTE_POSITION[0], | ||
| y: USER_NOTE_POSITION[1] | ||
| }) | ||
| await expect( | ||
| agentConversation.vueNodes.getNodeLocator(id) | ||
| ).toBeVisible() | ||
| return id | ||
| }) | ||
|
|
||
| await test.step('B keeps the edit once its chat loads', async () => { | ||
| transcript.release() | ||
| await expect(panel.userMessageBubbles).toHaveText([BACKGROUND.request]) | ||
| await expect( | ||
| agentConversation.vueNodes.getNodeLocator(noteId) | ||
| ).toBeVisible() | ||
| }) | ||
|
|
||
| await test.step('the next subscribe, to A, finds B never re-subscribed', async () => { | ||
| const aId = agentConversation.conversation.workflow.id | ||
| const aSubscribes = agentConversation.subscribeCount(aId) | ||
| await topbar.getWorkflowTab(FOREGROUND_NAME).click() | ||
| await expect | ||
| .poll(() => agentConversation.subscribeCount(aId)) | ||
| .toBeGreaterThan(aSubscribes) | ||
| expect(agentConversation.subscribeCount(BACKGROUND.id)).toBe( | ||
| subscribesBefore | ||
| ) | ||
| }) | ||
| }) | ||
| } | ||
| ) |
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.
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.