Skip to content

feat/extract webview trpc packages#3121

Open
bk201- wants to merge 4 commits into
mainfrom
feat/extract-webview-trpc-packages
Open

feat/extract webview trpc packages#3121
bk201- wants to merge 4 commits into
mainfrom
feat/extract-webview-trpc-packages

Conversation

@bk201-

@bk201- bk201- commented Jun 3, 2026

Copy link
Copy Markdown
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.
@bk201- bk201- requested a review from a team as a code owner June 3, 2026 12:10
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).
@bk201- bk201- force-pushed the feat/extract-webview-trpc-packages branch from 143a935 to 0f557f3 Compare June 3, 2026 12:13
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🎉 Build Summary

🔗 Source

📦 Package Information

🧪 Test Results

  • Unit Tests: ✅ success
  • Integration Tests: ✅ success

✅ Build Status

All checks completed successfully!

languy
languy previously approved these changes Jun 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔬 NoSQL language-service integration

Commit: 199e939
Pull Request: #3121 feat/extract webview trpc packages

🧪 Result

  • NoSQL integration tests: ✅ success

📥 Artifacts (run)

@github-actions

Copy link
Copy Markdown
Contributor

🎭 E2E Tests (Playwright + VS Code)

Commit: 199e939
Pull Request: #3121 feat/extract webview trpc packages

🧪 Result

  • E2E Tests: ✅ success

📥 Artifacts (run)

Tip: the HTML report artifact contains a self-contained Playwright report.
Download the zip, extract, and open index.html — or run
npx playwright show-report <extracted-dir> for the interactive view.

@github-actions

Copy link
Copy Markdown
Contributor

🔨 Build, Lint & Test

🔗 Source

📦 Package Information

🧪 Test Results

  • Unit Tests: ✅ success
  • Integration Tests (extension host): ✅ success

📥 Artifacts (run)

✅ Build Status

Build and local tests passed. See sibling comments below for E2E and NoSQL integration results.

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