Skip to content

Add GitHub Copilot as a built-in provider#3076

Open
huxcrux wants to merge 104 commits into
pingdotgg:mainfrom
huxcrux:hux-copliot-fix
Open

Add GitHub Copilot as a built-in provider#3076
huxcrux wants to merge 104 commits into
pingdotgg:mainfrom
huxcrux:hux-copliot-fix

Conversation

@huxcrux

@huxcrux huxcrux commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

This PR supersedes #2185. It includes the full Copilot integration from that PR plus the fixes and hardening discovered while testing it against the current codebase.

What Changed

  • Added GitHub Copilot as a first-class provider using the official Copilot SDK.
  • Wired Copilot through the server runtime for auth/status checks, model discovery, session start/resume, turn sending, permission replies, request handling, and event streaming.
  • Added Copilot-backed git text generation for commit messages, PR descriptions, branch names, and thread titles.
  • Added Copilot provider settings, defaults, model traits, reasoning effort, context window handling, and persisted configuration.
  • Updated the web UI so Copilot appears in provider/model pickers, settings, icons, context window selection, task rendering, and git writing model selection.
  • Hardened Copilot runtime behavior for queued turns, duplicate completions, tool-only turns, empty diffs, missing checkpoint refs, stale resume cursors, failed sends, task completions, and rollback-safe checkpointing.
  • Added regression coverage for the Copilot adapter, provider probing, text generation, context window handling, and related projection flows.

Why

T3 Code supports multiple agent providers, but did not have GitHub Copilot support. This adds Copilot end to end in the same shape as the existing providers, so users can configure Copilot, select Copilot models, use Copilot for git text generation, and rely on the same session/runtime flows as other providers.

The extra hardening keeps Copilot predictable under real usage: turns complete once, tool output and reasoning project correctly, diffs are only emitted when meaningful, permission replies resolve cleanly, checkpoint handling is safer, and provider status/model data stays accurate.

UI Changes

  • Added Copilot to the provider/model picker.
  • Added Copilot settings and model configuration surfaces.
  • Added Copilot icons, reasoning/context-window controls, and task output rendering.

Updated model picker:
image

Provider settings:
image

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

High Risk
Large changes to checkpoint revert ordering and provider lifecycle ingestion affect all providers; incorrect rollback or completion handling could leave sessions stuck or filesystem state inconsistent.

Overview
Introduces CopilotDriver and @github/copilot / @github/copilot-sdk on the server so Copilot instances get the same snapshot, adapter, and text-generation wiring as other built-in providers.

Checkpoint revert now verifies the target ref exists, restores the filesystem first, then calls provider rollback; failed rollback attempts to restore the current checkpoint, refreshes workspace entries, and records a failure activity instead of leaving disk and provider history out of sync (important when Copilot cannot roll back conversations).

Provider runtime ingestion accepts turn.completed without a turn id when the active turn matches the provider session (or the provider already cleared the active turn), rejects completion when no provider session exists, infers turn id on completion when the guard accepts the event, and projects content.delta into reasoning and tool-output activities; conflicting lifecycle events emit warning logs.

First-turn orchestration queues title and branch generation through a drainable worker (drain waits for title jobs), retries transient title generation, and broadens canReplaceThreadTitle so truncated client seeds and provider-expanded prompts can be replaced without overwriting user-edited titles.

Projection keeps latestTurnId on thread.session-set when activeTurnId is null. Integration and unit tests cover missing turn-id completion, revert failure paths, Copilot rollback limitations, and the title/runtime behaviors above.

Reviewed by Cursor Bugbot for commit 4cc4486. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add GitHub Copilot as a built-in provider with adapter, text generation, and settings support

  • Adds a new copilot provider driver (CopilotDriver.ts) that initializes a per-instance home directory, starts a Copilot SDK adapter, and refreshes provider status hourly.
  • Implements CopilotTextGeneration (CopilotTextGeneration.ts) with shared client pooling, a 30-second idle TTL, and strict JSON schema decoding for commit messages, PR content, branch names, and thread titles.
  • Adds CopilotSettings to server settings schema with binaryPath, serverUrl, and customModels fields; exposes settings via the UI with an 'Early Access' badge.
  • Extends the ingestion layer to emit activities for streaming content deltas (tool outputs, reasoning updates) and improves lifecycle guard logic for unscoped turn completions.
  • Fixes several bugs: applyThreadDetailEvent no longer runs its branch when activeTurnId is null; non-effort select descriptors (e.g., contextTier) are no longer treated as promptEffort; deriveLatestContextWindowSnapshot now correctly handles compaction boundaries.
  • Risk: adds @github/copilot and @github/copilot-sdk as runtime dependencies; the Copilot adapter starts an external SDK process per provider instance.

Macroscope summarized 4cc4486.

Copilot SDK Lifecycle Note (Adapter)

  • Turn completion is now signal-driven only: completion happens on assistant.idle or session.idle, not local timeout heuristics.
  • assistant.turn_end is treated as a completion marker for the active turn, but final completion waits for an idle signal to avoid ending multi-loop SDK turns too early.
  • Queued follow-up user turns can still settle the previous ended turn through the guarded completePendingActiveTurnEnd path before the next SDK turn is attributed.
  • Duplicate or repeated idle/end events remain idempotent through completedTurnIds and strict turn mapping guards.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1a83c4ea-d63e-4ade-9d92-db87e627eec0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Jun 14, 2026
Comment thread apps/server/src/orchestration/Layers/CheckpointReactor.ts
Comment thread packages/shared/src/providerToolClassification.ts Outdated
Comment thread apps/server/src/orchestration/Layers/CheckpointReactor.ts
@macroscopeapp

macroscopeapp Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

Diff is too large for automated approval analysis. A human reviewer should evaluate this PR.

You can customize Macroscope's approvability policy. Learn more.

Comment thread apps/server/src/orchestration/Layers/CheckpointReactor.ts
Comment thread packages/shared/src/providerToolClassification.ts Outdated
Comment thread apps/server/src/provider/Layers/CopilotAdapter.ts Outdated
Comment thread pnpm-workspace.yaml Outdated
Comment thread apps/server/src/provider/Layers/CopilotAdapter.ts Outdated
Comment thread apps/server/src/provider/Layers/CopilotAdapter.ts
Comment thread apps/server/src/provider/copilotRuntime.ts Outdated
Comment thread packages/contracts/src/settings.ts
Comment thread apps/server/src/provider/Layers/CopilotAdapter.ts
Comment thread apps/server/src/orchestration/Layers/ProviderCommandReactor.ts Outdated
@huxcrux huxcrux force-pushed the hux-copliot-fix branch 4 times, most recently from 5ae2460 to acf1c04 Compare June 18, 2026 01:41
Comment thread apps/server/src/provider/Layers/CopilotAdapter.ts
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
@huxcrux huxcrux force-pushed the hux-copliot-fix branch from 790af4a to f6e8dc1 Compare July 6, 2026 07:14
Comment thread apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts Outdated
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
Comment thread apps/server/src/provider/Layers/CopilotAdapter.ts
Comment thread apps/server/src/provider/Layers/CopilotAdapter.ts
Comment thread apps/server/src/provider/Layers/CopilotAdapter.ts
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts Outdated
Comment thread apps/server/src/provider/Layers/CopilotAdapter.ts

@macroscopeapp macroscopeapp Bot 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.

One retained error-convention issue in the new Copilot runtime. Details inline.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/provider/copilotRuntime.ts Outdated

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 07f5e62. Configure here.

Comment thread apps/server/src/provider/copilotRuntime.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants