Skip to content

feat: add GitHub Copilot support with rewritten inline suggestion architecture#850

Merged
datlechin merged 1 commit intomainfrom
feat/copilot-support
Apr 26, 2026
Merged

feat: add GitHub Copilot support with rewritten inline suggestion architecture#850
datlechin merged 1 commit intomainfrom
feat/copilot-support

Conversation

@datlechin
Copy link
Copy Markdown
Member

@datlechin datlechin commented Apr 24, 2026

Summary

Closes #754

Adds GitHub Copilot support to TablePro with a complete rewrite of the inline suggestion architecture and a new AI provider registry pattern.

Inline Suggestion Architecture Rewrite

  • Decompose the 464-line InlineSuggestionManager into a clean, protocol-based system
  • InlineSuggestionSource protocol for pluggable suggestion sources
  • GhostTextRenderer for CATextLayer ghost text display
  • AIChatInlineSource for existing AI provider path (Claude, OpenAI, etc.)
  • Dynamic source resolution via closure (settings changes take effect immediately)

Generic LSP Client

  • Core/LSP/ with LSPTransport (stdio JSON-RPC 2.0), LSPClient (typed methods), LSPTypes, LSPDocumentManager
  • Reusable for any language server (SQL language servers, linters, etc.)

GitHub Copilot Integration

  • CopilotService: language server lifecycle, OAuth device flow auth, exponential backoff restart
  • CopilotBinaryManager: download native binary from npm with SHA1 integrity verification
  • CopilotInlineSource: inline completions via textDocument/inlineCompletion with proper ghost text rendering and replacement range handling
  • CopilotDocumentSync: editor text changes synced to LSP with server-restart awareness
  • CopilotSchemaContext: database schema preamble (table names, columns, types) prepended to document for schema-aware suggestions
  • CopilotChatProvider: chat via conversation/create + conversation/turn LSP protocol with streaming

AI Provider Registry

  • AIProviderDescriptor + AIProviderRegistry + AIProviderRegistration for extensible provider registration
  • AIProviderFactory tries registry first, hardcoded switch as fallback
  • Adding a new provider (e.g., Codeium) = 1 file + register call

Unified Settings

  • Single InlineSuggestionProvider picker in Editor settings (Off / GitHub Copilot / AI Provider)
  • Copilot settings tab with sign-in flow, status indicator, telemetry toggle
  • Copilot Chat toggle in AI settings with feature routing support

Architecture

AIProviderRegistry
    ├── claude    → AnthropicProvider (chat)
    ├── openAI    → OpenAICompatibleProvider (chat)
    ├── copilot   → CopilotChatProvider (chat via LSP)
    └── [future]  → CodeiumProvider, SupermavenProvider, ...

InlineSuggestionManager (orchestrator)
    ├── GhostTextRenderer (CATextLayer)
    └── InlineSuggestionSource (protocol)
            ├── AIChatInlineSource (AI providers)
            └── CopilotInlineSource (Copilot LSP)
                    └── CopilotService → LSPClient → LSPTransport → Process

Files (36 changed)

New (18):

  • Core/LSP/ — LSPTypes, LSPTransport, LSPClient, LSPDocumentManager
  • Core/AI/InlineSuggestion/ — InlineSuggestionSource, GhostTextRenderer, AIChatInlineSource, InlineSuggestionManager
  • Core/AI/Copilot/ — CopilotService, CopilotAuthManager, CopilotBinaryManager, CopilotDocumentSync, CopilotInlineSource, CopilotSchemaContext, CopilotChatProvider
  • Core/AI/Registry/ — AIProviderDescriptor, AIProviderRegistry, AIProviderRegistration
  • Models/AI/CopilotSettings.swift, Views/Settings/CopilotSettingsView.swift

Modified (8): AIModels, AIProviderFactory, SQLEditorCoordinator, SQLEditorView, EditorSettings, EditorSettingsView, AISettingsView, AppSettingsManager, AppSettingsStorage, SettingsView, TableProApp

Deleted (1): Core/AI/InlineSuggestionManager.swift (replaced by decomposed files)

Test plan

  • Build succeeds
  • InlineSuggestionManagerFocusTests pass (12/12)
  • AISettingsTests pass (3/3)
  • Copilot server starts on app launch when enabled
  • Copilot auto-detects existing authentication
  • Copilot inline suggestions show real table/column names from schema
  • Ghost text renders correctly, Tab accepts, Escape dismisses both popup and ghost text
  • Settings > Editor > Inline Suggestions picker works (Off / Copilot / AI)
  • Settings > Copilot > sign-in/out, status indicator
  • Settings > AI > Copilot Chat toggle, feature routing
  • Copilot Chat streaming via conversation protocol
  • Verify no regressions in Vim mode + inline suggestions

@datlechin datlechin force-pushed the feat/copilot-support branch from 17d7287 to e50815a Compare April 24, 2026 05:35
…hitecture

Copilot integration:
- LSP infrastructure: JSON-RPC 2.0 transport, typed client, document manager
- Binary download from npm with SHA-512 integrity verification
- OAuth device flow authentication
- Inline suggestions via textDocument/inlineCompletion with schema context
- Chat via conversation/create, conversation/turn, $/progress streaming
- Real model list from copilot/models endpoint
- Conversation lifecycle: destroy on clear, turnDelete on regenerate

Inline suggestion rewrite:
- InlineSuggestionSource protocol with dynamic resolver
- GhostTextRenderer with CATextLayer and scroll-aware repositioning
- AIChatInlineSource for AI provider fallback
- CopilotInlineSource with preamble offset handling
- Unified provider picker (Off/Copilot/AI) in Editor settings

AI provider registry:
- AIProviderDescriptor with capabilities and factory closures
- AIProviderRegistry wired into AIProviderFactory (replaces hardcoded switch)
- AIProviderRegistration registers all built-in providers at launch

Settings and UX:
- Copilot settings tab with status, auth, telemetry
- Copilot chat toggle in AI settings with auth guard
- Confirmation dialogs for clear conversations and delete provider
- Cancel button for Copilot sign-in flow
- Connection policy preserved (Always Allow/Ask/Never)
@datlechin datlechin force-pushed the feat/copilot-support branch from 3c5f997 to 677569b Compare April 26, 2026 05:15
@datlechin datlechin merged commit 97b61f3 into main Apr 26, 2026
2 checks passed
@datlechin datlechin deleted the feat/copilot-support branch April 26, 2026 05:17
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: Add support for Github Copilot

1 participant