Skip to content

use getConvexSize and improve journal mismatch logging#203

Merged
ianmacartney merged 9 commits intomainfrom
ian/use-convex-size
Mar 3, 2026
Merged

use getConvexSize and improve journal mismatch logging#203
ianmacartney merged 9 commits intomainfrom
ian/use-convex-size

Conversation

@ianmacartney
Copy link
Copy Markdown
Member

@ianmacartney ianmacartney commented Feb 18, 2026

  • uses getConvexSize instead of bespoke handling - requires convex 1.31.7+
  • Consolidated internal size calculation mechanisms for consistency and removed deprecated sizing helpers.
  • Improved type safety for function argument handling.
  • Improved error message for journal mismatches
  • Added an example workflow to start a confirmation flow with an optional prompt and return a workflow identifier.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 18, 2026

Warning

Rate limit exceeded

@ianmacartney has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 23 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Replaces custom size helpers with getConvexSize, adjusts journal serialization/comparison to use picked step JSON, and narrows step/workflow argument types from unknown to object record types with normalization for undefined args.

Changes

Cohort / File(s) Summary
Size helpers removed & replaced
src/component/schema.ts, src/component/journal.ts
Deleted exported sizing helpers (valueSize, resultSize, stepSize, journalEntrySize) and replaced internal accumulation with getConvexSize(entry); imports adjusted to use getConvexSize.
Step serialization & comparison
src/client/step.ts
Step JSON now built with pick(entry.step, ["name","args","kind"]); journal vs. message comparison uses serialized stepJson and messageJson. Journal sizing uses getConvexSize(entry). Minor finalization/control-flow updates to match new serialization and sizing.
Argument typing & normalization
src/client/step.ts, src/client/workflowContext.ts
Tightened StepRequest arg types from unknown to Record<string, unknown>; runFunction args type changed to `Record<string, any>
Example workflow added
example/convex/userConfirmation.ts
Added startConfirmationWorkflow mutation returning WorkflowId, accepts optional prompt, and starts internal.userConfirmation.confirmationWorkflow with a default prompt when omitted.
Dependency bump
package.json
Peer dependency for convex updated from ^1.24.8 to ^1.31.7.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through code with gentle paws,

swapped sizes for Convex's laws,
picked steps tidy, args made whole,
workflows start with warmed-up soul,
a little rabbit, proud of my cause.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'use convex sizes' directly reflects the main objective of the PR, which is to replace custom sizing functions with Convex's native getConvexSize utility across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ian/use-convex-size

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 and usage tips.

Copy link
Copy Markdown
Member Author

ianmacartney commented Feb 18, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 18, 2026

Open in StackBlitz

npm i https://pkg.pr.new/get-convex/workflow/@convex-dev/workflow@203

commit: 2629473

@ianmacartney ianmacartney marked this pull request as ready for review February 18, 2026 06:04
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/client/step.ts (1)

39-42: kind: "workflow" args is still typed unknown, making the union collapse.

Because args: unknown on the workflow variant, TypeScript widens the entire message.target.args union to unknown (line 154), which forces the as Value assertion at line 159. Aligning it with the function variant would let the compiler reason about the type throughout.

♻️ Optional: tighten workflow args type
     | {
         kind: "workflow";
         function: FunctionReference<"mutation", "internal">;
-        args: unknown;
+        args: Record<string, any>;
       };

And align runWorkflow in workflowContext.ts to pass args ?? {} consistently with runFunction:

     target: {
       kind: "workflow",
       function: workflow,
-      args,
+      args: args ?? {},
     },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/client/step.ts` around lines 39 - 42, The workflow branch's args is typed
as unknown which widens message.target.args to unknown; change the workflow
variant's args type to the same tighter shape used by the function variant (the
same param type used by FunctionReference/"mutation"/"internal") so the union
doesn't collapse, update any related type alias where kind: "workflow" is
declared, and adjust runWorkflow in workflowContext.ts to call runWorkflow with
args ?? {} (mirroring runFunction) so callers consistently pass a non-undefined
args object; refer to the symbols kind: "workflow", FunctionReference,
message.target.args, runWorkflow, and runFunction when making these edits.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/client/step.ts`:
- Around line 39-42: The workflow branch's args is typed as unknown which widens
message.target.args to unknown; change the workflow variant's args type to the
same tighter shape used by the function variant (the same param type used by
FunctionReference/"mutation"/"internal") so the union doesn't collapse, update
any related type alias where kind: "workflow" is declared, and adjust
runWorkflow in workflowContext.ts to call runWorkflow with args ?? {} (mirroring
runFunction) so callers consistently pass a non-undefined args object; refer to
the symbols kind: "workflow", FunctionReference, message.target.args,
runWorkflow, and runFunction when making these edits.

@ianmacartney ianmacartney changed the title use convex sizes use getConvexSize and improve journal mismatch logging Feb 19, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/client/workflowContext.ts (1)

166-166: Record<string, any> is inconsistent with the Record<string, unknown> declared in StepRequest.target.args.

args: Record<string, any> | undefined erases type safety unnecessarily — the value flows directly into a Record<string, unknown> target. Using unknown here keeps the contract tighter.

♻️ Align args type with StepRequest
-  args: Record<string, any> | undefined,
+  args: Record<string, unknown> | undefined,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/client/workflowContext.ts` at line 166, The args property currently typed
as "Record<string, any> | undefined" in workflowContext.ts should be changed to
match StepRequest.target.args by using "Record<string, unknown> | undefined" to
preserve type safety; locate the args declaration (the args parameter/property
in the WorkflowContext/StepRequest-related type or function) and replace the
any-based type with unknown so the value flows into StepRequest.target.args
without erasing type guarantees.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/client/workflowContext.ts`:
- Line 166: The args property currently typed as "Record<string, any> |
undefined" in workflowContext.ts should be changed to match
StepRequest.target.args by using "Record<string, unknown> | undefined" to
preserve type safety; locate the args declaration (the args parameter/property
in the WorkflowContext/StepRequest-related type or function) and replace the
any-based type with unknown so the value flows into StepRequest.target.args
without erasing type guarantees.

@ianmacartney ianmacartney merged commit 4905b2d into main Mar 3, 2026
5 checks passed
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.

2 participants