Skip to content

Add GitHub event triggers and per-automation memory (#242) - #1591

Merged
currentbits merged 2 commits into
mainfrom
coder/event-driven-automation-triggers-github--c4ee0e
Oct 11, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/event-driven-automation-triggers-github--c4ee0e

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Summary

Closes #242.

GitHub event triggers

An automation can now run when a GitHub event happens, as an alternative to running on a schedule. Supported events:

  • PR opened
  • PR merged
  • Label added to a PR (optional label filter)
  • Review submitted
  • Push (optional branch filter)
  • CI run completed (optional branch filter and result filter: success / failure / cancelled / timed_out)

A desktop app has no public URL that webhooks could reach, so the existing minute tick polls the project's origin repo over the GitHub REST API instead. It uses the same token as the PR status poller.

  • Cursor: each automation stores a triggerCursor, which is the highest event key it has already handled.
  • First poll: this only records the starting cursor, so past events never fire.
  • Batching: all new matching events go into a single run. The prompt lists up to 20 of them and gives a count for the rest.
  • While a run is working: the cursor only moves forward when a run starts. Events that arrive during a run are picked up by the next one.
  • Errors: poll failures show up in lastError with a GitHub trigger: prefix. A successful poll clears only that kind of error.
  • Validation: writing an automation with an unknown event name fails with an error. It does not quietly fall back to schedule mode.

The new code lives in electron/automation-triggers.js. It is wired into electron/automations.js and services-settings.js, with a store migration in store-migrate.js and new IPC types in src/shared/ipc.ts.

Per-automation memory

Each automation now keeps memory notes on its record. Every run gets the notes in its prompt. A run replaces the notes by ending its output with an <automation-memory> block.

UI

AutomationsView lets you pick either a schedule or a GitHub trigger, set the event and its filters, and edit the memory notes. The dev mock in src/dev/automations.ts is updated to match.

Tests

  • New electron/test/automation-triggers.test.js
  • Small update to electron/test/automations.test.js
  • New UI tests in test/automationsView.test.tsx

🤖 Generated with Claude Code

Automations can fire on a GitHub event instead of a schedule: PR opened,
PR merged, label added, review submitted, push, CI completed, with
branch/label/result filters. The minute tick polls the project's origin
over the REST API; the first poll baselines a cursor, new events batch
into one run, and the cursor holds while a run is still working.

Each automation keeps memory notes on its record. Runs get them in the
prompt and replace them by ending with an <automation-memory> block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-10-11T08:58:17.823932Z 51b22a3 PR opened
ℹ️ 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.

@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: 51b22a34e6

ℹ️ 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 on lines +95 to +99
: source === "issueEvents"
? `${base}/issues/events?per_page=100`
: source === "runs"
? `${base}/actions/runs?status=completed&per_page=50`
: `${base}/events?per_page=100`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Paginate event sources before advancing the cursor

When more than 100 issue/activity events or 50 completed workflow runs arrive between polls, these requests return only the newest first page. If that page contains a match, pollTriggers advances triggerCursor to its highest key, so matching events on omitted older pages now compare below the cursor and are permanently skipped. Fetch additional pages until reaching the stored cursor before updating it.

Useful? React with 👍 / 👎.

Comment on lines +145 to +149
if (r.event !== "labeled") continue;
const name = r.label?.name || "";
if (trigger.label && name.toLowerCase() !== trigger.label.toLowerCase()) continue;
const kind = r.issue?.pull_request ? "PR" : "Issue";
matched.push({ key, text: `${kind} #${n} labeled "${name}": ${title} (${url})` });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude issue labels from PR-label triggers

For a pr_labeled automation, any ordinary issue-label event passes the checks here and starts a run, even though this trigger is defined as a label added to a pull request. Repositories that label issues will therefore launch unrelated PR automations; require r.issue?.pull_request before adding the match.

Useful? React with 👍 / 👎.

Comment on lines +180 to +183
} else {
if (r.type !== "PullRequestReviewEvent") continue;
const n = p.pull_request?.number;
const state = p.review?.state || "submitted";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Filter review triggers to newly submitted reviews

A PullRequestReviewEvent can represent a created, updated, or dismissed review, but this branch accepts all of them. Editing or dismissing an existing review will consequently fire an automation advertised as “Review submitted”; check the payload action and accept only newly created review events.

Useful? React with 👍 / 👎.

Comment on lines +153 to +155
case "ci_completed": {
const key = typeof r.updated_at === "string" ? r.updated_at : "";
if (!key) continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add a tie-breaker to the CI completion cursor

GitHub workflow timestamps have second-level precision, so two runs can share the same updated_at. If one completes after a poll has already stored that timestamp for another run, the later run's key equals the cursor and the strict > freshness test ignores it forever. Store a cursor that includes a unique run identifier as a tie-breaker rather than using only updated_at.

Useful? React with 👍 / 👎.

@currentbits
currentbits enabled auto-merge (squash) October 11, 2026 09:27
@currentbits
currentbits merged commit 3afff7f into main Oct 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event-driven automation triggers (GitHub/CI/Linear/Sentry/webhook) + NL authoring + per-automation memory

1 participant