Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,41 @@ export async function activate(context: vscode.ExtensionContext) {
}
});

const apiKey = configManager.getConfig<string>('OPENAI_API_KEY');
if (!apiKey) {
const result = await vscode.window.showWarningMessage(
'OpenAI API Key not configured. Would you like to configure it now?',
'Yes',
'No'
);
// Check API key based on configured AI provider
const aiProvider = configManager.getConfig<string>('AI_PROVIDER', 'openai');

if (aiProvider === 'gemini') {
const geminiApiKey = configManager.getConfig<string>('GEMINI_API_KEY');
if (!geminiApiKey) {
const result = await vscode.window.showWarningMessage(
'Gemini API Key not configured. Would you like to configure it now?',
'Yes',
'No'
);

if (result === 'Yes') {
await vscode.commands.executeCommand(
'workbench.action.openSettings',
'ai-commit.OPENAI_API_KEY'
if (result === 'Yes') {
await vscode.commands.executeCommand(
'workbench.action.openSettings',
'ai-commit.GEMINI_API_KEY'
);
}
}
} else {
// Default to OpenAI provider
const openaiApiKey = configManager.getConfig<string>('OPENAI_API_KEY');
if (!openaiApiKey) {
const result = await vscode.window.showWarningMessage(
'OpenAI API Key not configured. Would you like to configure it now?',
'Yes',
'No'
);

if (result === 'Yes') {
await vscode.commands.executeCommand(
'workbench.action.openSettings',
'ai-commit.OPENAI_API_KEY'
);
}
}
}
} catch (error) {
Expand Down