Skip to content

fix(webapp): forward condition value and windowSec in queryWatchFromPatch (#5065) - #5071

Closed
MilindChatrabhuji wants to merge 1 commit into
triggerdotdev:mainfrom
MilindChatrabhuji:fix/query-watch-patch-prefill-5065
Closed

MilindChatrabhuji wants to merge 1 commit into
triggerdotdev:mainfrom
MilindChatrabhuji:fix/query-watch-patch-prefill-5065

Conversation

@MilindChatrabhuji

Copy link
Copy Markdown

Summary

Fixes #5065

When the dashboard agent prefills a query watch alert patch, queryWatchFromPatch previously only forwarded operator: patch.condition?.operator into QueryWatchPrefill, dropping patch.condition?.value and patch.condition?.windowSec. In addition, useQueryAlertDraft initialized valueText to "", causing draft.valueValid to remain false even if an operator was prefilled, preventing automatic pre-selection of the threshold step.

Changes:

  • queryWatchFromPatch (apps/webapp/app/components/dashboard-agent/alert-creation/draftPatch.ts): Forwards value: patch.condition?.value and windowSec: patch.condition?.windowSec to QueryWatchPrefill.
  • QueryWatchPrefill & QueryAlertPrefill (QueryAlertTranscript.tsx, queryAlertLink.ts): Extended types to include optional value and windowSec fields, and forwarded from full in QueryAlertTranscript.
  • useQueryAlertDraft (apps/webapp/app/components/alerts/useQueryAlertDraft.ts):
    • Initializes valueText with prefill.value !== undefined ? String(prefill.value) : "" so draft.valueValid evaluates to true when prefilled with a valid number.
    • Converts prefill.windowSec into minutes when present (Math.round(prefill.windowSec / 60)) and validates against analysis limits before setting windowText.
  • Unit Test (draftPatch.test.ts): Added unit test verifying that queryWatchFromPatch properly forwards value and windowSec from the patch condition into QueryWatchPrefill.

@algora-pbc /claim #5065

@changeset-bot

changeset-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6ee18b5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @MilindChatrabhuji, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Oct 26, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment on lines +67 to +68
const prefillWindowMinutes =
prefill.windowSec !== undefined ? Math.round(prefill.windowSec / 60) : undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Query watch windows shorten unexpectedly

For a query patch requesting 630 seconds, prefillWindowMinutes becomes 10 instead of 11. The created alert watches a shorter interval than requested.

Learn more

Query watch alerts store their windows in whole minutes. The patch contract accepts any number of seconds, and applyDraftPatch rounds curated alert windows up. Rounding to the nearest minute here shortens intervals with a remainder under 30 seconds. The resulting window is used by queryAlertRequestBody when the alert is created.

Example: With a 601-second patch window and a 600-second minimum cadence, this code prefills 10 minutes and creates a 600-second alert rather than covering all 601 seconds.

Recommended fix: Use Math.ceil(prefill.windowSec / 60) before checking the analysis bounds, matching applyDraftPatch and avoiding a shorter requested interval.

Suggested change
const prefillWindowMinutes =
prefill.windowSec !== undefined ? Math.round(prefill.windowSec / 60) : undefined;
const prefillWindowMinutes =
prefill.windowSec !== undefined ? Math.ceil(prefill.windowSec / 60) : undefined;

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +70 to +71
value: patch.condition?.value,
windowSec: patch.condition?.windowSec,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Query watch fix missing release note

This user-facing query watch fix has no .server-changes entry. Customers will not see the fix in server release notes.

Learn more

The repository's server changes guidance requires a release note for a user-facing server-only bug fix. This change restores query watch condition and window prefills for customers, but the PR adds no release note.

Example: A customer whose query alert previously lost its threshold now sees it prefilled, but the release summary does not mention the fix.

Recommended fix: Add a .server-changes/ Markdown file with area: webapp, type: fix, and a one-sentence user-facing description of the restored query watch prefills.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

queryWatchFromPatch drops condition.value and windowSec from agent query alert patches

1 participant