Repository navigation
feat: disable, re-enable, and rotate chat automations with schedule preview - #30117
Conversation
…review
PATCH `enabled` now disables and re-enables chat automations:
- Disabling bumps queue_generation in a short automation-only
transaction, then deletes the automation's queued messages below the
new cutoff as chatd through the DeleteQueuedMessage transition, like a
manual delete. Rows the cleanup misses are discarded by the promotion
guard. Running turns are not interrupted.
- Anyone allowed to update an automation may send a request that only
disables it; enabling and every other change stay owner-only.
- Re-enabling a schedule moves its cursor to the next future occurrence,
so missed occurrences never run.
- DELETE disables first, so queued messages are removed before the row.
Add POST .../chat-automations/{automation}/secret/rotate (owner only,
webhooks only), which returns the new secret once and increments
webhook_secret_version, and POST .../chat-automations/schedule-preview,
which validates a schedule like create and returns its next run times.
Re-enabling a webhook automation sets no schedule cursor, and disabling an automation that is already disabled still removes queued messages an earlier cleanup missed. Neither path had a test. Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 490c9b7133
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A disabled automation has no pending occurrence, so disable now clears schedule_next_run_at instead of leaving the old cursor in responses. Re-enabling already computes the next future occurrence. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93986645a5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Delete no longer runs the disable update first, which required update permission. It deletes the row and then removes every queued message of the automation; the promotion guard discards any message whose automation no longer exists, so deleting the row is the cutoff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93986645a5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
--- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…1209b-automations-disable-rotate
…1209b-automations-disable-rotate # Conflicts: # codersdk/chatautomations.go # docs/reference/api/schemas.md
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22c6e1aa9f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
UpdateAutomation read the clock before waiting for the automation row lock, so a re-enable that waited across a cron boundary could store a cursor that was already in the past. Read it after the lock. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88d5f8964b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…cking Create computed its timestamps and first schedule cursor before waiting for the per-owner lock, and rotation read the clock before the row lock. Read both after the lock, like updates already do, so a stored cursor is never already in the past and updated_at never moves backward. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Readiness record (agent): ready, with follow-ups tracked.
Generated with |
…odagt-1209b-automations-disable-rotate No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main d9c13dc: no content conflicts; make gen produced no diff
Generated with |
Dismissing: approval from an account outside the Coder organization with no review content.
…odagt-1209b-automations-disable-rotate No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main 35abc22: no content conflicts; make gen produced no diff
Generated with |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum (an AI coding agent) prepared and posted this review on behalf of Mike. Each finding came from automated review passes and was re-verified against the code; please push back on anything that looks wrong.
No issues worth fixing were found. Disable, re-enable, delete, secret rotation, and schedule preview match the CODAGT-1209 scope, the earlier Codex threads are fixed at this head, and go test ./coderd -run TestChatAutomation passes locally. The TODO (CODAGT-1209) note in coderd/x/chatd/ARCHITECTURE.md was already flagged in an earlier thread and is listed as an author action. Later in the stack it is replaced with prose, so it needs no new comment.
Verdict: no blocking issues
Severity: P0 0, P1 0, P2 0, P3 0
Review coverage
- code-review Standards: 1 finding (ARCHITECTURE.md TODO), dropped because an earlier thread already raised it and a later layer replaces it with prose
- code-review Spec: CODAGT-1209 disable, re-enable, delete, rotate, and preview PASS, 0 findings
- frontend-review (generated
site/src/api/typesGenerated.tsonly): FE2 PASS, FE1 and FE3 to FE10 N/A - coder-frontend-review types-and-naming: PASS, 0 findings; other roles N/A (generated file only)
…odagt-1209b-automations-disable-rotate No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main d11809f: merged #30112
Generated with |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum re-reviewed this PR on behalf of @ibetitsmike using GPT-6.1 Sol (high) Exec subagents.
Rechecked the earlier cursor, delete-permission and post-lock clock fixes, with the architecture note resolved later in the stack. New findings: Standards 0, Spec 0, Frontend 0 across all eight frontend lanes. Archived-chat cleanup remains an accepted CODAGT-1227 deferral in the existing thread, without a duplicate inline comment. Verified final fresh-head OSS/enterprise automation, promotion/interrupt and capacity tests passed with GOMAXPROCS=4 and go test -p 2, as did diff and generated-contract checks; race/UAT were not rerun, and frozen Storybook CI remains failed with stack Pixel snapshot-report HTTP 500 evidence, not a demonstrated source defect.
…odagt-1209b-automations-disable-rotate Resolved conflicts in coderd/apidoc/docs.go, coderd/apidoc/swagger.json and dbauthz_test.go: dbauthz_test.go keeps both sides, the apidoc files come from make gen. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main a328bee: merged #30112
Generated with |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum validated this PR and approved it on behalf of @ibetitsmike.
Validated head b88411b73087. Prior cursor, delete-permission and post-lock clock findings remain fixed after the restack. Fresh real management/enterprise authorization-and-redaction plus queue/interrupt guard tests passed, and generated contracts are preserved. Current required CI passed. Archived-chat cleanup remains the accepted CODAGT-1227 follow-up, not a claimed fix; approval is limited to this layer.
…odagt-1209b-automations-disable-rotate No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
merged #30112
Generated with |
…odagt-1209b-automations-disable-rotate No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
merged #30112 (experiment display-name test fix)
Generated with |
…odagt-1209b-automations-disable-rotate No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Generated with |
…omations-disable-rotate Brings main ff158c0 into this layer. No conflicts. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Completes the chat automations management API from RFC step 3: disable and re-enable, delete that disables first, webhook secret rotation, and a server-side schedule preview. Stacked on #30112.
PATCHwith{"enabled": false}) runs in two steps. A short transaction that touches only the automation row setsenabled = falseand incrementsqueue_generation, the cutoff. After it commits, the automation's queued rows below the cutoff are deleted one chat at a time through chatd's existingDeleteQueuedtransition, run as chatd, so queue versions and stream updates match a manual delete. If a row is missed, for example after a crash between the steps, the queue promotion guard from feat(coderd): add chatd automation admission seam and queue promotion guard #30096 discards it, because its generation is stale. Running turns are not interrupted.{"enabled": true}) moves a schedule's cursor to the next future cron time, so the disabled period is not replayed. The generation never resets.{"enabled": false}(anything combined with it is 403), and can still list, read, and delete.POST .../chat-automations/{automation}/secret/rotate(owner only, webhooks only) returns the new secret once and incrementswebhook_secret_version. Only the SHA-256 hash is stored, and the rotation is audited with the hash redacted.POST .../chat-automations/schedule-previewevaluates an unsaved cron expression and time zone with create's rules and returns the next five run times, or 400.coderd/x/chatd/ARCHITECTURE.mdgets aTODO (CODAGT-1209)note about disable using the delete-queued transition. Author action before merge: replace that TODO with the architecture prose (agents do not write that document).Known gap, tracked in CODAGT-1227: when the target chat is archived, disable and delete cannot remove its queued automation rows, because
DeleteQueuedMessageis not allowed from archived states. The rows never run, since the promotion guard discards them, but they stay visible after the chat is unarchived. The fix needs a chatstate transition from the lower layer.Dogfood UAT ran on a real dev instance and passed. It covered disable removing only that automation's queued rows (the chat API agreed), delete, re-enable without replay, the permission matrix for an organization admin and the site owner, rotation (the stored hash matches the new secret, and neither secret appears in get or list), preview, and a runtime experiment rule. It also checked that a leftover row is discarded on promotion.
Closes CODAGT-1209
Part of CODAGT-1135
Refs CODAGT-1217
Stack: PR 3b of the Automations for Coder Agents stack, on top of #30112 (PR 3a), #30096, and #30085.
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high