@@ -2,6 +2,41 @@ import * as vscode from "vscode";
22import { generateCommitMessage , editCommitMessage , generateWithCustomPrompt } from "./generators/commit" ;
33import type { GitRepository , GitAPI , Language } from "./types" ;
44
5+ /**
6+ * Show an information message that auto-closes after a specified timeout.
7+ * Returns the selected button or undefined if auto-closed/dismissed.
8+ */
9+ function showAutoCloseMessage (
10+ message : string ,
11+ timeoutSeconds : number ,
12+ ...buttons : string [ ]
13+ ) : Promise < string | undefined > {
14+ return new Promise ( ( resolve ) => {
15+ let resolved = false ;
16+
17+ const resolveOnce = ( result : string | undefined ) => {
18+ if ( ! resolved ) {
19+ resolved = true ;
20+ resolve ( result ) ;
21+ }
22+ } ;
23+
24+ // Auto-close timer
25+ const timer = setTimeout ( ( ) => {
26+ resolveOnce ( undefined ) ;
27+ } , timeoutSeconds * 1000 ) ;
28+
29+ // Show message with countdown hint in text
30+ const messageWithHint = `${ message } (${ timeoutSeconds } s)` ;
31+ vscode . window
32+ . showInformationMessage ( messageWithHint , ...buttons )
33+ . then ( ( result ) => {
34+ clearTimeout ( timer ) ;
35+ resolveOnce ( result ) ;
36+ } ) ;
37+ } ) ;
38+ }
39+
540/**
641 * Get the Git repository from a SourceControl object passed by VS Code
742 * when a command is triggered from the SCM title menu.
@@ -157,16 +192,23 @@ export function activate(context: vscode.ExtensionContext): void {
157192 // Show different buttons based on mode
158193 const isManagedMode = claudeCodeManaged && preferredMethod === "cli" ;
159194
160- const action = isManagedMode
161- ? await vscode . window . showInformationMessage (
195+ const buttons = isManagedMode
196+ ? [ "Custom prompt" ]
197+ : [ "Edit with feedback" ] ;
198+
199+ // Get auto-close timeout from config
200+ const autoCloseSeconds = config . get < number > ( "messageAutoCloseSeconds" , 5 ) ;
201+
202+ // Show message with auto-close (or without if set to 0)
203+ const action = autoCloseSeconds > 0
204+ ? await showAutoCloseMessage (
162205 "Commit message generated!" ,
163- "Custom prompt" ,
164- "OK"
206+ autoCloseSeconds ,
207+ ... buttons
165208 )
166209 : await vscode . window . showInformationMessage (
167210 "Commit message generated!" ,
168- "Edit with feedback" ,
169- "OK"
211+ ...buttons
170212 ) ;
171213
172214 if ( action === "Edit with feedback" ) {
0 commit comments