fix(store): post open chat task states once after the posted-status migration

This commit is contained in:
sam committed 2026-10-25 02:46:43 +11:00
1 parent d2cbe25814
commit 49277babe4
4 files changed
+23 -8

No files matched your search

@@ -0,0 +1,11 @@
-- 0056 read the old posted flag as "the current status was posted", but a
-- task flagged by its approval request and now holding an open pull request
-- was never told about the PR. Tasks in a reportable non-final state post it
-- once.
-- +goose Up
UPDATE tasks SET outcome_posted_status = ''
WHERE origin <> '' AND status IN ('waiting_approval', 'pr_open');
-- +goose Down
SELECT 1;
@@ -750,17 +750,19 @@ func (q *Queries) LockTaskStatus(ctx context.Context, id int64) (string, error)
}
const markOutcomePosted = `-- name: MarkOutcomePosted :exec
UPDATE tasks SET outcome_posted_status = $2 WHERE id = $1
UPDATE tasks SET outcome_posted_status = COALESCE(NULLIF($1::text, ''), status) WHERE id = $2
`
type MarkOutcomePostedParams struct {
ID int64
OutcomePostedStatus string
Posted string
ID int64
}
// Records the status whose state reached the task's conversation.
// Records the status whose state reached the task's conversation. A caller
// that names none (an older archied) marks the current status, so a mixed
// deploy cannot leave a posted state looking unposted forever.
func (q *Queries) MarkOutcomePosted(ctx context.Context, arg MarkOutcomePostedParams) error {
_, err := q.db.Exec(ctx, markOutcomePosted, arg.ID, arg.OutcomePostedStatus)
_, err := q.db.Exec(ctx, markOutcomePosted, arg.Posted, arg.ID)
return err
}
@@ -112,8 +112,10 @@ ORDER BY id
LIMIT 50;
-- name: MarkOutcomePosted :exec
-- Records the status whose state reached the task's conversation.
UPDATE tasks SET outcome_posted_status = $2 WHERE id = $1;
-- Records the status whose state reached the task's conversation. A caller
-- that names none (an older archied) marks the current status, so a mixed
-- deploy cannot leave a posted state looking unposted forever.
UPDATE tasks SET outcome_posted_status = COALESCE(NULLIF(sqlc.arg(posted)::text, ''), status) WHERE id = sqlc.arg(id);
-- name: StampTaskBinding :exec
-- The capture's signature result is spelled as the access context spells it.
+1 -1
View File
@@ -957,7 +957,7 @@ func (s *Store) UnpostedOutcomes(ctx context.Context) ([]*workflow.Task, error)
// MarkOutcomePosted records that the task's state at status reached its
// conversation.
func (s *Store) MarkOutcomePosted(ctx context.Context, taskID int64, status string) error {
if err := s.queries().MarkOutcomePosted(ctx, postgresdb.MarkOutcomePostedParams{ID: taskID, OutcomePostedStatus: status}); err != nil {
if err := s.queries().MarkOutcomePosted(ctx, postgresdb.MarkOutcomePostedParams{ID: taskID, Posted: status}); err != nil {
return fmt.Errorf("store: mark outcome posted: %w", err)
}
return nil