Skip to content

feat: add GitHub Copilot CLI provider#6

Merged
mdemirhan merged 4 commits into
mdemirhan:mainfrom
atkaksoy501:feat/copilot-cli-provider
Apr 14, 2026
Merged

feat: add GitHub Copilot CLI provider#6
mdemirhan merged 4 commits into
mdemirhan:mainfrom
atkaksoy501:feat/copilot-cli-provider

Conversation

@atkaksoy501
Copy link
Copy Markdown

@atkaksoy501 atkaksoy501 commented Apr 12, 2026

Summary

Adds GitHub Copilot CLI (~/.copilot/session-state/) as a new provider to Code Trail. Discovers sessions from the events.jsonl JSONL event stream format and integrates Copilot CLI history under the existing Copilot section in the UI — no separate top-level chip.

Copilot CLI not installed → no errors, provider simply returns no sessions.


Changes

37 modified files · 5 new source files · 2 new fixture files · +557 lines / −58 lines

Core

  • New copilot_cli provider: session discovery (copilotCli.ts), JSONL stream adapter, event parser (parseCopilotCliEvent), registered across all provider registries and IPC contracts
  • platformDiscoveryDefaults.ts: added copilot_cli default path (~/.copilot/session-state/)
  • canonical.ts / providerMetadata.ts: copilot_cli added to all provider enumerations
  • searchMessages.ts: copilot_cli included in full-text search scope

Desktop

  • SettingsView.tsx: Copilot CLI row with >_ icon and independent-toggle tooltip
  • SearchView.tsx / HistoryLayout.tsx: Copilot CLI grouped under the Copilot chip (not a separate top-level entry)
  • ProjectPane.tsx: provider tag display handles Copilot CLI grouping
  • styles.css: copilot_cli accent color tokens
  • useLiveWatchController.ts: replaced inline EMPTY_PROVIDER_COUNTS with import from app/constants

Bug Fixes Included

# Bug Fix
1 events.jsonl was being read in full (8.4 MB for active sessions) Now reads ≤16 KB via readFirstJsonlObject
2 outputTokens from assistant.message events was discarded Now stored as tokenOutput
3 Missing data.result on tool.execution_complete produced a spurious "{}" DB row Fixed with null-guard before serializeUnknown
4 Path splitting used lastIndexOf("/") instead of node:path APIs Replaced with dirname / basename
5 Inline EMPTY_PROVIDER_COUNTS in useLiveWatchController could diverge from canonical source Now imported from app/constants

UI

  • Copilot CLI sessions appear under the Copilot chip in history and search (grouped, not a separate top-level chip)
  • Copilot CLI has its own independent toggle in Settings with a >_ terminal icon and a tooltip clarifying it can be toggled independently from VS Code Copilot
  • Copilot CLI not installed → no errors thrown, provider returns no sessions gracefully

Testing

  • 929 tests passing (36 new tests added)
Test file Coverage
copilotCli.test.ts (new) parseWorkspaceYaml — 9 cases: colons in values, CRLF, empty, whitespace, unknown keys
providerParsers.test.ts parseCopilotCliEvent — 12 cases: all event types, fallback IDs, token counts, empty result prevention
providerGroups.test.ts (new) getChipProviders / getProviderWithChildren / toggleGroupProviders — 13 edge-case tests
providerFixtures.integration.test.ts Updated discovery/indexing fixture counts to include copilot_cli
discoverSessionFiles.pythonFixtures.test.ts Updated discovery count and provider set

npx biome check clean on all modified files.


Implementation Notes

  • Uses jsonl_stream adapter — same pattern as other streaming providers; no new adapter introduced
  • workspace.yaml fallback: if the file is missing, session metadata is extracted from the first session.start JSONL event
  • Grouping is UI-side only — the database stores copilot_cli as a distinct provider value; the UI maps it under copilot for chips and search filters
  • No schema migration required

Screenshots

Screenshot 2026-04-12 at 5 22 37 PM

Adds `copilot_cli` as a new provider that discovers sessions from
~/.copilot/session-state/{uuid}/events.jsonl and integrates them
under the existing Copilot section in the UI.

Changes:
- New copilot_cli discovery, JSONL stream adapter, and event parser
- Registered across all provider registries, IPC contracts, and search
- UI: grouped under Copilot chip, independent Settings toggle with >_ icon
- styles.css: copilot_cli accent color tokens

Bug fixes:
- events.jsonl was read in full (8.4 MB+); now reads ≤16 KB via readFirstJsonlObject
- outputTokens from assistant.message events now stored as tokenOutput
- Missing data.result on tool.execution_complete no longer produces spurious "{}" DB row
- Path splitting with lastIndexOf replaced with dirname/basename from node:path
- Inline EMPTY_PROVIDER_COUNTS in useLiveWatchController replaced with import from app/constants

Tests: 929 passing (36 new) — parseWorkspaceYaml (9), parseCopilotCliEvent (12), providerGroups (13), integration fixture counts updated

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 12, 2026 14:32
Copy link
Copy Markdown

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

Adds a new GitHub Copilot CLI (copilot_cli) provider to Code Trail, discovering sessions from Copilot CLI’s events.jsonl stream under ~/.copilot/session-state/, indexing them as a distinct provider, and grouping them under the existing Copilot UI chip.

Changes:

  • Core: introduce copilot_cli discovery + parsing + adapter/registry wiring, and include it in provider enums and search facet counts.
  • Desktop: add UI grouping helpers so Copilot CLI is shown under the Copilot chip while remaining independently toggleable in Settings.
  • Tests/fixtures: add Copilot CLI fixture sessions and expand existing integration/unit tests for discovery, parsing, and grouping behavior.

Reviewed changes

Copilot reviewed 43 out of 44 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/core/src/contracts/canonical.ts Adds copilot_cli to canonical provider enum.
packages/core/src/contracts/providerMetadata.ts Adds Copilot CLI provider metadata + discovery path key.
packages/core/src/discovery/types.ts Extends DiscoveryConfig with copilotCliRoot.
packages/core/src/discovery/shared.ts Extends typed getDiscoveryPath overloads to include Copilot CLI.
packages/core/src/discovery/platformDiscoveryDefaults.ts Adds default Copilot CLI root path under ~/.copilot/session-state.
packages/core/src/discovery/providers/copilotCli.ts New Copilot CLI session discovery + lightweight workspace metadata parsing.
packages/core/src/providers/adapters/copilotCli.ts New provider adapter hooking discovery + parsing into the ingestion pipeline.
packages/core/src/providers/registry.ts Registers the new copilot_cli adapter.
packages/core/src/parsing/providerParsers.ts Adds parseCopilotCliEvent and registers it for event parsing.
packages/core/src/search/searchMessages.ts Adds copilot_cli facet counting to search aggregation results.
packages/core/src/testing/settingsInfoFixture.ts Adds copilotCliRoot to test settings fixture paths.
packages/core/test-fixtures/providers/copilot-cli/session-state/session-001/workspace.yaml New Copilot CLI workspace metadata fixture.
packages/core/test-fixtures/providers/copilot-cli/session-state/session-001/events.jsonl New Copilot CLI JSONL event stream fixture.
packages/core/src/discovery/providers/copilotCli.test.ts Unit tests for workspace.yaml parsing.
packages/core/src/parsing/providerParsers.test.ts Unit tests for parseCopilotCliEvent.
packages/core/src/indexing/providerFixtures.integration.test.ts Updates fixture indexing expectations to include Copilot CLI.
packages/core/src/discovery/discoverSessionFiles.pythonFixtures.test.ts Updates provider discovery expectations for fixtures to include Copilot CLI.
packages/core/src/indexing/systemMessageRules.test.ts Adds copilot_cli to default rules shape expectations.
packages/core/src/search/searchMessages.integration.test.ts Adds copilotCliRoot to integration test discovery config.
apps/desktop/src/renderer/lib/providerGroups.ts New UI-side grouping utilities (Copilot CLI under Copilot).
apps/desktop/src/renderer/lib/providerGroups.test.ts Tests for provider grouping/toggling helpers.
apps/desktop/src/renderer/features/SearchView.tsx Renders grouped provider chips + combined counts; group-toggle behavior.
apps/desktop/src/renderer/features/HistoryLayout.tsx Uses grouped provider toggling for the project pane provider filters.
apps/desktop/src/renderer/components/history/ProjectPane.tsx Displays grouped provider tags and combined counts in project pane.
apps/desktop/src/renderer/components/SettingsView.tsx Adds Copilot CLI settings row/icon + “child provider” UX.
apps/desktop/src/renderer/styles.css Adds Copilot CLI tag/chip styling tokens.
apps/desktop/src/renderer/features/useLiveWatchController.ts Replaces local empty provider counts with canonical constant import.
.gitignore Ignores .copilot/ and .squad/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/desktop/src/renderer/components/history/ProjectPane.tsx Outdated
Comment thread packages/core/src/discovery/providers/copilotCli.ts Outdated
Comment thread packages/core/src/discovery/providers/copilotCli.ts Outdated
Comment thread packages/core/src/discovery/providers/copilotCli.ts
- Remove unused toggleGroupProviders import in ProjectPane.tsx
- Set unresolvedProject dynamically based on projectPath presence
- Use 'unresolved' resolutionSource (not null) when cwd is absent
- Set repositoryUrl: null, store raw slug in sessionMetadata instead
- Strip surrounding quotes from parsed YAML values
- Add discovery integration tests (discoverCopilotCliFiles x6, discoverSingleCopilotCliFile x3)
- Fix TypeScript strict-mode array access in tests with non-null assertions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@atkaksoy501 atkaksoy501 requested a review from Copilot April 12, 2026 15:01
Copy link
Copy Markdown

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

Copilot reviewed 43 out of 44 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/parsing/providerParsers.ts
Comment thread apps/desktop/src/renderer/lib/providerGroups.ts
- Improve tool.execution_complete result handling: use content key when
  present (non-empty string), fall back to serializeUnknown only when
  result has keys other than 'content'; this prevents spurious messages
  for empty objects, empty-content wrappers, and similar edge cases
- Fix getProviderWithChildren JSDoc to accurately describe that the
  given provider itself is included only when present in allProviders
- Add tests: empty-content result, non-content structured result,
  and fix misleading test name in providerGroups.test.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

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

Copilot reviewed 43 out of 44 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/parsing/providerParsers.ts
Comment thread packages/core/src/parsing/providerParsers.test.ts
- suffix Copilot CLI tool_result message ids with :result when a
  toolCallId is present so tool_use and tool_result source ids stay distinct
- preserve the original toolCallId inside the serialized tool_use payload for
  correlation
- add regression coverage for distinct tool_use/tool_result ids and update
  parser expectations accordingly

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@atkaksoy501
Copy link
Copy Markdown
Author

The copilot review was directionally correct, not a pure false positive. The indexer did not crash because duplicate source IDs were being rewritten to ~dupN, but that still produced unstable message identity and noisy duplicate-rewrite notices. The parser now emits a distinct tool_result source ID ({toolCallId}:result) while preserving the original toolCallId inside the serialized tool-use payload for correlation.

Copy link
Copy Markdown

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

Copilot reviewed 43 out of 44 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/discovery/types.ts
Comment thread packages/core/src/discovery/providers/copilotCli.ts
Comment thread packages/core/src/parsing/providerParsers.ts
@mdemirhan mdemirhan merged commit 398d000 into mdemirhan:main Apr 14, 2026
3 of 7 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.

3 participants