feat(journeys,core): add runtime.canGoBack / canGoForward predicates#41
Conversation
Read-only predicates that mirror the guards in `goBack` / `goForward` exactly, so a shell-owned Back / Forward toolbar can gate enable-state authoritatively from a single instance id without duplicating the runtime's transition / entry opt-in logic. Factored a single `canGoBackFor(record, reg)` helper that's now the sole authority on "would goBack(id) rewind?". Used by: - `bindStepCallbacks` (gates the step-prop `goBack` closure) - `dispatchGoBack` (rejects calls that should be no-ops) - `runtime.canGoBack(id)` (new predicate) This collapses three inline copies of the rule and fixes a latent contradiction with the documented "Matches the closure form" promise: previously `dispatchGoBack` skipped the `entryAllowBackMode` check, so `runtime.goBack(id)` could rewind out of a step the module had explicitly declared non-rewindable. `validateJourneyContracts` already flagged this as a config error, but the runtime is now defensive when validation is skipped. Same pattern for `canGoForwardFor` / `dispatchGoForward` (no behavior change there). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR adds two new public query methods, ChangesNavigation Predicate API
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Two issues with the CI workflow surfaced on this PR:
1. The reusable `ci.common.yml` declares `permissions: contents: read`
on its build job, but the calling `build` job in `ci.yml` had no
`permissions:` block. Combined with the workflow-level
`permissions: {}` added in #39, the caller could not grant the
permissions the reusable workflow needs, so every CI run since #39
has been a `startup_failure` with zero jobs scheduled. Grant
`contents: read` on the caller job so the reusable workflow can run.
2. `PATH_TO_NAME` in `changed-files-job` enumerated every workspace
package except `packages/journeys`, so PRs touching only journeys
produced an empty `packages` output and skipped the build matrix
entirely. Add the missing entry.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
JourneyRuntime.canGoBack(id)andcanGoForward(id)— read-only predicates that mirror the guards ingoBack/goForward, so shell-owned Back / Forward toolbars can gate enable-state authoritatively from a single instance id without duplicating the runtime's transition / entry opt-in logic.canGoBackFor(record, reg)helper as the sole authority on "wouldgoBack(id)rewind?", used bybindStepCallbacks(step-prop closure),dispatchGoBack(call-site guard), andruntime.canGoBack(id). Same pattern forcanGoForwardFor.dispatchGoBack: now honoursentry.allowBack: falseon the active step's registered module descriptor. Previouslyruntime.goBack(id)could rewind out of a step the module had explicitly declared non-rewindable, contradicting the existing "Matches the closure form" JSDoc onJourneyRuntime.goBack.validateJourneyContractsalready flagged this configuration as an error, so the change is observable only when validation is skipped — strictly defensive.Test plan
pnpm vitest runinpackages/journeys— 426 tests pass, including new regression tests for the entry opt-out scenario (canGoBackreturnsfalseANDruntime.goBack(id)no-ops when the active entry declaresallowBack: false).vitesttypecheck integration).oxlintclean on touched files (one pre-existing unused-import warning unrelated to this change).🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation