Skip to content

feat(webview): thin telemetry middleware + generic TelemetryRunner (@microsoft/vscode-ext-webview 0.10.0)#795

Open
tnaum-ms wants to merge 18 commits into
mainfrom
dev/tnaum/webview-ext-thin-telemetry
Open

feat(webview): thin telemetry middleware + generic TelemetryRunner (@microsoft/vscode-ext-webview 0.10.0)#795
tnaum-ms wants to merge 18 commits into
mainfrom
dev/tnaum/webview-ext-thin-telemetry

Conversation

@tnaum-ms

@tnaum-ms tnaum-ms commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

De-engineers the @microsoft/vscode-ext-webview telemetry middleware and adopts the new shape across the extension's webviews. Based on feedback from the vscode-cosmosdb integration attempt, the telemetry body becomes a thin delegator and the TelemetryRunner becomes generic over the context enrichment, so a consumer's runner owns the telemetry scope, chooses what to contribute to ctx, and classifies the outcome. Duration and error classification are no longer duplicated by the package — the runner's backend (e.g. callWithTelemetryAndErrorHandling) already records them.

Bumps the package 0.9.10.10.0 (minor, not patch — see Breaking changes).

Package changes (@microsoft/vscode-ext-webview)

  • Thin telemetry body + generic runner (breaking): TelemetryRunner<TEnrichment>.run(eventId, invocation, invoke); telemetryMiddlewareBody(runner, { buildEventId }) is curried and wires as publicProcedure.use(telemetryMiddlewareBody(runner, options)); the body no longer stamps duration/result.
  • ProcedureLogger gains symmetric optional onStart / onEnd hooks (replaces the single log). Both fire at the dispatch layer (attachTrpc), paired one-to-one: onStart runs once before each query/mutation/subscription, and a matching onEnd always follows — including on early setup failure. An onStart-only logger passed through the panel option now receives events.
  • mergeRouters is now returned from initWebviewTrpc() and re-exported from the shared entry (no more direct @trpc/server import to compose routers).
  • AnyRouter is re-exported from . and ./react (was already on ./host).

See packages/vscode-ext-webview/MIGRATION.md for the full 0.9.1 → 0.10.0 upgrade guide, and the updated ADVANCED.md / README.md.

Extension changes

  • The DocumentDB telemetry runner injects the full IActionContext as ctx.actionContext. actionContext is not a field on the base RouterContext; it is modeled as an additive enrichment (WithTelemetry<T> = T & RpcEnrichment in _integration/trpc.ts). Instrumented procedures (publicProcedureWithTelemetry) narrow to WithTelemetry<RouterContext> to read ctx.actionContext.telemetry; plain publicProcedure procedures narrow to bare RouterContext, so reading actionContext there is a compile error instead of a runtime undefined. Controllers build the plain RouterContext (no Omit<...> root type).
  • Query Insights composes its main + events routers via the exposed mergeRouters (retires the flat-record workaround).
  • rpcConcurrencyLogger adopts the onEnd hook.
  • The .github/skills/ authoring guides (webview-trpc-messaging, telemetry-instrumentation) and the stale trpcToTelemetry code comments in queryInsightsEventsRouter.ts are updated to the new telemetryMiddlewareBody / TelemetryRunner / ctx.actionContext surface.

Breaking changes

The package is pre-1.0; the telemetry/logger API changes are breaking but internal — only this extension and vscode-cosmosdb consume the package. The release is a minor bump (0.10.0), not a patch: a patch (0.9.2) satisfies the common ^0.9.1 range (>=0.9.1 <0.10.0), so consumers would have received the breaking release on a clean install. The minor bump moves it outside that range, making the upgrade opt-in. All changes are documented in MIGRATION.md.

Review dispositions

  • Copilot — context loss on next({ ctx }): not reproducible. tRPC v11 shallow-merges the override over the existing context ({ ...opts.ctx, ...nextOpts.ctx }), so base fields (signal, sessionId, clusterId, …) are preserved. Thread resolved.
  • Copilot — unsound getInfo cast: fixed. documentsView.getInfo is now instrumented, and actionContext moved off the base context, so the cast is honest and tsc enforces the invariant everywhere.

Verification

  • npm run build ✅ · npm run lint
  • repo jest: 2674 passing
  • package jest: 95 passing

Note: this branch intentionally excludes the indexView webview migration (out of scope — part of #732, not yet on main).

tnaum-ms added 7 commits July 14, 2026 17:56
Redesign the telemetry middleware to a thin, dependency-free delegator that
resolves the event id and hands control to a generic TelemetryRunner<TEnrichment>.
The runner owns the telemetry scope, chooses what to contribute to ctx via
next({ ctx }), and classifies the outcome from the returned result. Duration is
recorded by the runner backend (e.g. callWithTelemetryAndErrorHandling).

- TelemetryRunner is generic over the ctx enrichment; run(eventId, invocation, invoke).
- telemetryMiddlewareBody(runner, { buildEventId }) is curried.
- Remove the body duration/result stamping and the WithTelemetry helper.
- Add TelemetryMiddlewareOptions.buildEventId.
Return mergeRouters from initWebviewTrpc() and re-export a default-instance
mergeRouters from the shared entry, so multi-router consumers can compose a
view main router with its events/subscription router without importing
initTRPC/mergeRouters directly from @trpc/server.
- Re-export the AnyRouter type from the shared (.) and ./react entries so
  consumers writing generic client helpers do not import @trpc/server directly
  (./host already re-exported it).
- Replace ProcedureLogger.log with optional onStart/onEnd hooks for symmetric
  span-style logging; loggingMiddlewareBody fires onStart before next() and
  onEnd after. Update consoleProcedureLogger, attachTrpc dispatch, and tests.
Adopt the new thin telemetry body in the extension integration layer:

- documentDbTelemetryRunner is now TelemetryRunner<RpcEnrichment> and injects
  the full IActionContext as ctx.actionContext (honest naming), replacing the
  as-unknown-as-ProcedureTelemetry bridge.
- The runner owns outcome classification (Canceled/Failed + parseError error,
  errorMessage, errorStack, errorCause); duration comes free from
  callWithTelemetryAndErrorHandling.
- Event ids are declarative via buildEventId.
- Declare actionContext on the DocumentDB BaseRouterContext so per-view
  RouterContext types expose it; remove the WithTelemetry helper.
- Replace every `ctx as WithTelemetry<RouterContext>` cast with `ctx as
  RouterContext` and read `ctx.actionContext.telemetry` across the collection,
  index, document, and query-insights routers.
- Declare `actionContext: IActionContext` on each view RouterContext; view
  controllers build the root context as Omit<RouterContext, "actionContext">
  since the runner injects it per call.
- Compose queryInsights with the exposed mergeRouters (retire the flat-record
  spread workaround); export mergeRouters from the integration trpc module.
- Update rpcConcurrencyLogger (+ test) to the ProcedureLogger.onEnd hook.
- Rewrite the ADVANCED.md telemetry adapters section for the thin body and
  generic TelemetryRunner; update the logger example to onStart/onEnd; replace
  the WithTelemetry section with contributed-context guidance.
- Update README telemetry/logging examples to the new shapes.
- Add MIGRATION.md documenting the 0.9.0-preview to 0.9.1-preview upgrade.
Copilot AI review requested due to automatic review settings July 14, 2026 18:07
@tnaum-ms tnaum-ms requested a review from a team as a code owner July 14, 2026 18:07
@tnaum-ms tnaum-ms added this to the 0.9.2 milestone Jul 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the shared @microsoft/vscode-ext-webview package and the DocumentDB extension’s webview integration to a new telemetry/logging API: telemetry middleware becomes a thin delegator with a generic TelemetryRunner<TEnrichment>, procedure logging gains onStart?/onEnd?, and router composition is standardized via a re-exported mergeRouters.

Changes:

  • Refactors telemetry middleware to delegate event-id resolution + context enrichment to a generic TelemetryRunner, and migrates DocumentDB webview routers to consume ctx.actionContext.telemetry.
  • Exposes and adopts mergeRouters to compose Query Insights query/mutation + subscription routers without direct @trpc/server imports.
  • Updates logging API from ProcedureLogger.log to optional onStart / onEnd, and migrates the concurrency logger + tests accordingly.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/webviews/documentdb/documentView/documentsViewRouter.ts Migrates router context typing and procedure handlers to use ctx.actionContext model.
src/webviews/documentdb/documentView/documentsViewController.ts Types root tRPC context as Omit<RouterContext, 'actionContext'> to reflect per-call injection.
src/webviews/documentdb/collectionView/queryInsights/queryInsightsRouter.ts Switches telemetry usage to actionContext, and composes routers via mergeRouters.
src/webviews/documentdb/collectionView/queryInsights/queryInsightsEventsRouter.ts Converts subscription exports to a router for mergeRouters composition; updates ctx narrowing.
src/webviews/documentdb/collectionView/collectionViewRouter.ts Adds actionContext to router context and migrates telemetry writes to actionContext.telemetry.
src/webviews/documentdb/collectionView/collectionViewController.ts Types root tRPC context as Omit<RouterContext, 'actionContext'>.
src/webviews/_integration/trpc.ts Implements DocumentDB TelemetryRunner<RpcEnrichment> and wires curried telemetryMiddlewareBody.
src/webviews/_integration/README.md Updates integration-layer docs to reflect RpcEnrichment / actionContext model.
src/webviews/_integration/observability/rpcConcurrencyLogger.ts Migrates to ProcedureLogger.onEnd and updates dev-only console logging call.
src/webviews/_integration/observability/rpcConcurrencyLogger.test.ts Updates tests to the new onEnd logger hook.
src/webviews/_integration/appRouter.ts Removes WithTelemetry re-export and updates docs/examples to ctx as RouterContext narrowing.
packages/vscode-ext-webview/src/shared/initWebviewTrpc.ts Returns and re-exports mergeRouters from the initialized tRPC instance.
packages/vscode-ext-webview/src/shared/initWebviewTrpc.test.ts Adds coverage for mergeRouters behavior via a composed router caller.
packages/vscode-ext-webview/src/shared/index.ts Re-exports mergeRouters and type-only AnyRouter from the shared entry.
packages/vscode-ext-webview/src/shared/BaseRouterContext.ts Updates docs to reflect runner-owned context enrichment and optional telemetry bag semantics.
packages/vscode-ext-webview/src/react/index.ts Re-exports type-only AnyRouter from the React entry.
packages/vscode-ext-webview/src/host/middleware/telemetry.ts Refactors telemetry middleware to curried thin delegator + generic runner contract.
packages/vscode-ext-webview/src/host/middleware/telemetry.test.ts Updates tests to reflect delegated event-id + runner-owned outcome classification.
packages/vscode-ext-webview/src/host/middleware/logging.ts Replaces log with optional onStart/onEnd hooks and emits start/end events.
packages/vscode-ext-webview/src/host/middleware/logging.test.ts Updates tests to onEnd and adds coverage for onStart ordering.
packages/vscode-ext-webview/src/host/middleware/index.ts Updates host middleware exports for new logging/telemetry types and removes WithTelemetry.
packages/vscode-ext-webview/src/host/index.ts Updates top-level host exports for new middleware type surface.
packages/vscode-ext-webview/src/host/attachTrpc.ts Updates dispatch logging call-site to use logger.onEnd?.(...).
packages/vscode-ext-webview/src/host/attachTrpc.test.ts Migrates logger mocks/usages to onEnd.
packages/vscode-ext-webview/README.md Updates public docs/snippets for new telemetry runner contract and logger hooks.
packages/vscode-ext-webview/package.json Bumps package version to 0.9.2.
packages/vscode-ext-webview/MIGRATION.md Adds 0.9.1 → 0.9.2 migration guide for telemetry/logger/mergeRouters/AnyRouter.
packages/vscode-ext-webview/ADVANCED.md Updates advanced docs to the new logger hooks and runner-owned context enrichment model.

Comment thread packages/vscode-ext-webview/src/host/middleware/telemetry.ts
Comment thread src/webviews/documentdb/documentView/documentsViewRouter.ts
The 0.9.1 -> 0.9.2 bump shipped source-breaking API changes (generic
TelemetryRunner, curried telemetry body, removed WithTelemetry, reshaped
ProcedureLogger) as a patch. For a pre-1.0 package, npm treats 0.9.2 as
satisfying the common ^0.9.1 caret range (>=0.9.1 <0.10.0), so consumers
would receive breaking changes on a clean install without opting in.

Bump to 0.10.0 (minor) so the release falls outside ^0.9.1 and upgrades
are opt-in. Update MIGRATION.md heading to 0.9.1 -> 0.10.0, the After
label, and add a note explaining the minor-bump rationale. Sync the
package-lock workspace entry to 0.10.0.
@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

F1 addressed — breaking changes now ship as 0.10.0 (not 0.9.2)

Commit: 0f3ed21

What changed

  • packages/vscode-ext-webview/package.json: 0.9.20.10.0
  • MIGRATION.md: heading is now 0.9.1 → 0.10.0, the After code label matches, and a short paragraph explains the minor-bump rationale
  • package-lock.json: workspace entry synced to 0.10.0

Why
This PR intentionally makes source-breaking changes (generic TelemetryRunner, curried telemetryMiddlewareBody, removed WithTelemetry, ProcedureLogger.logonStart?/onEnd?). For a pre-1.0 package, npm still treats a patch as caret-compatible: 0.9.2 satisfies the common ^0.9.1 range (>=0.9.1 <0.10.0). Consumers on that range would therefore receive the breaking release on a clean install and fail to compile without touching their manifest.

Bumping the minor to 0.10.0 moves the release outside ^0.9.1, so upgrades become opt-in. This keeps the "pre-1.0 may break on minor" convention the migration guide already documents, without the silent-patch hazard.

The dispatch pump advertised the symmetric ProcedureLogger contract
(onStart? / onEnd?) but only invoked onEnd, so a consumer passing an
onStart-only logger through the panel telemetry option received no
events at all.

attachTrpc now fires onStart exactly once before each query, mutation,
and subscription runs, paired one-to-one with the existing onEnd - even
when procedure setup fails, the start hook has already fired and the
outer catch still logs the matching completion. Both hooks stay optional.

- Add a logProcedureStart helper mirroring logProcedure.
- Fire it in handleDefaultMessage and handleSubscriptionMessage before
  the procedure runs.
- Add transport tests for onStart/onEnd ordering, exactly-once delivery,
  early subscription setup failure, and onStart-only loggers.
- Document the dispatch-layer onStart/onEnd behavior in ADVANCED.md.
@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

F2 addressed — ProcedureLogger.onStart now fires at the dispatch layer

Commit: 76fbf1d

What changed (packages/vscode-ext-webview/src/host/attachTrpc.ts)

  • Added a logProcedureStart helper that mirrors the existing logProcedure (onEnd) helper.
  • handleDefaultMessage (queries/mutations) and handleSubscriptionMessage (subscriptions) now call logProcedureStart({ type, path }) once, before the procedure runs.
  • Placed the start call before each handler's try, so an early setup failure still produces a start plus its matching onEnd with ok: false (one-to-one pairing).
  • Updated the attachTrpc logger JSDoc.
  • attachTrpc.test.ts: added transport tests for onStart/onEnd ordering, exactly-once delivery, early subscription-setup failure, and an onStart-only logger.
  • ADVANCED.md: documented the dispatch-layer onStart/onEnd behavior and pairing guarantees.

Why
ProcedureLogger advertises symmetric optional onStart / onEnd hooks, and the middleware body (loggingMiddlewareBody) already fired both — but the dispatch path used by attachTrpc / WebviewController / openWebview only fired onEnd. A consumer passing an onStart-only logger through the documented panel telemetry option received nothing, contradicting both the interface and the PR summary's "symmetric hooks" claim.

Both hooks remain optional (the common case is still onEnd-only). Start entries carry only type and path, since no duration or outcome exists yet. All 19 attachTrpc tests pass.

PR #795 removed the WithTelemetry helper and replaced the per-call
ctx.telemetry slot with an injected ctx.actionContext (the full
IActionContext contributed by the DocumentDB TelemetryRunner). The two
skill guides still taught the deleted APIs, so the examples no longer
compile and the "trpcToTelemetry" narrative no longer matches the code.

webview-trpc-messaging/SKILL.md:
- Drop the WithTelemetry import and casts; narrow with `ctx as
  RouterContext` and read telemetry via `ctx.actionContext.telemetry`.
- Remove WithTelemetry from the trpc.ts key-files row (now RpcEnrichment
  contributed to ctx.actionContext).
- Replace the "trpcToTelemetry (file-local)" description with
  telemetryMiddlewareBody delegating to the DocumentDB TelemetryRunner.
- Fix the telemetry column of the publicProcedure comparison table and
  the abort/subscription examples and pitfalls list.
- Frontmatter: telemetry middleware example name -> telemetryMiddlewareBody.

telemetry-instrumentation/SKILL.md:
- tRPC procedures section now reads ctx.actionContext.telemetry after
  narrowing to RouterContext (the callWithTelemetryAndErrorHandling
  examples that use ctx.telemetry are unchanged - there ctx *is* the
  action context).
@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

F4 addressed — skill guides updated to the ctx.actionContext surface

Commit: 34dc09e

What changed

  • .github/skills/webview-trpc-messaging/SKILL.md
    • Removed the type WithTelemetry import and every ctx as WithTelemetry<RouterContext> cast; procedures now narrow with ctx as RouterContext and read ctx.actionContext.telemetry.
    • Key-files table: trpc.ts row no longer lists WithTelemetry (now the RpcEnrichment shape contributed to ctx.actionContext).
    • Replaced the trpcToTelemetry (file-local) narrative with telemetryMiddlewareBody delegating to the DocumentDB TelemetryRunner; fixed the publicProcedure vs publicProcedureWithTelemetry comparison table, the abort/subscription examples, and the pitfalls list.
    • Frontmatter description: trpcToTelemetrytelemetryMiddlewareBody.
  • .github/skills/telemetry-instrumentation/SKILL.md
    • The "tRPC Procedures (auto-telemetry)" example now reads ctx.actionContext.telemetry after narrowing to RouterContext.
    • Left the callWithTelemetryAndErrorHandling(...) examples that use ctx.telemetry unchanged — in those the callback ctx is the IActionContext, so ctx.telemetry is correct there.

Why
These are the canonical authoring references the repo instructions direct contributors (and Copilot) to follow. This PR deleted WithTelemetry and moved telemetry from a fixed ctx.telemetry slot to an injected ctx.actionContext, so the guides were teaching code that no longer compiles or uses the wrong context shape. They're now aligned with the shipped routers (e.g. queryInsightsRouter.ts uses myCtx.actionContext.telemetry).

The telemetry reshape in this PR removed the trpcToTelemetry helper name
(the equivalent is now telemetryMiddlewareBody delegating to the
DocumentDB TelemetryRunner) and moved the per-call telemetry slot from
ctx.telemetry to ctx.actionContext. Three explanatory comments in
queryInsightsEventsRouter.ts still referenced the old names, which
misdescribed how the Stage 3 completion event relates to middleware
timing. Comment-only change; no behavior change.
@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

F5 addressed — refreshed stale trpcToTelemetry comments

Commit: 797f007

What changed (src/webviews/documentdb/collectionView/queryInsights/queryInsightsEventsRouter.ts)

  • Three explanatory comments (the STAGE3_COMPLETION_EVENT doc, the CompletionTelemetry accumulator doc, and the inline note in the subscription handler) referenced trpcToTelemetry wrapping opts.next() and recording onto ctx.telemetry.
  • Updated them to the current model: the telemetry middleware (telemetryMiddlewareBody) wraps the invocation — which for a subscription resolves at generator-creation time — and the deleted buffered procedure's keys mirror onto ctx.actionContext.telemetry.

Why
trpcToTelemetry no longer exists after this PR's reshape, so the comments misdescribed how the dedicated Stage 3 completion event relates to middleware timing. Comment-only change; no behavior change.


All independent findings (F1, F2, F4, F5) are now addressed. F3/C2 (the getInfo context cast) is a Copilot-thread item — I'll handle it in that review thread once its fix is confirmed.

tnaum-ms added 2 commits July 15, 2026 07:50
…chment (F3)

Previously each view's RouterContext declared actionContext as a required
field, and controllers subtracted it with Omit<RouterContext,
'actionContext'>. That let an uninstrumented procedure (documentsView
getInfo on plain publicProcedure) cast ctx as RouterContext and assert
actionContext exists even though the telemetry runner never injected it -
a latent TypeError waiting for the first myCtx.actionContext access.

Invert the model (Option C): actionContext is no longer part of the base
RouterContext. Add WithTelemetry<T> = T & RpcEnrichment in trpc.ts and
narrow to WithTelemetry<RouterContext> only in publicProcedureWithTelemetry
procedures that actually read actionContext. Plain publicProcedure
procedures narrow to bare RouterContext, so reading actionContext there is
now a compile error instead of a runtime undefined.

- trpc.ts: add + export WithTelemetry<T>; update RpcEnrichment docs.
- appRouter.ts: re-export type WithTelemetry.
- collectionViewRouter / documentsViewRouter: drop actionContext from
  RouterContext; flip the instrumented casts that read it.
- queryInsightsRouter: flip Stage1/Stage2 casts.
- controllers: root context is now plain RouterContext (no Omit).
- D1: instrument documentsView.getInfo (publicProcedureWithTelemetry +
  WithTelemetry<RouterContext>) to match collectionView.getInfo, making
  its cast honest.
- Update the webview-trpc-messaging and telemetry-instrumentation skill
  guides to teach the WithTelemetry<RouterContext> narrowing.
@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

F3 addressed — actionContext is now an additive WithTelemetry enrichment

Commit: efe086e
(also answered inline in the Copilot C2 thread: #795 (comment))

What changed

  • trpc.ts: added export type WithTelemetry<T> = T & RpcEnrichment and refreshed the RpcEnrichment docs.
  • appRouter.ts: re-exports WithTelemetry.
  • collectionViewRouter.ts / documentsViewRouter.ts: removed actionContext from RouterContext; the instrumented procedures that read it now narrow to WithTelemetry<RouterContext>.
  • queryInsights/queryInsightsRouter.ts: Stage 1 / Stage 2 casts narrowed to WithTelemetry<RouterContext>.
  • collectionViewController.ts / documentsViewController.ts: root context is now plain RouterContext (the Omit<RouterContext, 'actionContext'> is gone).
  • D1: documentsView.getInfo is now publicProcedureWithTelemetry (+ WithTelemetry<RouterContext>), matching its collectionView sibling — so its cast is honest.
  • Updated the webview-trpc-messaging and telemetry-instrumentation skill guides to teach the WithTelemetry<RouterContext> narrowing.

Why
RouterContext declared actionContext as required, but the telemetry runner only injects it for publicProcedureWithTelemetry. The uninstrumented getInfo cast ctx as RouterContext therefore asserted a field that wasn't there — harmless today (it only JSON.stringifys ctx) but a latent TypeError for the first myCtx.actionContext access. Inverting the model (actionContext out of the base type, added back via WithTelemetry<T>) makes reading actionContext on a plain publicProcedure a compile error instead of a runtime undefined. tsc flagged all 28 actionContext reads on bare RouterContext; each was reconciled. Full build + 319 webview tests pass.


Bookkeeping: commit 5f07c5f is a formatting-only follow-up to F4 (Prettier table-column re-alignment in webview-trpc-messaging/SKILL.md) — no content change.

- README.md: Status line 0.9.0-preview -> 0.10.0 (matches package.json).
- MIGRATION.md: document the additive WithTelemetry<T> = T & { actionContext }
  consumer pattern as the recommended alternative to baking actionContext
  into RouterContext + Omit, so an uninstrumented (plain publicProcedure)
  procedure can't assert an actionContext that was never injected. This is
  the pattern the DocumentDB reference extension now uses (F3).

Verified: l10n (no string changes), prettier, eslint, full jest (2674),
and build all pass.
@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

Final documentation & 0.10.0 migration review

Commit: 87f3766

Swept all manuals, docs, and skills for 0.10.0 consistency and stale telemetry references. Two shipped-doc fixes:

  • README.md — Status line 0.9.0-preview0.10.0 (now matches package.json).
  • MIGRATION.md — added the additive WithTelemetry<T> = T & { actionContext } consumer pattern as the recommended alternative to baking actionContext into RouterContext + Omit<…>, so an uninstrumented (plain publicProcedure) procedure can't assert an actionContext that was never injected. This is the pattern the reference extension adopted in F3.

Reviewed and confirmed already-consistent (no change needed):

  • MIGRATION.md heading/labels are 0.9.1 → 0.10.0; the 0.9.2 mentions that remain are the intentional "why a minor, not a patch" rationale.
  • ADVANCED.md documents the dispatch-layer onStart/onEnd (F2) and the telemetryMiddlewareBody + TelemetryRunner flow.
  • README.md / src/host/middleware/README.md reflect the current ProcedureLogger (onStart?/onEnd?) surface.
  • Both skill guides (webview-trpc-messaging, telemetry-instrumentation) teach WithTelemetry<RouterContext>; the remaining ctx as RouterContext examples are signal-only and correct.
  • Repo docs/user-manual and docs/release-notes contain no package/telemetry references. Remaining trpcToTelemetry/0.9.2 hits are confined to historical docs/ai-and-plans/PRs/** planning archives (accurate as history) and CONTRIBUTING.md generic version examples.

Verification (full PR checklist):

  • npm run l10n — no bundle changes (no user-facing strings added/changed/removed)
  • Prettier — clean
  • npm run lint — clean
  • npx jest --no-coverage2674 passed / 159 suites
  • npm run build — clean (package builds as @microsoft/vscode-ext-webview@0.10.0)

@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

Follow-up — skill example consistency

Commit: 4c7cf5c

Audited every ctx as WithTelemetry<RouterContext> occurrence after the F3 change. All casts in shipped code and current docs are correct (build + 2674 tests confirm they compile). The docs/ai-and-plans/PRs/** hits are frozen planning archives (historical), and MIGRATION.md's 0.9.1-labelled one is the intentional "before" example of the removed package-level helper.

One internal inconsistency fixed: the webview-trpc-messaging section-2 getData example cast to WithTelemetry<RouterContext> but never read actionContext, which contradicted the least-privilege rule elsewhere in the same guide ("narrow with WithTelemetry when the procedure reads telemetry, RouterContext otherwise"). The example now writes a telemetry property, so the cast is justified and the guide is self-consistent.

@tnaum-ms tnaum-ms changed the title feat(webview): thin telemetry middleware + generic TelemetryRunner (@microsoft/vscode-ext-webview 0.9.2) feat(webview): thin telemetry middleware + generic TelemetryRunner (@microsoft/vscode-ext-webview 0.10.0) Jul 15, 2026
@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

@microsoft-github-policy-service

@tnaum-ms tnaum-ms enabled auto-merge July 15, 2026 10:52
@github-actions

Copy link
Copy Markdown
Contributor

✅ Code Quality Checks

Check Status How to fix
Localization (l10n) ✅ Passed
ESLint ✅ Passed
Prettier formatting ✅ Passed

This comment is updated automatically on each push.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Build Size Report

Metric Base (main) PR Delta
VSIX (vscode-documentdb-0.9.1.vsix) 8.01 MB 8.01 MB ⬆️ +0 KB (+0.0%)
Webview bundle (views.js) 5.88 MB 5.88 MB ✅ 0 KB (0.0%)

Download artifact · updated automatically on each push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants