feat(data-inspector): writable data sources with live edits and change notifications - #153
Merged
Conversation
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
# Conflicts: # plugins/data-inspector/src/spa/App.vue # plugins/data-inspector/src/spa/composables/workbench.ts
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Data sources can now opt into live edits: connected inspectors mutate the source's live object in place, and sources gain an API to notify connected views when their data changes.
Registry
DataSourceEntry.writable?: boolean— opt-in (default read-only).static: true+writable: trueis a contradiction (a memoized snapshot is read-only): registration reports the newDP_DATA_INSPECTOR_0004diagnostic warning and the source stays read-only.registerDataSource()(and the context service'sregister) now returns a handle —{ notifyChanged(), unregister() }— instead of a bare dispose function.DataSourceEntry.subscribe?: (notify) => dispose— declarative bridge for sources with their own change signal; wired on registration, disposed on unregister/replace.onDataSourceDataChanged(listener)feeds the node-side broadcast.RPC & events
devframes:plugin:data-inspector:write—{ sourceId, request, options }where the request is one of set / delete / add / rename, container-generic on the wire; the server dispatches on what theNodePathresolves to (object / array / Map / Set). Values travel as discriminated payloads ({ kind: 'json', value } | { kind: 'undefined' }) soundefinedsurvives JSON transport. Not agent-exposed.devframes:plugin:data-inspector:data:changed(source id payload) on every successful write andnotifyChangedcall; clients auto re-run behind a 300 ms trailing throttle.sources:changedbroadcast to use the proper{ method, args }options form.engine/write.ts) mirrorsnavigate's descent semantics (including theexcludeFunctionsarray-index shift), rename is atomic server-side, and every failure returns a named error outcome (ReadonlySource,PathNotFound,FrozenTarget,WrongContainer,InvalidKey, …).Workbench UI
$) of a writable source, where the display transform records realNodePaths (string-keyed Maps and Sets included;$refs, truncation markers, and non-string-keyed Map entries excluded).string / number / boolean / null / undefined / json), plus add-entry, rename-key, and delete (with confirm).writable: true(its factory memoizes, so edits stick) — a live demo of the feature.Verified end-to-end with a headless browser against the standalone CLI: pencils render on the root view, the panel round-trips a
set(os.platform→ new value visible on re-query), and derived queries drop the affordance and show the hint.Breaking (pre-1.0):
registerDataSourcereturns the handle instead of a dispose function;DataSourceMetagains a requiredwritablefield. API snapshots updated.Created with the help of an agent.