From 06ad4681fb8a86a3775c067379a61ef0868a6c49 Mon Sep 17 00:00:00 2001 From: James Rushford Date: Wed, 27 Aug 2025 17:22:17 +0200 Subject: [PATCH 1/6] Use URL params for forking agent/flow --- .../components/ai_catalog_item_drawer.vue | 81 ++++++++++++++++--- .../catalog/pages/ai_catalog_agents_new.vue | 24 ++++++ .../ai/catalog/pages/ai_catalog_flows_new.vue | 22 +++++ locale/gitlab.pot | 6 ++ 4 files changed, 123 insertions(+), 10 deletions(-) diff --git a/ee/app/assets/javascripts/ai/catalog/components/ai_catalog_item_drawer.vue b/ee/app/assets/javascripts/ai/catalog/components/ai_catalog_item_drawer.vue index 9c66f831b86773..ff949898900394 100644 --- a/ee/app/assets/javascripts/ai/catalog/components/ai_catalog_item_drawer.vue +++ b/ee/app/assets/javascripts/ai/catalog/components/ai_catalog_item_drawer.vue @@ -4,6 +4,7 @@ import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { DRAWER_Z_INDEX } from '~/lib/utils/constants'; import { getContentWrapperHeight } from '~/lib/utils/dom_utils'; import { AI_CATALOG_TYPE_AGENT, AI_CATALOG_TYPE_FLOW } from '../constants'; +import { AI_CATALOG_AGENTS_NEW_ROUTE, AI_CATALOG_FLOWS_NEW_ROUTE } from '../router/constants'; import AiCatalogAgentDetails from './ai_catalog_agent_details.vue'; import AiCatalogFlowDetails from './ai_catalog_flow_details.vue'; @@ -56,6 +57,54 @@ export default { detailsComponent() { return DETAILS_COMPONENT_MAP[this.activeItem.itemType]; }, + duplicateRoute() { + switch (this.activeItem.itemType) { + case AI_CATALOG_TYPE_AGENT: + return AI_CATALOG_AGENTS_NEW_ROUTE; + + case AI_CATALOG_TYPE_FLOW: + return AI_CATALOG_FLOWS_NEW_ROUTE; + + default: + return null; + } + }, + duplicateRouteParams() { + if (!this.duplicateRoute || !this.activeItem) { + return {}; + } + + const baseParams = { + projectId: this.activeItem.project?.id, + // eslint-disable-next-line @gitlab/require-i18n-strings + name: `${this.activeItem.name} (Copy)`, + description: this.activeItem.description, + public: this.activeItem.public, + }; + + if (this.activeItem.itemType === AI_CATALOG_TYPE_AGENT) { + return { + ...baseParams, + systemPrompt: this.activeItem.latestVersion?.systemPrompt || '', + userPrompt: this.activeItem.latestVersion?.userPrompt || '', + tools: JSON.stringify(this.activeItem.latestVersion?.tools?.nodes.map((t) => t.id) || []), + }; + } + + if (this.activeItem.itemType === AI_CATALOG_TYPE_FLOW) { + return { + ...baseParams, + steps: JSON.stringify( + this.activeItem.latestVersion?.steps?.nodes.map((s) => ({ + id: s.agent.id, + name: s.agent.name, + })) || [], + ), + }; + } + + return baseParams; + }, }, DRAWER_Z_INDEX, }; @@ -74,16 +123,28 @@ export default {

{{ activeItem.name }}

- +
+ + +