feat(workflow): render a PRD's generated view on the plan approval card
agent.run gains views: the agent may return an OpenUI Lang view of its answer through an optional view tool, read as steps.<id>.view. human.approve stores it as the task's plan_view, and the approval card renders it with the dashboard's own components, falling back to the plan text when there is no view or it does not parse. The feasibility prd step uses it.
This commit is contained in:
1 parent
cae19ca42e
commit
54a78175b4
34 files changed
+1035
-153
No files matched your search
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
const activeTasksByOrigin = `-- name: ActiveTasksByOrigin :many
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status FROM tasks
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_view FROM tasks
|
||||
WHERE origin = $1 AND origin <> '' AND status IN ('queued', 'running') AND ($2::text IS NULL OR org_id = $2)
|
||||
ORDER BY id
|
||||
`
|
||||
@@ -84,6 +84,7 @@ func (q *Queries) ActiveTasksByOrigin(ctx context.Context, arg ActiveTasksByOrig
|
||||
&i.BindingAddr,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanView,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -163,7 +164,7 @@ func (q *Queries) BeginRemediationTask(ctx context.Context, arg BeginRemediation
|
||||
const claimByIssue = `-- name: ClaimByIssue :one
|
||||
UPDATE tasks SET status = 'running', attempt = attempt + 1, outputs = '', updated_at = now()
|
||||
WHERE owner = $1 AND repo = $2 AND issue_number = $3 AND status = 'queued'
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_view
|
||||
`
|
||||
|
||||
type ClaimByIssueParams struct {
|
||||
@@ -228,6 +229,7 @@ func (q *Queries) ClaimByIssue(ctx context.Context, arg ClaimByIssueParams) (Tas
|
||||
&i.BindingAddr,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanView,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -242,7 +244,7 @@ WHERE id = (
|
||||
FOR UPDATE SKIP LOCKED
|
||||
LIMIT 1
|
||||
)
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_view
|
||||
`
|
||||
|
||||
// FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two
|
||||
@@ -305,6 +307,7 @@ func (q *Queries) ClaimNextTask(ctx context.Context) (Task, error) {
|
||||
&i.BindingAddr,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanView,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -422,7 +425,7 @@ FROM number, (SELECT COALESCE(
|
||||
'org-sys'
|
||||
) AS id) AS owner_org
|
||||
WHERE $11::text IS NULL OR owner_org.id = $11
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_view
|
||||
`
|
||||
|
||||
type InsertChatTaskParams struct {
|
||||
@@ -519,6 +522,7 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams)
|
||||
&i.BindingAddr,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanView,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -602,7 +606,7 @@ func (q *Queries) ListOpenPRs(ctx context.Context, scopeOrg pgtype.Text) ([]List
|
||||
const listTaskSummaries = `-- name: ListTaskSummaries :many
|
||||
SELECT id, owner, repo, issue_number, title, status, workflow,
|
||||
pr_number, tokens_used, iterations, attempt, park_reason, retry_count,
|
||||
created_at, updated_at, plan, source, identity, binding_id, binding_version,
|
||||
created_at, updated_at, plan, plan_view, source, identity, binding_id, binding_version,
|
||||
outputs, review_gate, rereview_rounds
|
||||
FROM tasks
|
||||
WHERE ($1::text IS NULL OR org_id = $1)
|
||||
@@ -640,6 +644,7 @@ type ListTaskSummariesRow struct {
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Plan string
|
||||
PlanView string
|
||||
Source string
|
||||
Identity string
|
||||
BindingID string
|
||||
@@ -691,6 +696,7 @@ func (q *Queries) ListTaskSummaries(ctx context.Context, arg ListTaskSummariesPa
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Plan,
|
||||
&i.PlanView,
|
||||
&i.Source,
|
||||
&i.Identity,
|
||||
&i.BindingID,
|
||||
@@ -1000,7 +1006,7 @@ func (q *Queries) StampTaskBinding(ctx context.Context, arg StampTaskBindingPara
|
||||
}
|
||||
|
||||
const taskByID = `-- name: TaskByID :one
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status FROM tasks WHERE id = $1 AND ($2::text IS NULL OR org_id = $2)
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_view FROM tasks WHERE id = $1 AND ($2::text IS NULL OR org_id = $2)
|
||||
`
|
||||
|
||||
type TaskByIDParams struct {
|
||||
@@ -1062,12 +1068,13 @@ func (q *Queries) TaskByID(ctx context.Context, arg TaskByIDParams) (Task, error
|
||||
&i.BindingAddr,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanView,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const taskByIssue = `-- name: TaskByIssue :one
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_view FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3
|
||||
AND ($4::text IS NULL OR org_id = $4)
|
||||
`
|
||||
|
||||
@@ -1137,12 +1144,13 @@ func (q *Queries) TaskByIssue(ctx context.Context, arg TaskByIssueParams) (Task,
|
||||
&i.BindingAddr,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanView,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const taskByPR = `-- name: TaskByPR :one
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_view FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4
|
||||
AND ($5::text IS NULL OR org_id = $5)
|
||||
`
|
||||
|
||||
@@ -1217,6 +1225,7 @@ func (q *Queries) TaskByPR(ctx context.Context, arg TaskByPRParams) (Task, error
|
||||
&i.BindingAddr,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanView,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -1256,7 +1265,7 @@ func (q *Queries) TransitionTask(ctx context.Context, arg TransitionTaskParams)
|
||||
}
|
||||
|
||||
const unpostedOutcomes = `-- name: UnpostedOutcomes :many
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status FROM tasks
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_view FROM tasks
|
||||
WHERE origin <> '' AND outcome_posted_status <> status
|
||||
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
|
||||
AND ($1::text IS NULL OR org_id = $1)
|
||||
@@ -1326,6 +1335,7 @@ func (q *Queries) UnpostedOutcomes(ctx context.Context, scopeOrg pgtype.Text) ([
|
||||
&i.BindingAddr,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanView,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1338,22 +1348,23 @@ func (q *Queries) UnpostedOutcomes(ctx context.Context, scopeOrg pgtype.Text) ([
|
||||
}
|
||||
|
||||
const updateTask = `-- name: UpdateTask :exec
|
||||
UPDATE tasks SET workflow = $1, branch = $2, plan = $3, notes = $4,
|
||||
pr_number = $5, tokens_used = $6, iterations = $7, park_reason = $8,
|
||||
watch_comment_id = $9, retry_count = $10, remediation_rounds = $11,
|
||||
review_payload = $12,
|
||||
workflow_definition_version = CASE WHEN $13::text = '' THEN workflow_definition_version ELSE $14 END,
|
||||
workflow_definition_digest = CASE WHEN $13::text = '' THEN workflow_definition_digest ELSE $15 END,
|
||||
workflow_definition_yaml = CASE WHEN $13::text = '' THEN workflow_definition_yaml ELSE $13::text END,
|
||||
outputs = $16, review_gate = $17, rereview_rounds = $18,
|
||||
retry_mode = $19, updated_at = now()
|
||||
WHERE id = $20
|
||||
UPDATE tasks SET workflow = $1, branch = $2, plan = $3, plan_view = $4, notes = $5,
|
||||
pr_number = $6, tokens_used = $7, iterations = $8, park_reason = $9,
|
||||
watch_comment_id = $10, retry_count = $11, remediation_rounds = $12,
|
||||
review_payload = $13,
|
||||
workflow_definition_version = CASE WHEN $14::text = '' THEN workflow_definition_version ELSE $15 END,
|
||||
workflow_definition_digest = CASE WHEN $14::text = '' THEN workflow_definition_digest ELSE $16 END,
|
||||
workflow_definition_yaml = CASE WHEN $14::text = '' THEN workflow_definition_yaml ELSE $14::text END,
|
||||
outputs = $17, review_gate = $18, rereview_rounds = $19,
|
||||
retry_mode = $20, updated_at = now()
|
||||
WHERE id = $21
|
||||
`
|
||||
|
||||
type UpdateTaskParams struct {
|
||||
Workflow string
|
||||
Branch string
|
||||
Plan string
|
||||
PlanView string
|
||||
Notes string
|
||||
PrNumber int64
|
||||
TokensUsed int64
|
||||
@@ -1380,6 +1391,7 @@ func (q *Queries) UpdateTask(ctx context.Context, arg UpdateTaskParams) error {
|
||||
arg.Workflow,
|
||||
arg.Branch,
|
||||
arg.Plan,
|
||||
arg.PlanView,
|
||||
arg.Notes,
|
||||
arg.PrNumber,
|
||||
arg.TokensUsed,
|
||||
|
||||
Reference in new issue
Block a user