The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
R5: use the owner route type and colocate resolver tests
yoniebans22db21391755
diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.owner-boundary.test.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.owner-boundary.test.tsdeleted file mode 100644index f6efac3eee6..00000000000--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.owner-boundary.test.ts+++ /dev/null@@ -1,29 +0,0 @@-import { afterEach, expect, it } from 'vitest'--import { $activeSessionId, _resetSessionOwnerHintsForTests, setSessionOwnerHint, setSessions } from '@/store/session'-import { $sessionTiles } from '@/store/session-states'--import { resolveActiveTranscriptSession } from './use-background-sync'--afterEach(() => {- $activeSessionId.set(null)- $sessionTiles.set([])- setSessions([])- _resetSessionOwnerHintsForTests()-})--it('does not promote a different runtime tile into the active transcript owner', () => {- const ownerRoute = { connectionId: 'local', profile: 'other-profile', mode: 'local' as const }- setSessions([{ id: 'shared', profile: 'default', source: 'desktop' } as never])- $sessionTiles.set([{ storedSessionId: 'shared', runtimeId: 'other-runtime', ownerRoute }])-- expect(resolveActiveTranscriptSession('shared', 'active-runtime')).toEqual({ profile: 'default' })-})--it('does not treat an ownerless active tile as corroboration for a stale hint', () => {- setSessions([{ id: 'shared', profile: 'default', source: 'desktop' } as never])- setSessionOwnerHint('shared', { connectionId: 'stale-connection', profile: 'stale-profile', mode: 'remote' })- $sessionTiles.set([{ storedSessionId: 'shared', runtimeId: 'active-runtime' }])-- expect(resolveActiveTranscriptSession('shared', 'active-runtime')).toEqual({ profile: 'default' })-})diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.test.tsindex fc6975231bf..d22a6dc41b2 100644--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts+++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts@@ -182,6 +182,24 @@ afterEach(() => {resetTypingActivityTracking()})+describe('resolveActiveTranscriptSession', () => {+ it('does not promote a different runtime tile into the active transcript owner', () => {+ const ownerRoute = { connectionId: 'local', profile: 'other-profile', mode: 'local' as const }+ setSessions([{ id: 'shared', profile: 'default', source: 'desktop' } as never])+ $sessionTiles.set([{ storedSessionId: 'shared', runtimeId: 'other-runtime', ownerRoute }])++ expect(resolveActiveTranscriptSession('shared', 'active-runtime')).toEqual({ profile: 'default' })+ })++ it('does not treat an ownerless active tile as corroboration for a stale hint', () => {+ setSessions([{ id: 'shared', profile: 'default', source: 'desktop' } as never])+ setSessionOwnerHint('shared', { connectionId: 'stale-connection', profile: 'stale-profile', mode: 'remote' })+ $sessionTiles.set([{ storedSessionId: 'shared', runtimeId: 'active-runtime' }])++ expect(resolveActiveTranscriptSession('shared', 'active-runtime')).toEqual({ profile: 'default' })+ })+})+describe('active transcript refresh', () => {beforeEach(() => {vi.mocked(getLatestSessionMessages).mockResolvedValue(transcript('answer') as never)diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.tsindex acf64852feb..4523e1664f3 100644--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts+++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.ts@@ -21,7 +21,7 @@ import {sessionMatchesStoredId,setCurrentCwd} from '@/store/session'-import type { SessionProfileRoute } from '@/store/session-request-router'+import type { SessionOwnerRoute } from '@/store/session-request-router'import {$sessionStates,$sessionTiles,@@ -35,7 +35,7 @@ import type { ClientSessionState } from '../../types'import type { GatewayRequester } from '../types'interface ActiveTranscriptSession {- ownerRoute?: SessionProfileRoute+ ownerRoute?: SessionOwnerRouteprofile?: string | null}@@ -99,7 +99,7 @@ function tileRuntimeOwnsLiveState(runtimeId: string): boolean {return Boolean(state && (state.busy || state.awaitingResponse || state.needsInput || state.turnLive))}-type TileTranscriptTarget = { ownerRoute?: SessionProfileRoute; storedSessionId: string; runtimeId?: string }+type TileTranscriptTarget = { ownerRoute?: SessionOwnerRoute; storedSessionId: string; runtimeId?: string }/** Signature key per tile — carries the owner route so two connections/profiles* sharing a stored id (or a tile re-homed to another owner) never alias. */