Skip to content

Commit 1b497b0

Browse files
committed
feat(ui): add progress notification for commit message generation
- Add progress indicator with cancellable notification - Display step-by-step status updates during generation - Show progress for git diff, API key check and message generation - Import ProgressLocation from vscode API
1 parent 9e10e58 commit 1b497b0

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/extension.ts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { commands, window, workspace, type ExtensionContext, type TextDocument } from "vscode"
1+
import { commands, ProgressLocation, window, workspace, type ExtensionContext, type TextDocument } from "vscode"
22
import { APIKeyManager } from "./apiKeyManager"
33
import { CommitMessageGenerator } from "./commitMessageGenerator"
44
import { ConfigManager } from "./configManager"
@@ -18,21 +18,33 @@ export function activate(context: ExtensionContext) {
1818
return undefined
1919
}
2020

21-
const diff = await gitManager.getDiff()
22-
if (!diff) {
23-
window.showErrorMessage("No changes detected")
24-
return undefined
25-
}
21+
return await window.withProgress(
22+
{
23+
location: ProgressLocation.Notification,
24+
title: "Generating commit message...",
25+
cancellable: false,
26+
},
27+
async (progress) => {
28+
progress.report({ message: "Getting git diff..." })
29+
const diff = await gitManager.getDiff()
30+
if (!diff) {
31+
window.showErrorMessage("No changes detected")
32+
return undefined
33+
}
2634

27-
const apiKey = (await apiKeyManager.getAPIKey()) ?? (await apiKeyManager.setAPIKey())
28-
if (!apiKey) {
29-
window.showErrorMessage("API Key is required")
30-
return undefined
31-
}
35+
progress.report({ message: "Checking API key..." })
36+
const apiKey = (await apiKeyManager.getAPIKey()) ?? (await apiKeyManager.setAPIKey())
37+
if (!apiKey) {
38+
window.showErrorMessage("API Key is required")
39+
return undefined
40+
}
3241

33-
const config = configManager.getConfig()
34-
const generator = new CommitMessageGenerator(apiKey)
35-
return await generator.generateMessage(diff, config)
42+
progress.report({ message: "Generating message..." })
43+
const config = configManager.getConfig()
44+
const generator = new CommitMessageGenerator(apiKey)
45+
return await generator.generateMessage(diff, config)
46+
},
47+
)
3648
}
3749

3850
// Register all commands

0 commit comments

Comments
 (0)