Skip to content

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

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

Description

Fixes #5065

When an agent suggests a query alert draft patch, queryWatchFromPatch dropped condition.value and condition.windowSec, only forwarding operator. This resulted in useQueryAlertDraft initializing valueText to "", leaving draft.valueValid as false and preventing threshold step pre-selection in QueryAlertTranscript.

Changes

  1. queryWatchFromPatch: Forward value: patch.condition?.value and windowSec: patch.condition?.windowSec to QueryWatchPrefill.
  2. QueryWatchPrefill & QueryAlertPrefill: Added optional value?: number and windowSec?: number fields.
  3. QueryAlertTranscript: Pass value and windowSec through to QueryAlertPrefill.
  4. useQueryAlertDraft: Initialize valueText from prefill.value (if defined), and initialize windowText from prefill.windowSec (converted to minutes and bounded within limits) when provided.
  5. Unit Tests: Added unit test in draftPatch.test.ts verifying that condition.value and windowSec are accurately preserved in queryWatchFromPatch.

@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

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

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

🟡 Suggested alert window gets shortened

For a 601-second query window, prefillWindowMinutes selects 10 minutes instead of 11. The resulting alert watches less history than requested.

Learn more

Alert windows are entered and saved as whole minutes. The agent supplies condition.windowSec in seconds, which is forwarded to this hook. Rounding to the nearest minute can produce a shorter window, although applyDraftPatch rounds the same input upward for curated alerts. The alert then evaluates a different window than the one the agent suggested.

Example: With a minimum of 10 minutes, a 601-second suggestion becomes 10 minutes here, whereas rounding up gives 11 minutes.

Recommended fix: Use Math.ceil when converting seconds to minutes, as applyDraftPatch does; keep the existing bounds check.

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.

🟡 Alert fix missing release note

This user-facing webapp fix has no .server-changes entry. The alert prefill improvement will be absent from customer release notes.

Learn more

The agent now passes suggested alert thresholds and windows into the query alert setup. That changes behavior users can notice. The repository requires a .server-changes/ entry for a user-facing change confined to server apps; this PR changes only the webapp and has no entry. Without one, the release process has no note to include for this fix.

Example: A user creating an alert from an agent suggestion now sees the suggested threshold and window populated, but the release notes omit the fix.

Recommended fix: Add a .server-changes/ file with area: webapp, type: fix, and a one-line description of the user-visible prefill improvement.

Devin Review


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

Comment on lines +270 to +284
it("forwards condition value and windowSec in queryWatchFromPatch", () => {
const patch = {
area: "query",
query: "SELECT count() FROM runs",
querySignalChoice: { mode: "threshold" as const, measure: "count" },
condition: { operator: ">" as const, value: 42, windowSec: 1800 },
};
expect(queryWatchFromPatch(patch)).toEqual({
query: "SELECT count() FROM runs",
mode: "threshold",
measure: "count",
operator: ">",
value: 42,
windowSec: 1800,
});

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.

🔍 Prefill test does not cover creation

The new test checks forwarding but not the displayed threshold or saved window. A flow test can cover both values through alert creation.

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