Skip to content

feat(data-inspector): writable data sources with live edits and change notifications - #153

Merged
antfu merged 4 commits into
mainfrom
frank-insects-fly
Jul 31, 2026
Merged

feat(data-inspector): writable data sources with live edits and change notifications#153
antfu merged 4 commits into
mainfrom
frank-insects-fly

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

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?: booleanopt-in (default read-only). static: true + writable: true is a contradiction (a memoized snapshot is read-only): registration reports the new DP_DATA_INSPECTOR_0004 diagnostic warning and the source stays read-only.
  • registerDataSource() (and the context service's register) 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.
  • New onDataSourceDataChanged(listener) feeds the node-side broadcast.

RPC & events

  • New action 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 the NodePath resolves to (object / array / Map / Set). Values travel as discriminated payloads ({ kind: 'json', value } | { kind: 'undefined' }) so undefined survives JSON transport. Not agent-exposed.
  • New broadcast devframes:plugin:data-inspector:data:changed (source id payload) on every successful write and notifyChanged call; clients auto re-run behind a 300 ms trailing throttle.
  • Fixed the pre-existing sources:changed broadcast to use the proper { method, args } options form.
  • The write applier (engine/write.ts) mirrors navigate's descent semantics (including the excludeFunctions array-index shift), rename is atomic server-side, and every failure returns a named error outcome (ReadonlySource, PathNotFound, FrozenTarget, WrongContainer, InvalidKey, …).

Workbench UI

  • Edit affordances appear only at provably-source paths — the identity view ($) of a writable source, where the display transform records real NodePaths (string-keyed Maps and Sets included; $refs, truncation markers, and non-string-keyed Map entries excluded).
  • A quiet hover pencil per node opens a side panel: path breadcrumb, prefilled current value, a type picker (string / number / boolean / null / undefined / json), plus add-entry, rename-key, and delete (with confirm).
  • Read-only sources show a lock hint; a writable source under a derived query shows a "root view only" hint. The static SPA backend rejects writes like it already does saved queries.
  • The built-in example source is now 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): registerDataSource returns the handle instead of a dispose function; DataSourceMeta gains a required writable field. API snapshots updated.


Created with the help of an agent.

@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit b47640b
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a6c682387848700088b8477
😎 Deploy Preview https://deploy-preview-153--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

antfubot and others added 3 commits July 31, 2026 06:40
# Conflicts:
#	plugins/data-inspector/src/spa/App.vue
#	plugins/data-inspector/src/spa/composables/workbench.ts
@antfu
antfu merged commit 6db7aee into main Jul 31, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants