feat(automations): Linear trigger provider
Merged
SA
3mo ago+756+756+012345678901234567890123456789-5-5-0123456789
Summary
Adds the Linear trigger provider to automations. Four events, per the brief:
| event | sentence | filters |
|---|---|---|
issue.created | Issue created in team in [project] with label [label] | teams · projects · labels |
issue.status_changed | Issue moved to [status] in team in [project] with label [label] assigned to [assignee] | teams · projects · labels · toStatus · assignee |
issue.assigned | Issue assigned to [assignee] in team in [project] with label [label] | teams · projects · labels · assignee |
cycle.ended | Cycle ended in team | teams |
What changed
packages/shared/automation-triggers.ts—linearTriggerConfigSchemagainslabels,toStatus(scopes) andassignee(actor), plusissue.assigned.describeTriggerProblems: teams required, assignee must be non-empty or Anyone (same rules as GitHub's repositories/actor).packages/shared/automation-matching/linear.ts—LinearMatchableEvent(teamId, projectId, stateId, assigneeId, labelIds, names) joins theMatchableEventunion;linearEventNamesmaps a Linear delivery to product events usingupdatedFrom(Linear's previous-values map);linearTriggerMatchesapplies the filters.nullteams matches nothing; optional narrowings treatnullas "any" (GitHub convention). Onecase "linear"intriggerMatches.apps/api/.../integrations/linear/callback/route.ts— upserts the connecting user's Linear identity (see below).apps/api/.../integrations/linear/webhook/route.ts— the existing route (signature verified on the raw body first, unchanged) now normalizes each entity delivery into aLinearMatchableEvent, records deliveries a trigger can name asautomation_events(providerlinear, idempotent on theLinear-Deliveryheader) and hands off to the shared@/lib/automations/dispatchMatchingTriggers, per connection, after the task sync. Only deliveries with a named event are recorded: Linear sends every attachment/comment edit to the same hook and mostIssue.updates touch nothing a trigger filters on.packages/trpcintegration.linear—getTriggerOptions(teams, projects, labels, workflow states in one GraphQL round trip; state/label names are suffixed with the team key since they repeat across teams) andlistLinkedPeople(user_identitiesprovider=linear).- desktop
providers/linear/— grammar, sentence renderer (existingScopeChip/ActorChiponly),useLinearOptionsreturning{ linear: { teams, projects, labels, statuses, people } }; one registry line and oneuseProviderOptionsline. No seam files touched beyond those.
Event semantics (defaults taken; flagged to the coordinator)
issue.assignedfires whenassigneeIdbecomes non-null: new assignment, reassignment, and an issue created with an assignee. Unassign does not fire.issue.status_changed=Issue.updatewithupdatedFrom.stateId; not on create.cycle.ended=Cycle.updatewherecompletedAtgoes null → set.toStatusis an optional narrowing (Any status by default), like GitHub's branches.
Not in this PR / needs an outside action
- Identity: the Linear connect callback now upserts the connecting user's
user_identitiesrow (providerlinear,externalId= viewer id, scoped to the Linear workspace id), which is whatmeand the assignee people list resolve through. Other members still have no way to link a Linear account; that flow is deliberately not built here. - Superset's Linear OAuth-app webhook is not subscribed to Cycles (zero
Cycle.*deliveries in three days of ingest).cycle.endedis verified by signed replay; it needs the resource enabled in Linear's app settings to fire for real. - No migration:
automation_triggers.kind/integration_provideralready carrylinear; the config lives in jsonb.
Verification
Desktop over CDP against this workspace's API (renderer :8605, API :8601, CDP :9333):
- Add Trigger → Linear → Issue… → Status changed; picked team Superset, status Duplicate · SUPER, label Agent · SUPER from real Linear data; Save → "Triggers saved"; reload → sentence re-renders from the persisted row with labels resolved. Also added Cycle ended and Issue assigned; Save with empty teams was refused with "Some triggers need additional configuration" and both team chips marked.
automation_triggersrows:kind=linearwith the full config (status_changed / assigned / cycle.ended).
Signed replays at POST /api/integrations/linear/webhook (HMAC with LINEAR_WEBHOOK_SECRET, Linear-Delivery header):
- a real
Issue.updatestatus change from ingest →automation_eventsrow (Issue.update,linear:issue:<id>, titleSUPER-1527 …), matcher selected the trigger and reachedqstash.batchJSON(QStash rejects the loopback URL locally, as for every provider); replaying the same delivery id →Not recorded as automation event (duplicate delivery). - synthetic
issue.assignedandcycle.endedpayloads → recorded + selected; a status change to a different state → recorded, no match (reason: "status").
bun run typecheck exit 0 in shared, trpc, api, desktop. bun run lint fails only on a pre-existing TerminalAgentAutoResume.tsx a11y error on main; biome is clean on every touched file.
Summary by CodeRabbit
- New Features
- Added Linear automation triggers for issue creation, assignment, status changes, and cycle completion.
- Added filters for teams, projects, labels, statuses, and assignees, including an “Anyone” option.
- Added Linear trigger configuration and option selection in the automation editor.
- Linear webhook events now trigger matching automations after synchronization.
- Linked Linear users are available as assignee options.
- Linear identities are saved during OAuth sign-in.