Skip to content

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

Open
datlechin wants to merge 35 commits intomainfrom
feat/copilot-support
Open

feat: add GitHub Copilot support with rewritten inline suggestion architecture#850
datlechin wants to merge 35 commits intomainfrom
feat/copilot-support

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

@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
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