Files
vscode/extensions/copilot/src/platform/multiFileEdit/common
Zhichao Li 548eda26df Add workspace metadata (git branch, commit, remote, file path) to OTel events and GH telemetry (#4844)
* feat: define workspace metadata OTel attributes and resolver

Add CopilotChatAttr constants for repo.head_branch_name,
repo.head_commit_hash, repo.remote_url, and file.relative_path.

Create WorkspaceOTelMetadata interface and resolveWorkspaceOTelMetadata()
helper that synchronously resolves git metadata from activeRepository.

Refs: microsoft/vscode#306397, microsoft/vscode-internalbacklog#7297

* feat: extend OTel edit events with optional workspace metadata

Add optional WorkspaceOTelMetadata param to emitEditFeedbackEvent,
emitEditHunkActionEvent, emitInlineDoneEvent, emitEditSurvivalEvent.

Existing callers compile unchanged since the new param is optional.

Refs: microsoft/vscode#306397

* feat: add workspace metadata to invoke_agent OTel span

Inject IGitService into ToolCallingLoop and spread resolved workspace
metadata (branch, commit, remote) onto the invoke_agent span attributes.

Refs: microsoft/vscode#306397

* feat: extend EditSurvivalResult with workspace metadata

Add workspace field to EditSurvivalResult interface and populate it
in EditSurvivalReporter._report() using resolveWorkspaceOTelMetadata().

The reporter already injects IGitService and has the document URI,
so no new DI is needed.

Refs: microsoft/vscode#306397

* feat: inject IGitService into UserActions and pass workspace metadata

Add workspace metadata to emitEditFeedbackEvent, emitEditHunkActionEvent,
and emitInlineDoneEvent calls in UserFeedbackService using the file URI
from each event action.

Refs: microsoft/vscode#306397

* feat: pass workspace metadata to OTel survival events

Forward res.workspace from EditSurvivalResult to emitEditSurvivalEvent
at all 4 call sites: inline_chat, code_mapper, apply_patch, replace_string.

Refs: microsoft/vscode#306397

* feat: add workspace metadata to GH telemetry edit events

Add headBranchName, headCommitHash, remoteUrl, fileRelativePath to
sendGHTelemetryEvent/sendEnhancedGHTelemetryEvent calls for:
- inline.trackEditSurvival
- fastApply/trackEditSurvival
- applyPatch/trackEditSurvival
- replaceString/trackEditSurvival
- fastApply/editOutcome

Refs: microsoft/vscode-internalbacklog#7297

* test: add unit tests for workspace metadata resolver and events

Test resolveWorkspaceOTelMetadata (branch, commit, URL, relative path,
edge cases) and workspaceMetadataToOTelAttributes (OTel key mapping).

Add tests for emitEditFeedbackEvent and emitEditSurvivalEvent verifying
workspace metadata is included/omitted correctly.

Refs: microsoft/vscode#306397

* fix: propagate IGitService to ToolCallingLoop subclasses

Pass the new IGitService constructor parameter through to super() in
all 5 ToolCallingLoop subclasses: McpToolCallingLoop,
CodebaseToolCallingLoop, DefaultToolCallingLoop,
ExecutionSubagentToolCallingLoop, SearchSubagentToolCallingLoop.

Refs: microsoft/vscode#306397

* fix: address review - URI-safe path, brace style, trim tests

- Fix path prefix false-positive by using isEqualOrParent/relativePath
  instead of string startsWith (e.g. /repo matching /repo2/file.ts)
- Expand one-line if blocks to multi-line per repo coding standards
- Remove as-any mutation in test, remove trivial conversion tests,
  add test for path prefix false-positive edge case
2026-03-30 23:24:34 +00:00
..