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.
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user