fix: dedupe vscode notifications across panels

Prevents duplicate native notifications when a session is open in both sidebar and editor
Uses an extension-host claim step so only one VS Code webview displays each notification
Keeps notification behavior unchanged for single-panel sessions
This commit is contained in:
Bohdan Triapitsyn
2026-05-19 16:41:16 +03:00
parent c81441ecfc
commit 04f4b71396
2 changed files with 55 additions and 4 deletions
@@ -22,6 +22,26 @@ type SystemRuntimeDeps = {
clientReloadDelayMs: number;
};
const NOTIFICATION_CLAIM_TTL_MS = 10_000;
const notificationClaims = new Map<string, number>();
const claimNotification = (key: string): boolean => {
const now = Date.now();
for (const [claimKey, claimedAt] of notificationClaims) {
if (now - claimedAt > NOTIFICATION_CLAIM_TTL_MS) {
notificationClaims.delete(claimKey);
}
}
const existing = notificationClaims.get(key);
if (existing && now - existing <= NOTIFICATION_CLAIM_TTL_MS) {
return false;
}
notificationClaims.set(key, now);
return true;
};
const getOpenChamberConfigDir = (): string => {
if (process.platform === 'win32') {
@@ -225,6 +245,13 @@ export async function handleSystemBridgeMessage(
return { id, type, success: true, data: getSessionActivitySnapshot() };
}
case 'api:notifications:claim': {
const key = typeof (payload as { key?: unknown } | undefined)?.key === 'string'
? (payload as { key: string }).key.trim()
: '';
return { id, type, success: true, data: { claimed: key ? claimNotification(key) : false } };
}
case 'api:zen:models': {
const models = await fetchFreeZenModels();
return { id, type, success: true, data: { models } };