The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): preserve registry owner for session sends
aryaabe584288b26
diff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsxindex d4390d71ae9..8fccc4c3f82 100644--- a/apps/desktop/src/app/contrib/wiring.tsx+++ b/apps/desktop/src/app/contrib/wiring.tsx@@ -72,7 +72,7 @@ import {$selectedStoredSessionId,$sessionResumeRequest,$sessions,- knownSessionProfile,+ knownSessionOwner,sessionMatchesStoredId,sessionPinId,setAwaitingResponse,@@ -358,7 +358,7 @@ export function ContribWiring({ children }: { children: ReactNode }) {let owner: SessionOwnerScope =(routingSessionId ? sessionTileOwnerRoute(routingSessionId) : undefined) ??- knownSessionProfile($sessions.get(), routingSessionId)+ knownSessionOwner($sessions.get(), routingSessionId)if (!owner && routingSessionId) {// Unknown owner for a REAL session: probe across profiles (REST, not thediff --git a/apps/desktop/src/store/session.test.ts b/apps/desktop/src/store/session.test.tsindex 06f4a48680a..71913e31ecf 100644--- a/apps/desktop/src/store/session.test.ts+++ b/apps/desktop/src/store/session.test.ts@@ -33,6 +33,7 @@ import {getRememberedRoute,getRememberedSessionId,getSessionOwnerHint,+ knownSessionOwner,knownSessionProfile,mergeSessionPage,rememberedSessionProfile,@@ -60,6 +61,28 @@ import {const session = (over: Partial<SessionInfo>): SessionInfo => makeSessionInfo({ id: 'live', ...over })describe('session owner hints', () => {+ it('preserves the registry owner recorded on a discovered session row', () => {+ expect(+ knownSessionOwner(+ [session({ connection_id: 'test-amnezia', id: 'registry-session', profile: 'default' })],+ 'registry-session'+ )+ ).toEqual({ connectionId: 'test-amnezia', profile: 'default' })+ })++ it('preserves the exact registry owner for session-scoped RPC routing', () => {+ const route = {+ connectionId: 'test-amnezia',+ mode: 'remote' as const,+ profile: 'default',+ targetProfile: 'default'+ }++ setSessionOwnerHint('remote-session', route)++ expect(knownSessionOwner([session({ id: 'remote-session', profile: 'default' })], 'remote-session')).toEqual(route)+ })+it('keeps identical session ids separate across connection and profile owners', () => {const sourceA = { connectionId: 'source-a', mode: 'remote' as const, profile: 'worker', targetProfile: 'backend-a' }const sourceB = { connectionId: 'source-b', mode: 'remote' as const, profile: 'worker', targetProfile: 'backend-b' }diff --git a/apps/desktop/src/store/session.ts b/apps/desktop/src/store/session.tsindex 447c2708096..5ce62957836 100644--- a/apps/desktop/src/store/session.ts+++ b/apps/desktop/src/store/session.ts@@ -141,6 +141,35 @@ export function knownSessionProfile(sessions: readonly SessionInfo[], sessionId:return (hint?.targetProfile ?? hint?.profile)?.trim() || undefined}+/**+ * The exact owner a session-scoped RPC should use, preserving registry+ * connection identity when the session was discovered through a named remote+ * connection. Falling back to only the profile is safe solely when no exact+ * route hint exists.+ */+export function knownSessionOwner(+ sessions: readonly SessionInfo[],+ sessionId: null | string+): SessionProfileRoute | string | undefined {+ if (!sessionId) {+ return undefined+ }++ const session = sessions.find(candidate => sessionMatchesStoredId(candidate, sessionId))+ const connectionId = session?.connection_id?.trim()++ if (connectionId) {+ return {+ connectionId,+ profile: session?.profile?.trim() || 'default'+ }+ }++ const hint = getSessionOwnerHint(sessionId)++ return hint ?? (session?.profile?.trim() || undefined)+}+/*** The profile a routed session belongs to, for keying the remembered id and* other PRESENTATION uses (which profile's sidebar/navigation this session sits