The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): no notification cooldown after a benign daemon swap on Linux
kshitijk4poorc93b15724993
diff --git a/apps/desktop/electron/notification-linux.test.ts b/apps/desktop/electron/notification-linux.test.tsindex ba8b0b4384d..9aaaf147837 100644--- a/apps/desktop/electron/notification-linux.test.ts+++ b/apps/desktop/electron/notification-linux.test.ts@@ -66,6 +66,12 @@ function setup(alreadyRunning = false) {calls.push(message)const promise = new Promise((resolve, reject) => {+ // Like the real bus: a call addressed to a unique name that has gone away+ // is answered with an error, not routed to the new owner.+ if (message.destination?.startsWith(':') && message.destination !== owner) {+ reject(Object.assign(new Error('no such name'), { dbusName: 'org.freedesktop.DBus.Error.NameHasNoOwner' }))+ return+ }if (failures.has(message.member ?? '')) {reject(Object.assign(new Error('fixture failure'), { dbusName: failures.get(message.member ?? '') }))return@@ -271,6 +277,10 @@ it.skipIf(process.platform !== 'linux')(race.raceOwnerReply()expect(await race.notify({ tag: 'obsolete-owner', focusSessionId: 'must-not-open' })).toBe(false)expect(race.calls.filter(call => call.member === 'Notify')).toHaveLength(0)+ // A daemon swap is not a daemon failure: the next notification goes to the+ // new owner right away instead of sitting out the failure cooldown.+ expect(await race.notify({ tag: 'after-race' })).toBe(true)+ expect(race.calls.filter(call => call.member === 'Notify')).toHaveLength(1)race.connection.emit('close')const h = setup(true)diff --git a/apps/desktop/electron/notification-linux.ts b/apps/desktop/electron/notification-linux.tsindex bd2bb75d721..9082ae5cfd7 100644--- a/apps/desktop/electron/notification-linux.ts+++ b/apps/desktop/electron/notification-linux.ts@@ -173,6 +173,9 @@ export function createLinuxNotifications() {pending++const timer = setTimeout(() => abort.abort(), DELIVERY_TIMEOUT_MS)const callOptions = { signal: abort.signal, timeout: DELIVERY_TIMEOUT_MS }+ // The owner this delivery was addressed to; the catch below reads it to+ // tell a daemon that failed from a daemon that was replaced under us.+ let addressed: { state: Connection; generation: number } | undefinedtry {const state = connect()@@ -207,6 +210,7 @@ export function createLinuxNotifications() {}const { owner, generation } = destination+ addressed = { state, generation }if (state.generation !== generation) {throw new Error('Notification owner changed during lookup')}@@ -295,7 +299,11 @@ export function createLinuxNotifications() {} catch {// A timeout may still have delivered remotely. Never replay it, and do// not discard older healthy notifications' callbacks on this connection.- retryAfter = Date.now() + RETRY_COOLDOWN_MS+ // A failure against an owner that has since been replaced says nothing+ // about the new daemon, so it earns no cooldown.+ if (!addressed || addressed.state.generation === addressed.generation) {+ retryAfter = Date.now() + RETRY_COOLDOWN_MS+ }release()notification.emit('failed')