feat(archied): tell the chat when its task opens a pull request
This commit is contained in:
1 parent
b006b1c943
commit
b577b02eb6
3 files changed
+19
-16
No files matched your search
@@ -106,6 +106,9 @@ func outcomeText(t *task.Task) string {
|
||||
if kind := taskstate.ApprovalKind(t.Status, t.ReviewGate); kind != "" {
|
||||
return fmt.Sprintf("Task %d (%s) needs your approval of its %s. Approve or reject it on the task page.", t.ID, t.Title, approvalNoun[kind])
|
||||
}
|
||||
if t.Status == task.StatusPROpen {
|
||||
return fmt.Sprintf("Task %d (%s) opened PR #%d for review.", t.ID, t.Title, t.PRNumber)
|
||||
}
|
||||
text := fmt.Sprintf("Task %d (%s) finished: %s", t.ID, t.Title, t.Status)
|
||||
if t.PRNumber > 0 {
|
||||
text += fmt.Sprintf(", PR #%d", t.PRNumber)
|
||||
|
||||
@@ -140,7 +140,7 @@ func (q *Queries) ArchiveTaskDelete(ctx context.Context, arg ArchiveTaskDeletePa
|
||||
}
|
||||
|
||||
const beginRemediationTask = `-- name: BeginRemediationTask :execrows
|
||||
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}', updated_at = now()
|
||||
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, outcome_posted = false, retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}', updated_at = now()
|
||||
WHERE id = $1 AND status = 'pr_open'
|
||||
`
|
||||
|
||||
@@ -788,7 +788,7 @@ func (q *Queries) ParkTask(ctx context.Context, arg ParkTaskParams) (int64, erro
|
||||
|
||||
const promotePendingReview = `-- name: PromotePendingReview :execrows
|
||||
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '',
|
||||
park_class = 'needs_human',
|
||||
park_class = 'needs_human', outcome_posted = false,
|
||||
review_payload = pending_reviews->>0, pending_reviews = pending_reviews - 0,
|
||||
retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}',
|
||||
updated_at = now()
|
||||
@@ -1216,7 +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,
|
||||
outcome_posted = CASE WHEN status IN ('waiting_approval', 'pr_open') 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,
|
||||
@@ -1234,8 +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.
|
||||
// Leaving a state the conversation was told about (an approval request, an
|
||||
// open pull request) clears outcome_posted, so the next state is posted too.
|
||||
func (q *Queries) TransitionTask(ctx context.Context, arg TransitionTaskParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, transitionTask,
|
||||
arg.ID,
|
||||
@@ -1253,14 +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', 'waiting_approval')
|
||||
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
|
||||
AND ($1::text IS NULL OR org_id = $1)
|
||||
ORDER BY id
|
||||
LIMIT 50
|
||||
`
|
||||
|
||||
// Chat tasks that finished or wait for approval, whose state has not reached
|
||||
// their conversation yet.
|
||||
// Chat tasks that finished, wait for approval or have a pull request open,
|
||||
// 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 {
|
||||
|
||||
@@ -102,11 +102,11 @@ WHERE origin = sqlc.arg(origin) AND origin <> '' AND status IN ('queued', 'runni
|
||||
ORDER BY id;
|
||||
|
||||
-- name: UnpostedOutcomes :many
|
||||
-- Chat tasks that finished or wait for approval, whose state has not reached
|
||||
-- their conversation yet.
|
||||
-- Chat tasks that finished, wait for approval or have a pull request open,
|
||||
-- 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', 'waiting_approval')
|
||||
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
|
||||
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||
ORDER BY id
|
||||
LIMIT 50;
|
||||
@@ -152,11 +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.
|
||||
-- Leaving a state the conversation was told about (an approval request, an
|
||||
-- open pull request) clears outcome_posted, so the next state is posted too.
|
||||
UPDATE tasks
|
||||
SET status = $2,
|
||||
outcome_posted = CASE WHEN status = 'waiting_approval' THEN false ELSE outcome_posted END,
|
||||
outcome_posted = CASE WHEN status IN ('waiting_approval', 'pr_open') 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,
|
||||
@@ -210,7 +210,7 @@ RETURNING *;
|
||||
-- A remediation must continue the branch its pull request lives on, so it
|
||||
-- records that dispatch mode explicitly (taskstate.RetryContinuePushedWork)
|
||||
-- rather than leaving prepareWorkspace to infer it from the workflow.
|
||||
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}', updated_at = now()
|
||||
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, outcome_posted = false, retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}', updated_at = now()
|
||||
WHERE id = $1 AND status = 'pr_open';
|
||||
|
||||
-- name: AppendPendingReview :execrows
|
||||
@@ -231,7 +231,7 @@ WHERE id = $1 AND status IN ('queued', 'running') AND workflow = 'remediate';
|
||||
-- waiting: the oldest becomes the active payload and the task is queued
|
||||
-- again, so it is remediated after the run that just finished.
|
||||
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '',
|
||||
park_class = 'needs_human',
|
||||
park_class = 'needs_human', outcome_posted = false,
|
||||
review_payload = pending_reviews->>0, pending_reviews = pending_reviews - 0,
|
||||
retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}',
|
||||
updated_at = now()
|
||||
|
||||
Reference in new issue
Block a user