From 891a2eb573ffdf730cf8cc5154d63672e3de5a34 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Wed, 16 Sep 2026 12:53:27 -0700 Subject: [PATCH] test(desktop): trim the same-named-profile routing coverage to two invariants Keep one invariant per owner ladder from #113284: the dispatcher routes a session whose events arrived on the LOCAL connection back to that connection while the window's primary is another connection, and knownOwnerForSession prefers the event-proven (connectionId, profile) over a bare row profile. The mirror-topology, control and no-session-context variants restated behaviour that the existing "exact owner rungs" describe already pins. --- .../contrib/session-rpc-dispatcher.test.ts | 47 ------------------- apps/desktop/src/store/session-states.test.ts | 6 --- 2 files changed, 53 deletions(-) diff --git a/apps/desktop/src/app/contrib/session-rpc-dispatcher.test.ts b/apps/desktop/src/app/contrib/session-rpc-dispatcher.test.ts index 2a5517e3bc..7544aeeb11 100644 --- a/apps/desktop/src/app/contrib/session-rpc-dispatcher.test.ts +++ b/apps/desktop/src/app/contrib/session-rpc-dispatcher.test.ts @@ -241,53 +241,6 @@ describe('createSessionRpcDispatcher: routes by the session OWNING connection wh expect(gatewayMocks.requestGatewayForProfile).not.toHaveBeenCalled() expect(ambientRequest).not.toHaveBeenCalled() }) - - it('routes a session that lives on the REMOTE connection to that connection', async () => { - gatewayMocks.activeConnectionId = 'local' - twoConnections() - recordSessionEventScope({ connectionId: 'homelab', profile: 'default', session_id: 'rt-remote' }) - setSessions([makeSessionInfo({ id: 'rt-remote', profile: 'default' })]) - const { ambientRequest, request } = dispatcher() - - await expect(request('prompt.submit', { session_id: 'rt-remote', text: 'again' })).resolves.toEqual({ - routed: true - }) - - expect(gatewayMocks.requestGatewayForAgent).toHaveBeenCalledWith('homelab', 'default', 'prompt.submit', { - session_id: 'rt-remote', - text: 'again' - }) - expect(gatewayMocks.requestGatewayForProfile).not.toHaveBeenCalled() - expect(ambientRequest).not.toHaveBeenCalled() - }) - - it('keeps a connection-tagged row owner over a conflicting event scope', async () => { - gatewayMocks.activeConnectionId = 'homelab' - twoConnections() - setSessions([makeSessionInfo({ connection_id: 'source-b', id: 'stored-shared', profile: 'default' })]) - recordSessionEventScope({ connectionId: 'local', profile: 'default', session_id: 'stored-shared' }) - - await expect(dispatcher().request('session.resume', { session_id: 'stored-shared' })).resolves.toEqual({ - routed: true - }) - - expect(gatewayMocks.requestGatewayForAgent).toHaveBeenLastCalledWith('source-b', 'default', 'session.resume', { - session_id: 'stored-shared' - }) - }) - - it('leaves a request with NO session context on the ambient socket, ledger or not', async () => { - gatewayMocks.activeConnectionId = 'homelab' - twoConnections() - recordSessionEventScope({ connectionId: 'local', profile: 'default', session_id: 'rt-local' }) - const { ambientRequest, request } = dispatcher() - - await expect(request('config.get', {})).resolves.toEqual({ ambient: true }) - - expect(ambientRequest).toHaveBeenCalledWith('config.get', {}) - expect(gatewayMocks.requestGatewayForAgent).not.toHaveBeenCalled() - expect(gatewayMocks.requestGatewayForProfile).not.toHaveBeenCalled() - }) }) describe('createSessionRpcDispatcher: stale runtime recovery', () => { diff --git a/apps/desktop/src/store/session-states.test.ts b/apps/desktop/src/store/session-states.test.ts index 2d522bf810..cd78911b3b 100644 --- a/apps/desktop/src/store/session-states.test.ts +++ b/apps/desktop/src/store/session-states.test.ts @@ -1314,12 +1314,6 @@ describe('knownOwnerForSession / requestForOwnedSession (#91684 client half)', ( expect(knownOwnerForSession('rt-local')).toEqual({ connectionId: 'local', profile: 'default' }) }) - it('still answers with the bare row profile when no event ever named the connection', () => { - setSessions([{ id: 'rt-unproven', profile: 'default' } as never]) - - expect(knownOwnerForSession('rt-unproven')).toBe('default') - }) - it('returns undefined (ambient) when no owner is known, and for null ids', () => { expect(knownOwnerForSession('unknown-session')).toBeUndefined() expect(knownOwnerForSession(null)).toBeUndefined()