feat(workflows): test-run unsaved drafts and browse workflow version history

A test run pins a validated draft, runs with forge and push writes
suppressed and recorded per step, and is excluded from workflow stats.
The History tab lists revisions that changed a workflow, diffs them as
YAML and on the canvas, restores into the editor, and ties runs to the
revision they used.
This commit is contained in:
sam committed 2026-10-13 12:27:40 +11:00
1 parent 2f05cbd34f
commit 2a066f6d4f
37 files changed
+677 -132

No files matched your search

@@ -67,19 +67,25 @@ SELECT status, count(*)::int AS count FROM tasks WHERE (sqlc.narg(scope_org)::te
-- StampTaskBinding adds only the provenance.
-- The task runs in its identity's org; a caller confined to another org
-- inserts nothing, so it cannot start work under an identity it does not own.
-- A non-empty draft_yaml makes the task a test run: it is pinned to that
-- definition and its source is 'test'.
WITH number AS (
INSERT INTO chat_issue_numbers (owner, repo, last_number)
VALUES (sqlc.arg(owner), sqlc.arg(repo), sqlc.arg(fallback_issue_number)::bigint + 1)
ON CONFLICT (owner, repo) DO UPDATE SET last_number = chat_issue_numbers.last_number + 1
RETURNING last_number
)
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, inputs, origin)
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, inputs, origin, workflow_definition_yaml, workflow_definition_digest)
SELECT
sqlc.arg(owner), sqlc.arg(repo), number.last_number,
sqlc.arg(title), sqlc.arg(body), 'chat', sqlc.arg(workflow), 'chat', sqlc.arg(identity),
sqlc.arg(title), sqlc.arg(body), 'chat', sqlc.arg(workflow),
CASE WHEN sqlc.arg(draft_yaml)::text = '' THEN 'chat' ELSE 'test' END,
sqlc.arg(identity),
owner_org.id,
sqlc.arg(inputs),
sqlc.arg(origin)
sqlc.arg(origin),
sqlc.arg(draft_yaml)::text,
sqlc.arg(draft_digest)::text
FROM number, (SELECT COALESCE(
(SELECT a.org_id FROM org_agents a WHERE a.identity_id = sqlc.arg(identity)),
(SELECT m.org_id FROM memberships m WHERE m.identity_id = sqlc.arg(identity)