fmt(js): npm run fix on merge (#92815)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
hermes-seaeye[bot]
2026-08-23 08:45:37 +00:00
committed by GitHub
parent ecf63ad3f3
commit f377140e3d
17 changed files with 75 additions and 122 deletions
+1 -2
View File
@@ -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)
})
}
@@ -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 () => {
+1 -3
View File
@@ -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'
})
@@ -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(
@@ -378,23 +378,13 @@ describe('useRouteResume', () => {
}
const { rerender } = render(
<RouteResumeHarness
{...props}
locationPathname="/session-1"
routedSessionId="session-1"
/>
<RouteResumeHarness {...props} locationPathname="/session-1" routedSessionId="session-1" />
)
expect(resumeSession).toHaveBeenCalledWith('session-1', true, ownerRoute)
resumeSession.mockClear()
rerender(
<RouteResumeHarness
{...props}
locationPathname="/session-2"
routedSessionId="session-2"
/>
)
rerender(<RouteResumeHarness {...props} locationPathname="/session-2" routedSessionId="session-2" />)
expect(resumeSession).toHaveBeenCalledTimes(1)
expect(resumeSession).toHaveBeenCalledWith('session-2', true)
@@ -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(
<Harness
activeSessionId="runtime-shared"
onReady={value => { 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<unknown>
resume: (storedSessionId: string, replaceRoute?: boolean, ownerRoute?: SessionProfileRoute) => Promise<unknown>
) => void
requestGateway: <T>(method: string, params?: Record<string, unknown>) => Promise<T>
runtimeIdByStoredSessionIdRef?: MutableRefObject<Map<string, string>>
@@ -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<unknown>) = null
let resume:
null | ((storedSessionId: string, replaceRoute?: boolean, ownerRoute?: SessionProfileRoute) => Promise<unknown>) =
null
render(
<ResumeHarness
@@ -1894,12 +1884,9 @@ describe('resumeSession warm-cache mapping integrity', () => {
'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',
@@ -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)
@@ -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))
+1 -1
View File
@@ -316,7 +316,7 @@ async function readPluginSourceText(file: string): Promise<string> {
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"
)
}
+3 -3
View File
@@ -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({
+7 -5
View File
@@ -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()
+4 -9
View File
@@ -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
@@ -150,9 +150,11 @@ describe('requestForSessionProfile', () => {
installDesktop()
await ensureGatewayForProfile('other')
const desktop = (window as unknown as {
hermesDesktop: { getConnectionFor: ReturnType<typeof vi.fn> }
}).hermesDesktop
const desktop = (
window as unknown as {
hermesDesktop: { getConnectionFor: ReturnType<typeof vi.fn> }
}
).hermesDesktop
const ambient = vi.fn(async () => ({ ambient: true }))
@@ -95,14 +95,7 @@ export function requestForSessionProfile<T>(
return timeoutMs === undefined && signal === undefined
? requestGatewayForAgent<T>(connectionId, normKey(ownerProfile.profile), method, routedParams)
: requestGatewayForAgent<T>(
connectionId,
normKey(ownerProfile.profile),
method,
routedParams,
timeoutMs,
signal
)
: requestGatewayForAgent<T>(connectionId, normKey(ownerProfile.profile), method, routedParams, timeoutMs, signal)
}
if (!sessionRpcNeedsProfileRoute(ownerProfile)) {
+1 -3
View File
@@ -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(
+16 -13
View File
@@ -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<Record<string, TranscriptTailState>>({})
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
+1 -4
View File
@@ -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<ReturnType<typeof getActionStatus>>,
applyStartedAtMs: number
): boolean {
function receiptProvesOutcome(status: Awaited<ReturnType<typeof getActionStatus>>, applyStartedAtMs: number): boolean {
const receipt = status.receipt
if (!receipt || !receipt.finished_at || !receipt.started_at) {