Skip to content

surface ctx.getHistory() -> { size, stepCount }#206

Open
ianmacartney wants to merge 5 commits intoian/resumefrom
ian/get-history
Open

surface ctx.getHistory() -> { size, stepCount }#206
ianmacartney wants to merge 5 commits intoian/resumefrom
ian/get-history

Conversation

@ianmacartney
Copy link
Member

@ianmacartney ianmacartney commented Feb 19, 2026

Adds workflow history tracking with a new ctx.getHistory() method to monitor workflow execution metrics.

Fixes #178

What changed?

  • Refactored StepExecutor to track workflow execution metrics:
    • Replaced journalEntrySize with journalSize and added stepCount to track both total size and number of steps
    • Added a getHistory() method that returns these metrics
    • Modified journal size tracking to increment as steps are processed rather than calculating upfront
  • Exposed the history tracking functionality to workflow context:
    • Added a getHistory() method to the WorkflowCtx type
    • Updated the createWorkflowCtx function to accept and expose the history getter

How to test?

  1. Create a workflow that calls ctx.getHistory()
  2. Run the workflow and verify it returns an object with size and stepCount properties
  3. Run multiple steps in the workflow and check that the metrics increase appropriately
  4. Verify that journal size limits are still enforced correctly

Why make this change?

This change provides developers with visibility into workflow execution metrics, allowing them to monitor the size and complexity of their workflows. This is particularly useful for debugging performance issues and preventing workflows from hitting size limits unexpectedly. The incremental tracking approach is also more efficient than calculating the entire journal size upfront.

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e6c3530-7173-4507-9705-c753c7995719

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ian/get-history

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
Member Author

ianmacartney commented Feb 19, 2026

@ianmacartney ianmacartney marked this pull request as ready for review February 19, 2026 06:02
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2026

Open in StackBlitz

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

commit: 994880a

@ianmacartney ianmacartney force-pushed the ian/resume branch 2 times, most recently from acee365 to b7fdb37 Compare March 3, 2026 23:38
@ianmacartney ianmacartney changed the base branch from ian/resume to graphite-base/206 March 6, 2026 01:38
@ianmacartney ianmacartney changed the base branch from graphite-base/206 to ian/resume March 6, 2026 01:40
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.

1 participant