feat(frontend): triggers section redesign for the agent playground#4978
Conversation
…hnical users Reworks the gateway-trigger schedule drawer so non-technical users can create and manage cron schedules from the agent playground. Builder & message UX - Friendly cadence builder (daily/weekly/monthly/custom) bridged to cron via a new pure scheduleBuilder core (builderToCron/cronToBuilder/describeBuilder), with unit tests. Custom mode falls back to a raw cron editor. - Single "message" composer over inputs_fields via a new messageInputs core: chat-shaped apps map to a messages array, completion apps to the schema's primary input. Detection uses the runtime executionMode (flag + schema), and a schema-agnostic preview powers the list/row summaries. Unit-tested. - ConfigAccordionSection gains size/status/summaryCollapsedOnly props so config sections show required-field status + a collapsed summary. Playground master-detail - Drawer becomes master-detail in the playground: a schedule list (scoped to the active workflow id + app slug) plus multi-draft create/edit, draft removal and schedule deletion with safe fallback selection. - List ordered newest-first; right pane no longer flashes loading on create (detail cache is seeded); Run-in-playground stays disabled until saved; opening an existing schedule no longer spawns a phantom draft. Triggers config rows - Rows are message-forward with a passive status dot; the run action simulates a schedule with its configured inputs (no captured-delivery replay) and uses a flask icon. Engineering - Use EnhancedDrawer (base drawer) and move all data fetching / master-detail state into a ScheduleDrawerContent that mounts only while the drawer is open. - Theme-aware message/modal: imperative toasts/confirms go through @agenta/ui / Modal.useModal so they render correctly in dark mode.
…agent-aware mapping, event-sourced runs Subscription drawer rebuilt on shared primitives (footer, version rail, list rail, draft master-detail, event-source picker). Source selection is a browse-first page: a provider grid with infinite scroll (ScrollSentinel gains root/rootMargin for an off-screen prefetch buffer) plus per-provider connect; picking resolves to events. Triggers config list is grouped by provider (subscriptions first, schedules last), with collapsible per-provider groups (persisted, counts), de-badged section title, and count-badged nested subheaders. "What the agent gets" is agent-aware: agent workflows get a two-column token composer (raw-event field panel + inline pills) gated by isAgent; non-agent workflows keep the raw-JSON mapping editor. The field panel + preview always source the raw event (catalog schema / draft probe), never the mapped delivery output. Parts-aware message extraction is shared across previews and playground replays, so a triggered run injects the real message (not a JSON blob). Stored inputs_fields shape is unchanged. Run-in-playground (drawer + list) uses the event picker (wait / recent deliveries) to run a specific captured event; saved triggers poll their own deliveries to avoid the provider trigger_id collision. Also: SchemaForm flat mode, dark-mode/box-sizing fixes, and shared delivery helpers.
A trigger "Run in playground" test shouldn't append to the user's current chat. The simulated-run request gains a `newSession` flag: the chat panel creates + activates a new session, then clears the flag so the new session's conversation sends the turn (the per-session consumer skips flagged runs until then). All trigger run paths (subscription picker + run button, schedule run, deliveries drawer) set the flag.
…awer-redesign # Conflicts: # web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/AgentTemplateControl.tsx
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR adds cron/builder and message-template helpers, introduces a visual schedule builder field, refactors schedule and trigger management drawers, updates replay runs to start fresh sessions, and adjusts several shared UI components and gateway-trigger hooks. ChangesGateway Trigger Scheduling & Management Overhaul
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…edule
The New Schedule / New Subscription drawers omitted `flags` from the create body, so the
backend default (is_active=true) always won and a schedule/trigger created with Active
turned off still started active. The create body now sends `flags: {is_active: enabled}`
(subscription is_valid still defaults true). Edit already set this correctly.
Fixes #4977
…ter create In the playground create flow the master-detail switches its internal selectedId to the saved subscription, but the root drawer title only read `state.subscriptionId` (which stays unset), so it was stuck on "New trigger". The content now publishes whether the open form is a saved subscription via an atom, and the root title reads it.
The trigger list's per-provider groups toggled with an instant `{open && …}` render. Wrap
the group body in HeightCollapse (the same primitive ConfigAccordionSection uses) for a
smooth height transition on expand/collapse.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Schedule creation ignored the requested active state: `TriggerScheduleCreate` had no `flags` field (so the FE's `flags` was dropped) and `map_schedule_dto_to_dbe_create` hardcoded `TriggerScheduleFlags()` (is_active=True). Add `flags` to the create DTO (mirroring Edit and TriggerSubscriptionCreate) and persist `schedule.flags` in the create mapping. Completes the frontend fix in #4977 (subscriptions already honored flags on create).
|
Scope update: this PR now includes a small backend fix so the schedule Active toggle is honored on creation (#4977). |
There was a problem hiding this comment.
Actionable comments posted: 7
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 62484b79-3309-4d28-8a19-0f83cd3aea09
📒 Files selected for processing (27)
web/oss/src/components/AgentChatSlice/AgentChatPanel.tsxweb/packages/agenta-entities/src/gatewayTrigger/core/eventMessageTemplate.tsweb/packages/agenta-entities/src/gatewayTrigger/core/messageInputs.tsweb/packages/agenta-entities/src/gatewayTrigger/core/scheduleBuilder.tsweb/packages/agenta-entities/src/gatewayTrigger/hooks/useTriggerCatalogIntegrations.tsweb/packages/agenta-entities/src/gatewayTrigger/hooks/useTriggerSchedule.tsweb/packages/agenta-entities/src/gatewayTrigger/hooks/useTriggerSchedules.tsweb/packages/agenta-entities/src/gatewayTrigger/index.tsweb/packages/agenta-entities/tests/unit/gatewayTriggerEventMessageTemplate.test.tsweb/packages/agenta-entities/tests/unit/gatewayTriggerMessageInputs.test.tsweb/packages/agenta-entities/tests/unit/gatewayTriggerScheduleBuilder.test.tsweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/AgentTemplateControl.tsxweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/TriggerManagementSection.tsxweb/packages/agenta-entity-ui/src/gatewayTool/components/SchemaForm.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/ScheduleBuilderField.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerDeliveriesDrawer.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerScheduleDrawer.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerSubscriptionDrawer.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/EventSourcePicker.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/RunVersionField.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/TriggerDrawerFooter.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/TriggerListRail.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/deliveries.tsweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/useDraftMasterDetail.tsweb/packages/agenta-shared/src/state/simulatedAgentRun.tsweb/packages/agenta-ui/src/components/ScrollSentinel.tsxweb/packages/agenta-ui/src/components/presentational/section/ConfigAccordionSection.tsx
…and rail a11y Address PR review on the triggers section: - Strict message round-trip: parseMessageTemplate/getScheduleMessage are representable only when the stored payload is exactly what the composer emits (single user message, text-only content; subscription also rejects extra keys since compile drops them). contentToTemplate returns null for non-text parts. Both composers open in the raw-JSON editor in edit mode when a saved payload isn't representable, so it's never silently collapsed. (+9 unit tests) - Shared parseInputsFields() enforces a non-array object for inputs_fields at both save boundaries (was JSON.parse accepting arrays/strings/numbers). - SubscriptionRunPopover surfaces recents load/poll failures instead of a false empty state. - RowRemoveButton is a real keyboard-operable sibling button, not a nested span. - Block saving a Deployed (environment) trigger/schedule without an app slug rather than persisting an ambiguous environment-only reference.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/TriggerListRail.tsx (1)
13-27: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winGeneric
aria-label="Remove"lacks row context.Screen reader users navigating multiple rows will hear identical "Remove" announcements with no indication of which item is being removed. Consider accepting a label/name prop and interpolating it, e.g.
aria-label={Remove ${name}}.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1ec22f88-38d8-480f-9128-981490fdbb69
📒 Files selected for processing (11)
api/oss/src/core/triggers/dtos.pyapi/oss/src/dbs/postgres/triggers/mappings.pyweb/packages/agenta-entities/src/gatewayTrigger/core/eventMessageTemplate.tsweb/packages/agenta-entities/src/gatewayTrigger/core/messageInputs.tsweb/packages/agenta-entities/src/gatewayTrigger/index.tsweb/packages/agenta-entities/tests/unit/gatewayTriggerEventMessageTemplate.test.tsweb/packages/agenta-entities/tests/unit/gatewayTriggerMessageInputs.test.tsweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/TriggerManagementSection.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerScheduleDrawer.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerSubscriptionDrawer.tsxweb/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/TriggerListRail.tsx
🚧 Files skipped from review as they are similar to previous changes (5)
- web/packages/agenta-entities/src/gatewayTrigger/index.ts
- web/packages/agenta-entities/tests/unit/gatewayTriggerEventMessageTemplate.test.ts
- web/packages/agenta-entities/src/gatewayTrigger/core/eventMessageTemplate.ts
- web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerScheduleDrawer.tsx
- web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/TriggerManagementSection.tsx
Summary
Reworks the agent-playground Triggers experience for non-technical users: a rebuilt
subscription drawer, a provider-grouped trigger list, an agent-aware event→message mapping,
and event-sourced "Run in playground". No backend changes; the persisted
inputs_fieldsshape is unchanged.
What changed
Subscription drawer — rebuilt on shared primitives (footer, version rail, list rail,
draft master-detail, event-source picker). Source selection is a browse-first page: a
provider grid with infinite scroll (
ScrollSentinelgainedroot/rootMarginfor anoff-screen prefetch buffer) + per-provider connect; picking drills into the event.
Triggers config list — grouped by provider (subscriptions first, schedules last),
collapsible per-provider groups (persisted, counted), de-badged section title, count-badged
nested subheaders. Two-tier actions: provider parent (expand + "add for this provider"),
event children (run + ⋯).
"What the agent gets" — agent-aware:
gated by
workflowMolecule.selectors.isAgent.InputsMappingField.never the mapped delivery output.
Runs — parts-aware message extraction is shared across previews and playground replays,
so a triggered run injects the real message (not a JSON blob). "Run in playground" (drawer +
list) uses the event picker (wait / recent deliveries) to run a specific captured event;
saved triggers poll their own deliveries (avoids the provider
trigger_idcollision). Atrigger test now starts a fresh chat session instead of appending to the current one.
Notes
inputs_fields) and resolver/dispatcher untouched. A composed message is one usermessage whose
contentis a parts array (the runtime acceptsstr | ContentBlock[]).POST /subscriptions/test500s when an activesub already covers the same event (unique
trigger_idcollision) — the FE works around it bypolling deliveries for saved triggers.
Testing
@agenta/{shared,ui,entities,entity-ui}tsc --noEmitclean (one pre-existinguseModelHarnesserror from base, untouched);
eslintclean; 89 gatewayTrigger unit tests pass.real delivery shown), non-agent (raw-JSON editor), run-in-playground (clean message, new session).