feat(archied): post approval requests to the chat that started the task

This commit is contained in:
sam committed 2026-10-24 23:59:25 +11:00
1 parent 28033a25e9
commit 348c08cebb
3 files changed
+22 -4

No files matched your search

@@ -1216,6 +1216,7 @@ func (q *Queries) TaskByPR(ctx context.Context, arg TaskByPRParams) (Task, error
const transitionTask = `-- name: TransitionTask :execrows
UPDATE tasks
SET status = $2,
outcome_posted = CASE WHEN status = 'waiting_approval' THEN false ELSE outcome_posted END,
park_reason = CASE WHEN $2 = 'parked' THEN $3 ELSE park_reason END,
park_class = CASE WHEN $2 = 'parked' THEN $4 ELSE park_class END,
park_blocker = CASE WHEN $2 = 'parked' THEN '' ELSE park_blocker END,
@@ -1233,6 +1234,8 @@ type TransitionTaskParams struct {
// Arriving at 'parked' also records why. The class is normalized by the
// caller, so an unknown value persists as needs_human rather than as itself.
// Leaving 'waiting_approval' clears outcome_posted: the approval request was
// posted, and the task's final outcome still has to be.
func (q *Queries) TransitionTask(ctx context.Context, arg TransitionTaskParams) (int64, error) {
result, err := q.db.Exec(ctx, transitionTask,
arg.ID,
@@ -1250,13 +1253,14 @@ 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, outcome_posted, binding_signature, binding_addr, park_blocker FROM tasks
WHERE origin <> '' AND NOT outcome_posted
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed')
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval')
AND ($1::text IS NULL OR org_id = $1)
ORDER BY id
LIMIT 50
`
// Finished chat tasks whose outcome has not reached their conversation yet.
// Chat tasks that finished or wait for approval, whose state has not reached
// their conversation yet.
func (q *Queries) UnpostedOutcomes(ctx context.Context, scopeOrg pgtype.Text) ([]Task, error) {
rows, err := q.db.Query(ctx, unpostedOutcomes, scopeOrg)
if err != nil {