The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
R4: pin hidden owner hint scope for hydration and refresh
yoniebansa63d6af68334
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 d22a6dc41b2..a4b53115a02 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@@ -28,6 +28,7 @@ import {type ActiveTranscriptRefreshDeps,isTypingBurstActive,noteRendererKeyboardActivity,+ profileScopeForTranscriptSession,reconcileActiveTranscript,reconcileTileTranscripts as reconcileTileTranscriptsForTest,rehydrateLiveSessionStatuses,@@ -53,7 +54,7 @@ const { refreshProjectTree } = await import('@/store/projects')const ACTIVE_RUNTIME_ID = 'runtime-active'const ACTIVE_STORED_ID = 'stored-active'-function transcript(answer: string, sessionId = ACTIVE_STORED_ID) {+function transcript(answer: string, sessionId = ACTIVE_STORED_ID): Awaited<ReturnType<typeof getLatestSessionMessages>> {return {messages: [{ content: 'question', role: 'user', timestamp: 1 },@@ -183,8 +184,31 @@ afterEach(() => {})describe('resolveActiveTranscriptSession', () => {+ it('uses a unique hidden owner hint for hydration and refresh scope', async () => {+ const ownerRoute = {+ connectionId: 'hidden-remote',+ profile: 'connection-profile',+ targetProfile: 'bot-profile',+ mode: 'remote' as const+ }++ setSessionOwnerHint(ACTIVE_STORED_ID, ownerRoute)+ const scope = profileScopeForTranscriptSession(resolveActiveTranscriptSession(ACTIVE_STORED_ID, ACTIVE_RUNTIME_ID))++ expect(scope).toEqual({ connectionId: ownerRoute.connectionId, profile: ownerRoute.targetProfile })+ vi.mocked(getLatestSessionMessages).mockResolvedValue(transcript('hint-owned answer'))+ const fixture = makeRefresh(resolveActiveTranscriptSession)+ await fixture.refresh()++ expect(getLatestSessionMessages).toHaveBeenCalledWith(ACTIVE_STORED_ID, scope)+ expect(fixture.states.get(ACTIVE_RUNTIME_ID)?.messages.at(-1)?.parts[0]).toMatchObject({+ text: 'hint-owned answer'+ })+ })+it('does not promote a different runtime tile into the active transcript owner', () => {const ownerRoute = { connectionId: 'local', profile: 'other-profile', mode: 'local' as const }+ // SAFETY: Ownership resolution reads only identity and profile fields; omitted session metadata is unused.setSessions([{ id: 'shared', profile: 'default', source: 'desktop' } as never])$sessionTiles.set([{ storedSessionId: 'shared', runtimeId: 'other-runtime', ownerRoute }])@@ -192,6 +216,7 @@ describe('resolveActiveTranscriptSession', () => {})it('does not treat an ownerless active tile as corroboration for a stale hint', () => {+ // SAFETY: Ownership resolution reads only identity and profile fields; omitted session metadata is unused.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' }])@@ -684,9 +709,10 @@ describe('reconcileActiveTranscript', () => {ownerRoute: namedOwner}])- setSessions([{ id: S, profile: 'default', source: 'desktop', connectionId: 'local' } as never])+ // SAFETY: Ownership resolution reads only identity and profile fields; omitted session metadata is unused.+ setSessions([{ id: S, profile: 'default', source: 'desktop', connection_id: 'local' } as never])const fixture = makeRefresh(resolveActiveTranscriptSession)- vi.mocked(getLatestSessionMessages).mockResolvedValue(transcript('named-profile answer') as never)+ vi.mocked(getLatestSessionMessages).mockResolvedValue(transcript('named-profile answer'))await fixture.refresh()