Skip to content

[fix] Unblock editing schedule and subscription triggers - #5552

Merged
mmabrouk merged 7 commits into
release/v0.106.1from
fix/schaedule-trigger-related-issues
Jul 29, 2026
Merged

[fix] Unblock editing schedule and subscription triggers#5552
mmabrouk merged 7 commits into
release/v0.106.1from
fix/schaedule-trigger-related-issues

Conversation

@ashrafchowdury

@ashrafchowdury ashrafchowdury commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Context

Editing an existing schedule or subscription trigger hit several dead ends. The worst: opening a validly-bound trigger and changing an unrelated field (the cron, the message) failed to save with "Bind a workflow", even though the binding was untouched. The save guard only accepted a leaf revision id from the picker, but the backend also binds by artifact, variant, or slug, and by an id the picker can't display. So a perfectly good binding read as "nothing bound".

A few smaller edit-flow issues rode along: schedule messages stored as a messages payload showed blank, run times could only be replaced by delete-and-re-add, and the message editor dropped you into raw JSON on edit.

Fixed 4 Trigger drawer issue

  1. Getting an error message whenever I try to update the trigger
  2. Trigger 9:00 time update was not editable by default
  3. Removed the Deployed option from "Which version to run" section
  4. Always display the trigger message the way we added by default instead of displaying the json

Changes

Saving a bound trigger no longer requires re-picking the workflow.
RunVersionField gains three shared helpers backed by one bind-key table (application/evaluator/workflow, each × _revision/_variant/bare), mirroring the prefix scan in triggers/service.py::_validate_references:

  • hasBoundWorkflow — does the stored family already pin a workflow? Accepts an artifact- or variant-level ref with no revision, and slug-keyed refs. Excludes a deployed family (environment) so Pinned can't silently resend an environment ref.
  • extractBoundWorkflowId — the most-specific bound id the picker can resolve, or null.
  • isRunVersionBound — the single source of truth the save guard and the section header both read, so the header can't say "complete" while save refuses.

Both drawers now compute versionChosen from isRunVersionBound(...) and drop the duplicated three-key id extraction in favor of extractBoundWorkflowId.

A messages payload edits as a message even when the schema says completion.
The bound agent may be unresolved (schema selectors report "completion" until it loads), or the mapping may have been written by the API. getScheduleMessage/setScheduleMessage now key off the payload's own shape (Array.isArray(obj.messages)), not just the isChat flag. The getter and setter check the same shape so an edit writes back where it was read from.

Before, opening this in the composer showed a blank message field:
{"messages": [{"role": "user", "content": "publish an article"}]}

Now it reads "publish an article".

Run times are inline-editable instead of static chips.
TimesField swaps each removable Tag for a live TimePicker, so "this is editable" needs no discovering. The last time can't be removed (an empty list emits 0 0 * * * and silently reschedules to midnight). The cross-product guard and its warning are unchanged.

The message editor opens on the message, not raw JSON.
MessageComposer no longer auto-switches to "Advanced (raw JSON)" on edit. It always opens on the friendly message; when the stored mapping is richer than one user message, it shows an inline warning ("typing here replaces it. Edit it under Advanced") instead of silently collapsing it. The now-unused isEdit prop is removed.

The Deployed (environment) bind option is temporarily hidden.
RunVersionField takes a hideEnvironment flag that leaves a Pinned-only rail; both drawers set it and comment out the environment-query wiring behind restore notes. The tool "Reference by" control still offers both modes.

Tests

  • runVersionReferences.test.ts (new, 157 lines): hasBoundWorkflow across leaf/artifact/slug/deployed families, extractBoundWorkflowId specificity and artifact fallback, isRunVersionBound for both modes, and buildRunVersionReferences resend/route behavior.
  • gatewayTriggerMessageInputs.test.ts: added cases for reading and writing a messages payload under a completion schema.

What to QA

  • Open an existing schedule bound to an app (not a specific revision the picker shows). Change only the cron and save. It saves, no "Bind a workflow" error.
  • Open a schedule whose message came in as a messages payload. The message field shows the text, not blank, and editing it saves back into messages.
  • In the schedule builder, click a run time and change it inline. Add a second time, then remove it; you can't remove the last remaining time.
  • Edit a schedule whose inputs are richer than one message. The composer opens on the message with a warning; switching to Advanced shows the full JSON intact.
  • Confirm the "Deployed" option is gone from both drawers, leaving only Pinned. Regression: the tool-side "Reference by" control still shows Deployed.
  • Regression: create a brand-new schedule and subscription, pin a revision, save. Binding and message still work as before.

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jul 29, 2026 6:59pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 60a623e8-f6db-4c96-b1a5-19ba2f84230d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The update improves trigger message mapping, makes schedule times editable with validation and duplicate prevention, centralizes workflow-version binding interpretation, preserves stored references during submission, hides deployed-version options, and adjusts schedule message editing warnings.

Changes

Trigger scheduling behavior

Layer / File(s) Summary
Chat payload message mapping
web/packages/agenta-entities/src/gatewayTrigger/core/messageInputs.ts, web/packages/agenta-entities/tests/unit/gatewayTriggerMessageInputs.test.ts
Messages-array payloads are read and written as chat mappings even when the schema flag indicates completion, with coverage for both directions.
Editable schedule times
web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/ScheduleBuilderField.tsx
Cron times use editable pickers, prevent duplicates, reject invalid grids, retain prior values after failed edits, and support removal while keeping one time.
Run-version reference interpretation
web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/RunVersionField.tsx, web/packages/agenta-entity-ui/tests/unit/runVersionReferences.test.ts
Binding helpers identify stored workflow references, extract pinned IDs, determine completed bindings, conditionally hide environments, and validate reference-building behavior.
Drawer binding and message submission
web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerScheduleDrawer.tsx, web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerSubscriptionDrawer.tsx
Schedule and subscription drawers use stored-reference fallbacks and shared binding validation, keep deployed options hidden, and start message editing in mapped mode with richer-mapping replacement warnings.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ScheduleForm
  participant RunVersionField
  participant BindingHelpers
  participant ReferenceBuilder
  ScheduleForm->>RunVersionField: select workflow or environment binding
  ScheduleForm->>BindingHelpers: evaluate stored references and bind mode
  BindingHelpers-->>ScheduleForm: versionChosen
  ScheduleForm->>ReferenceBuilder: build references with stored fallback
  ReferenceBuilder-->>ScheduleForm: submission references
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: fixing schedule and subscription trigger editing.
Description check ✅ Passed The description is detailed and directly describes the trigger-editing fixes in the changeset.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/schaedule-trigger-related-issues

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ashrafchowdury

Copy link
Copy Markdown
Contributor Author

One Issue I have intentionally not added to this PR is showing which revision we are running on this trigger. I think we need to align it with the linear history ui for better consistency

image

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/RunVersionField.tsx (1)

144-181: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

hideEnvironment strands legacy "Deployed" bindings with no way to re-bind. The root cause is RunVersionField.tsx's render condition, which shows the Pinned picker whenever hideEnvironment is true even if the stored bindMode is "environment", and the rail offers no way to switch bindMode back; both drawers trigger this by passing hideEnvironment unconditionally to an entity that may already be environment-bound.

  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/RunVersionField.tsx#L144-L181: have onRevisionSelect's caller (or this component) reset bindMode to "revision" when a revision is picked while hideEnvironment is true, so the picked revision isn't silently discarded on save.
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerScheduleDrawer.tsx#L840-L863: once the above is fixed, verify picking a revision here correctly flips bindMode and persists on save for a schedule that was previously environment-bound.
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerSubscriptionDrawer.tsx#L1047-L1061: same verification for subscriptions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f9f3e6c-c5b8-4176-a31d-3b438818fd04

📥 Commits

Reviewing files that changed from the base of the PR and between a3e7fdf and 9759558.

📒 Files selected for processing (7)
  • web/packages/agenta-entities/src/gatewayTrigger/core/messageInputs.ts
  • web/packages/agenta-entities/tests/unit/gatewayTriggerMessageInputs.test.ts
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/ScheduleBuilderField.tsx
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerScheduleDrawer.tsx
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/TriggerSubscriptionDrawer.tsx
  • web/packages/agenta-entity-ui/src/gatewayTrigger/drawers/shared/RunVersionField.tsx
  • web/packages/agenta-entity-ui/tests/unit/runVersionReferences.test.ts

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-07-29T20:23:04.587Z

@mmabrouk
mmabrouk merged commit 2e82ba8 into release/v0.106.1 Jul 29, 2026
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Simplify schedule trigger edit view [bug] Scheduled trigger updates fail in agent playground

4 participants