Skip to content

Commit 0bc7c03

Browse files
author
wangyudong
committed
fix: prevent duplicate same session ID notifications
Add tracking of last notified session ID to avoid showing repeated notifications when the same session ID is detected in clipboard checks.
1 parent af281db commit 0bc7c03

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/extension.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ export function activate(context: vscode.ExtensionContext) {
516516
showCollapseAll: true
517517
});
518518

519+
// 记录已经提醒过的相同Session ID,避免重复提醒
520+
let lastNotifiedSameSessionId: string | null = null;
521+
519522
// 剪贴板检测功能
520523
async function checkClipboardForSession() {
521524
try {
@@ -540,11 +543,17 @@ export function activate(context: vscode.ExtensionContext) {
540543
vscode.window.showInformationMessage(t('messages.sessionIdAutoUpdated'));
541544
provider.refresh();
542545
}
546+
// 重置已提醒的Session ID,因为检测到了不同的Session ID
547+
lastNotifiedSameSessionId = null;
543548
} else {
544-
// 如果Session ID相同,提示用户识别到相同的Session ID
545-
vscode.window.showInformationMessage(
546-
t('messages.sameSessionIdDetected', { sessionId: sessionId.substring(0, 20) })
547-
);
549+
// 如果Session ID相同,且之前没有提醒过这个Session ID,则提示用户
550+
if (lastNotifiedSameSessionId !== sessionId) {
551+
vscode.window.showInformationMessage(
552+
t('messages.sameSessionIdDetected', { sessionId: sessionId.substring(0, 20) })
553+
);
554+
// 记录已经提醒过的Session ID
555+
lastNotifiedSameSessionId = sessionId;
556+
}
548557
}
549558
}
550559
} catch (error) {

0 commit comments

Comments
 (0)