- Added AIChatPanel component with context header, user and AI message handling. - Integrated streaming responses via IPC and error handling for chat mutations. - Enhanced user experience with input handling and auto-scrolling features. - Updated AppShell to derive AI chat context from the current route. - Introduced ScrollArea component for better scrolling behavior in various dialogs. - Added support for Tailwind typography and improved global styles. - Updated project and task dialogs to utilize ScrollArea for better UX.
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import { app } from 'electron';
|
|
import { registerProvider, type AIProvider } from './provider';
|
|
|
|
// Dynamic import type — @github/copilot-sdk is ESM-only
|
|
type CopilotClientType = import('@github/copilot-sdk').CopilotClient;
|
|
|
|
let client: CopilotClientType | null = null;
|
|
let isReady = false;
|
|
|
|
const copilotProvider: AIProvider = {
|
|
name: 'copilot',
|
|
displayName: 'GitHub Copilot',
|
|
usesExternalAuth: true,
|
|
|
|
async initialize(): Promise<boolean> {
|
|
try {
|
|
// Stop existing client if re-initializing
|
|
if (client) {
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
await client.stop().catch(() => {});
|
|
client = null;
|
|
}
|
|
|
|
const { CopilotClient } = await import('@github/copilot-sdk');
|
|
// No githubToken — uses stored OAuth credentials from Copilot CLI
|
|
// (authenticate first with `copilot auth login`)
|
|
client = new CopilotClient({
|
|
autoStart: true,
|
|
autoRestart: true,
|
|
logLevel: 'warning',
|
|
});
|
|
await client.start();
|
|
isReady = true;
|
|
console.log('[AI] CopilotClient started (using CLI OAuth credentials)');
|
|
return true;
|
|
} catch (err) {
|
|
console.error('[AI] Failed to start CopilotClient:', err);
|
|
client = null;
|
|
isReady = false;
|
|
return false;
|
|
}
|
|
},
|
|
|
|
isReady(): boolean {
|
|
return isReady && client !== null;
|
|
},
|
|
};
|
|
|
|
/** Get the CopilotClient instance (null if not initialized). */
|
|
export function getCopilotClient(): CopilotClientType | null {
|
|
return client;
|
|
}
|
|
|
|
// Clean shutdown on app quit
|
|
app.on('before-quit', () => {
|
|
if (client) {
|
|
client.stop().catch((err: unknown) => console.error('[AI] Error stopping CopilotClient:', err));
|
|
}
|
|
});
|
|
|
|
registerProvider(copilotProvider);
|