The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
R2: require the captured runtime for transcript owner resolution
yoniebans1323acea8927
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.tsindex a9272a12136..f6efac3eee6 100644--- 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.ts@@ -14,7 +14,6 @@ afterEach(() => {it('does not promote a different runtime tile into the active transcript owner', () => {const ownerRoute = { connectionId: 'local', profile: 'other-profile', mode: 'local' as const }- $activeSessionId.set('active-runtime')setSessions([{ id: 'shared', profile: 'default', source: 'desktop' } as never])$sessionTiles.set([{ storedSessionId: 'shared', runtimeId: 'other-runtime', ownerRoute }])@@ -22,7 +21,6 @@ it('does not promote a different runtime tile into the active transcript owner',})it('does not treat an ownerless active tile as corroboration for a stale hint', () => {- $activeSessionId.set('active-runtime')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' }])diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.tsindex b7d4702c41a..b3a9e8bf90c 100644--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts+++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.ts@@ -39,20 +39,6 @@ interface ActiveTranscriptSession {profile?: string | null}-/** Only a bound tile's explicit route can override visible session ownership. */-function preferredActiveTranscriptOwner(- storedSessionId: string,- runtimeSessionId?: null | string-): SessionProfileRoute | undefined {- const runtimeId = runtimeSessionId ?? $activeSessionId.get()- const tiles = $sessionTiles.get().filter(tile => tile.storedSessionId === storedSessionId)- const activeTile = runtimeId- ? tiles.find(tile => tile.runtimeId === runtimeId)- : tiles.length === 1 ? tiles[0] : undefined-- return activeTile?.ownerRoute-}-/** Profile/connection scope used to read an active transcript from storage. */export function profileScopeForTranscriptSession(stored: ActiveTranscriptSession | undefined): ProfileScope {if (!stored) {@@ -69,14 +55,14 @@ export function profileScopeForTranscriptSession(stored: ActiveTranscriptSessionreturn stored.profile}-/** Resolve an active transcript from a verified owner, matching visible rows,- * or its unique hidden owner. Visible-first remains when no owner is verified- * so a stale hint cannot rewrite a viewed session row. */+/** Only a runtime-matched explicit tile owner overrides visible rows; unique hints are the last fallback. */export function resolveActiveTranscriptSession(storedSessionId: string,- runtimeSessionId?: null | string+ runtimeSessionId: string): ActiveTranscriptSession | undefined {- const verifiedOwner = preferredActiveTranscriptOwner(storedSessionId, runtimeSessionId)+ const verifiedOwner = $sessionTiles.get().find(+ tile => tile.storedSessionId === storedSessionId && tile.runtimeId === runtimeSessionId+ )?.ownerRouteif (verifiedOwner) {return { ownerRoute: verifiedOwner, profile: verifiedOwner.profile }@@ -98,7 +84,7 @@ export interface ActiveTranscriptRefreshDeps {busyRef: MutableRefObject<boolean>requestSequenceRef: MutableRefObject<number>selectedStoredSessionIdRef: MutableRefObject<string | null>- resolveSession: (storedSessionId: string) => ActiveTranscriptSession | null | undefined+ resolveSession: (storedSessionId: string, runtimeSessionId: string) => ActiveTranscriptSession | null | undefinedsignatureRef: MutableRefObject<Map<string, string>>updateSessionState: (sessionId: string,@@ -263,7 +249,7 @@ export async function reconcileActiveTranscript({return}- const stored = resolveSession(storedSessionId)+ const stored = resolveSession(storedSessionId, runtimeSessionId)if (!stored) {returndiff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsxindex dafcca25fcd..dd315eddf65 100644--- a/apps/desktop/src/app/contrib/wiring.tsx+++ b/apps/desktop/src/app/contrib/wiring.tsx@@ -536,7 +536,7 @@ export function ContribWiring({ children }: { children: ReactNode }) {activeSessionIdRef,busyRef,requestSequenceRef: activeTranscriptRequestSequenceRef,- resolveSession: id => resolveActiveTranscriptSession(id, activeSessionIdRef.current),+ resolveSession: resolveActiveTranscriptSession,selectedStoredSessionIdRef,signatureRef: activeTranscriptSignatureRef,updateSessionState