diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts index afba8100a1..0351a5396b 100644 --- a/apps/desktop/electron/main.ts +++ b/apps/desktop/electron/main.ts @@ -13820,8 +13820,7 @@ ipcMain.handle('hermes:api', async (_event, request) => { isDefaultProfile: profile => profile === 'default', isValidProfileName: profile => PROFILE_NAME_RE.test(profile), prepareLocal: localRequest => prepareProfileDeleteRequest(localRequest).then(() => undefined), - teardownConnection: (connectionId, profile) => - teardownConnectionScopedProfileBackend(connectionId, profile) + teardownConnection: (connectionId, profile) => teardownConnectionScopedProfileBackend(connectionId, profile) }) } diff --git a/apps/desktop/electron/profile-delete-routing.test.ts b/apps/desktop/electron/profile-delete-routing.test.ts index 236d4b3fa1..a63e864bc9 100644 --- a/apps/desktop/electron/profile-delete-routing.test.ts +++ b/apps/desktop/electron/profile-delete-routing.test.ts @@ -186,12 +186,7 @@ test('explicit registered local DELETE holds one gate through teardown and dispa ) assert.equal(result, 'deleted') - assert.deepEqual(events, [ - 'gate:worker', - 'prepare:local:worker', - 'dispatch:primary', - 'release:worker' - ]) + assert.deepEqual(events, ['gate:worker', 'prepare:local:worker', 'dispatch:primary', 'release:worker']) }) test('explicit registered SSH DELETE tears down its source backend before dispatch', async () => { @@ -220,12 +215,7 @@ test('explicit registered SSH DELETE tears down its source backend before dispat ) assert.equal(result, 'deleted') - assert.deepEqual(events, [ - 'gate:worker', - 'teardown:build-host:worker', - 'dispatch:primary', - 'release:worker' - ]) + assert.deepEqual(events, ['gate:worker', 'teardown:build-host:worker', 'dispatch:primary', 'release:worker']) }) test('non-identity connection DELETE tears down the logical pool and deletes the backend target', async () => { diff --git a/apps/desktop/src/api/profiles.ts b/apps/desktop/src/api/profiles.ts index 514e367da5..b021639ab9 100644 --- a/apps/desktop/src/api/profiles.ts +++ b/apps/desktop/src/api/profiles.ts @@ -45,9 +45,7 @@ export function deleteProfile(name: string, scope?: ProfileScope): Promise<{ ok: return hermesApi<{ ok: boolean; path: string }>({ ...capabilityScoped(scope), - ...(scope && typeof scope === 'object' && scope.connectionId?.trim() === 'local' - ? { connectionId: 'local' } - : {}), + ...(scope && typeof scope === 'object' && scope.connectionId?.trim() === 'local' ? { connectionId: 'local' } : {}), path: `/api/profiles/${encodeURIComponent(normalized)}`, method: 'DELETE' }) diff --git a/apps/desktop/src/app/chat/transcript-backfill.ts b/apps/desktop/src/app/chat/transcript-backfill.ts index 43b4135466..c7151ec59f 100644 --- a/apps/desktop/src/app/chat/transcript-backfill.ts +++ b/apps/desktop/src/app/chat/transcript-backfill.ts @@ -17,11 +17,7 @@ import { getOlderSessionMessages } from '@/hermes' import { type ChatMessage, toChatMessages } from '@/lib/chat-messages' -import { - recordTranscriptBackfillPage, - type TranscriptProfileScope, - transcriptTailState -} from '@/store/transcript-tail' +import { recordTranscriptBackfillPage, type TranscriptProfileScope, transcriptTailState } from '@/store/transcript-tail' /** Older rows likely exist beyond what the in-memory store holds. */ export function transcriptBackfillAvailable( diff --git a/apps/desktop/src/app/session/hooks/use-route-resume.test.tsx b/apps/desktop/src/app/session/hooks/use-route-resume.test.tsx index c33eeb2cbb..b7bdead6bb 100644 --- a/apps/desktop/src/app/session/hooks/use-route-resume.test.tsx +++ b/apps/desktop/src/app/session/hooks/use-route-resume.test.tsx @@ -378,23 +378,13 @@ describe('useRouteResume', () => { } const { rerender } = render( - + ) expect(resumeSession).toHaveBeenCalledWith('session-1', true, ownerRoute) resumeSession.mockClear() - rerender( - - ) + rerender() expect(resumeSession).toHaveBeenCalledTimes(1) expect(resumeSession).toHaveBeenCalledWith('session-2', true) diff --git a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx index d21790c4b0..c0b0ec6359 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 @@ -17,12 +17,7 @@ import { import { createClientSessionState } from '@/lib/chat-runtime' import { clearSessionDraft, stashSessionDraft, takeSessionDraft } from '@/store/composer' import { requestGatewayForAgent } from '@/store/gateway' -import { - $activeGatewayProfile, - $newChatProfile, - $newChatRoute, - ensureGatewayProfile -} from '@/store/profile' +import { $activeGatewayProfile, $newChatProfile, $newChatRoute, ensureGatewayProfile } from '@/store/profile' import { $projectScope, $projectTree, ALL_PROJECTS } from '@/store/projects' import { $activeSessionId, @@ -183,7 +178,9 @@ describe('connection-qualified session deletion', () => { render( { actions = value }} + onReady={value => { + actions = value + }} requestGateway={requestGateway} selectedStoredSessionId="shared-session" /> @@ -198,12 +195,9 @@ describe('connection-qualified session deletion', () => { connectionId: 'source-a', profile: 'worker' }) - expect(requestGatewayForAgent).toHaveBeenCalledWith( - 'source-a', - 'worker', - 'session.close', - { session_id: 'runtime-shared' } - ) + expect(requestGatewayForAgent).toHaveBeenCalledWith('source-a', 'worker', 'session.close', { + session_id: 'runtime-shared' + }) expect(requestGateway).not.toHaveBeenCalledWith('session.close', expect.anything()) }) }) @@ -713,11 +707,7 @@ function ResumeHarness({ }: { onStateUpdate?: (sessionId: string, state: ClientSessionState) => void onReady: ( - resume: ( - storedSessionId: string, - replaceRoute?: boolean, - ownerRoute?: SessionProfileRoute - ) => Promise + resume: (storedSessionId: string, replaceRoute?: boolean, ownerRoute?: SessionProfileRoute) => Promise ) => void requestGateway: (method: string, params?: Record) => Promise runtimeIdByStoredSessionIdRef?: MutableRefObject> @@ -1801,7 +1791,9 @@ describe('resumeSession warm-cache mapping integrity', () => { setMessages([]) setSessions([]) vi.mocked(getSession).mockReset() - vi.mocked(getLatestSessionMessages).mockReset().mockResolvedValue({ messages: [] } as never) + vi.mocked(getLatestSessionMessages) + .mockReset() + .mockResolvedValue({ messages: [] } as never) vi.mocked(requestGatewayForAgent).mockReset() vi.restoreAllMocks() }) @@ -1850,11 +1842,9 @@ describe('resumeSession warm-cache mapping integrity', () => { const ambientRequest = vi.fn(async () => ({}) as never) - let resume: null | (( - storedSessionId: string, - replaceRoute?: boolean, - ownerRoute?: SessionProfileRoute - ) => Promise) = null + let resume: + null | ((storedSessionId: string, replaceRoute?: boolean, ownerRoute?: SessionProfileRoute) => Promise) = + null render( { 'session.activate', expect.objectContaining({ session_id: 'runtime-warm' }) ) - expect(requestGatewayForAgent).toHaveBeenCalledWith( - 'source-a', - 'default', - 'session.usage', - { session_id: 'runtime-warm' } - ) + expect(requestGatewayForAgent).toHaveBeenCalledWith('source-a', 'default', 'session.usage', { + session_id: 'runtime-warm' + }) expect(requestGatewayForAgent).toHaveBeenCalledWith( 'source-a', 'default', 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.ts index 7d2f11221e..75733e38ff 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 @@ -72,7 +72,11 @@ import { setWorkspaceCwdOwner, setYoloActive } from '@/store/session' -import { requestForSessionProfile, type SessionOwnerScope, type SessionProfileRoute } from '@/store/session-request-router' +import { + requestForSessionProfile, + type SessionOwnerScope, + type SessionProfileRoute +} from '@/store/session-request-router' import { $sessionTiles, closeSessionTile, @@ -774,7 +778,8 @@ export function useSessionActions({ // A row spliced from a CONNECTED registry gateway (#88880) carries its // owning connection — activate THAT gateway, not a same-named local // profile. Rows without the tag keep the legacy profile path. - const sessionOwner: SessionOwnerScope = ownerRoute || + const sessionOwner: SessionOwnerScope = + ownerRoute || (storedForProfile?.connection_id ? { connectionId: storedForProfile.connection_id, @@ -1821,12 +1826,9 @@ export function useSessionActions({ try { if (closingRuntimeId) { - await requestForSessionProfile( - removedOwner, - requestGateway, - 'session.close', - { session_id: closingRuntimeId } - ).catch(() => undefined) + await requestForSessionProfile(removedOwner, requestGateway, 'session.close', { + session_id: closingRuntimeId + }).catch(() => undefined) } await deleteSession(storedSessionId, removedOwner) diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts b/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts index f2e80ba758..07e5a2dbab 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 @@ -1318,7 +1318,8 @@ export async function resolveStoredSession( profile: ownerRoute.targetProfile || ownerRoute.profile } - const cachedOwnerMatches = cached && + const cachedOwnerMatches = + cached && cached.connection_id === ownerRoute.connectionId && (!cached.profile || normalizeProfileKey(cached.profile) === normalizeProfileKey(ownerRoute.profile)) diff --git a/apps/desktop/src/contrib/runtime-loader.ts b/apps/desktop/src/contrib/runtime-loader.ts index e1587cc7c5..3c94f37dfa 100644 --- a/apps/desktop/src/contrib/runtime-loader.ts +++ b/apps/desktop/src/contrib/runtime-loader.ts @@ -316,7 +316,7 @@ async function readPluginSourceText(file: string): Promise { if (result.truncated) { throw new PluginSourceOversizeError( - 'plugin.js exceeds this shell\'s 512 KiB read limit — update Hermes Desktop to load larger plugins' + "plugin.js exceeds this shell's 512 KiB read limit — update Hermes Desktop to load larger plugins" ) } diff --git a/apps/desktop/src/hermes.test.ts b/apps/desktop/src/hermes.test.ts index 0d4f0a2d36..5936f1d9b9 100644 --- a/apps/desktop/src/hermes.test.ts +++ b/apps/desktop/src/hermes.test.ts @@ -444,9 +444,9 @@ describe('Hermes REST helpers', () => { api.mockResolvedValue({ ok: true, path: '/profiles/worker' }) await deleteProfile('backend-worker', { connectionId: 'source-a', profile: 'backend-worker' }) - await expect( - deleteProfile('worker', { connectionId: 'source-a', profile: 'default' }) - ).rejects.toThrow(/default profile cannot be deleted/i) + await expect(deleteProfile('worker', { connectionId: 'source-a', profile: 'default' })).rejects.toThrow( + /default profile cannot be deleted/i + ) expect(api).toHaveBeenCalledOnce() expect(api).toHaveBeenCalledWith({ diff --git a/apps/desktop/src/sdk/host-state.test.ts b/apps/desktop/src/sdk/host-state.test.ts index 487b8edc1d..2c2c2650c6 100644 --- a/apps/desktop/src/sdk/host-state.test.ts +++ b/apps/desktop/src/sdk/host-state.test.ts @@ -217,11 +217,13 @@ describe('host.state.focusedSessionProfile', () => { profile: 'worker', targetProfile: 'backend-worker-b' }) - session.$sessions.set([{ - connection_id: 'source-a', - id: 'ambiguous-hint', - profile: 'worker' - } as never]) + session.$sessions.set([ + { + connection_id: 'source-a', + id: 'ambiguous-hint', + profile: 'worker' + } as never + ]) session.$selectedStoredSessionId.set('ambiguous-hint') expect(host.state.focusedSessionOwner.get()).toBeNull() diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts index 1c9cf344aa..c7e4328bd4 100644 --- a/apps/desktop/src/sdk/index.ts +++ b/apps/desktop/src/sdk/index.ts @@ -132,9 +132,7 @@ export interface PluginFocusedSessionOwner { const $focusedSessionOwner = computed( [$focusedStoredSessionId, $sessions, $activeGatewayProfile, $connection], (focused, sessions, activeProfile, connection): PluginFocusedSessionOwner | null => { - const activeConnectionId = String( - connection?.connectionId || (connection?.mode === 'local' ? 'local' : '') - ).trim() + const activeConnectionId = String(connection?.connectionId || (connection?.mode === 'local' ? 'local' : '')).trim() const fallback = { connectionId: activeConnectionId, @@ -175,8 +173,8 @@ const $focusedSessionOwner = computed( const $focusedSessionProfile = computed( [$focusedSessionOwner, $focusedStoredSessionId, $sessions, $activeGatewayProfile], - (owner, focused, sessions, activeProfile) => owner?.profile || - rememberedSessionProfile(sessions, focused, activeProfile) + (owner, focused, sessions, activeProfile) => + owner?.profile || rememberedSessionProfile(sessions, focused, activeProfile) ) export interface PluginProfileRoute { @@ -577,10 +575,7 @@ export const host = { retireLocalProfileGateways(targetProfile) } - await deleteProfile( - targetProfile, - route ? { connectionId: route.connectionId, profile: route.profile } : undefined - ) + await deleteProfile(targetProfile, route ? { connectionId: route.connectionId, profile: route.profile } : undefined) // The profile rail paints from the shared $profiles cache; without a // refresh the deleted profile's badge survives and clicking it starts a diff --git a/apps/desktop/src/store/session-request-router.test.ts b/apps/desktop/src/store/session-request-router.test.ts index 05b4dae4f0..cd020dea61 100644 --- a/apps/desktop/src/store/session-request-router.test.ts +++ b/apps/desktop/src/store/session-request-router.test.ts @@ -150,9 +150,11 @@ describe('requestForSessionProfile', () => { installDesktop() await ensureGatewayForProfile('other') - const desktop = (window as unknown as { - hermesDesktop: { getConnectionFor: ReturnType } - }).hermesDesktop + const desktop = ( + window as unknown as { + hermesDesktop: { getConnectionFor: ReturnType } + } + ).hermesDesktop const ambient = vi.fn(async () => ({ ambient: true })) diff --git a/apps/desktop/src/store/session-request-router.ts b/apps/desktop/src/store/session-request-router.ts index be59112cfc..f147df5b7a 100644 --- a/apps/desktop/src/store/session-request-router.ts +++ b/apps/desktop/src/store/session-request-router.ts @@ -95,14 +95,7 @@ export function requestForSessionProfile( return timeoutMs === undefined && signal === undefined ? requestGatewayForAgent(connectionId, normKey(ownerProfile.profile), method, routedParams) - : requestGatewayForAgent( - connectionId, - normKey(ownerProfile.profile), - method, - routedParams, - timeoutMs, - signal - ) + : requestGatewayForAgent(connectionId, normKey(ownerProfile.profile), method, routedParams, timeoutMs, signal) } if (!sessionRpcNeedsProfileRoute(ownerProfile)) { diff --git a/apps/desktop/src/store/session.ts b/apps/desktop/src/store/session.ts index 330d9c57cc..9539761593 100644 --- a/apps/desktop/src/store/session.ts +++ b/apps/desktop/src/store/session.ts @@ -645,9 +645,7 @@ export function setSessionOwnerHint(sessionId: string, route: SessionProfileRout export function getSessionOwnerHints(sessionId: string): SessionProfileRoute[] { const id = sessionId.trim() - return [...sessionOwnerHints.values()] - .filter(entry => entry.id === id) - .map(entry => ({ ...entry.route })) + return [...sessionOwnerHints.values()].filter(entry => entry.id === id).map(entry => ({ ...entry.route })) } export function getSessionOwnerHint( diff --git a/apps/desktop/src/store/transcript-tail.ts b/apps/desktop/src/store/transcript-tail.ts index 1016fa2a72..8f18ed67c4 100644 --- a/apps/desktop/src/store/transcript-tail.ts +++ b/apps/desktop/src/store/transcript-tail.ts @@ -28,10 +28,13 @@ export interface TranscriptTailState { profile?: TranscriptProfileScope } -export type TranscriptProfileScope = null | string | { - connectionId?: null | string - profile?: null | string -} +export type TranscriptProfileScope = + | null + | string + | { + connectionId?: null | string + profile?: null | string + } export const $transcriptTailBySessionId = atom>({}) const TRANSCRIPT_TAIL_LIMIT = 256 @@ -60,9 +63,7 @@ function transcriptTailKey(storedSessionId: string, profile?: TranscriptProfileS return scope ? JSON.stringify([scope.connectionId, scope.profile, storedSessionId]) : storedSessionId } -function matchingTailEntries( - storedSessionId: string -): Array<[string, TranscriptTailState]> { +function matchingTailEntries(storedSessionId: string): Array<[string, TranscriptTailState]> { return Object.entries($transcriptTailBySessionId.get()).filter(([key]) => { if (key === storedSessionId) { return true @@ -131,9 +132,10 @@ export function recordTranscriptBackfillPage( ): void { const current = $transcriptTailBySessionId.get() - const selected: Array<[string, TranscriptTailState | undefined]> = profile === undefined - ? matchingTailEntries(storedSessionId) - : [[transcriptTailKey(storedSessionId, profile), current[transcriptTailKey(storedSessionId, profile)]]] + const selected: Array<[string, TranscriptTailState | undefined]> = + profile === undefined + ? matchingTailEntries(storedSessionId) + : [[transcriptTailKey(storedSessionId, profile), current[transcriptTailKey(storedSessionId, profile)]]] if (selected.length !== 1) { return @@ -168,9 +170,10 @@ export function transcriptTailState( export function clearTranscriptTail(storedSessionId: string, profile?: TranscriptProfileScope): void { const current = $transcriptTailBySessionId.get() - const keys = profile === undefined - ? matchingTailEntries(storedSessionId).map(([key]) => key) - : [transcriptTailKey(storedSessionId, profile)] + const keys = + profile === undefined + ? matchingTailEntries(storedSessionId).map(([key]) => key) + : [transcriptTailKey(storedSessionId, profile)] if (keys.length === 0) { return diff --git a/apps/desktop/src/store/updates.ts b/apps/desktop/src/store/updates.ts index 0cf8059651..9dd9e60c95 100644 --- a/apps/desktop/src/store/updates.ts +++ b/apps/desktop/src/store/updates.ts @@ -592,10 +592,7 @@ function completedAfterRestart( * run started at-or-after we kicked the update off counts — an older * receipt describes a previous update, and a still-running one proves * nothing yet. The 60s slack absorbs client/backend clock skew. */ -function receiptProvesOutcome( - status: Awaited>, - applyStartedAtMs: number -): boolean { +function receiptProvesOutcome(status: Awaited>, applyStartedAtMs: number): boolean { const receipt = status.receipt if (!receipt || !receipt.finished_at || !receipt.started_at) {