bobbai00 commented on code in PR #9604:
URL: https://github.com/apache/texera/pull/9604#discussion_r4675762912
##########
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);
+ // A step that reaches the page before the agent's workflow has been
fetched carries the
+ // content alone. Reloaded as it came, it made the workspace forget
which workflow it had
+ // open: the title went blank and this agent's own tab locked as on
another workflow. An
+ // agent bound to the open workflow works on it, so that workflow's
id and name stand in.
+ // An agent bound to none keeps what it sent, so its content is not
saved over this one.
+ const open = this.workflowActionService.getWorkflowMetadata();
+ const boundWid = this.agentInfo.delegate?.workflowId;
+ const isBoundToOpen = !!boundWid && boundWid === open.wid;
+ this.workflowActionService.reloadWorkflow(isBoundToOpen ? { ...open,
...workflow } : workflow, false, false);
Review Comment:
Agreed, typing the stream as `WorkflowContent` is cleaner. The chat is its
only consumer today, and the change also has to settle what an agent bound to
no workflow reloads, so I'll leave it to a follow-up.
##########
frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html:
##########
@@ -131,8 +130,30 @@
</ng-template>
<ng-template nz-tab>
<texera-agent-chat
+ *ngIf="canSwitchToAgent(agent); else onAnotherWorkflow"
[agentInfo]="agent"
[isActive]="activeAgentId === agent.id"></texera-agent-chat>
+ <!-- An agent that works on another workflow has no chat here:
chatting with it would
+ load its workflow into this canvas. Its tab says where the chat
is instead. Only
+ such an agent reaches this template, so its delegate is set.
The link is a plain
+ one, so that the browser loads the page: the workspace reads
the workflow's id
+ from its address only when it is created, and the router would
keep the same
+ workspace for another workflow's address. -->
+ <ng-template #onAnotherWorkflow>
+ <div
+ *ngIf="agent.delegate!.workflowId as workflowId"
+ class="other-workflow-notice">
+ <p>
+ This agent is working on a different workflow: {{
agent.delegate!.workflowName || "#" + workflowId }}.
+ </p>
+ <a
+ nz-button
+ nzType="primary"
+ [href]="workspaceCanvasUrl(workflowId)">
+ Open that workflow
+ </a>
Review Comment:
Thanks. Right, after the reload the panel opens on "+ Agent", so the chat is
one more click away. Opening the agent's tab on arrival, and a workspace that
follows `paramMap` so this can be a `routerLink`, both fit a follow-up better.
##########
frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.ts:
##########
@@ -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;
}
Review Comment:
Renamed. I went with `isOnAnotherWorkflow`, the opposite check, because an
agent bound to no workflow also gets its chat here, and "on the open workflow"
would not describe it. It also drops three negations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]