Conversation
📝 WalkthroughWalkthroughThe changes introduce support for editing writable computed getters in Pinia stores through the devtools. A new Changes
Sequence DiagramsequenceDiagram
participant User as Devtools User
participant DevTools as Devtools UI
participant Plugin as DevTools Plugin
participant Store as Pinia Store
participant Computed as Computed Getter
User->>DevTools: Attempts to edit computed getter value
DevTools->>Plugin: editComponentState(path=['getters', 'myComputed'], payload)
Plugin->>Store: Validate: store._editableComputed.has('myComputed')?
alt Is Writable Computed
Store-->>Plugin: ✓ Found in _editableComputed
Plugin->>Plugin: Disable timeline logging
Plugin->>Computed: payload.set(newValue)
Computed-->>Store: Update computed value
Plugin->>Plugin: Re-enable timeline logging
Plugin-->>DevTools: Success
DevTools-->>User: Changes reflected
else Is Readonly Computed
Store-->>Plugin: ✗ Not found in _editableComputed
Plugin-->>DevTools: Error toast (invalid path)
DevTools-->>User: Edit rejected
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/pinia/src/devtools/plugin.ts (1)
185-200: Consider marking editable getters in component inspector view.The
inspectComponenthandler still shows all getters witheditable: false(line 189). For consistency with the inspector state and to enable editing writable computed refs from the component panel, consider checkingstore._editableComputedhere as well.♻️ Suggested improvement
if (store._getters && store._getters.length) { payload.instanceData.state.push({ type: getStoreType(store.$id), key: 'getters', - editable: false, + editable: store._editableComputed?.size ? true : false, value: store._getters.reduce((getters, key) => {Or more granularly, you'd need to restructure to pass individual getter editability, which would require changes to how getters are represented in the component state.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/pinia/src/devtools/plugin.ts` around lines 185 - 200, The getters block always sets editable: false; update it to consider store._editableComputed so writable computed refs appear editable in the inspector: when building the getters entry pushed to payload.instanceData.state (the block that checks store._getters and pushes an object with type: getStoreType(store.$id), key: 'getters'), set editable to true when store._editableComputed is present (or, for finer granularity, derive editability per key from store._editableComputed while preserving the current value-building logic using store._getters and store[key]); adjust the payload shape accordingly if you choose per-key editability.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/pinia/src/devtools/plugin.ts`:
- Around line 185-200: The getters block always sets editable: false; update it
to consider store._editableComputed so writable computed refs appear editable in
the inspector: when building the getters entry pushed to
payload.instanceData.state (the block that checks store._getters and pushes an
object with type: getStoreType(store.$id), key: 'getters'), set editable to true
when store._editableComputed is present (or, for finer granularity, derive
editability per key from store._editableComputed while preserving the current
value-building logic using store._getters and store[key]); adjust the payload
shape accordingly if you choose per-key editability.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0ca2a94c-42c8-4e1e-a0cb-caa2faa54ea8
📒 Files selected for processing (4)
packages/pinia/src/devtools/formatting.tspackages/pinia/src/devtools/plugin.tspackages/pinia/src/store.tspackages/pinia/src/types.ts
computedvalues with bothgetandsetcould not be edited from pinia devtools before.Example:
This change makes writable getters (computed) editable in the devtools while keeping readonly computed values readonly.
Summary by CodeRabbit
Release Notes