feat/extract webview trpc packages#3121
Open
bk201- wants to merge 4 commits into
Open
Conversation
bk201-
commented
Jun 3, 2026
Contributor
- chore(webview): align tRPC infra with documentdb package
- refactor(packages): extract @cosmosdb/webview-rpc
Snapshot of pre-extraction state. Brings cosmosdb's webview tRPC infrastructure to behavioural and API parity with @vscode-ext-react-webview from vscode-documentdb:
- Split tRPC middleware into logging/telemetry with pluggable ProcedureLogger and TelemetryRunner<T> adapters (azextTelemetryRunner, outputChannelLogger, consoleProcedureLogger fallback).
- Generic BaseRouterContext = { signal?; telemetry? }; WithRequired<T,K> + WithTelemetry<T> helpers.
- Abort-aware telemetry: ctx.signal?.aborted -> properties.aborted='true', result='Canceled'.
- useTrpcClient migrated to options-object API; TrpcClient<T> alias via non-deprecated TRPCClient.
- WithWebviewContext provider helper with memoized value.
- BaseTab gains onDisposed EventEmitter + isDisposed getter with idempotent dispose guard.
- TypedEventSink: iterator.return() + idempotent close(); 15 tests covering edge cases.
- setupTrpc: abort flow for query/mutation, iterator.return() on subscription.stop and panel.dispose, per-op context clone, undefined->null structured-clone coalesce, safer postMessage.
- vscodeLink: abort flow with pre-aborted signal early-exit, sendSafe strips non-serializable signal, abort listener cleanup.
- 18 tests for vscodeLink, 6 tests for errorLink.
Sees plans/webview-vs-documentdb-package.md for full delta analysis.
Move the generic tRPC transport for VS Code webviews out of src/ into a standalone workspace package. The package is intentionally cosmosdb-agnostic — concrete routers, telemetry adapters, and logger adapters stay in the consumer (src/panels/trpc/middleware/...). Subpaths: * '@cosmosdb/webview-rpc' — TypedEventSink, wire-protocol types (shared) * '@cosmosdb/webview-rpc/server' — setupTrpc, BaseRouterContext, middleware factories (loggingMiddlewareBody, telemetryMiddlewareBody), middleware types (ProcedureInvocation, ProcedureType, MiddlewareResultLike), ProcedureLogger / TelemetryRunner adapter interfaces, WithRequired<T,K> / WithTelemetry<T> helpers * '@cosmosdb/webview-rpc/client' — vscodeLink, errorLink (browser-only, no vscode API) * '@cosmosdb/webview-rpc/react' — WebviewContext + WithWebviewContext provider, useTrpcClient<TRouter>(options?) hook (memoised tRPC client wired up with loggerLink + optional errorLink + vscodeLink) Build wiring: * tsconfig.base.json — path aliases for all four subpaths * vite.config.ext.mjs — server/client/shared aliases (no /react — that's browser-only) * vite.config.views.mjs — client/react/shared aliases (no /server — vscode/Node-only, noExtensionImports plugin would reject) * tsconfig.test.json — exclude packages/**/*.test.ts so Mocha tsc doesn't pick up vitest tests Validation gate green: tsc (main + test + vitest), vitest (1121 passed / 1 skipped), npm run vite-prod (ext + views), oxlint (0 errors / 436 baseline warnings), eslint --quiet (clean).
143a935 to
0f557f3
Compare
Contributor
🎉 Build Summary🔗 Source
📦 Package Information
🧪 Test Results
✅ Build StatusAll checks completed successfully! |
languy
previously approved these changes
Jun 10, 2026
# Conflicts: # package-lock.json # package.json # tsconfig.test.json
Contributor
🔬 NoSQL language-service integrationCommit: 199e939 🧪 Result
📥 Artifacts (run)
|
Contributor
🎭 E2E Tests (Playwright + VS Code)Commit: 199e939 🧪 Result
📥 Artifacts (run)
|
Contributor
🔨 Build, Lint & Test🔗 Source
📦 Package Information
🧪 Test Results
📥 Artifacts (run)✅ Build StatusBuild and local tests passed. See sibling comments below for E2E and NoSQL integration results. |
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.