The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): routed fresh chat keeps its exact owner after session.create
Zeus-Deus77edf1b4df12
diff --git a/apps/desktop/src/app/contrib/wiring-routing.test.ts b/apps/desktop/src/app/contrib/wiring-routing.test.tsindex e195fa516af..77694efe199 100644--- a/apps/desktop/src/app/contrib/wiring-routing.test.ts+++ b/apps/desktop/src/app/contrib/wiring-routing.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest'-import { findStoredIdForRuntimeId, resolveRoutingSessionId } from './wiring-routing'+import { findStoredIdForRuntimeId, resolveRoutingSessionId, resolveSessionRpcOwner } from './wiring-routing'describe('findStoredIdForRuntimeId', () => {it('reverse-resolves a runtime id to its stored id', () => {@@ -76,3 +76,65 @@ describe('resolveRoutingSessionId', () => {).toBeNull()})})++describe('resolveSessionRpcOwner', () => {+ const none = () => undefined+ const omar = { connectionId: 'local', mode: 'local' as const, profile: 'omar' }+ const homelab = { connectionId: 'homelab', mode: 'remote' as const, profile: 'worker', targetProfile: 'w' }++ it('returns undefined for an RPC with no session (ambient chrome)', () => {+ expect(+ resolveSessionRpcOwner({+ routingSessionId: null,+ sessionOwnerHint: none,+ sessionRowOwner: none,+ tileOwnerRoute: none+ })+ ).toBeUndefined()+ })++ it('prefers the persisted tile owner route over the hint and the row', () => {+ const owner = resolveSessionRpcOwner({+ routingSessionId: 'stored-bot',+ sessionOwnerHint: () => omar,+ sessionRowOwner: () => 'default',+ tileOwnerRoute: () => homelab+ })++ expect(owner).toEqual(homelab)+ })++ it('prefers the exact unique owner hint over the session row profile', () => {+ // The row is presentation state: an optimistic row minted while the+ // ambient profile stayed `default` reads `default` even though the create+ // ran on local::omar. The hint recorded at create time is exact.+ const owner = resolveSessionRpcOwner({+ routingSessionId: 'stored-omar',+ sessionOwnerHint: id => (id === 'stored-omar' ? omar : undefined),+ sessionRowOwner: () => 'default',+ tileOwnerRoute: none+ })++ expect(owner).toEqual(omar)+ })++ it('falls back to the session row profile, then to undefined for the probe', () => {+ expect(+ resolveSessionRpcOwner({+ routingSessionId: 'stored-1',+ sessionOwnerHint: none,+ sessionRowOwner: () => 'coder',+ tileOwnerRoute: none+ })+ ).toBe('coder')++ expect(+ resolveSessionRpcOwner({+ routingSessionId: 'stored-1',+ sessionOwnerHint: none,+ sessionRowOwner: () => ' ',+ tileOwnerRoute: none+ })+ ).toBeUndefined()+ })+})diff --git a/apps/desktop/src/app/contrib/wiring-routing.ts b/apps/desktop/src/app/contrib/wiring-routing.tsindex cc679dc4752..5cb1baa9119 100644--- a/apps/desktop/src/app/contrib/wiring-routing.ts+++ b/apps/desktop/src/app/contrib/wiring-routing.ts@@ -48,3 +48,57 @@ export function resolveRoutingSessionId(args: {return focusedStoredSessionId ?? selectedStoredSessionId}++/** The owner shapes the ladder below can return: an exact route (connection ++ * profile), a bare profile name, or undefined (unknown — probe, never+ * "active"). Structural twin of store/session-request-router's+ * SessionOwnerScope, kept local so this module stays import-free. */+export interface SessionRpcOwnerRoute {+ connectionId: string+ mode?: 'local' | 'remote'+ profile: string+ targetProfile?: string+}++/**+ * The SYNC owner a session-scoped RPC routes to, resolved in this order:+ *+ * 1. the persisted tile owner route (a bot chat / split tile records the+ * exact connectionId + profile it was opened with, survives relaunch);+ * 2. the exact, UNIQUE session owner hint (recorded the moment a routed+ * session.create returns, or at plugin open time) — the only durable+ * exact owner a fresh main-pane chat or a hidden session has;+ * 3. the session row's owner — an EXACT route when the row is+ * connection-tagged (optimistic row from a routed create, or the+ * unified list splice), else its bare profile (the cross-profile+ * aggregator tags rows, but a bare profile loses the connection and+ * can lag the create);+ * 4. undefined → the caller runs the cross-profile probe.+ *+ * The hint outranks the row because the row is presentation state that can+ * be stamped from the AMBIENT profile (an optimistic row minted while+ * All-profiles / Bot routing left `default` active), and because it carries+ * no connection: a fresh chat created on `local::omar` whose row read+ * `default` ran its first turn on omar and then 4001'd "session not found"+ * on the second, when the row's `default` owner won the route.+ */+export function resolveSessionRpcOwner(args: {+ routingSessionId: null | string+ tileOwnerRoute: (storedSessionId: string) => SessionRpcOwnerRoute | undefined+ sessionOwnerHint: (storedSessionId: string) => SessionRpcOwnerRoute | undefined+ sessionRowOwner: (storedSessionId: string) => null | SessionRpcOwnerRoute | string | undefined+}): SessionRpcOwnerRoute | string | undefined {+ const { routingSessionId, sessionOwnerHint, sessionRowOwner, tileOwnerRoute } = args++ if (!routingSessionId) {+ return undefined+ }++ const fromRow = sessionRowOwner(routingSessionId)++ return (+ tileOwnerRoute(routingSessionId) ??+ sessionOwnerHint(routingSessionId) ??+ (typeof fromRow === 'string' ? fromRow.trim() || undefined : (fromRow ?? undefined))+ )+}diff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsxindex 6b2b43113dc..b466879bd3c 100644--- a/apps/desktop/src/app/contrib/wiring.tsx+++ b/apps/desktop/src/app/contrib/wiring.tsx@@ -72,6 +72,7 @@ import {$selectedStoredSessionId,$sessionResumeRequest,$sessions,+ getSessionOwnerHint,knownSessionOwner,sessionMatchesStoredId,sessionPinId,@@ -153,7 +154,7 @@ import { McpInstallDeepLinkDialog } from './mcp-install-deeplink-dialog'import { $restartPreviewServer, useTitlebarToolContributions } from './panes'import { ChatRoutesSurface, SidebarSurface, StatusbarSurface, TerminalSurface } from './surfaces'import type { WiringActions, WiringApi } from './types'-import { findStoredIdForRuntimeId, resolveRoutingSessionId } from './wiring-routing'+import { findStoredIdForRuntimeId, resolveRoutingSessionId, resolveSessionRpcOwner } from './wiring-routing'// Overlay views the controller mounts over the shell — lazy, load on demand.// The workspace-route full-page views (skills/messaging/artifacts) are the@@ -319,11 +320,17 @@ export function ContribWiring({ children }: { children: ReactNode }) {// Session-scoped RPCs route to the backend that OWNS the session — its// profile's own local gateway — never to whatever is "active" (active is// presentation only). Resolve the owner from, in order: the tile's persisted- // route (bot chats carry an exact connectionId+profile), the known session- // owner (row or open-time hint), then a cross-profile REST probe that- // stamps ownership for a hidden/unlisted session. Only a request with NO- // session at all (a fresh draft, global chrome) falls to the ambient socket.- // The probe result is cached as an owner hint so the next call is sync.+ // route (bot chats carry an exact connectionId+profile), the exact UNIQUE+ // session owner hint (stamped the moment a routed session.create returns,+ // or at plugin open time), the session row's profile, then a cross-profile+ // REST probe that stamps ownership for a hidden/unlisted session. The hint+ // outranks the row: a row is presentation state that can be stamped from+ // the AMBIENT profile and carries no connection, so a fresh chat created on+ // local::omar while `default` stayed active ran turn one on omar and then+ // 4001'd on turn two when the row's `default` won the route. Only a request+ // with NO session at all (a fresh draft, global chrome) falls to the ambient+ // socket. The probe result is cached as an owner hint so the next call is+ // sync — see resolveSessionRpcOwner for the ladder.const requestGateway = useCallback(async <T,>(method: string, params?: Record<string, unknown>, timeoutMs?: number, signal?: AbortSignal) => {// Route each RPC by the session IT targets, not by whatever tile is@@ -356,9 +363,12 @@ export function ContribWiring({ children }: { children: ReactNode }) {undefined})- let owner: SessionOwnerScope =- (routingSessionId ? sessionTileOwnerRoute(routingSessionId) : undefined) ??- knownSessionOwner($sessions.get(), routingSessionId)+ let owner: SessionOwnerScope = resolveSessionRpcOwner({+ routingSessionId,+ sessionOwnerHint: storedSessionId => getSessionOwnerHint(storedSessionId),+ sessionRowOwner: storedSessionId => knownSessionOwner($sessions.get(), storedSessionId),+ tileOwnerRoute: sessionTileOwnerRoute+ })if (!owner && routingSessionId) {// Unknown owner for a REAL session: probe across profiles (REST, not thediff --git a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsxindex 781dc8f2751..7e20f884b5f 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx@@ -1,3 +1,4 @@+import { registryBackendScopeKey } from '@hermes/shared'import { useStore } from '@nanostores/react'import { act, cleanup, render, waitFor } from '@testing-library/react'import type { MutableRefObject } from 'react'@@ -5,6 +6,7 @@ import { useEffect, useRef } from 'react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { NO_PROJECT_ID } from '@/app/chat/sidebar/projects/workspace-groups'+import { resolveSessionRpcOwner } from '@/app/contrib/wiring-routing'import { $terminalTakeover, setTerminalTakeover } from '@/app/right-sidebar/store'import { noteActiveTreeGroup, revealTreePane } from '@/components/pane-shell/tree/store'import {@@ -46,6 +48,9 @@ import {$selectedStoredSessionId,$sessions,$turnStartedAt,+ getSessionOwnerHint,+ knownSessionOwner,+ sessionMatchesStoredId,setActiveSessionId,setActiveSessionStoredIdRotation,setAwaitingResponse,@@ -65,8 +70,8 @@ import {setSessions,setTurnStartedAt} from '@/store/session'-import type { SessionProfileRoute } from '@/store/session-request-router'-import { $sessionTiles } from '@/store/session-states'+import { requestForSessionProfile, type SessionProfileRoute } from '@/store/session-request-router'+import { $sessionTiles, sessionTileOwnerRoute } from '@/store/session-states'import { $sessionSeenCounts, $unreadFinishedMarkers } from '@/store/session-unread'import sessionResumeActiveTurn from '../../../../../../tests/fixtures/session-resume-active-turn.json'@@ -3833,3 +3838,145 @@ describe('removeSession / archiveSession profile routing (#78836)', () => {expect($sessions.get()).toEqual([])})})++// A fresh chat created through $newChatRoute must keep the route as its EXACT+// owner after session.create. The create RPC already rode+// requestGatewayForAgent(capturedRoute); but the optimistic row was stamped+// from $activeGatewayProfile (still `default` in All-profiles / Bot routing)+// and no owner hint was recorded, so the first turn ran on omar while every+// later session-scoped RPC resolved the row as `default` → "session not+// found" on the default backend, and the orphaned omar runtime was eventually+// ws-orphan-reaped.+describe('routed fresh chat keeps its exact owner across turns', () => {+ const route: SessionProfileRoute = { connectionId: 'local', mode: 'local', profile: 'omar' }+ const STORED = 'stored-omar-fresh'++ afterEach(() => {+ cleanup()+ $newChatProfile.set(null)+ $newChatRoute.set(null)+ $activeGatewayProfile.set('default')+ $sessionTiles.set([])+ setSessions([])+ setCurrentCwd('')+ setNewChatWorkspaceTarget(undefined)+ vi.restoreAllMocks()+ })++ // The SAME sync ladder contrib/wiring's requestGateway runs for every+ // session-scoped RPC (prompt.submit, session.resume, attach, interrupt,+ // redirect, recovery): tile route → exact unique hint → row owner.+ const ownerFor = (storedSessionId: string) =>+ resolveSessionRpcOwner({+ routingSessionId: storedSessionId,+ sessionOwnerHint: id => getSessionOwnerHint(id),+ sessionRowOwner: (id: string) => knownSessionOwner($sessions.get(), id),+ tileOwnerRoute: sessionTileOwnerRoute+ })++ async function createRoutedFreshChat() {+ // Ambient dispatcher = the DEFAULT backend. It never heard of the session:+ // any session-scoped RPC landing here is exactly the bug.+ const ambientRequest = vi.fn(async (method: string, params?: Record<string, unknown>) => {+ if (typeof params?.session_id === 'string') {+ throw new Error(`Session not found: ${params.session_id} (ambient/default backend, ${method})`)+ }++ return {} as never+ })++ // The owning backend, local::omar. Anything else 4001s.+ vi.mocked(requestGatewayForAgent).mockImplementation(async (connectionId, profile, method) => {+ if (connectionId === 'local' && profile === 'omar') {+ if (method === 'session.create') {+ return { session_id: RUNTIME_SESSION_ID, stored_session_id: STORED } as never+ }++ return { ok: true } as never+ }++ throw new Error(`Session not found (${connectionId}::${profile}, ${method})`)+ })++ // Ambient profile = default; the draft is routed at local::omar.+ $activeGatewayProfile.set('default')+ $newChatProfile.set(route.profile)+ $newChatRoute.set({ ...route })++ let handle: HarnessHandle | null = null+ render(<Harness onReady={value => (handle = value)} requestGateway={ambientRequest} />)+ await waitFor(() => expect(handle).not.toBeNull())++ let runtimeId: null | string = null++ await act(async () => {+ runtimeId = await handle!.createBackendSessionForSend('hello omar')+ })++ expect(runtimeId).toBe(RUNTIME_SESSION_ID)++ return { ambientRequest, runtimeId: runtimeId as unknown as string }+ }++ it('unit: an explicitly routed fresh create never resolves its follow-up owner to the ambient default', async () => {+ await createRoutedFreshChat()++ const followupOwner = ownerFor(STORED)+ const foregroundScope = registryBackendScopeKey(route.connectionId, route.profile)++ const followupOwnerKey =+ followupOwner && typeof followupOwner === 'object'+ ? `${followupOwner.connectionId}::${followupOwner.profile}`+ : followupOwner++ // The exact failing shape: the foreground socket is omar's, the follow-up+ // routes to default.+ expect({ followupOwner: followupOwnerKey, foregroundScope }).not.toEqual({+ followupOwner: 'default',+ foregroundScope: 'conn:local::omar'+ })+ expect({ followupOwner: followupOwnerKey, foregroundScope }).toEqual({+ followupOwner: 'local::omar',+ foregroundScope: 'conn:local::omar'+ })++ // Both owner records carry the route, and the ambient profile never moved.+ expect(getSessionOwnerHint(STORED)).toEqual(route)+ expect($sessions.get().find(session => sessionMatchesStoredId(session, STORED))).toMatchObject({+ connection_id: 'local',+ is_default_profile: false,+ profile: 'omar'+ })+ expect($activeGatewayProfile.get()).toBe('default')+ })++ it('integration: both turns hit local::omar with default ambient — no session-not-found, no orphaned runtime', async () => {+ const { ambientRequest, runtimeId } = await createRoutedFreshChat()++ const submitTurn = (text: string) =>+ requestForSessionProfile(ownerFor(STORED), ambientRequest, 'prompt.submit', { session_id: runtimeId, text })++ // First turn on omar.+ await expect(submitTurn('first turn')).resolves.toEqual({ ok: true })++ // Keep default as the ambient profile (All-profiles / Bot routing never+ // moved it) and submit the second turn.+ $activeGatewayProfile.set('default')+ await expect(submitTurn('second turn')).resolves.toEqual({ ok: true })++ const submits = vi.mocked(requestGatewayForAgent).mock.calls.filter(call => call[2] === 'prompt.submit')++ expect(submits.map(call => [call[0], call[1], (call[3] as { text: string }).text])).toEqual([+ ['local', 'omar', 'first turn'],+ ['local', 'omar', 'second turn']+ ])+ // No session-not-found: the default backend never saw a session-scoped RPC.+ expect(ambientRequest).not.toHaveBeenCalledWith('prompt.submit', expect.anything())+ expect(ambientRequest.mock.calls.filter(call => typeof call[1]?.session_id === 'string')).toEqual([])+ // No ws_orphan_reap: the client never closed or abandoned the runtime it+ // minted on omar — no session.close on any route, the binding stands.+ expect(vi.mocked(requestGatewayForAgent).mock.calls.filter(call => call[2] === 'session.close')).toEqual([])+ expect(ambientRequest).not.toHaveBeenCalledWith('session.close', expect.anything())+ expect(getSessionOwnerHint(STORED)).toEqual(route)+ })+})diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts b/apps/desktop/src/app/session/hooks/use-session-actions/index.tsindex 84a7e463dd5..27092046e96 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts+++ b/apps/desktop/src/app/session/hooks/use-session-actions/index.ts@@ -79,6 +79,7 @@ import {setResumeExhaustedSessionId,setResumeFailedSessionId,setSelectedStoredSessionId,+ setSessionOwnerHint,setSessionStartedAt,setTurnStartedAt,setWorkspaceCwdOwner,@@ -487,6 +488,19 @@ export function useSessionActions({const stored = created.stored_session_id ?? null+ // Record the EXACT owner the moment a routed create returns a stored+ // id — before the drift check, the optimistic row, navigation, or any+ // session-scoped RPC can resolve this session's owner. The route is+ // the only authority: in All-profiles / Bot routing the ambient+ // $activeGatewayProfile stays on `default` while the session lives on+ // `capturedRoute` (e.g. local::omar). Without this hint the optimistic+ // row (stamped from ambient) was the only owner record, so the first+ // turn ran on omar and every later session-scoped RPC resolved the row+ // as `default` and 4001'd "session not found".+ if (stored && capturedRoute) {+ setSessionOwnerHint(stored, capturedRoute)+ }+// Only a genuine move to a DIFFERENT chat mid-create should orphan the// session we just minted. The active runtime ref is deliberately not a// prong: background gateway events retarget it while other sessions@@ -505,7 +519,17 @@ export function useSessionActions({if (drift) {console.warn('[submit-drift-abort]', drift, { phase: 'mid-create' })- await requestGateway('session.close', { session_id: created.session_id }).catch(() => undefined)++ // Close on the backend that minted the session: the ambient socket+ // is a different machine/profile for a routed create and would+ // 4001 while the orphan lives on (and later ws-orphan-reaps) there.+ const closeCreated = capturedRoute+ ? requestGatewayForAgent(capturedRoute.connectionId, capturedRoute.profile, 'session.close', {+ session_id: created.session_id+ })+ : requestGateway('session.close', { session_id: created.session_id })++ await closeCreated.catch(() => undefined)return null}@@ -521,7 +545,9 @@ export function useSessionActions({// reads meaningfully while the turn is in flight, instead of flashing// "Untitled session" until the turn persists and auto-title runs. The// server later returns its own preview/title and supersedes this.- upsertOptimisticSession(created, stored, null, preview?.trim() || null)+ // The row carries the create route's exact owner (backend profile ++ // connection), never the ambient profile — see upsertOptimisticSession.+ upsertOptimisticSession(created, stored, null, preview?.trim() || null, null, undefined, capturedRoute)navigate(sessionRoute(stored), { replace: true })// Other windows (e.g. the main window when this is the pop-out) can't// see this session until they re-pull the shared list.@@ -648,12 +674,18 @@ export function useSessionActions({createdThisRun.add(stored)+ // Same ownership transition as createBackendSessionForSend: the route+ // that minted the session is its exact owner from this moment on.+ if (capturedRoute) {+ setSessionOwnerHint(stored, capturedRoute)+ }+// Seed the per-runtime cache so the tile renders immediately without a// redundant resume. Only add the row to the SIDEBAR when `listed` — an// unlisted (draft) tab stays out of the session list until its first// turn persists and a refresh surfaces it.if (listed) {- upsertOptimisticSession(created, stored, null, null)+ upsertOptimisticSession(created, stored, null, null, null, undefined, capturedRoute)}// A tile lives in its OWN worktree, so it must not run the fulldiff --git a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts b/apps/desktop/src/app/session/hooks/use-session-actions/utils.tsindex ab342ddb812..6f35f387139 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts+++ b/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts@@ -1248,15 +1248,21 @@ export function upsertOptimisticSession(preview: string | null = null,parentSessionId: string | null = null,lastActive?: number,- ownerRoute?: SessionProfileRoute+ owner?: null | SessionProfileRoute) {const now = lastActive ?? Date.now() / 1000- // Stamp the profile/source the session was just created on so the scoped- // sidebar shows the new row immediately instead of filtering it out as- // "default" until the aggregator re-fetches. The active gateway is only a- // presentation detail: a concurrent source switch can move it before this- // optimistic row is inserted.- const profileKey = normalizeProfileKey(ownerRoute?.profile ?? $activeGatewayProfile.get())+ // Stamp the profile the session was just created on so the scoped sidebar+ // shows the new row immediately instead of filtering it out as "default"+ // until the aggregator re-fetches. An explicitly routed create ($newChatRoute+ // / a tile's route) names its EXACT owner: the backend profile that route+ // serves, on that route's connection. The live gateway's profile is only the+ // owner for an unrouted create — in All-profiles / Bot routing the ambient+ // profile stays on `default` while the session lives on another backend (and+ // a concurrent source switch can move the active gateway before this row is+ // inserted), so a row stamped `default` then misroutes every session-scoped+ // RPC that resolves its owner off the row ("session not found" on turn two).+ const profileKey = normalizeProfileKey(owner ? owner.targetProfile || owner.profile : $activeGatewayProfile.get())+ const connectionId = owner?.connectionId.trim() || ''const session: SessionInfo = {// Seed cwd so the grouped sidebar can place the new row in its repo/worktree@@ -1279,11 +1285,11 @@ export function upsertOptimisticSession(started_at: now,title,tool_call_count: 0,- ...(ownerRoute?.connectionId.trim() ? { connection_id: ownerRoute.connectionId.trim() } : {})+ ...(connectionId ? { connection_id: connectionId } : {})}- if (ownerRoute) {- setSessionOwnerHint(id, ownerRoute)+ if (owner) {+ setSessionOwnerHint(id, owner)}setSessions(prev => [session, ...prev.filter(s => s.id !== id)])diff --git a/apps/desktop/src/store/session-states.ts b/apps/desktop/src/store/session-states.tsindex 792f3d502e1..a936d0c301d 100644--- a/apps/desktop/src/store/session-states.ts+++ b/apps/desktop/src/store/session-states.ts@@ -43,6 +43,7 @@ import {$selectedStoredSessionId,$sessions,clearReadBaseline,+ getSessionOwnerHint,knownSessionOwner,lineageAliases,markSessionRead,@@ -844,8 +845,12 @@ export function openTileGatewayScopes(): Set<string> {/*** Sync owner resolution for a session id that may be a RUNTIME or a STORED id.* Tile route first (exact connectionId+profile, survives relaunch), then the- * known session owner (row or open-time hint). Returns undefined when no- * owner is known — the caller falls back to ambient, never to "active".+ * exact unique owner hint (stamped when a routed create returns / at open+ * time), then the known session owner (a connection-tagged row's exact route,+ * else its profile / the hint). The hint outranks the row for the same reason+ * as contrib/wiring's ladder: a row can be stamped from the ambient profile+ * and carries no connection. Returns undefined when no owner is known — the+ * caller falls back to ambient, never to "active".*/export function knownOwnerForSession(sessionId: null | string | undefined): SessionOwnerScope {if (!sessionId) {@@ -854,7 +859,11 @@ export function knownOwnerForSession(sessionId: null | string | undefined): Sessconst storedSessionId = storedSessionIdForRuntimeId(sessionId) ?? sessionId- return sessionTileOwnerRoute(storedSessionId) ?? knownSessionOwner($sessions.get(), storedSessionId)+ return (+ sessionTileOwnerRoute(storedSessionId) ??+ getSessionOwnerHint(storedSessionId) ??+ knownSessionOwner($sessions.get(), storedSessionId)+ )}/**