Skip to content

feat(site/src): add the schedule automation editor - #30187

Merged
ThomasK33 merged 28 commits into
tk/codagt-1213-automations-list-pagefrom
tk/codagt-1214-automations-editor
Oct 2, 2026
Merged

ThomasK33 merged 28 commits into
tk/codagt-1213-automations-list-pagefrom
tk/codagt-1214-automations-editor

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Adds an editor for schedule automations on the Agents automations page. Owners can create and edit schedules without calling the API.

Part of CODAGT-1214 (this is part 11a; part 11b adds the webhook controls and closes the ticket).
Part of CODAGT-1135.

Stack: PR 11a of "Automations for Coder Agents". Base: tk/codagt-1213-automations-list-page (#30171). The webhook editor (11b) stacks on this PR.

What changes

  1. New automation and a per-row Edit button open a dialog with name, prompt, schedule, and target.
  2. The cron expression is the stored value. Repeat and Time are shortcuts that write a generated expression into it; they never parse the stored cron.
  3. Upcoming runs come only from POST /schedule-preview (debounced). The client does not evaluate cron. An invalid expression shows the server's validation error under the cron field, in a live region.
  4. Targets:
    • existing chat: a picker over the owner's root chats (server-side title:, archived:false, source:created_by_me filters), plus When busy;
    • new chat each run: model and reasoning effort through ModelSelector.
  5. Kind and target mode are read-only on edit. Edits send a PATCH with only the changed fields; target changes apply to the next run.
  6. Server errors stay in the dialog with the form values. A non-owner org admin sees a note and the server's 403 message ("Only the owner of a chat automation can change it.").
  7. API client and query options for create and schedule preview. The create response is never written to a query cache (in 11b it carries the webhook secret).

Deviations and follow-ups

  • Reasoning effort only for new-chat targets. The ticket and RFC say existing-chat automations pick an effort, but the backend from CODAGT-1209 rejects reasoning_effort for existing_chat. The backend is unchanged here; CODAGT-1240 tracks which side wins.
  • Deferred to CODAGT-1245: Repeat and Time do not reflect a stored cron on edit, the Hourly shortcut ignores the hour, and the time zone select has no search (same Select as the workspace schedule forms).
  • Size: 1,570 added lines, of which 542 are tests and stories. Splitting further would separate the dialog from its only caller; webhooks are already split out to 11b.

Validation

  • Vitest: AgentAutomationsPage.test.tsx (18 tests) covers the create bodies for both targets, the shortcut-to-cron and preview requests, the picker search query, required-field and server validation errors (including stale error clearing), PATCH with only changed fields, the 403 alert text, and focus return. Storybook: AutomationEditorDialog.stories.tsx (create, new chat target, edit, preview error, forbidden).
  • pnpm lint:types, pnpm check, pnpm lint, make pre-commit, make pre-push.
  • coder-frontend-review self-review (8 roles): all checkpoints pass after fixes. Kept on purpose: border-0 border-t border-solid (repo convention) and two comments on non-obvious invariants in chatAutomations.ts.
  • Remote dogfood UAT (two rounds, agent-browser against a dev instance with chat-automations on): all acceptance checks pass. Round 1 found a broken picker search and eight minor issues, all fixed in round 2 except the CODAGT-1245 items.
UAT screenshots (round 2)

Existing-chat schedule from Repeat Weekdays and Time 09:30, with runs from the server preview:

Create for an existing chat

New chat each run with model and reasoning effort:

New chat target

Invalid cron: the server error on the cron field, nothing created:

Invalid cron

Chat picker search with plain text:

Picker search

Editing a target; kind and target mode read-only:

Edit

Edit read-only fields

Org admin editing another user's automation gets the 403:

Org admin 403


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Owners can create and edit schedule automations from the Agents
automations page. The editor shares name, prompt, and target fields:
an existing root chat with a When busy choice, or a new chat each run
with a model and reasoning effort. The cron expression is the stored
value; Repeat and Time only write generated expressions into it, and
every upcoming run comes from POST /schedule-preview. Kind and target
mode are fixed after creation, edits send only changed fields, and
server errors (403 for non-owners, 400 validations) show in the dialog.

Reasoning effort is offered only for new_chat targets because the
server rejects it for existing_chat automations (CODAGT-1240).
…page' into tk/codagt-1214-automations-editor

# Conflicts:
#	site/src/pages/AgentsPage/AgentAutomationsPage.test.tsx
#	site/src/pages/AgentsPage/AgentAutomationsPage.tsx
#	site/src/pages/AgentsPage/components/Automations/AutomationRow.tsx
- Chat picker search sends a chat search query (search:"..." archived:false)
  instead of raw text, which the chats API rejected with 400.
- Server field errors apply only while the field keeps its submitted value.
- The top alert shows only errors that have no rendered field, using the
  shared Alert with the server message instead of ErrorAlert.
- The cron field shows one error (save error, else preview error) in a
  polite live region; Upcoming runs shows a neutral line instead.
- The model selector shows the effective reasoning effort; the request
  still omits it until the user changes it.
- noValidate lets one Save show every required field error.
- "Changes apply to the next run." shows only when editing, and non-owners
  see that only the owner can save.
- Focus returns to the button that opened the editor.
…strings

The automation chat picker lists chat titles only, but it searched with
the full-text search: term, which matches whole words and message
content. Typing a prefix such as "Alph" returned no chats. Use the
title: filter, a case-insensitive title substring match, instead.
…ed fields

The schedule editor lists server validations for fields the form does
not render in its alert, but no test covered that path. Parametrize the
save failure test so a 400 on such a field must show in the alert.
@linear-code

linear-code Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

CODAGT-1135

CODAGT-1214

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7ff9aa71a

ℹ️ 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".

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T21:30:38.832794Z e4283eb Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ThomasK33

Copy link
Copy Markdown
Member Author

CI for head 0e1a89d9e6b6685290b578b93c077413d2f48daa (pushes to stacked PRs currently get no pull_request ci run, so it was dispatched manually): https://github.com/coder/coder/actions/runs/36720615198

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e1a89d9e6

ℹ️ 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".

Comment thread site/src/api/queries/chatAutomations.ts Resolved
@ThomasK33

Copy link
Copy Markdown
Member Author

CI for head e7f1f9f8308623b7031f256af16f4b52006edc82 (dispatched manually; pushes to stacked PRs currently get no pull_request ci run): https://github.com/coder/coder/actions/runs/36724509098

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7f1f9f830

ℹ️ 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".

@ThomasK33

Copy link
Copy Markdown
Member Author

CI for head 900435db4c (Codex round 3 fixes): this push started no pull_request ci run, so I dispatched one manually: https://github.com/coder/coder/actions/runs/36767670338 (workflow_dispatch, headSha 900435db4c7e7a2ff038a8e8865d8460e666111d).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 900435db4c

ℹ️ 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".

@ThomasK33

Copy link
Copy Markdown
Member Author

Remote UAT round 5 on 900435db4c

A narrow confirmation of the Codex round 1-3 fixes on the exact head (git rev-parse HEAD = 900435db4c7e7a2ff038a8e8865d8460e666111d, server v2.37.3-devel+900435db4c). The run used a local dev deployment only; an isolation proof was taken before the first change.

Raw verdict: FAIL, on one sub-check. All other checks pass.

Check Result
h. Save lock: fields, pickers, Escape, overlay and Cancel locked while create or update is pending; editable again after a failed save PASS
i. Selected time zone sent to the preview and reflected in Upcoming runs PASS
i. Default when the browser reports Etc/Unknown FAIL: the field defaults to Etc/Unknown and the preview and create get 400; picking UTC recovers
j. No "No chats found." while a new search is pending PASS
k. Reselecting the current model keeps an explicit effort; changing model resets it PASS
l. Target errors cleared after switching target mode PASS
m. Name length counted in code points (128 saves, 129 rejected client-side) PASS
Round 4 create and edit regression PASS

Not tested: organization scoping of the picker (the local deployment has one org and no multi-org license), and zones the browser rejects outright.

The failing sub-check was added to this round's prompt; the plan did not require it. The default comes from getPreferredTimezone() in site/src/utils/timeZones.ts, which returns the browser zone unchecked. It is recoverable and doesn't block the reviewed flows, so it is tracked as a defect in CODAGT-1245 (item 4), with a regression-test requirement.

Create dialog locked while the POST is pending
Target error cleared after switching to Existing chat
Etc/Unknown browser zone: create rejected with 400

Evidence bundle r5-evidence.tar.gz (sha256 8c32fed28a6594228ec31a3e419eb3c8a248fd82b865d748af776f3c246dc1ca) and manifest r5-manifest.md (sha256 8755cf3dfe0ea656e3f11ace10649fe9282cbb0a4121e76b4f3a824ea483cc04) are archived with the remote UAT chat.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…e automation editor

The Codex round 3 fix moved overflow-y-auto onto the fieldset that locks
the form while saving. Chrome does not scroll a flex-sized fieldset, so
the Target, When busy and Upcoming runs fields were unreachable at 1280x720.

Put the scrolling div back and nest the fieldset inside it.

Generated with xum. Model: anthropic:claude-opus-5-5. Thinking: high.
@ThomasK33

Copy link
Copy Markdown
Member Author

CI for head e4283eb7d0 (restores the form scroll container, which 900435d broke): this push started no pull_request ci run, so I dispatched one manually: https://github.com/coder/coder/actions/runs/36779310716 (workflow_dispatch, headSha e4283eb7d0f6458755a854a1c973ae5abc8cc1a1).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Build the chat picker search query from an array of terms.
Pin the browser time zone in the CreateSchedule and NewChatTarget stories.
Add stories for the chat-not-found and could-not-load-chat picker labels
and for the UTC fallback when the browser does not know the zone.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

sync with main 35abc22: merged #30171 (resolved import and test setup conflicts); addressed Mike's review (chat picker terms joined from an array, pinned story time zone, new picker and UTC preview stories). Declined: extracting AutomationTargetFields (refactor outside this layer's scope)


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1214-automations-editor

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

sync with main 35abc22: merged #30171 to pick up 64cc207 (test-only); main not merged this pass


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1214-automations-editor

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

sync with main d11809f: merged #30171


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ibetitsmike ibetitsmike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xum re-reviewed this PR on behalf of @ibetitsmike using GPT-6.1 Sol (high) Exec subagents.

The prior picker-state stories, deterministic story zones, Unicode validation, save locking and model/error wiring fixes remain intact at this head. New-to-GitHub counts are Standards 1, Spec 0 and Frontend 1, deduplicated to the unchanged, previously unposted P3 story-wiring finding; this refresh introduces no new candidate. The deferred text-only test cleanup and contested accessibility-test policy stay on their existing discussions. Current-head validation passed 25 page unit tests, TypeScript, 4 real-module preview HTTP probes and 8 Chromium story setup checks; those setup checks are not Pixel visual validation, whose frozen result remains pending.

},
};

const editPreviewQuery = (scheduleTimeZone: string) => ({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Keep each story's preview query wiring inline

Standards S1: “the story blocks conceal their seeded cron and result data behind an extra helper; reviewing or changing a single visual fixture requires following shared wiring.” This is the exact reviewability contract in FE9 (.claude/docs/FRONTEND_PATTERNS.md:251-253), not a rendering failure. Inline the { key, data } entries in TargetChatNotFound, TargetChatLoadError and UnknownTimeZonePreview, keeping nextRunTimes shared.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0ae9c98: TargetChatNotFound, TargetChatLoadError and UnknownTimeZonePreview now inline their preview query entries; nextRunTimes stays shared.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1214-automations-editor

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

sync with main a328bee: merged #30171


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

… each editor story

TargetChatNotFound, TargetChatLoadError and UnknownTimeZonePreview now
spell out their preview query entries, so each visual fixture reads on
its own. nextRunTimes stays shared.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

review fix: inlined the schedule preview query in TargetChatNotFound, TargetChatLoadError and UnknownTimeZonePreview (Mike's story-wiring P3)


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ibetitsmike ibetitsmike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xum validated this PR and approved it on behalf of @ibetitsmike.

Verified at 0ae9c98b2ca9be109ee230b63dfe0481d579b22e: all three preview query entries are inline and preserve their existing inputs/results. The follow-up Standards, Spec, frontend-review, and all eight coder-frontend-review roles found no new own-layer issue. Prior accepted deferrals and policy disagreements remain on their existing threads; this does not clear the inherited #30171 focus issue or approve the whole stack.

Validation: eight actual Chromium editor-story setup tests passed; targeted Biome check/lint, Oxlint, and TypeScript checks passed. Missing-chat, load-error, and unknown-zone screenshots were inspected. Source stayed clean. No Pixel approval, full local suite, or remote UAT is claimed. Current-head required CI and all observed checks were green at the posting gate.

…agt-1214-automations-editor

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

merged #30171 (main 15382eb)


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1214-automations-editor

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

merged #30171 (main dc07908)


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1214-automations-editor

No conflicts. make gen produced no diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

merged #30171 (archived automation chat history fix)


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…agt-1214-automations-editor

Resolved the conflict in AgentAutomationsPage.tsx: kept this layer's AutomationEditorDialog import and EditorState type, and took #30171's automationsFlag import and the useDashboard call inside AutomationsList (no threaded organization props).

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

Merged #30171; resolved AgentAutomationsPage.tsx (automationsFlag import, useDashboard inside AutomationsList).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ibetitsmike ibetitsmike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xum validated this PR and approved it on behalf of @ibetitsmike.

Re-reviewed the exact introducing-layer source and inherited changes against the original Standards/Spec/frontend records and accepted deferrals.

Validation: 27 maintained unit cases and 18 actual Chromium Storybook cases, authored Biome/Oxlint and whole TypeScript. Real editor timezone controls also passed under UTC and America/Los_Angeles.

This approval covers this PR's own scope, not whole-stack merge readiness. #30167 and #30171 test-contract findings and #30220 documentation wording remain held at their introducing layers. No fresh Pixel, remote UAT or full-suite run is claimed.

…tions-editor

Brings main ff158c0 into this layer. No conflicts.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…tions-editor

Brings the new_chat automation title source fix from #30134.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33
ThomasK33 merged commit adcee75 into main Oct 2, 2026
27 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 2, 2026
@ThomasK33
ThomasK33 deleted the tk/codagt-1214-automations-editor branch October 2, 2026 15:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants