diff --git a/apps/desktop/src/main/__tests__/runtime-host-collaboration-ipc-main.test.ts b/apps/desktop/src/main/__tests__/runtime-host-collaboration-ipc-main.test.ts index 3da977f0a2..a161321e20 100644 --- a/apps/desktop/src/main/__tests__/runtime-host-collaboration-ipc-main.test.ts +++ b/apps/desktop/src/main/__tests__/runtime-host-collaboration-ipc-main.test.ts @@ -165,9 +165,11 @@ function peerReachability() { test('treats an unavailable collaboration authority as an empty background inbox', async () => { const handlers = new Map(); + let queryCalls = 0; registerRuntimeHostCollaborationIpc( { async queryCollaborationTurnRequests() { + queryCalls += 1; throw new RuntimeHostOperationError( 'collaboration.turn-request.query', 'operation_unavailable', @@ -191,6 +193,11 @@ test('treats an unavailable collaboration authority as an empty background inbox canRequestTurns: false, requests: [], }); + assert.deepEqual(await query({} as Parameters[0]), { + canRequestTurns: false, + requests: [], + }); + assert.equal(queryCalls, 1); await assert.rejects( query({} as Parameters[0], 'session-1'), RuntimeHostOperationError, diff --git a/apps/desktop/src/main/runtime-host-collaboration-ipc-main.ts b/apps/desktop/src/main/runtime-host-collaboration-ipc-main.ts index 502d5b9b23..47e5a677fc 100644 --- a/apps/desktop/src/main/runtime-host-collaboration-ipc-main.ts +++ b/apps/desktop/src/main/runtime-host-collaboration-ipc-main.ts @@ -46,6 +46,7 @@ export function registerRuntimeHostCollaborationIpc( | DesktopCollaborationConnectionTarget | Promise, ): void { + let backgroundInboxUnavailable = false; ipcMain.handle( 'session-collaboration:prepare', async ( @@ -97,10 +98,14 @@ export function registerRuntimeHostCollaborationIpc( async (_event, sessionId: unknown) => { const requestedSessionId = sessionId === undefined ? undefined : requiredId(sessionId, 'Session'); + if (requestedSessionId === undefined && backgroundInboxUnavailable) { + return { canRequestTurns: false, requests: [] }; + } try { return await client.queryCollaborationTurnRequests(requestedSessionId); } catch (error) { if (requestedSessionId === undefined && isCollaborationInboxUnavailable(error)) { + backgroundInboxUnavailable = true; return { canRequestTurns: false, requests: [] }; } throw error;