Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ function makeStep(overrides: Partial<ReActStep> = {}): 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<AgentChatComponent>;
let component: AgentChatComponent;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@
AI Agents
</h4>

<!-- Tabs -->
<!-- Tabs. Not animated: an animated pane is hidden only once its fade-out transition ends,
and none ends while this panel is docked ([hidden] above). The panes of the agents
loaded meanwhile would stay, invisible, over the registration tab and take its clicks. -->
<nz-tabs
[nzSelectedIndex]="selectedTabIndex"
(nzSelectedIndexChange)="onTabSelectChange($event)"
[nzAnimated]="false"
class="agent-tabs"
nzType="card">
<ng-template nzTabBarExtraContent="end">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading