From 481de4c6d12384fa0798c533c802d9716401802a Mon Sep 17 00:00:00 2001 From: Jiadong Bai <43344272+bobbai00@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:13:00 -0800 Subject: [PATCH 1/5] fix(frontend): hide agent tab panes without an animation With pane animations on, ng-zorro hides an inactive tab pane only when its fade-out transition ends. The agent panel loads minimized, with its body hidden, and no transition ends in a hidden subtree. The panes of the agents listed meanwhile stayed, invisible, over the registration tab and took every click, so a user could not select a model or create an agent. The agent tabs no longer animate, so an inactive pane is hidden at once. --- .../agent-panel/agent-panel.component.html | 5 ++++- .../agent-panel/agent-panel.component.spec.ts | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html index a2154d8e96f..3db915c4522 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html @@ -72,10 +72,13 @@ AI Agents - + diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts index c732e899a6a..3571dad2544 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts @@ -17,7 +17,7 @@ * under the License. */ -import { Component, EventEmitter, Input, Output } from "@angular/core"; +import { ANIMATION_MODULE_TYPE, Component, EventEmitter, Input, Output } from "@angular/core"; import { ComponentFixture, TestBed } from "@angular/core/testing"; import { HttpClientTestingModule } from "@angular/common/http/testing"; import { NoopAnimationsModule } from "@angular/platform-browser/animations"; @@ -304,6 +304,22 @@ describe("AgentPanelComponent", () => { expect(component.width).toBe(0); expect(fixture.nativeElement.querySelector("#agent-docked-button")).toBeTruthy(); }); + + it("hides an agent's pane at once while docked, so it cannot stay over the registration tab", () => { + // These specs run with NoopAnimationsModule; the app does not. With pane animations on, + // ng-zorro hides an inactive pane only once its fade-out transition has ended, and none + // ends inside the docked panel's hidden body (nor in jsdom). The pane then stayed, + // invisible, over the registration tab and took every click. + TestBed.overrideProvider(ANIMATION_MODULE_TYPE, { useValue: "BrowserAnimations" }); + agentService.agentList = [makeAgent("a")]; + createComponent(); + expect((fixture.nativeElement.querySelector("#content") as HTMLElement).hidden).toBe(true); + + const panes = Array.from(fixture.nativeElement.querySelectorAll(".ant-tabs-tabpane")) as HTMLElement[]; + expect(panes.length).toBe(2); + expect(panes[0].classList.contains("ant-tabs-tabpane-active")).toBe(true); + expect(panes[1].classList.contains("ant-tabs-tabpane-hidden")).toBe(true); + }); }); describe("onAgentCreated", () => { From 1b8c513b0df95f1459140a7af794884f43acfa48 Mon Sep 17 00:00:00 2001 From: Jiadong Bai <43344272+bobbai00@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:13:00 -0800 Subject: [PATCH 2/5] fix(frontend): open the agent panel inside the window The panel was placed at the right edge of its host, which is as wide as the viewport but starts after the dashboard sidebar. It opened past the window's right edge by the sidebar's width, hiding its minimize button and half of the form. It is now placed against the viewport, as the property editor is. --- .../component/agent/agent-panel/agent-panel.component.scss | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.scss b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.scss index 80c3ec719d0..c0cfea27196 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.scss +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.scss @@ -25,9 +25,12 @@ z-index: 3; } +// Placed against the viewport, as the property editor is. The host is as wide as the viewport +// but starts where the workspace does, to the right of the dashboard sidebar, so a box put at +// the host's right edge hangs off the screen by the sidebar's width. #agent-container { - position: absolute; - top: calc(-100% + 80px); + position: fixed; + top: 80px; right: 0; z-index: 3; background: white; From 681e313974beacd486cfdf7cbf73b10edb3fa48e Mon Sep 17 00:00:00 2001 From: Jiadong Bai <43344272+bobbai00@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:13:00 -0800 Subject: [PATCH 3/5] fix(frontend): put the unit notice above Create Agent The notice that a computing unit is needed sat beside the button, squeezed into what the button's minimum width left over. It now spans the form above the button. --- .../agent-registration/agent-registration.component.scss | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-registration/agent-registration.component.scss b/frontend/src/app/workspace/component/agent/agent-panel/agent-registration/agent-registration.component.scss index 639dcb78eb0..541a7e46169 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-registration/agent-registration.component.scss +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-registration/agent-registration.component.scss @@ -137,9 +137,16 @@ } } +// The computing-unit notice goes above the button at full width. Side by side, the button's +// minimum width left the notice a sliver to wrap its one sentence into. .action-buttons { display: flex; - justify-content: center; + flex-direction: column; + align-items: center; + + nz-alert { + align-self: stretch; + } button { min-width: 200px; From 9310e4e7cdb4c04a77b968e1d92bc0ce7044af3b Mon Sep 17 00:00:00 2001 From: Jiadong Bai <43344272+bobbai00@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:13:00 -0800 Subject: [PATCH 4/5] fix(frontend): keep the workflow's id on an agent reload An agent's step can reach the page before the agent's workflow has been fetched, and then carries the content alone. Reloading the workspace from it dropped the open workflow's id and name: the title went blank and the agent's own tab locked as belonging to a different workflow. The reload now keeps the open workflow's metadata for whatever the agent's workflow does not carry. --- .../agent-chat/agent-chat.component.spec.ts | 17 ++++++++++++++++- .../agent-chat/agent-chat.component.ts | 10 +++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.spec.ts b/frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.spec.ts index e2f70a6dc37..4fb82fd4de5 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.spec.ts +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.spec.ts @@ -101,6 +101,9 @@ function makeStep(overrides: Partial = {}): ReActStep { }; } +/** What the workspace knows about the workflow it has open, apart from its content. */ +const OPEN_WORKFLOW = { wid: 42, name: "wf" }; + describe("AgentChatComponent", () => { let fixture: ComponentFixture; let component: AgentChatComponent; @@ -139,7 +142,7 @@ describe("AgentChatComponent", () => { // so the real service is required to render the system-info modal. NzModalService, { provide: AgentService, useValue: agentService }, - { provide: WorkflowActionService, useValue: { reloadWorkflow } }, + { provide: WorkflowActionService, useValue: { reloadWorkflow, getWorkflowMetadata: () => OPEN_WORKFLOW } }, { provide: NotificationService, useValue: notification }, { provide: WorkflowPersistService, useValue: persist }, ...commonTestProviders, @@ -341,6 +344,18 @@ describe("AgentChatComponent", () => { } as unknown as Workflow); expect(reloadWorkflow).toHaveBeenCalledTimes(2); }); + + it("keeps the open workflow's id and name when the agent's workflow carries only its content", () => { + // A step can reach the page before the workflow itself has been fetched, and then all there + // is to put on the stream is the content. Reloading that as it came wiped the workspace's + // workflow id and name, and the agent's own tab locked as "a different workflow". + createComponent(makeAgentInfo(), true); + const content = { operators: [{ operatorID: "op-9" }] }; + + agentService.workflowSubject.next({ content } as unknown as Workflow); + + expect(reloadWorkflow).toHaveBeenCalledWith({ ...OPEN_WORKFLOW, content }, false, false); + }); }); describe("sendMessage / onEnterPress", () => { diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.ts b/frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.ts index 867e21aa7ee..f7d21c84e83 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.ts +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.ts @@ -284,7 +284,15 @@ export class AgentChatComponent implements OnInit, AfterViewChecked, OnDestroy, ) .subscribe(workflow => { if (workflow) { - this.workflowActionService.reloadWorkflow(workflow, false, false); + // The agent's stream can carry the workflow's content alone: a step that arrives before + // the workflow itself has been fetched has nothing else to send. The id, name and the + // rest are then the open workflow's own. Reloading without them made the workspace + // forget which workflow it had open, and this agent's tab locked as "a different one". + this.workflowActionService.reloadWorkflow( + { ...this.workflowActionService.getWorkflowMetadata(), ...workflow }, + false, + false + ); } }); } From c22b6a80e624bff7d72b2eb47ef21b41b38fdb7e Mon Sep 17 00:00:00 2001 From: Jiadong Bai <43344272+bobbai00@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:43:33 -0800 Subject: [PATCH 5/5] fix(frontend): link a locked agent tab to its workflow The tab of an agent that works on another workflow was disabled: it showed a lock and could not be clicked, so its chat could not be reached again. The tab can now be selected. In place of the chat it names the agent's workflow and links to it. The agent is not activated there, since an active agent loads its workflow into the canvas. The link is a plain one, because the workspace reads the workflow's id from its address only when it is created. --- .../agent-panel/agent-panel.component.html | 24 ++++++- .../agent-panel/agent-panel.component.scss | 18 ++++++ .../agent-panel/agent-panel.component.spec.ts | 62 +++++++++++++------ .../agent-panel/agent-panel.component.ts | 26 +++----- 4 files changed, 92 insertions(+), 38 deletions(-) diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html index 3db915c4522..241731b5aef 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html @@ -100,8 +100,7 @@ + [nzForceRender]="true"> @@ -134,8 +133,29 @@ + + +
+

+ This agent is working on a different workflow: {{ agent.delegate?.workflowName || "#" + workflowId }}. +

+ + Open that workflow + +
+
diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.scss b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.scss index c0cfea27196..50499947c4f 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.scss +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.scss @@ -139,6 +139,24 @@ } } +// Shown in place of the chat of an agent that works on another workflow. +.other-workflow-notice { + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 16px; + padding: 20px; + text-align: center; + font-size: 14px; + color: #595959; + + p { + margin: 0; + } +} + .agent-tab-close { padding: 0 !important; width: 20px !important; diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts index 3571dad2544..ae2d8a2c936 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts @@ -125,7 +125,6 @@ describe("AgentPanelComponent", () => { providers: [ { provide: AgentService, useValue: agentService }, { provide: WorkflowActionService, useValue: workflowAction }, - { provide: NotificationService, useValue: notification }, ...commonTestProviders, ], }).compileComponents(); @@ -411,18 +410,18 @@ describe("AgentPanelComponent", () => { expect(component.selectedTabIndex).toBe(2); }); - it("blocks switching to an agent bound to a different workflow and warns", () => { - agentService.agentList = [makeDelegateAgent("foreign", 99)]; + it("selects the tab of an agent bound to a different workflow without activating it", () => { + agentService.agentList = [makeAgent("local"), makeDelegateAgent("foreign", 99)]; createComponent(); + component.onTabSelectChange(1); // "local" active - component.onTabSelectChange(1); + component.onTabSelectChange(2); - expect(notification.warning).toHaveBeenCalledTimes(1); - const message = notification.warning.mock.calls[0][0] as string; - expect(message).toContain('Cannot switch to agent "Agent foreign"'); - expect(message).toContain("Open workflow #99"); - expect(agentService.activateAgent).not.toHaveBeenCalled(); - expect(component.selectedTabIndex).toBe(0); + // An active agent loads its workflow into the canvas, here over the open one. + expect(agentService.activateAgent).not.toHaveBeenCalledWith("foreign"); + expect(agentService.deactivateAgent).toHaveBeenCalledWith("local"); + expect(component.activeAgentId).toBeNull(); + expect(component.selectedTabIndex).toBe(2); }); it("allows switching when the agent's workflow matches the current one", () => { @@ -431,7 +430,6 @@ describe("AgentPanelComponent", () => { component.onTabSelectChange(1); - expect(notification.warning).not.toHaveBeenCalled(); expect(agentService.activateAgent).toHaveBeenCalledWith("bound"); expect(component.selectedTabIndex).toBe(1); }); @@ -494,6 +492,28 @@ describe("AgentPanelComponent", () => { expect(titles[0].classList.contains("workflow-mismatch")).toBe(false); expect(titles[1].classList.contains("workflow-mismatch")).toBe(true); }); + + it("gives an agent from another workflow a link to that workflow in place of a chat", () => { + agentService.agentList = [ + makeAgent("local"), + makeAgent("named", { delegate: { userInfo: USER_INFO, workflowId: 99, workflowName: "Orders" } }), + makeDelegateAgent("unnamed", 7), + ]; + createComponent(); + + const chats = fixture.debugElement.queryAll(By.directive(StubAgentChatComponent)); + expect(chats.map(chat => chat.componentInstance.agentInfo.id)).toEqual(["local"]); + + const notices = Array.from(fixture.nativeElement.querySelectorAll(".other-workflow-notice")) as HTMLElement[]; + expect(notices.map(notice => notice.querySelector("p")?.textContent?.trim())).toEqual([ + "This agent is working on a different workflow: Orders.", + "This agent is working on a different workflow: #7.", + ]); + expect(notices.map(notice => notice.querySelector("a")?.getAttribute("href"))).toEqual([ + "/user/workflow/99", + "/user/workflow/7", + ]); + }); }); describe("deleteAgent", () => { @@ -847,21 +867,23 @@ describe("AgentPanelComponent", () => { expect(chats().map(c => c.isActive)).toEqual([false, true]); }); - it("disables the tab of an agent bound to another workflow so a click cannot select it", () => { + it("clicking the tab of an agent bound to another workflow shows the link to it, not a chat", async () => { service.agentList = [makeAgent("local"), makeDelegateAgent("foreign", 99)]; createComponent(); - const headers = tabHeaders(); - expect(headers[1].classList.contains("ant-tabs-tab-disabled")).toBe(false); - expect(headers[2].classList.contains("ant-tabs-tab-disabled")).toBe(true); - - (headers[2].querySelector(".ant-tabs-tab-btn") as HTMLElement).click(); + (tabHeaders()[2].querySelector(".ant-tabs-tab-btn") as HTMLElement).click(); + fixture.detectChanges(); + await settle(); fixture.detectChanges(); - // Disabled by the template, so onTabSelectChange never runs and never warns. - expect(notification.warning).not.toHaveBeenCalled(); + expect(component.selectedTabIndex).toBe(2); + const selectedPane = fixture.nativeElement.querySelector(".ant-tabs-tabpane-active") as HTMLElement; + expect(selectedPane.querySelector("a")?.getAttribute("href")).toBe("/user/workflow/99"); + expect(selectedPane.querySelector("texera-agent-chat")).toBeNull(); + // The agent stays inactive, and the only chat is that of the agent on this workflow. expect(service.activateAgent).not.toHaveBeenCalled(); - expect(chats().map(c => c.isActive)).toEqual([false, false]); + expect(chats().map(c => c.agentInfo.id)).toEqual(["local"]); + expect(chats().map(c => c.isActive)).toEqual([false]); }); it("the close button on a tab header deletes that agent without selecting its tab", () => { diff --git a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.ts b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.ts index 3a5e1650171..fe617ebe557 100644 --- a/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.ts +++ b/frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.ts @@ -22,7 +22,7 @@ import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; import { NzResizeEvent, NzResizableDirective, NzResizeHandlesComponent } from "ng-zorro-antd/resizable"; import { AgentService, AgentInfo } from "../../../service/agent/agent.service"; import { WorkflowActionService } from "../../../service/workflow-graph/model/workflow-action.service"; -import { NotificationService } from "../../../../common/service/notification/notification.service"; +import { workspaceCanvasUrl } from "../../../../app-routing.constant"; import { NgIf, NgFor } from "@angular/common"; import { NzSpaceCompactItemDirective } from "ng-zorro-antd/space"; import { NzButtonComponent } from "ng-zorro-antd/button"; @@ -66,6 +66,7 @@ import { AgentChatComponent } from "./agent-chat/agent-chat.component"; }) export class AgentPanelComponent implements OnInit, OnDestroy, OnChanges { protected readonly window = window; + protected readonly workspaceCanvasUrl = workspaceCanvasUrl; private static readonly MIN_PANEL_WIDTH = 400; private static readonly MIN_PANEL_HEIGHT = 450; @@ -91,8 +92,7 @@ export class AgentPanelComponent implements OnInit, OnDestroy, OnChanges { constructor( private agentService: AgentService, - private workflowActionService: WorkflowActionService, - private notificationService: NotificationService + private workflowActionService: WorkflowActionService ) {} ngOnInit(): void { @@ -210,7 +210,7 @@ export class AgentPanelComponent implements OnInit, OnDestroy, OnChanges { } /** - * Handle tab selection change - validates workflow compatibility before switching + * Handle tab selection change - activates the tab's agent only on the workflow it works on */ public onTabSelectChange(index: number): void { // Tab 0 is registration - always allow @@ -227,19 +227,13 @@ export class AgentPanelComponent implements OnInit, OnDestroy, OnChanges { } const agent = this.agents[agentIndex]; - const agentWorkflowId = agent.delegate?.workflowId; - const currentWorkflowId = this.workflowActionService.getWorkflowMetadata().wid; - // If agent has a workflow ID, check if it matches the current workflow - if (agentWorkflowId !== undefined && agentWorkflowId !== 0) { - if (currentWorkflowId !== agentWorkflowId) { - // Block switching - workflow mismatch - this.notificationService.warning( - `Cannot switch to agent "${agent.name}": It's working on a different workflow. ` + - `Open workflow #${agentWorkflowId} to interact with this agent.` - ); - return; - } + // An agent that works on another workflow is shown, not activated: its tab holds a link to + // that workflow in place of the chat, and an active agent loads its workflow into the canvas. + if (!this.canSwitchToAgent(agent)) { + this.deactivateCurrentAgent(); + this.selectedTabIndex = index; + return; } // Workflow matches or agent has no workflow - allow switch