The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): refresh remote WebSocket header cache recency
Marco Fernstaedt024b9c0545cc
diff --git a/apps/desktop/electron/remote-ws-headers.test.ts b/apps/desktop/electron/remote-ws-headers.test.tsindex 19806ad9014..4aad322736b 100644--- a/apps/desktop/electron/remote-ws-headers.test.ts+++ b/apps/desktop/electron/remote-ws-headers.test.ts@@ -71,6 +71,40 @@ function expectNoHeadersForNearbyUrls(store: ReturnType<typeof createRemoteWsHea}describe('registry gateway WebSocket headers', () => {+ it('evicts the least recently accessed exact URL', () => {+ const store = createRemoteWsHeaderStore(2)+ const firstUrl = 'wss://gateway.example/api/ws?token=first&profile=research'+ const secondUrl = 'wss://gateway.example/api/ws?token=second&profile=research'+ const thirdUrl = 'wss://gateway.example/api/ws?token=third&profile=research'++ store.remember(firstUrl, accessHeaders)+ store.remember(secondUrl, accessHeaders)+ expect(store.headersFor('wss://gateway.example/api/ws?token=missing&profile=research')).toEqual({})+ expect(store.headersFor(firstUrl)).toEqual(accessHeaders)++ store.remember(thirdUrl, accessHeaders)++ expect(store.headersFor(firstUrl)).toEqual(accessHeaders)+ expect(store.headersFor(secondUrl)).toEqual({})+ expect(store.headersFor(thirdUrl)).toEqual(accessHeaders)+ })++ it('updates headers without changing insertion recency', () => {+ const store = createRemoteWsHeaderStore(2)+ const firstUrl = 'wss://gateway.example/api/ws?token=first'+ const secondUrl = 'wss://gateway.example/api/ws?token=second'+ const thirdUrl = 'wss://gateway.example/api/ws?token=third'++ store.remember(firstUrl, { 'CF-Access-Client-Id': 'old-client-id' })+ store.remember(secondUrl, accessHeaders)+ store.remember(firstUrl, { 'CF-Access-Client-Id': 'updated-client-id' })+ store.remember(thirdUrl, accessHeaders)++ expect(store.headersFor(firstUrl)).toEqual({})+ expect(store.headersFor(secondUrl)).toEqual(accessHeaders)+ expect(store.headersFor(thirdUrl)).toEqual(accessHeaders)+ })+it('token path binds headers to the exact profile scoped URL', async () => {const { ensureBackend, handler, mintTicket, store } = createHarness({authMode: 'token',diff --git a/apps/desktop/electron/remote-ws-headers.ts b/apps/desktop/electron/remote-ws-headers.tsindex 77fe935dd6b..5686ceb6483 100644--- a/apps/desktop/electron/remote-ws-headers.ts+++ b/apps/desktop/electron/remote-ws-headers.ts@@ -44,7 +44,19 @@ export function createRemoteWsHeaderStore(limit = 100) {}}- const headersFor = (requestUrl: string): Record<string, string> => headersByUrl.get(String(requestUrl)) ?? {}+ const headersFor = (requestUrl: string): Record<string, string> => {+ const key = String(requestUrl)+ const headers = headersByUrl.get(key)++ if (!headers) {+ return {}+ }++ headersByUrl.delete(key)+ headersByUrl.set(key, headers)++ return headers+ }return { headersFor, remember }}