You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: preserve action identity across store re-exports - #3221
Returning another store's action from a setup store currently reuses its wrapper. For example, return { advance: original.increment } renames subsequent original.increment() notifications to advance, while facade.advance() never notifies the facade's subscribers.
Give each store's public action its own subscription identity while delegating to the source action with its original store context. Same-store helper aliases retain their own names without duplicate notifications. Add regression coverage for aliases, chained facades, identical store IDs across Pinia instances, helper reuse, arguments, return values, errors and Promise callback ordering, and document the behavior.
Validated independently against the complete commit:
Reproduced both failures on the unchanged base; both controls passed.
Root TypeScript build, all five Pinia build formats, declaration tests and production dist import passed.
Whole-workspace tests, lint and other package builds were not run.
Summary by CodeRabbit
Bug Fixes
Re-exported actions now preserve the original action’s store context and name when called. Subscribers on both the source and receiving stores are notified with the appropriate store and action details.
Documentation
Clarified how action notifications work when a setup store returns an action from another store.
No actionable comments were generated in the recent review.
Walkthrough
The action wrapper now tracks the source store and original function for re-exported actions. Calls use the source store context, and subscribers on both stores receive notifications with their respective store and action names.
Changes: Re-exported actions
Layer / File(s)
Summary
Track action ownership and aliases packages/pinia/src/store.ts
The action marker records the owning store and original function. The wrapper reuses compatible wrappers and unwraps the original function when creating a differently named alias.
Dispatch calls and validate notifications packages/pinia/src/store.ts, packages/pinia/__tests__/reexportActions.spec.ts, packages/docs/core-concepts/actions.md
Re-exported calls use the source store as their context. Both stores receive action notifications with their own store and action names. Tests cover aliases, callback behavior, return values, and errors; documentation describes the notifications.
sequenceDiagram
participant FacadeStore
participant ActionWrapper
participant FacadeSubscriber
participant SourceSubscriber
participant SourceStore
FacadeStore->>ActionWrapper: Call re-exported action
ActionWrapper->>FacadeSubscriber: Notify with facade store and action name
ActionWrapper->>SourceSubscriber: Notify with source store and action name
ActionWrapper->>SourceStore: Invoke original action with source store context
Loading
Suggested reviewers:posva
Merge Risk: Minimal · up to bd930
This fixes setup stores that return another store's action, so subscribers on both stores now receive notifications with their own store and action names. The change is confined to the action wrapper, has dedicated regression tests and documentation, and no concrete merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix: preserve action identity across store re-exports" matches the main change in the changeset. The store.ts changes keep same-store wrappers, unwrap the original function for differently …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix: preserve action identity across store re-exports" matches the main change in the changeset. The store.ts changes keep same-store wrappers, unwrap the original function for differently named aliases, and invoke re-exported actions with their source store as this. The new reexportActions.spec.ts covers re-export identity and delegation, and the docs describe the notification behavior. The title is specific and concise, and it is consistent with the PR objectives.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: ce7661af-68f2-46cf-833d-a9a96ddf0aae
Commits
Reviewing files that changed from the base of the PR and between 4023d12 and bd93064.
Files selected for processing: 3
packages/docs/core-concepts/actions.md
packages/pinia/__tests__/reexportActions.spec.ts
packages/pinia/src/store.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.40%. Comparing base (05ece25) to head (bd93064). ⚠️ Report is 2 commits behind head on v4.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Returning another store's action from a setup store currently reuses its wrapper. For example,
return { advance: original.increment }renames subsequentoriginal.increment()notifications toadvance, whilefacade.advance()never notifies the facade's subscribers.Give each store's public action its own subscription identity while delegating to the source action with its original store context. Same-store helper aliases retain their own names without duplicate notifications. Add regression coverage for aliases, chained facades, identical store IDs across Pinia instances, helper reuse, arguments, return values, errors and Promise callback ordering, and document the behavior.
Validated independently against the complete commit:
Whole-workspace tests, lint and other package builds were not run.
Summary by CodeRabbit