Skip to content

fix: expand Chronicle session_files/refs tracking to match VS Code tool names#312285

Merged
digitarald merged 3 commits intomainfrom
digitarald/fix-chronicle-session-tracking
Apr 24, 2026
Merged

fix: expand Chronicle session_files/refs tracking to match VS Code tool names#312285
digitarald merged 3 commits intomainfrom
digitarald/fix-chronicle-session-tracking

Conversation

@digitarald
Copy link
Copy Markdown
Contributor

Problem

The session_files and session_refs tables in the Chronicle local session history store are always empty (0 rows across 460+ sessions).

Root cause: FILE_TRACKING_TOOLS only recognized CLI-agent tool names (str_replace_editor, create) but VS Code emits model-facing names (replace_string_in_file, insert_edit_into_file, etc). Similarly, isGitHubMcpTool() only matched the github-mcp-server- prefix, not VS Code's mcp_github_ prefix.

Fix

  • Expand FILE_TRACKING_TOOLS from 4 to 11 entries matching VS Code's ToolName enum
  • Add extraction for multi_replace_string_in_file (nested replacements array)
  • Add apply_patch input text parsing (*** Update/Add/Delete File: lines)
  • Update isGitHubMcpTool() to match both mcp_github_ and github-mcp-server- prefixes
  • 29 new tests, all 119 chronicle tests pass

Fixes #312281

Copilot AI review requested due to automatic review settings April 24, 2026 02:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expands Chronicle’s session history extraction so session_files/session_refs are populated for VS Code-hosted Copilot sessions by recognizing VS Code tool names and GitHub MCP tool prefixes.

Changes:

  • Expand file-tracking tool-name coverage to include VS Code’s model-facing tool names and add apply_patch input parsing.
  • Update GitHub MCP tool detection to accept both mcp_github_ (VS Code) and github-mcp-server- (CLI) prefixes.
  • Add new focused unit tests for file/ref/repo extraction behavior.
Show a summary per file
File Description
extensions/copilot/src/extension/chronicle/common/sessionStoreTracking.ts Adds broader tool-name recognition and patch parsing for file/ref tracking.
extensions/copilot/src/extension/chronicle/common/test/sessionStoreTracking.spec.ts New unit tests for file path extraction, GitHub MCP tool detection, repo/ref extraction, and terminal ref extraction.
extensions/copilot/src/extension/chronicle/common/test/standupPrompt.spec.ts Updates existing expectations to reflect read_file now being tracked for file paths.

Copilot's findings

Comments suppressed due to low confidence (2)

extensions/copilot/src/extension/chronicle/common/sessionStoreTracking.ts:52

  • multi_replace_string_in_file can apply replacements across multiple files (per tool schema). Returning only the first replacement’s filePath will under-report affected files in session_files. Consider extracting all unique filePaths from args.replacements and recording one session_files row per path (likely by adjusting the tracker to accept multiple paths).
	// multi_replace_string_in_file stores filePath in each replacement item
	if (toolName === 'multi_replace_string_in_file' && Array.isArray(args.replacements)) {
		const first = args.replacements[0];
		if (typeof first === 'object' && first !== null) {
			const fp = (first as Record<string, unknown>).filePath;
			if (typeof fp === 'string') { return fp; }
		}
	}

extensions/copilot/src/extension/chronicle/common/sessionStoreTracking.ts:68

  • apply_patch supports patching multiple files in a single input (multiple *** Update/Add/Delete File: sections). Extracting only the first match means session_files will miss additional touched files. Consider extracting all file paths from the patch input and recording each one (deduping if needed).
	// apply_patch encodes file paths in the patch input text
	if (toolName === 'apply_patch' && typeof args.input === 'string') {
		return extractFirstFileFromPatch(args.input);
	}

	return undefined;
}

/**
 * Extract the first file path from an apply_patch input string.
 * Matches lines like `*** Update File: /path/to/file` or `*** Add File: /path`.
 */
function extractFirstFileFromPatch(input: string): string | undefined {
	const match = input.match(/^\*\*\*\s+(?:Update|Add|Delete)\s+File:\s*(.+)$/m);
	return match?.[1]?.trim();
  • Files reviewed: 3/3 changed files
  • Comments generated: 1

@digitarald digitarald marked this pull request as ready for review April 24, 2026 02:42
@digitarald digitarald merged commit 13bad5b into main Apr 24, 2026
26 checks passed
@digitarald digitarald deleted the digitarald/fix-chronicle-session-tracking branch April 24, 2026 04:41
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone Apr 24, 2026
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.

Chat session history: session_files and session_refs tables are never populated

3 participants