diff --git a/api/openapi-v2.json b/api/openapi-v2.json index 5a9e09bd5..cf6ae782d 100644 --- a/api/openapi-v2.json +++ b/api/openapi-v2.json @@ -18860,6 +18860,11 @@ "description": "The creator name value.", "type": "string" }, + "current_revision_id": { + "description": "The current revision id value.", + "nullable": true, + "type": "integer" + }, "description": { "description": "The description value.", "type": "string" @@ -33284,6 +33289,11 @@ "nullable": true, "type": "string" }, + "definition_revision_id": { + "description": "The definition revision id value.", + "nullable": true, + "type": "integer" + }, "duration_ms": { "description": "The duration ms value.", "nullable": true, @@ -33401,6 +33411,11 @@ "description": "The creator name value.", "type": "string" }, + "current_revision_id": { + "description": "The current revision id value.", + "nullable": true, + "type": "integer" + }, "description": { "description": "The description value.", "type": "string" @@ -33558,6 +33573,313 @@ ], "type": "object" }, + "GetWorkspacesWorkspaceIdActionsActionIdRevisionsResult": { + "additionalProperties": false, + "properties": { + "data": { + "items": { + "additionalProperties": false, + "properties": { + "action_id": { + "description": "The action id value.", + "type": "integer" + }, + "change_summary": { + "description": "The change summary value.", + "type": "string" + }, + "changed_fields": { + "description": "The changed fields value.", + "items": { + "type": "string" + }, + "type": "array" + }, + "created_at": { + "description": "The created at value.", + "format": "date-time", + "type": "string" + }, + "editor_source": { + "description": "The editor source value.", + "type": "string" + }, + "editor_user_id": { + "description": "The editor user id value.", + "nullable": true, + "type": "integer" + }, + "editor_username": { + "description": "The editor username value.", + "type": "string" + }, + "id": { + "description": "The id value.", + "type": "integer" + }, + "revision_number": { + "description": "The revision number value.", + "type": "integer" + }, + "source": { + "description": "The source value.", + "type": "string" + }, + "workspace_id": { + "description": "The workspace id value.", + "type": "integer" + } + }, + "required": [ + "action_id", + "changed_fields", + "created_at", + "id", + "revision_number", + "source", + "workspace_id" + ], + "type": "object" + }, + "type": "array" + }, + "pagination": { + "$ref": "#/components/schemas/Pagination" + } + }, + "required": [ + "data", + "pagination" + ], + "type": "object" + }, + "GetWorkspacesWorkspaceIdActionsActionIdRevisionsRevisionIdResult": { + "additionalProperties": false, + "properties": { + "data": { + "additionalProperties": false, + "nullable": true, + "properties": { + "action_id": { + "description": "The action id value.", + "type": "integer" + }, + "change_summary": { + "description": "The change summary value.", + "type": "string" + }, + "changed_fields": { + "description": "The changed fields value.", + "items": { + "type": "string" + }, + "type": "array" + }, + "created_at": { + "description": "The created at value.", + "format": "date-time", + "type": "string" + }, + "editor_source": { + "description": "The editor source value.", + "type": "string" + }, + "editor_user_id": { + "description": "The editor user id value.", + "nullable": true, + "type": "integer" + }, + "editor_username": { + "description": "The editor username value.", + "type": "string" + }, + "id": { + "description": "The id value.", + "type": "integer" + }, + "revision_number": { + "description": "The revision number value.", + "type": "integer" + }, + "snapshot": { + "additionalProperties": false, + "description": "The snapshot value.", + "properties": { + "actor_user_id": { + "description": "The actor user id value.", + "nullable": true, + "type": "integer" + }, + "allowed_role_ids": { + "description": "The allowed role ids value.", + "items": { + "type": "integer" + }, + "type": "array" + }, + "description": { + "description": "The description value.", + "type": "string" + }, + "edges": { + "description": "The edges value.", + "items": { + "additionalProperties": false, + "properties": { + "action_id": { + "description": "The action id value.", + "type": "integer" + }, + "created_at": { + "description": "The created at value.", + "format": "date-time", + "type": "string" + }, + "edge_type": { + "description": "The edge type value.", + "type": "string" + }, + "id": { + "description": "The id value.", + "type": "integer" + }, + "source_handle": { + "description": "The source handle value.", + "type": "string" + }, + "source_node_id": { + "description": "The source node id value.", + "type": "integer" + }, + "target_handle": { + "description": "The target handle value.", + "type": "string" + }, + "target_node_id": { + "description": "The target node id value.", + "type": "integer" + } + }, + "required": [ + "action_id", + "created_at", + "edge_type", + "id", + "source_node_id", + "target_node_id" + ], + "type": "object" + }, + "type": "array" + }, + "is_enabled": { + "description": "The is enabled value.", + "type": "boolean" + }, + "name": { + "description": "The name value.", + "type": "string" + }, + "nodes": { + "description": "The nodes value.", + "items": { + "additionalProperties": false, + "properties": { + "action_id": { + "description": "The action id value.", + "type": "integer" + }, + "created_at": { + "description": "The created at value.", + "format": "date-time", + "type": "string" + }, + "id": { + "description": "The id value.", + "type": "integer" + }, + "node_config": { + "description": "The node config value.", + "type": "string" + }, + "node_type": { + "description": "The node type value.", + "type": "string" + }, + "position_x": { + "description": "The position x value.", + "type": "number" + }, + "position_y": { + "description": "The position y value.", + "type": "number" + }, + "updated_at": { + "description": "The updated at value.", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "action_id", + "created_at", + "id", + "node_config", + "node_type", + "position_x", + "position_y", + "updated_at" + ], + "type": "object" + }, + "type": "array" + }, + "trigger_config": { + "description": "The trigger config value.", + "type": "string" + }, + "trigger_type": { + "description": "The trigger type value.", + "type": "string" + } + }, + "required": [ + "allowed_role_ids", + "edges", + "is_enabled", + "name", + "nodes", + "trigger_type" + ], + "type": "object" + }, + "source": { + "description": "The source value.", + "type": "string" + }, + "workspace_id": { + "description": "The workspace id value.", + "type": "integer" + } + }, + "required": [ + "action_id", + "changed_fields", + "created_at", + "id", + "revision_number", + "snapshot", + "source", + "workspace_id" + ], + "type": "object" + } + }, + "required": [ + "data" + ], + "type": "object" + }, "GetWorkspacesWorkspaceIdActionsResult": { "additionalProperties": false, "properties": { @@ -33596,6 +33918,11 @@ "description": "The creator name value.", "type": "string" }, + "current_revision_id": { + "description": "The current revision id value.", + "nullable": true, + "type": "integer" + }, "description": { "description": "The description value.", "type": "string" @@ -49267,6 +49594,11 @@ "description": "The creator name value.", "type": "string" }, + "current_revision_id": { + "description": "The current revision id value.", + "nullable": true, + "type": "integer" + }, "description": { "description": "The description value.", "type": "string" @@ -60670,6 +61002,11 @@ "description": "The creator name value.", "type": "string" }, + "current_revision_id": { + "description": "The current revision id value.", + "nullable": true, + "type": "integer" + }, "description": { "description": "The description value.", "type": "string" @@ -91364,6 +91701,11 @@ "description": "The creator name value.", "type": "string" }, + "current_revision_id": { + "description": "The current revision id value.", + "nullable": true, + "type": "integer" + }, "description": { "description": "The description value.", "type": "string" @@ -124761,6 +125103,173 @@ ] } }, + "/workspaces/{workspace_id}/actions/{action_id}/revisions": { + "get": { + "description": "List action definition revisions. Results include only resources visible to the authenticated caller; collections use their documented stable order and bounds.", + "operationId": "getWorkspacesWorkspaceIdActionsActionIdRevisions", + "parameters": [ + { + "description": "The workspace identifier.", + "in": "path", + "name": "workspace_id", + "required": true, + "schema": { + "minimum": 1, + "type": "integer" + } + }, + { + "description": "The action identifier.", + "in": "path", + "name": "action_id", + "required": true, + "schema": { + "minimum": 1, + "type": "integer" + } + }, + { + "description": "One-based page number.", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Maximum number of resources to return.", + "in": "query", + "name": "page_size", + "required": false, + "schema": { + "default": 50, + "maximum": 1000, + "minimum": 1, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetWorkspacesWorkspaceIdActionsActionIdRevisionsResult" + } + } + }, + "description": "List action definition revisions response." + }, + "401": { + "$ref": "#/components/responses/AuthenticationError" + }, + "403": { + "$ref": "#/components/responses/PermissionError" + }, + "404": { + "$ref": "#/components/responses/NotFoundError" + }, + "429": { + "$ref": "#/components/responses/RateLimitError" + }, + "500": { + "$ref": "#/components/responses/InternalError" + } + }, + "security": [ + { + "BearerAuth": [] + } + ], + "summary": "List action definition revisions", + "tags": [ + "Automation" + ], + "x-required-scopes": [ + "actions:read" + ] + } + }, + "/workspaces/{workspace_id}/actions/{action_id}/revisions/{revision_id}": { + "get": { + "description": "Get an action definition revision. Results include only resources visible to the authenticated caller; collections use their documented stable order and bounds.", + "operationId": "getWorkspacesWorkspaceIdActionsActionIdRevisionsRevisionId", + "parameters": [ + { + "description": "The workspace identifier.", + "in": "path", + "name": "workspace_id", + "required": true, + "schema": { + "minimum": 1, + "type": "integer" + } + }, + { + "description": "The action identifier.", + "in": "path", + "name": "action_id", + "required": true, + "schema": { + "minimum": 1, + "type": "integer" + } + }, + { + "description": "The definition revision identifier.", + "in": "path", + "name": "revision_id", + "required": true, + "schema": { + "minimum": 1, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetWorkspacesWorkspaceIdActionsActionIdRevisionsRevisionIdResult" + } + } + }, + "description": "Get an action definition revision response." + }, + "401": { + "$ref": "#/components/responses/AuthenticationError" + }, + "403": { + "$ref": "#/components/responses/PermissionError" + }, + "404": { + "$ref": "#/components/responses/NotFoundError" + }, + "429": { + "$ref": "#/components/responses/RateLimitError" + }, + "500": { + "$ref": "#/components/responses/InternalError" + } + }, + "security": [ + { + "BearerAuth": [] + } + ], + "summary": "Get an action definition revision", + "tags": [ + "Automation" + ], + "x-required-scopes": [ + "actions:read" + ] + } + }, "/workspaces/{workspace_id}/agent-runs": { "get": { "description": "Returns at most 200 visible agent runs in stable newest-first ID order. next_cursor resumes exclusively before the final returned run; private verification runs and unauthorized runs are omitted.", diff --git a/frontend/src/lib/api/actions.js b/frontend/src/lib/api/actions.js index 36b104a0d..57754ea9a 100644 --- a/frontend/src/lib/api/actions.js +++ b/frontend/src/lib/api/actions.js @@ -57,6 +57,13 @@ export const actions = { }), getLogs: (workspaceId, actionId) => fetchAllV2Pages(`/workspaces/${workspaceId}/actions/${actionId}/logs`), + // Definition history: immutable, attributable revisions of the executable + // configuration. Listing returns metadata; getRevision returns the full + // snapshot so an operator can reconstruct what actually ran. + getRevisions: (workspaceId, actionId) => + fetchAllV2Pages(`/workspaces/${workspaceId}/actions/${actionId}/revisions`), + getRevision: (workspaceId, actionId, revisionId) => + fetchV2Data(`/workspaces/${workspaceId}/actions/${actionId}/revisions/${revisionId}`), }; // Action templates: read-only registry shipped with the binary, plus diff --git a/frontend/src/lib/features/actions/ActionHistory.svelte b/frontend/src/lib/features/actions/ActionHistory.svelte new file mode 100644 index 000000000..e9a1b7f7d --- /dev/null +++ b/frontend/src/lib/features/actions/ActionHistory.svelte @@ -0,0 +1,307 @@ + + +
+
+ +
+

{t('actions.history.title')}

+

{action.name}

+
+
+ +
+ {#if loading} + + {:else} + ({ 'data-testid': `action-history-row-${item.id}` })} + > + {#snippet source(item)} + {sourceLabel(item.source)} + {/snippet} + + {#snippet editor(item)} + {#if item.editor_username} + {item.editor_username} + {:else} + {t('actions.history.system')} + {/if} + {/snippet} + + {#snippet changed(item)} + {changedFields(item)} + {/snippet} + + {#snippet date(item)} + {formatDate(item.created_at)} + {/snippet} + + {#snippet details(item)} + + {/snippet} + + {/if} +
+
+ +{#if selectedRevision} + + +
+ {#if detailLoading} + + {:else} +
+ {sourceLabel(selectedRevision.source)} + + {selectedRevision.editor_username || t('actions.history.system')} + + {formatDate(selectedRevision.created_at)} +
+ +
+
{t('actions.history.changedFields')}
+
+ {changedFields(selectedRevision)} +
+
+ +
+
{t('actions.history.snapshot')}
+
+
+ {t('common.name')} + + {selectedRevision.snapshot?.name} + +
+
+ {t('actions.history.triggerType', 'Trigger')} + {selectedRevision.snapshot?.trigger_type} +
+
+ {t('actions.history.nodes')} + + {selectedRevision.snapshot?.nodes?.length ?? 0} + +
+
+ {t('actions.history.edges')} + + {selectedRevision.snapshot?.edges?.length ?? 0} + +
+
+
+ +
+
{t('actions.history.nodes')}
+
    + {#each selectedRevision.snapshot?.nodes ?? [] as node, index} +
  • + {node.node_type} + {node.node_config} +
  • + {/each} +
+
+ {/if} +
+
+{/if} + + diff --git a/frontend/src/lib/features/actions/ActionsManager.svelte b/frontend/src/lib/features/actions/ActionsManager.svelte index d2847bfc2..335c39b39 100644 --- a/frontend/src/lib/features/actions/ActionsManager.svelte +++ b/frontend/src/lib/features/actions/ActionsManager.svelte @@ -10,6 +10,7 @@ import Play from '@lucide/svelte/icons/play'; import Zap from '@lucide/svelte/icons/zap'; import MoreHorizontal from '@lucide/svelte/icons/more-horizontal'; + import History from '@lucide/svelte/icons/history'; import Pencil from '@lucide/svelte/icons/pencil'; import Copy from '@lucide/svelte/icons/copy'; import Trash2 from '@lucide/svelte/icons/trash-2'; @@ -18,7 +19,7 @@ import PageHeader from '../../layout/PageHeader.svelte'; import Badge from '../../components/Badge.svelte'; - /** @type {{ workspaceId: any, actions?: any[], loading?: boolean, oncreate?: () => void, onfromtemplate?: () => void, onedit?: (action: any) => void, onrename?: (action: any) => void, onduplicate?: (action: any) => void, ontoggle?: (action: any) => void, ondelete?: (action: any) => void, onviewlogs?: (action: any) => void, ontestexecuted?: (action: any) => void }} */ + /** @type {{ workspaceId: any, actions?: any[], loading?: boolean, oncreate?: () => void, onfromtemplate?: () => void, onedit?: (action: any) => void, onrename?: (action: any) => void, onduplicate?: (action: any) => void, ontoggle?: (action: any) => void, ondelete?: (action: any) => void, onviewlogs?: (action: any) => void, onviewhistory?: (action: any) => void, ontestexecuted?: (action: any) => void }} */ let { workspaceId, actions = [], @@ -31,6 +32,7 @@ ontoggle, ondelete, onviewlogs, + onviewhistory, ontestexecuted, } = $props(); @@ -96,6 +98,10 @@ onviewlogs?.(action); } + function handleViewHistory(action) { + onviewhistory?.(action); + } + function moreItems(action) { return [ ...(onrename ? [{ id: 'rename', title: t('actions.rename'), icon: Pencil, testid: `action-rename-${action.id}`, onClick: () => onrename(action) }] : []), @@ -204,6 +210,14 @@ +