Repository navigation
Add GitHub event triggers and per-automation memory (#242) - #1591
Conversation
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]>
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: 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".
| : source === "issueEvents" | ||
| ? `${base}/issues/events?per_page=100` | ||
| : source === "runs" | ||
| ? `${base}/actions/runs?status=completed&per_page=50` | ||
| : `${base}/events?per_page=100`; |
There was a problem hiding this comment.
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 👍 / 👎.
| 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})` }); |
There was a problem hiding this comment.
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 👍 / 👎.
| } else { | ||
| if (r.type !== "PullRequestReviewEvent") continue; | ||
| const n = p.pull_request?.number; | ||
| const state = p.review?.state || "submitted"; |
There was a problem hiding this comment.
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 👍 / 👎.
| case "ci_completed": { | ||
| const key = typeof r.updated_at === "string" ? r.updated_at : ""; | ||
| if (!key) continue; |
There was a problem hiding this comment.
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 👍 / 👎.
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:
A desktop app has no public URL that webhooks could reach, so the existing minute tick polls the project's
originrepo over the GitHub REST API instead. It uses the same token as the PR status poller.triggerCursor, which is the highest event key it has already handled.lastErrorwith aGitHub trigger:prefix. A successful poll clears only that kind of error.The new code lives in
electron/automation-triggers.js. It is wired intoelectron/automations.jsandservices-settings.js, with a store migration instore-migrate.jsand new IPC types insrc/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
AutomationsViewlets you pick either a schedule or a GitHub trigger, set the event and its filters, and edit the memory notes. The dev mock insrc/dev/automations.tsis updated to match.Tests
electron/test/automation-triggers.test.jselectron/test/automations.test.jstest/automationsView.test.tsx🤖 Generated with Claude Code