Skip to content

Commit 9f23da8

Browse files
rllyy97Copilot
andauthored
feat(DesignerV2): Standard Draft A2A, Consumption Draft Req, Tree log bugs (#8700)
* Updated draft a2a chat iframe endpoint * Added iframe with headers as test * Small changes * Updated draft a2a chat iframe endpoint, consumption run support * Fixed a few small tree view / log bugs * -wip * Added test * Update apps/Standalone/src/designer/app/AzureLogicAppsDesigner/Services/WorkflowAndArtifacts.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update apps/Standalone/src/designer/app/AzureLogicAppsDesigner/laDesignerConsumptionV2.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Added more tests --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b44f666 commit 9f23da8

File tree

14 files changed

+1447
-45
lines changed

14 files changed

+1447
-45
lines changed

apps/Standalone/src/designer/app/AzureLogicAppsDesigner/Services/WorkflowAndArtifacts.tsx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,16 @@ const getAllCustomCodeFiles = async (
163163
return customCodeFiles;
164164
};
165165

166-
export const useWorkflowAndArtifactsConsumption = (workflowId: string) => {
167-
return useQuery(['workflowArtifactsConsumption', workflowId], () => getWorkflowAndArtifactsConsumption(workflowId), {
166+
export const useWorkflowAndArtifactsConsumption = (workflowId: string, isDraft = false) => {
167+
return useQuery(['workflowArtifactsConsumption', workflowId, isDraft], () => getWorkflowAndArtifactsConsumption(workflowId, isDraft), {
168168
refetchOnMount: false,
169169
refetchOnReconnect: false,
170170
refetchOnWindowFocus: false,
171171
});
172172
};
173173

174-
export const getWorkflowAndArtifactsConsumption = async (workflowId: string): Promise<Workflow> => {
175-
const uri = `${baseUrl}${workflowId}?api-version=${consumptionApiVersion}`;
174+
export const getWorkflowAndArtifactsConsumption = async (workflowId: string, isDraft = false): Promise<Workflow> => {
175+
const uri = `${baseUrl}${workflowId}${isDraft ? '/drafts/default' : ''}?api-version=${consumptionApiVersion}`;
176176
const response = await axios.get(uri, {
177177
headers: {
178178
Authorization: `Bearer ${environment.armToken}`,
@@ -425,6 +425,7 @@ export const fetchAgentUrl = (siteResourceId: string, workflowName: string, host
425425

426426
try {
427427
let queryParams: AgentQueryParams | undefined = undefined;
428+
let a2aKey = '';
428429
let a2aCodeForDraft = '';
429430
const authentication = await fetchAuthentication(siteResourceId);
430431

@@ -440,7 +441,7 @@ export const fetchAgentUrl = (siteResourceId: string, workflowName: string, host
440441
const oboData = await fetchOBOData(siteResourceId);
441442

442443
// Add authentication tokens if available
443-
const a2aKey = a2aData?.key;
444+
a2aKey = a2aData?.key;
444445
if (a2aKey) {
445446
queryParams = { apiKey: a2aKey };
446447

@@ -453,13 +454,30 @@ export const fetchAgentUrl = (siteResourceId: string, workflowName: string, host
453454
}
454455

455456
const agentBaseUrl = hostName.startsWith('https://') ? hostName : `https://${hostName}`;
457+
456458
const agentUrl = `${agentBaseUrl}/api/Agents/${workflowName}`;
457-
const agentCardUrlForDraft = `${agentBaseUrl}/runtime/webhooks/workflow/scaleUnits/prod-00/agents/${workflowName}/draft/.well-known/agent-card.json${a2aCodeForDraft ? `${encodeURIComponent(`?${a2aCodeForDraft}`)}` : ''}`;
458-
const chatUrl = `${agentBaseUrl}/api/agentsChat/${workflowName}/IFrame${isDraftMode ? `?agentCard=${agentCardUrlForDraft}` : ''}`;
459+
const prodChatUrl = `${agentBaseUrl}/api/agentsChat/${workflowName}/IFrame`;
460+
461+
const agentCardUrlForDraft = new URL(
462+
`${agentBaseUrl}/runtime/webhooks/workflow/scaleUnits/prod-00/agents/${workflowName}/draft/.well-known/agent-card.json`
463+
);
464+
if (a2aKey) {
465+
agentCardUrlForDraft.searchParams.append('x-api-key', a2aKey);
466+
}
467+
if (a2aCodeForDraft) {
468+
const codeParamParts = a2aCodeForDraft.split('=');
469+
if (codeParamParts.length > 1 && codeParamParts[1]) {
470+
agentCardUrlForDraft.searchParams.append('code', decodeURIComponent(codeParamParts[1]));
471+
}
472+
}
473+
474+
const draftChatUrl = new URL(`${agentBaseUrl}/api/draftAgentsChat/${workflowName}/IFrame`);
475+
draftChatUrl.searchParams.append('api-version', '2022-05-01');
476+
draftChatUrl.searchParams.append('agentCard', agentCardUrlForDraft.href);
459477

460478
return {
461-
agentUrl,
462-
chatUrl,
479+
agentUrl: agentUrl,
480+
chatUrl: isDraftMode ? draftChatUrl.href : prodChatUrl,
463481
queryParams,
464482
hostName,
465483
};

apps/Standalone/src/designer/app/AzureLogicAppsDesigner/laDesignerConsumptionV2.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ const DesignerEditorConsumption = () => {
9292
isError: isWorkflowAndArtifactsError,
9393
error: workflowAndArtifactsError,
9494
} = useWorkflowAndArtifactsConsumption(workflowId);
95+
96+
const {
97+
workflow: prodWorkflow,
98+
connectionReferences,
99+
parameters,
100+
notes,
101+
} = useMemo(() => getDataForConsumption(workflowAndArtifactsData), [workflowAndArtifactsData]);
102+
103+
const { data: draftWorkflowAndArtifactsData, isFetching: isDraftWorkflowAndArtifactsLoading } = useWorkflowAndArtifactsConsumption(
104+
workflowId,
105+
true
106+
);
107+
108+
const { workflow: draftWorkflow } = useMemo(() => getDataForConsumption(draftWorkflowAndArtifactsData), [draftWorkflowAndArtifactsData]);
109+
95110
const { data: runInstanceData } = useRunInstanceConsumption(workflowName, appId, runId);
96111

97112
const { data: tenantId } = useCurrentTenantId();
@@ -109,15 +124,6 @@ const DesignerEditorConsumption = () => {
109124
setIsDraftMode(draftMode);
110125
}, []);
111126

112-
const {
113-
workflow: prodWorkflow,
114-
connectionReferences,
115-
parameters,
116-
notes,
117-
} = useMemo(() => getDataForConsumption(workflowAndArtifactsData), [workflowAndArtifactsData]);
118-
// TODO: Implement draft workflow fetching properly
119-
const draftWorkflow = useMemo(() => prodWorkflow, [prodWorkflow]);
120-
121127
const [definition, setDefinition] = useState<any>();
122128
const codeEditorRef = useRef<{ getValue: () => string | undefined; hasChanges: () => boolean }>(null);
123129

@@ -371,7 +377,7 @@ const DesignerEditorConsumption = () => {
371377
}, [isMonitoringView, runInstanceData]);
372378

373379
useEffect(() => {
374-
if (isWorkflowAndArtifactsLoading || !prodWorkflow) {
380+
if (isWorkflowAndArtifactsLoading || !prodWorkflow || isDraftWorkflowAndArtifactsLoading) {
375381
return;
376382
}
377383

@@ -384,7 +390,7 @@ const DesignerEditorConsumption = () => {
384390
} else {
385391
setWorkflow(prodWorkflow as any);
386392
}
387-
}, [isWorkflowAndArtifactsLoading, draftWorkflow, isDraftMode, prodWorkflow, resetDraftWorkflow]);
393+
}, [isWorkflowAndArtifactsLoading, draftWorkflow, isDraftMode, prodWorkflow, isDraftWorkflowAndArtifactsLoading]);
388394

389395
if (isWorkflowAndArtifactsError) {
390396
throw workflowAndArtifactsError;
@@ -470,7 +476,8 @@ const DesignerEditorConsumption = () => {
470476
saveDraftWorkflow={saveWorkflowFromDesigner}
471477
onRun={onRun}
472478
isDarkMode={isDarkMode}
473-
isDraftMode={false} // TODO: Support draft mode runs once backend is ready
479+
isDraftMode={isDraftMode}
480+
isConsumption={true}
474481
/>
475482
</div>
476483
)}

0 commit comments

Comments
 (0)