Port content mapper inspector extension into bundled extension - #64173
Port content mapper inspector extension into bundled extension#64173Andrew Branch (andrewbranch) wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Offset encoding and mapper-registration invalidation currently break core inspector behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a bundled VS Code inspector for content-mapper virtual files, mappings, and diagnostic directives, addressing #64055.
Changes:
- Adds LSP requests for mapped-file metadata.
- Adds virtual documents, mapping highlights, hovers, and directive views.
- Adds protocol and helper tests.
File summaries
| File | Description |
|---|---|
tsc/internal/lsp/server.go |
Implements inspector requests. |
tsc/internal/lsp/server_contentmapper_test.go |
Tests new requests. |
tsc/internal/lsp/lsproto/lsp_generated.go |
Adds generated protocol types. |
tsc/internal/lsp/lsproto/_generate/generate.mts |
Defines protocol generation inputs. |
packages/vscode-typescript/test/index.test.ts |
Registers the new test. |
packages/vscode-typescript/test/contentMapperVirtualFiles.test.ts |
Tests output identities. |
packages/vscode-typescript/src/session.ts |
Exposes inspector requests. |
packages/vscode-typescript/src/extension.ts |
Registers the inspector provider. |
packages/vscode-typescript/src/diagnosticDirectivesView.ts |
Implements the directives tree. |
packages/vscode-typescript/src/contentMapperVirtualFiles.ts |
Defines client models and identities. |
packages/vscode-typescript/src/contentMapperVirtualDocuments.ts |
Implements virtual documents and mapping UI. |
packages/vscode-typescript/src/client.ts |
Sends inspector LSP requests. |
packages/vscode-typescript/package.nls.json |
Adds contribution labels. |
packages/vscode-typescript/package.json |
Contributes commands, menus, and view. |
packages/vscode-typescript/l10n/bundle.l10n.json |
Adds localized runtime strings. |
Review details
Files not reviewed (1)
- tsc/internal/lsp/lsproto/lsp_generated.go: Generated file
- Files reviewed: 14/15 changed files
- Comments generated: 4
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
Restart synchronization can leave inspector documents stale, and absent directive ranges are reported as real source locations.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Files not reviewed (1)
- tsc/internal/lsp/lsproto/lsp_generated.go: Generated file
Suppressed comments (1)
packages/vscode-typescript/src/contentMapperVirtualDocuments.ts:123
- Refreshing mapped outputs on server initialization races the contribution synchronization that initialization also triggers. For extension-contributed inferred mappers, this request can return no outputs, causing
refreshto delete the tracked entries; the later synchronization event only updates the context, so already-open inspector documents remain deleted or stale after a restart. Defer refreshing tracked sources until contributions have synchronized.
for (const source of this.sourceToVirtualUris.keys()) {
this.refreshSource(vscode.Uri.parse(source));
}
- Files reviewed: 14/15 changed files
- Comments generated: 2
- Review effort level: Balanced
| if (editor?.document.uri.scheme === "file") { | ||
| try { | ||
| isContentMapped = await this.provider.isContentMapped(editor.document.uri); |
| OriginalRange: &lsproto.ContentMapperTextRange{ | ||
| Pos: int32(originalPositions.UTF8ToUTF16(directive.OriginalRange.Pos())), | ||
| End: int32(originalPositions.UTF8ToUTF16(directive.OriginalRange.End())), | ||
| }, |
Fixes #64055
This was originally something I completely vibed as a separate extension, and then ported into here after team feedback was positive on bundling it. I have not yet looked closely at the client side implementation.
Screen.Recording.2026-09-04.at.1.41.23.PM.mov