fix(desktop): a tab promoted into MAIN keeps its owner for session.control.read
KoNit-K's two commits stamp an owner on tab-strip `+` drafts at create time, which clears the banner ON the draft tile. Promoting that draft into main (⌘W on the workspace tab, or a tab dragged out of main) still raised "Session controls unavailable": closeSessionTile drops the tile AND evicts its $sessionStates mirror in one tick, resumeSession then makes the runtime active before the view republishes, and the composer's control read lands in that gap — storedSessionIdForRuntimeId had no tile, no mirror, and so never reached the stored-id hint that was there all along. Give the translation one more rung: the active runtime maps to the selected stored id. Only main's own binding qualifies; unrelated runtime ids stay unknown and keep failing closed. Live (Electron + mock gateway, bot chat in main, `+` draft, close main's tab so the draft promotes): main → banner; KoNit-K alone → banner on promote; with this rung → no banner at any step, send works. Invariant test red on main, green here.
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
workspaceScopeKey
|
||||
} from '@/components/pane-shell/workspace-scope'
|
||||
import { $activeGatewayProfile } from '@/store/profile'
|
||||
import { $activeSessionId, $connection, $selectedStoredSessionId, setSessions } from '@/store/session'
|
||||
import { $activeSessionId, $connection, $selectedStoredSessionId, setSessionOwnerHint, setSessions } from '@/store/session'
|
||||
import type { SessionProfileRoute } from '@/store/session-request-router'
|
||||
import type { SessionTile } from '@/store/session-states'
|
||||
import type * as SessionStatesModule from '@/store/session-states'
|
||||
@@ -1269,6 +1269,26 @@ describe('knownOwnerForSession / requestForOwnedSession (#91684 client half)', (
|
||||
expect(knownOwnerForSession('stored-2')).toBe('loki')
|
||||
})
|
||||
|
||||
// A tile promoted into MAIN (⌘W on the workspace tab, its tab dragged out of
|
||||
// main) loses its tile and its evicted mirror entry in the same tick, while
|
||||
// the resume has already made its runtime the active one. The composer's
|
||||
// control read for that runtime must still find the stored-id owner hint
|
||||
// instead of failing closed with "Session controls unavailable" (#108369).
|
||||
it('translates the active runtime through the selected stored id when no tile or mirror binds it', () => {
|
||||
setSessionOwnerHint('stored-main', { connectionId: 'local', profile: 'alpha' })
|
||||
$sessionTiles.set([])
|
||||
$sessionStates.set({})
|
||||
$selectedStoredSessionId.set('stored-main')
|
||||
$activeSessionId.set('rt-main')
|
||||
|
||||
expect(knownOwnerForSession('rt-main')).toEqual({ connectionId: 'local', profile: 'alpha' })
|
||||
// Only MAIN's own runtime gets this rung: an unrelated runtime id stays unknown.
|
||||
expect(knownOwnerForSession('rt-other')).toBeUndefined()
|
||||
|
||||
$activeSessionId.set(null)
|
||||
$selectedStoredSessionId.set(null)
|
||||
})
|
||||
|
||||
it('keeps a session row connection owner when profiles share the same name', () => {
|
||||
setSessions([{ connection_id: 'source-b', id: 'stored-shared', profile: 'default' } as never])
|
||||
|
||||
|
||||
@@ -1146,7 +1146,18 @@ export function storedSessionIdForRuntimeId(sessionId: string): null | string {
|
||||
// Without this rung such ids fell straight to the ambient socket.
|
||||
const mirrored = $sessionStates.get()[sessionId]?.storedSessionId?.trim()
|
||||
|
||||
return mirrored || null
|
||||
if (mirrored) {
|
||||
return mirrored
|
||||
}
|
||||
|
||||
// Main's own binding. A tile promoted into main (⌘W on the workspace tab,
|
||||
// a tab dragged out of main) loses its tile AND its evicted mirror entry in
|
||||
// the same tick, while the resume sets the runtime active before the view
|
||||
// republishes the mirror. The composer's control read lands in that gap
|
||||
// and, with nothing to translate, never reaches the stored-id hint.
|
||||
const selected = $selectedStoredSessionId.get()
|
||||
|
||||
return sessionId === $activeSessionId.get() && selected ? selected : null
|
||||
}
|
||||
|
||||
const BOT_CHAT_SCOPE_KEY = 'hermes.desktop.botChatSessions.v1'
|
||||
|
||||
Reference in New Issue
Block a user