Skip to content

feat: add GitHub Copilot Chat (VS Code) agent support#171

Merged
vakovalskii merged 7 commits intovakovalskii:mainfrom
MaxRyabov:feat/copilot-agent
Apr 21, 2026
Merged

feat: add GitHub Copilot Chat (VS Code) agent support#171
vakovalskii merged 7 commits intovakovalskii:mainfrom
MaxRyabov:feat/copilot-agent

Conversation

@MaxRyabov
Copy link
Copy Markdown
Contributor

Summary

Добавляет GitHub Copilot Chat (расширение VS Code) как поддерживаемый агент в CodeDash — загрузка сессий, детальный просмотр, поиск, leaderboard, полная интеграция в UI.

Использует tool name copilot-chat, чтобы не конфликтовать с PR #167 (Copilot CLI, tool: copilot).

Closes #166

What changed

  • добавлено обнаружение сессий Copilot Chat из VS Code workspaceStorage/*/chatSessions/*.json и *.jsonl с маппингом workspace → проект через workspace.json (декодирование file URI, нормализация путей Windows)
  • поддержка двух форматов хранения Copilot: JSON (полное состояние сессии) и JSONL mutation log (kind:0 init, kind:1 set, kind:2 splice) с целевым replay — извлекаются только requests и responses
  • загрузка detail в унифицированный формат — текст пользователя из request.message.text, текст ассистента конкатенируется из response[] items где kind отсутствует, text или markdownContent
  • дисковый кэш метаданных сессий по ключу path|mtime|size — холодный скан ~5с для 300+ сессий, тёплый скан ~120мс
  • оптимизация парсинга JSONL: пропуск нерелевантных мутаций (inputState, image byte-array вложения) через проверку префикса строки до JSON.parse, сокращение загрузки detail для 200+ МБ файлов с зависания до ~1с
  • обработка формата Copilot Chat в _computeSessionDailyBreakdown() через parseCopilotJsonl/parseCopilotJson вместо построчного сканирования — фикс зависания leaderboard на больших сессиях
  • computeSessionCost() возвращает пустую стоимость (нет локальных данных о токенах, как Cursor/Kiro)
  • UI: сайдбар фильтр с иконкой, фиолетовый бейдж (.tool-copilot-chat / #8b6fc0), фильтр в календаре, метка в аналитике, цвет в heatmap, запись в AGENT_INSTALL
  • кросс-платформенные пути VS Code: %APPDATA%/Code (Windows), ~/Library/Application Support/Code (macOS), ~/.config/Code (Linux)

Validation

Проверено локально на реальных данных VS Code (319 сессий, 50+ проектов):

  • node -c src/data.js — синтаксис ОК
  • node bin/cli.js version — CLI стартует
  • loadSessions() — 319 Copilot Chat сессий с корректными путями проектов из .json и .jsonl форматов
  • loadSessionDetail() — сообщения с корректными ролями user/assistant
  • computeSessionCost() — возвращает пустую стоимость
  • getLeaderboardStats() — Copilot Chat в разбивке по агентам, leaderboard загружается без зависаний
  • дашборд стартует, сессии с фиолетовыми бейджами, фильтр в сайдбаре работает

Known limitations

  • Стоимость недоступна — Copilot Chat не хранит данные о токенах локально (как Cursor и Kiro)
  • Active session detection не поддерживается — Copilot Chat работает внутри VS Code, не как отдельный процесс
  • Количество сообщений для больших JSON-файлов (>1МБ) оценивается по размеру файла при сканировании; точное количество доступно в detail view
  • Вариант Code - Insiders пока не сканируется (только стандартная директория Code)

@vakovalskii
Copy link
Copy Markdown
Owner

Conflicts after merging recent PRs (#165 Kilo, #177 Linux focus, #172 WSL). Please rebase on latest main.

@vakovalskii vakovalskii mentioned this pull request Apr 16, 2026
@vakovalskii
Copy link
Copy Markdown
Owner

Still conflicts. Please rebase on latest main (v7.1.0+).

@MaxRyabov MaxRyabov force-pushed the feat/copilot-agent branch 2 times, most recently from b5493d5 to 109da75 Compare April 17, 2026 08:08
@MaxRyabov
Copy link
Copy Markdown
Contributor Author

Rebased on latest main (v7.2.3). All conflicts resolved — Kilo, WSL, Linux focus, collapse/expand, analytics sub-tabs are preserved alongside Copilot Chat additions.

Verified locally:

  • node -c passes for all 5 source files (bin/cli.js, data.js, server.js, terminals.js, html.js)
  • node bin/cli.js version → 7.2.3
  • node bin/cli.js help → OK
  • 322 copilot-chat sessions loaded (both .json and .jsonl formats)
  • Detail loading works for both formats (27 msgs from JSON, 23 from JSONL)
  • computeSessionCost() → 0 (expected, no local token data)
  • getLeaderboardStats() → 339ms, copilot-chat appears in agents breakdown
  • Dashboard starts cleanly, sessions visible with purple badges, sidebar filter works

Copy link
Copy Markdown
Collaborator

@NovakPAai NovakPAai left a comment

Choose a reason for hiding this comment

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

Code Review

⚠️ _isCopilotLineRelevant is called but not visible in the diffscanCopilotJsonlMetadata calls _isCopilotLineRelevant(line) as a filter, but this function is not defined anywhere in the diff. If it's missing from the submitted code, calling it will throw ReferenceError at runtime and crash the entire session scan (silently swallowed by the outer try/catch, so all Copilot sessions will silently disappear). Please verify this function exists in the submitted branch.

⚠️ README shows only the Linux storage path — the README change adds:

~/.config/Code/User/workspaceStorage/   Copilot Chat (JSON/JSONL)

But the code correctly handles all three platforms (macOS: Library/Application Support/Code, Windows: AppData/Roaming/Code, Linux: .config/Code). The README should reflect this or use a cross-platform note like <vscode-user-data>/workspaceStorage/.

⚠️ Disk cache for workspace mapping written to /tmpCOPILOT_WS_MAP_CACHE_FILE is in os.tmpdir(). On macOS, /tmp is periodically cleaned by the OS, which is fine for a cache. But the 10-minute TTL (COPILOT_WS_MAP_TTL) means a stale entry could cause new workspaces to be missed for up to 10 minutes after creation. Consider a shorter TTL or invalidating when workspaceStorage dir mtime changes.

ℹ️ Potential conflict with PR #167 — both PRs add Copilot support with tool: 'copilot' but use different storage paths (CLI sessions vs VS Code extension). Once both are merged, the tool identifier needs to be unique per source, or sessions from both will appear under the same label.

@vakovalskii
Copy link
Copy Markdown
Owner

Привет! Отличный PR, хочу взять в мерж. Только что вмержили поддержку Qwen (#201 + #202 + #203), из-за чего твоя ветка теперь конфликтует с main в нескольких frontend-файлах (app.js, analytics.js, heatmap.js, calendar.js, styles.css, index.html) и в data.js.

Основная вещь, которая изменилась и скорее всего подменит твои правки — в app.js появился централизованный TOOL_META объект с getToolLabel/getResumeCommand/getConvertTargets хелперами (см. PR #202). Надо будет добавить туда запись 'copilot-chat' вместо разбросанных label-мапов.

Сможешь сделать rebase на свежий main? После этого смерджу. Если упрётся во что-то непонятное — пинганите, помогу.

Максим Рябов added 6 commits April 21, 2026 12:02
Scan VS Code workspaceStorage for Copilot Chat sessions (JSON and JSONL
mutation format). Includes workspace-to-project mapping with disk cache,
targeted JSONL replay for request/response extraction, and integration
into loadSessions/findSessionFile/loadSessionDetail/computeSessionCost.
Add sidebar item with copilot-only filter, .tool-copilot CSS class,
calendar filter toggle, analytics label, heatmap color, and
AGENT_INSTALL entry for GitHub Copilot.
Update agent counts and tables in README.md, CLAUDE.md, ARCHITECTURE.md,
README_RU.md, and README_ZH.md. Add Copilot storage section to
ARCHITECTURE.md with session format details.
- Skip irrelevant JSONL lines (inputState, attachments) before JSON.parse
- Add disk cache for parsed Copilot session metadata
- Use peek-based extraction for large JSON files (>1MB)
- Cold scan: 46s -> 5s, warm scan: 120ms, detail 232MB: 1.1s
_computeSessionDailyBreakdown now uses parseCopilotJsonl/parseCopilotJson
for Copilot sessions instead of generic line-by-line JSONL scan that
would read entire multi-hundred-MB files without extracting any data.
Fixes leaderboard hanging on projects with large Copilot sessions.
…opilot CLI

PR vakovalskii#167 adds Copilot CLI support with tool: 'copilot'. Our implementation
covers Copilot Chat (VS Code extension) — a different agent with different
storage format. Rename to 'copilot-chat' so both can coexist.
@MaxRyabov MaxRyabov force-pushed the feat/copilot-agent branch from 109da75 to 32b9c24 Compare April 21, 2026 09:07
@MaxRyabov
Copy link
Copy Markdown
Contributor Author

Rebased on latest main (v7.4.0). Qwen merge conflicts resolved.

Key change: added 'copilot-chat' entry to the centralized TOOL_META object in app.js per the new architecture from #202. The old inline label map in analytics.js is replaced by getToolLabel(name) which now reads from TOOL_META. Also added 'kilo' to TOOL_META since it was missing there (it used the default fallback before).

Verified locally (v7.4.0):

  • node -c passes for all 5 source files
  • node bin/cli.js version → 7.4.0
  • 322 copilot-chat sessions loaded (both .json and .jsonl formats)
  • Detail loading works for both formats (27 msgs from JSON, 23 from JSONL)
  • computeSessionCost() → 0 (expected, no local token data)
  • getLeaderboardStats() → 499ms, copilot-chat appears in agents breakdown
  • Dashboard renders correctly: sidebar filter, purple badges, analytics label "Copilot Chat"

- README.md: replace Linux-only Copilot Chat path with cross-platform notation
- src/data.js: invalidate workspace map cache when VSCODE_WORKSPACE_STORAGE
  mtime changes, not just on 10-min TTL expiry — catches new workspaces
  created within TTL window
- docs/ARCHITECTURE.md: update stale tool name "copilot" → "copilot-chat"
@MaxRyabov
Copy link
Copy Markdown
Contributor Author

MaxRyabov commented Apr 21, 2026

Thanks for the review @NovakPAai! Addressed in abea73a:

1. _isCopilotLineRelevant missing — false alarm, the function is defined at src/data.js:1405 (just outside the original diff context). Verified by running loadSessions() successfully — 322 copilot-chat sessions load without errors.

2. README cross-platform paths — fixed. Replaced the Linux-only path with a <vscode-user-data>/workspaceStorage/ placeholder and explicit Linux/macOS/Windows notes.

3. Workspace map cache invalidation — fixed. Added mtime-based check: cache is now invalidated when VSCODE_WORKSPACE_STORAGE directory mtime changes, not just on 10-min TTL. New workspaces are picked up immediately on the next scan instead of waiting up to 10 min.

4. Conflict with PR #167 — already handled. This branch uses tool: 'copilot-chat' (renamed earlier to distinguish from PR #167's Copilot CLI which uses 'copilot'). Both can coexist after merge.

Bonus: also fixed a stale tool: "copilot" reference in docs/ARCHITECTURE.md:247"copilot-chat".

Copy link
Copy Markdown
Collaborator

@NovakPAai NovakPAai left a comment

Choose a reason for hiding this comment

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

Code Review

Good implementation overall — addressed all previous review points. One item to verify before merge.

⚠️ Verify _isCopilotLineRelevant is present in the submitted branch
scanCopilotJsonlMetadata calls _isCopilotLineRelevant(line) as a filter. The previous review flagged this as missing from the diff. Author stated it's at src/data.js:1405 — please confirm the function exists in the current HEAD of this branch (e.g. grep -n '_isCopilotLineRelevant' src/data.js). If absent, the entire Copilot session scan silently returns empty (swallowed by outer try/catch).

✅ Previous review points addressed:

  • README now uses <vscode-user-data>/workspaceStorage/ with per-platform notes (macOS/Linux/Windows) — correct
  • Workspace map cache now invalidated on VSCODE_WORKSPACE_STORAGE mtime change, not just TTL — correct
  • tool: 'copilot-chat' is distinct from PR #167's tool: 'copilot' — no collision

ℹ️ Merge order note
PR #198 also modifies src/data.js (loadSessionDetail) and styles.css. Merging this PR first avoids a conflict for #198's author — they will need to rebase over the Copilot additions regardless, but a clean base makes that easier.

✅ What's good:

  • Dual cache invalidation (TTL + mtime) for workspace mapping
  • JSONL line prefix check before JSON.parse avoids parsing irrelevant mutations — smart optimization
  • 'copilot-chat' entry added to centralized TOOL_META in app.js per #202 architecture
  • Cross-platform paths handled correctly for macOS/Linux/Windows

@MaxRyabov
Copy link
Copy Markdown
Contributor Author

Thanks for the review @NovakPAai! Confirmed — the function is present on current branch HEAD (abea73a). It was introduced in the optimization commit together with the JSONL prefix-check pattern it enables, and sits between its two callers (function hoisting makes the ordering safe).

$ grep -n '_isCopilotLineRelevant' src/data.js
1396:    if (!_isCopilotLineRelevant(line)) continue;   # caller #1: scanCopilotJsonMetadata
1417: function _isCopilotLineRelevant(line) {           # definition
1435:    if (!_isCopilotLineRelevant(line)) continue;   # caller #2: parseCopilotJsonl

Also verified end-to-end: loadSessions() returns 322 copilot-chat sessions with no errors, which would be impossible if the function were missing (outer try/catch would swallow the ReferenceError and return 0).

Copy link
Copy Markdown
Collaborator

@NovakPAai NovakPAai left a comment

Choose a reason for hiding this comment

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

Thanks for the quick response and the grep output — that settles it. Merge approved, passing to the maintainer.

@vakovalskii vakovalskii merged commit 6aaa027 into vakovalskii:main Apr 21, 2026
6 checks passed
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.

feat: добавить поддержку GitHub Copilot Chat агента

3 participants