Skip to content

Port content mapper inspector extension into bundled extension - #64173

Draft
Andrew Branch (andrewbranch) wants to merge 2 commits into
microsoft:mainfrom
andrewbranch:content-mapper-inspector
Draft

Port content mapper inspector extension into bundled extension#64173
Andrew Branch (andrewbranch) wants to merge 2 commits into
microsoft:mainfrom
andrewbranch:content-mapper-inspector

Conversation

@andrewbranch

@andrewbranch Andrew Branch (andrewbranch) commented Sep 4, 2026

Copy link
Copy Markdown
Member

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

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.

🟡 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.

Comment thread tsc/internal/lsp/server.go
Comment thread packages/vscode-typescript/src/contentMapperVirtualDocuments.ts
Comment thread packages/vscode-typescript/src/contentMapperVirtualDocuments.ts Outdated
Comment thread packages/vscode-typescript/src/diagnosticDirectivesView.ts Outdated

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.

🟡 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 refresh to 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

Comment on lines +286 to +288
if (editor?.document.uri.scheme === "file") {
try {
isContentMapped = await this.provider.isContentMapped(editor.document.uri);
Comment on lines +2522 to +2525
OriginalRange: &lsproto.ContentMapperTextRange{
Pos: int32(originalPositions.UTF8ToUTF16(directive.OriginalRange.Pos())),
End: int32(originalPositions.UTF8ToUTF16(directive.OriginalRange.End())),
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debug extension / mode for content-mapper

2 participants