fix(devtools): make settable getters (computed) editable - #3151
Conversation
Replace the _editableComputed bookkeeping set with a runtime isReadonly() check on the raw computed ref. Also drop the dead edit handlers for the root inspector and component inspector, whose getters entries are not editable.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughPinia devtools now identify writable computed store properties, mark them editable, and write edits directly to those properties. The playground counter store demonstrates a computed value with a setter that updates its underlying state. ChangesWritable computed devtools support
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Devtools
participant PiniaStore
participant WritableComputedCheck
participant InspectorEditor
Devtools->>PiniaStore: Inspect getter
PiniaStore->>WritableComputedCheck: Read raw property
WritableComputedCheck-->>Devtools: Return writable status
Devtools->>InspectorEditor: Mark writable getter editable
InspectorEditor->>PiniaStore: Apply direct getter assignment
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v4 #3151 +/- ##
=======================================
Coverage 89.39% 89.39%
=======================================
Files 10 10
Lines 415 415
Branches 120 120
=======================================
Hits 371 371
Misses 17 17
Partials 27 27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Supersedes and closes #3110 — thanks @waradu for the original implementation, whose commit is preserved here!
computedvalues with bothgetandsetcould not be edited from the pinia devtools inspector. This makes writable computeds editable while keeping getter-only computeds readonly.Compared to #3110, the implementation is simplified: instead of tracking writable computeds in a
_editableComputedset on the store (which required changes instore.ts,types.ts, and HMR syncing), writability is detected at runtime in the devtools code withisReadonly()on the raw computed ref:This keeps the feature entirely within
src/devtools/and stays in sync after HMR by construction.Also dropped two dead code paths from the original PR: the root inspector and component inspector getters entries are not editable (
editable: false), so their edit handlers could never fire — and the root-inspector one would have written onto the pinia instance instead of the store.Summary by CodeRabbit
New Features
Bug Fixes
Tests