refactor(desktop,shared,db): make trigger providers additive
Why
Adding a trigger provider meant editing six files GitHub had shaped: the sentence grammar, the menu table, the slot renderer, the card's option fetching, the matcher, and the dispatcher. Two agents adding Slack and Linear in parallel would collide on every one of them. This PR makes a provider one module plus registry lines, so those can proceed in parallel.
Zero behaviour change is the bar. Nothing user-visible should differ.
What
Desktop — providers/<name>/ owns a provider's config kind, icon, Add Trigger subtree, config factory and sentence renderer. Three things iterate TRIGGER_PROVIDERS instead of naming providers:
TriggerMenuItemsrenders the menu (single-leaf providers become the leaf; multi-leaf become a submenu)flattenTriggerMenubuilds the search index — same registry, so menu and search can't driftTriggerSentencehands the row's state (set,mark,options,disabled) to whichever provider owns the config
Pickable values move to per-provider hooks composed by useProviderOptions; the card no longer knows what a repository is.
Shared — automation-matching splits the same way: shared primitives in core.ts, GitHub's matcher in github.ts, and triggerMatches(config, event, ctx) dispatching on config.kind. A kind with no matcher does not match — an event for a provider that can't yet evaluate it must not fire by default.
DB — doing this exposed that packages/db's hand-written TriggerConfig had drifted from the zod schema that validates every write (events: string[] vs event: string; an "org_members" actor the schema never had). The only thing keeping it from a runtime mismatch was an as never at the read site. DB types are now derived from the schema and that cast is gone.
To add a provider
providers/<name>/implementingTriggerProvider- append to
TRIGGER_PROVIDERS - a
caseintriggerMatches - if it has pickable values, its hook in
useProviderOptions
Verified in the running app
- menu lists the same 3 providers with icons; GitHub submenu has the same 11 entries
- search still flattens to
GitHub › PR review submitted › Approved - a comment trigger renders, configures and saves —
Triggers saved, zero console errors - schedule row shows one clock (provider-supplied) not two
- typecheck and lint pass with real exit codes
One intentional visual: the schedule row's clock now comes from the provider like every other row's icon, rather than ScheduleSentence drawing its own. Same pixel, one source.
Summary by cubic
Refactors triggers so providers are additive and registry-driven. Behavior is unchanged; an unknown persisted GitHub event that previously crashed the editor now renders as its raw name.
- Desktop:
providers/<name>/owns a provider’s kind, icon, Add Trigger subtree, config factory, and sentence renderer.TriggerMenuItems,flattenTriggerMenu, andTriggerSentenceiterateTRIGGER_PROVIDERS. Pickable values move to per-provider hooks composed byuseProviderOptions, soTriggersCardno longer fetches repos/people directly. The schedule row’s clock icon now comes from the provider (same visual). Unknown GitHub events render as text to avoid an editor crash. - Shared/API:
@superset/shared/automation-matchingsplits intocore.ts(shared primitives) and provider modules;triggerMatchesdispatches onconfig.kind. The GitHub webhook route usestriggerMatcheswith provider context. A kind with no matcher does not match. - DB:
TriggerConfigand related types derive from the zod schema in@superset/shared, removing drift and unsafe casts.
Migration
- Add a provider by implementing
providers/<name>/as aTriggerProvider, appending it toTRIGGER_PROVIDERS, adding its case totriggerMatches, and registering its options hook inuseProviderOptionsif needed. No data or user migration is required.
Summary by CodeRabbit
- New Features
- Added a unified automation trigger editor for schedule, GitHub, and webhook triggers.
- Added provider-based trigger menus with icons, grouped options, and sentence-style configuration.
- Added GitHub repository, branch, label, actor, and comment filters.
- Added schedule defaults, timezone handling, and next-run information.
- Bug Fixes
- Improved trigger matching for scopes, actors, and text filters.
- Invalid regular expressions now safely produce no match.
- Style
- Removed the unused clock icon from schedule controls.