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

@@ -102,10 +102,11 @@ WHERE origin = sqlc.arg(origin) AND origin <> '' AND status IN ('queued', 'runni
ORDER BY id;
-- name: UnpostedOutcomes :many
-- 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.
SELECT * 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 (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
ORDER BY id
LIMIT 50;
@@ -151,8 +152,11 @@ SELECT status FROM tasks WHERE id = $1 FOR UPDATE;
-- name: TransitionTask :execrows
-- 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.
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,