fix(ui): prevent duplicate loop completion notifications

Add deduplication guard to prevent spamming the same completion toast.
Uses a Set to track shown completions per session, with 30s expiry to
allow re-notification if loop restarts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-19 17:22:55 +01:00
co-authored by Claude Opus 4.5
parent 3b072c051f
commit d1a6955931
+12
View File
@@ -498,6 +498,18 @@ class ClaudemanApp {
this.eventSource.addEventListener('session:innerCompletionDetected', (e) => {
const data = JSON.parse(e.data);
// Prevent duplicate notifications for the same completion
const completionKey = `${data.sessionId}:${data.phrase}`;
if (this._shownCompletions?.has(completionKey)) {
return;
}
if (!this._shownCompletions) {
this._shownCompletions = new Set();
}
this._shownCompletions.add(completionKey);
// Clear after 30 seconds to allow re-notification if loop restarts
setTimeout(() => this._shownCompletions?.delete(completionKey), 30000);
this.showToast(`Loop completed: ${data.phrase}`, 'success');
// Update inner state to mark loop as inactive
const existing = this.innerStates.get(data.sessionId) || {};