Skip to content

workflows: rollback types#6766

Merged
danlapid merged 6 commits into
mainfrom
vaish/rollbacks-types
May 21, 2026
Merged

workflows: rollback types#6766
danlapid merged 6 commits into
mainfrom
vaish/rollbacks-types

Conversation

@vaishnav-mk

Copy link
Copy Markdown
Contributor

Adds Workers types for optional step.do(name, config?, callback, { rollback, rollbackConfig }) Workflow rollback options.

@vaishnav-mk vaishnav-mk requested review from a team as code owners May 18, 2026 14:53

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

I'm Bonk, and I've done a quick review of your PR.

This PR adds TypeScript types for Workflow step.do() rollback options (WorkflowRollbackContext, WorkflowRollbackHandler, WorkflowStepRollbackOptions).

Issues

  1. [MEDIUM] WorkflowStepRollbackOptions<T> generic not threaded through do() overloads — The WorkflowStepRollbackOptions type accepts a generic T that flows to WorkflowRollbackContext<T>.output, but both do() overloads use the bare WorkflowStepRollbackOptions (defaulting T to unknown). This means ctx.output in the rollback handler is always unknown, even though the step's return type T is known. Users will have to cast output manually, which defeats the purpose of the generic. See inline suggestion.

  2. [LOW] Type tests assert output is unknown — masks issue #1 — The type tests currently assert ctx.output is unknown, which passes but only because the generic isn't wired through. If/when you fix issue #1, the tests for the first overload should assert the inferred type (e.g., string), which would catch any future regression.


These comments were generated by an AI code reviewer and may not be perfect. Please use your judgment when evaluating them.

Comment thread types/defines/rpc.d.ts
Comment thread types/defines/rpc.d.ts
Comment thread types/test/types/rpc.ts Outdated
@ask-bonk

ask-bonk Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

I've posted a review on PR #6766 with 2 findings:

  1. [MEDIUM] Generic T not threaded through do() overloads — Both do() overloads use bare WorkflowStepRollbackOptions without passing T, so ctx.output in the rollback handler is always unknown even when the step's return type is known. Inline suggestions provided for both overloads in types/defines/rpc.d.ts.

  2. [LOW] Type tests mask the issue — The tests assert ctx.output is unknown, which only passes because of issue Rename BUILD -> BUILD.bazel #1. Suggested updating the assertion to string to match the inferred callback return type once the generic is wired through.

github run

@codspeed-hq

codspeed-hq Bot commented May 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 72 untouched benchmarks
⏩ 129 skipped benchmarks1


Comparing vaish/rollbacks-types (4a51e89) with main (fff20c4)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@petebacondarwin

Copy link
Copy Markdown
Contributor

/bonk review

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

Previous review findings have all been addressed — WorkflowStepRollbackOptions<T> is now correctly threaded through both do() overloads, and the type tests assert string | undefined instead of unknown.

Remaining findings:

  1. [LOW] No backward-compatibility test for do() without rollback options — All three test cases pass a rollback options object (even {}). Consider adding a test that calls do() without the trailing parameter to verify the existing API shape still works.

  2. [LOW] Separate import type statementimport type {WorkflowStep} on line 12 could be folded into the existing import block on lines 5-11 using inline type syntax (import { ..., type WorkflowStep }) to reduce import clutter.


These comments were generated by an AI code reviewer and may not be perfect. Please use your judgment when evaluating them.

Comment thread types/test/types/rpc.ts
Comment thread types/test/types/rpc.ts Outdated
@ask-bonk

ask-bonk Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

I've posted a review on PR #6766 with 2 findings:

  1. [LOW] No backward-compatibility test for do() without rollback options — All test cases pass a rollback options object. Suggested adding tests that exercise the original do() signatures without the trailing parameter to verify backward compatibility.

  2. [LOW] Separate import type statement — The standalone import type {WorkflowStep} could be merged into the existing import block using inline type syntax.

The previous review's MEDIUM finding (generic T not threaded through do() overloads) and LOW finding (tests asserting unknown instead of string) have both been addressed in the current revision. The type definitions, generated snapshots, and test coverage are all consistent.

github run

@vaishnav-mk vaishnav-mk force-pushed the vaish/rollbacks-types branch from b1e522d to 4a51e89 Compare May 21, 2026 10:42
@vaishnav-mk

Copy link
Copy Markdown
Contributor Author

/bonk review

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

All findings from previous reviews have been addressed:

  • [RESOLVED] Generic T threaded through both do() overloads — WorkflowStepRollbackOptions<T> now correctly propagates the callback's return type to ctx.output in the rollback handler.
  • [RESOLVED] Type tests updated to assert string | undefined instead of unknown.
  • [RESOLVED] Backward-compatibility tests added for do() without rollback options (both 2-arg and 3-arg forms).
  • [RESOLVED] Import merged into single block using inline type syntax.

No new findings. The type definitions are correct, overloads are unambiguous, generated snapshots are consistent across all four files, and test coverage is thorough. The ChatCompletionsInput -> ChatCompletionsBase change in the snapshots is an expected artifact of regeneration against the current main branch.


These comments were generated by an AI code reviewer and may not be perfect. Please use your judgment when evaluating them.

@ask-bonk

ask-bonk Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

I've posted a review on PR #6766 with no new findings. All issues from the two previous reviews have been addressed:

  1. Generic T is now correctly threaded through both do() overloads
  2. Type tests assert string | undefined instead of unknown
  3. Backward-compatibility tests added for do() without rollback options
  4. Import merged using inline type syntax

The PR is clean — type definitions are correct, overloads are unambiguous, snapshots are consistent, and test coverage is thorough. It has approvals from both petebacondarwin and dom96.

github run

@danlapid danlapid merged commit d0e7038 into main May 21, 2026
21 of 24 checks passed
@danlapid danlapid deleted the vaish/rollbacks-types branch May 21, 2026 14:27
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.

4 participants