Skip to content

feat: add ctx.diagnostics host; rename ctx.logs to ctx.messages#302

Merged
antfu merged 1 commit intomainfrom
antfu/messages-diagnostics
May 1, 2026
Merged

feat: add ctx.diagnostics host; rename ctx.logs to ctx.messages#302
antfu merged 1 commit intomainfrom
antfu/messages-diagnostics

Conversation

@antfu
Copy link
Copy Markdown
Member

@antfu antfu commented May 1, 2026

Description

Two coordinated changes on the DevToolsNodeContext:

  1. New ctx.diagnostics — a DevToolsDiagnosticsHost that wraps logs-sdk. Plugins can register their own coded errors / warnings via ctx.diagnostics.register(defineDiagnostics({ codes: { … } })) and emit them through the shared ctx.diagnostics.logger — without taking a direct logs-sdk dependency. The host also re-exports defineDiagnostics and createLogger for plugins that want their own typed logger reference.
  2. Rename ctx.logsctx.messages end-to-end: field, host class (DevToolsLogsHostDevToolsMessagesHost), all DevToolsLog* types, RPC wire names (devtoolskit:internal:logs:*:messages:*), event names (log:addedmessage:added etc.), file names, and the dock panel ("Logs & Notifications" → "Messages & Notifications", id ~logs~messages). Deprecated DevToolsLogs* type aliases and a ctx.logs getter that emits a new DF0018 warning on first access keep the old surface working for one release cycle.

Includes guides at /kit/diagnostics and /devframe/guide/diagnostics, an agent skill reference at skills/vite-devtools-kit/references/diagnostics-patterns.md, and the renamed messages doc/skill counterparts.

Linked Issues

None — refactor + new API.

Additional context

This is a wire-protocol break for any external consumer that calls the internal devtoolskit:internal:logs:* RPCs directly: the shipped Vue UI and webcomponents are migrated together, but third-party clients on the old method names will not connect. The deprecated ctx.logs getter logs DF0018 once per process, so source-level migration can happen at the consumer's pace within one release cycle.

🤖 Generated with Claude Code

Introduce `ctx.diagnostics` — a `DevToolsDiagnosticsHost` that wraps
logs-sdk and lets integrations register their own coded errors / warnings
into a shared logger via `register()` / `defineDiagnostics` / `createLogger`,
without taking a direct logs-sdk dependency.

Rename the user-facing message subsystem from `logs` → `messages` end-to-end:
the `ctx.logs` field, host class, types, RPC wire names
(`devtoolskit:internal:logs:*` → `:messages:*`), event names
(`log:added/...` → `message:added/...`), file names, and the dock panel
("Logs & Notifications" → "Messages & Notifications", id `~logs` → `~messages`).
Deprecated `DevToolsLogs*` type aliases and a `ctx.logs` getter that emits
DF0018 on first access keep the old surface working for one cycle.

Wire-protocol break: clients on `:logs:*` will not connect to a server on
`:messages:*`. The Vue components and webcomponents UI ship updated
together; external consumers must update RPC method strings if they call
the internals directly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 1, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@vitejs/devtools@302
npm i https://pkg.pr.new/@vitejs/devtools-kit@302
npm i https://pkg.pr.new/@vitejs/devtools-rolldown@302
npm i https://pkg.pr.new/@vitejs/devtools-self-inspect@302

commit: 695f656

@antfu antfu merged commit 1a2a81d into main May 1, 2026
9 checks passed
@antfu antfu deleted the antfu/messages-diagnostics branch May 1, 2026 08:43
antfu added a commit that referenced this pull request May 1, 2026
Resolves a numbering conflict: main's #302 introduced DF0018 for the
`ctx.logs` deprecation warning, so my jsonSerializable diagnostics
shift up by one. New numbering on this branch:

- DF0018 (main) — `ctx.logs` deprecated.
- DF0019 — Agent Requires JSON-Serializable RPC.
- DF0020 — Non-JSON Value in JSON-Serializable RPC.
- DF0021..DF0028 — migrated from DTK0001..DTK0008.

Updates code, callsites, docs pages, sidebar count (28), error
index table, and skill / guide references to the new numbers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant