Skip to content

refactor(react-ag-ui): share interrupt-response validation between submitInterruptResponses and steerAway#5025

Open
ShobhitPatra wants to merge 1 commit into
mainfrom
refactor/ag-ui-shared-interrupt-validation
Open

refactor(react-ag-ui): share interrupt-response validation between submitInterruptResponses and steerAway#5025
ShobhitPatra wants to merge 1 commit into
mainfrom
refactor/ag-ui-shared-interrupt-validation

Conversation

@ShobhitPatra

@ShobhitPatra ShobhitPatra commented Jul 17, 2026

Copy link
Copy Markdown
Member

This PR dedupes the interrupt-response validation in react-ag-ui so both interrupt entry points validate through one shared helper.

What

submitInterruptResponses and steerAway each carried a near identical per-entry validation loop (interruptId presence, status validity, unknown id, duplicate), differing only in the error prefix. This extracts the loop into one private helper, collectInterruptResponses, on AgUiThreadRuntimeCore.

  • Per-method error prefixes are preserved: [agui] submitInterruptResponses: vs [agui] steerAway:.
  • Each caller keeps its own policy: submit still requires a response for every open interrupt and runs the expiry checks; steerAway still fills unanswered interrupts with cancelled.
  • No public surface change; patch changeset for @assistant-ui/react-ag-ui.

Why

The copies had already drifted in wording and check order, and any check added to one method silently misses the other. Sharing the loop keeps the two error surfaces consistent by construction.

Impact

Accept/reject behavior is unchanged; only the error message selected under multiple simultaneous violations moves, plus two wording unifications:

Input Before After
submit: unknown id unknown interrupt ids: <ids> unknown interrupt id <id> (matches steerAway)
submit: unknown id + unanswered interrupts missing-responses error unknown-id error
submit: same unknown id twice duplicate error unknown-id error
steerAway: entry without interruptId every response must have an interruptId every entry must have an interruptId
  • One test regex updated (the plural unknown-ids pin); new tests pin the previously untested checks and the ordering change.
  • react-ag-ui suite green (230 tests), full turbo build green.

Rationale

The two methods' policies differ by design (submit is strict answer-everything, steerAway is cancel-what-I-skipped), so only the per-entry validation is shared and the policies stay at the call sites.

Review in cubic

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: edea0fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@assistant-ui/react-ag-ui Patch

Not sure what this means? Click here to learn what changesets are.

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

@rupic-app rupic-app Bot added stage/draft Author still working; not ready for review pkg/react-ag-ui Changes a package under packages/ R3 Draft; not ready for review type/refactor Code refactor, no behavior change labels Jul 17, 2026
@ShobhitPatra
ShobhitPatra marked this pull request as ready for review July 17, 2026 15:33
@ShobhitPatra
ShobhitPatra requested a review from a team July 17, 2026 15:33
@rupic-app rupic-app Bot added stage/needs-review No reviews yet; waiting for a maintainer R1 Actionable, normal priority and removed stage/draft Author still working; not ready for review R3 Draft; not ready for review labels Jul 17, 2026
@claude

claude Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Claude finished @ShobhitPatra's task in 1m 40s —— View job


Reviewing PR #5025

  • Gather context (CI status, previous reviews, diff)
  • Analyze code changes in AgUiThreadRuntimeCore.ts
  • Analyze test changes
  • Check changeset / repo requirements
  • Post comprehensive review
  • Collect simplify agent findings

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "refactor(react-ag-ui): share interrupt-r..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 3 files

Re-trigger cubic

@rupic-app rupic-app Bot added stage/awaiting-reviewer Has reviews but not approved; reviewer follow-up needed and removed stage/needs-review No reviews yet; waiting for a maintainer labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg/react-ag-ui Changes a package under packages/ R1 Actionable, normal priority stage/awaiting-reviewer Has reviews but not approved; reviewer follow-up needed type/refactor Code refactor, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant