Skip to content

Commit 7d20b8b

Browse files
yamork779claude
andcommitted
fix(message-box): resolve auto-close not working for success message
- Add configurable `messageAutoCloseSeconds` setting (0-60s, default 5s) to auto-close the commit message success dialog - Implement `showAutoCloseMessage()` helper function to display messages with automatic dismissal after specified timeout - Update success message UI to use auto-close behavior, supporting both managed and feedback modes - Display countdown hint in message text to inform user of auto-close delay 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 398eca6 commit 7d20b8b

2 files changed

Lines changed: 56 additions & 6 deletions

File tree

‎package.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@
138138
"default": false,
139139
"markdownDescription": "Keep Co-Authored-By signature in commit message. **Only works in Claude Code managed mode**",
140140
"order": 9
141+
},
142+
"claudeCommit.messageAutoCloseSeconds": {
143+
"type": "number",
144+
"default": 5,
145+
"minimum": 0,
146+
"maximum": 60,
147+
"description": "Auto-close timeout for the success message in seconds. Set to 0 to disable auto-close.",
148+
"order": 10
141149
}
142150
}
143151
}

‎src/extension.ts‎

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@ import * as vscode from "vscode";
22
import { generateCommitMessage, editCommitMessage, generateWithCustomPrompt } from "./generators/commit";
33
import 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

Comments
 (0)