From 9ed8331ced22f37f121d04e432557593bfcd3720 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Wed, 2 Sep 2026 02:49:36 +0530 Subject: [PATCH] style(desktop): eslint --fix + prettier on the salvaged files; null-guard respondToApprovalAction latch --- .../use-message-stream/gateway-event/index.ts | 2 +- apps/desktop/src/store/composer-status.ts | 11 ++++------- apps/desktop/src/store/gateway.ts | 1 - apps/desktop/src/store/goals.ts | 11 +++++------ .../src/store/native-notifications.test.ts | 2 +- apps/desktop/src/store/native-notifications.ts | 4 ++-- apps/desktop/src/store/prompts.test.ts | 12 +++++++++--- apps/desktop/src/store/prompts.ts | 17 +++++------------ apps/desktop/src/store/runtime-gone.test.ts | 6 +++--- apps/desktop/src/store/runtime-gone.ts | 3 +-- 10 files changed, 31 insertions(+), 38 deletions(-) diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/index.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/index.ts index beec741503..8c86f65d81 100644 --- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/index.ts +++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/index.ts @@ -11,8 +11,8 @@ import { reconcileSessionCompacting } from '@/store/compaction' import { $gateway, activeGatewayConnectionId } from '@/store/gateway' import { $activeGatewayProfile, normalizeProfileKey } from '@/store/profile' import { replayPendingApproval } from '@/store/prompts' -import { isSessionGone } from '@/store/session-gone-latch' import { setSessionProviderWait } from '@/store/provider-wait' +import { isSessionGone } from '@/store/session-gone-latch' import { setSessionDraftingTool } from '@/store/tool-drafting' import type { RpcEvent } from '@/types/hermes' diff --git a/apps/desktop/src/store/composer-status.ts b/apps/desktop/src/store/composer-status.ts index a260a0926a..f63bbe33ca 100644 --- a/apps/desktop/src/store/composer-status.ts +++ b/apps/desktop/src/store/composer-status.ts @@ -8,13 +8,7 @@ import { $gateway } from './gateway' import { $goalsBySession, type GoalStatus } from './goals' import { dispatchNativeNotification } from './native-notifications' import { notifyError } from './notifications' -import { - isSessionGone, - isSessionGoneForBackgroundPolling, - markSessionGone, - noteRuntimeAlive, - resetBackgroundPollingGuard -} from './runtime-gone' +import { isSessionGone, isSessionGoneForBackgroundPolling, markSessionGone, noteRuntimeAlive } from './runtime-gone' import { $sessions, lineageAliases } from './session' import { $sessionStates, requestForOwnedSession } from './session-states' import { $subagentsBySession, type SubagentProgress } from './subagents' @@ -409,6 +403,7 @@ export async function refreshBackgroundProcesses(sid: string): Promise { try { const ambientRequest = (method: string, params?: Record) => gateway.request(method, params ?? {}) + const result = await requestForOwnedSession<{ processes?: GatewayProcessEntry[] }>( sid, ambientRequest, @@ -474,6 +469,7 @@ export async function stopBackgroundProcess(sid: string, id: string): Promise(method: string, params?: Record) => gateway.request(method, params ?? {}) + await requestForOwnedSession(sid, ambientRequest, 'process.kill', { process_id: id, session_id: sid }) dismissBackgroundProcess(sid, id) } catch (err) { @@ -513,6 +509,7 @@ export function resetSessionBackground(sid: string) { if (gateway && !isSessionGone(sid)) { const ambientRequest = (method: string, params?: Record) => gateway.request(method, params ?? {}) + void requestForOwnedSession(sid, ambientRequest, 'process.kill', { process_id: item.id, session_id: sid diff --git a/apps/desktop/src/store/gateway.ts b/apps/desktop/src/store/gateway.ts index cbd643f066..b07971d13f 100644 --- a/apps/desktop/src/store/gateway.ts +++ b/apps/desktop/src/store/gateway.ts @@ -530,7 +530,6 @@ async function openSecondary(entry: Secondary): Promise { // Best effort for partial test/HMR graphs. Production always loads the // real store; a failed import must not make the transport unrecoverable. } - } // Registry-scoped entries dial through getConnectionFor when the bridge has diff --git a/apps/desktop/src/store/goals.ts b/apps/desktop/src/store/goals.ts index 1bd648b525..9d846fbcaf 100644 --- a/apps/desktop/src/store/goals.ts +++ b/apps/desktop/src/store/goals.ts @@ -172,12 +172,11 @@ export async function refreshSessionGoal(sid: string): Promise { try { const ambientRequest = (method: string, params?: Record) => gateway.request(method, params ?? {}) - const result = await requestForOwnedSession<{ output?: string }>( - sid, - ambientRequest, - 'slash.exec', - { command: 'goal status', session_id: sid } - ) + + const result = await requestForOwnedSession<{ output?: string }>(sid, ambientRequest, 'slash.exec', { + command: 'goal status', + session_id: sid + }) applyGoalStatusText(sid, result?.output ?? '', { hydrate: true }) } catch (error) { diff --git a/apps/desktop/src/store/native-notifications.test.ts b/apps/desktop/src/store/native-notifications.test.ts index 7bbb5cd888..69adfb0df0 100644 --- a/apps/desktop/src/store/native-notifications.test.ts +++ b/apps/desktop/src/store/native-notifications.test.ts @@ -15,8 +15,8 @@ import { } from './native-notifications' import { __resetNativeNotifyBaselineForTests, markNativeNotifyBaseline } from './notify-baseline' import { $approvalRequest, setApprovalRequest } from './prompts' -import { $activeSessionId, setActiveSessionId } from './session' import { markSessionGone, resetBackgroundPollingGuard } from './runtime-gone' +import { $activeSessionId, setActiveSessionId } from './session' const desktopWindow = window as unknown as { hermesDesktop?: Window['hermesDesktop'] } const initialHermesDesktop = desktopWindow.hermesDesktop diff --git a/apps/desktop/src/store/native-notifications.ts b/apps/desktop/src/store/native-notifications.ts index cfe87ce0c5..4a76acb8a0 100644 --- a/apps/desktop/src/store/native-notifications.ts +++ b/apps/desktop/src/store/native-notifications.ts @@ -6,8 +6,8 @@ import { persistString, storedString } from '@/lib/storage' import { $gateway } from './gateway' import { withinNativeNotifyBaseline } from './notify-baseline' import { clearApprovalRequest } from './prompts' +import { isSessionGone, isSessionGoneForBackgroundPolling, markSessionGone } from './runtime-gone' import { $activeSessionId } from './session' -import { isSessionGoneForBackgroundPolling, isSessionGone, markSessionGone } from './runtime-gone' import { requestForOwnedSession } from './session-states' export type { HermesOpenTarget } @@ -379,7 +379,7 @@ export async function respondToApprovalAction(sessionId: null | string, actionId ) clearApprovalRequest(sessionId) } catch (error) { - if (isSessionGoneForBackgroundPolling(error)) { + if (sessionId && isSessionGoneForBackgroundPolling(error)) { markSessionGone(sessionId) } diff --git a/apps/desktop/src/store/prompts.test.ts b/apps/desktop/src/store/prompts.test.ts index 6e121c5b9e..3b9e4ac825 100644 --- a/apps/desktop/src/store/prompts.test.ts +++ b/apps/desktop/src/store/prompts.test.ts @@ -17,8 +17,8 @@ import { setSecretRequest, setSudoRequest } from './prompts' -import { $activeSessionId, setActiveSessionId } from './session' import { isSessionGone, resetBackgroundPollingGuard } from './runtime-gone' +import { $activeSessionId, setActiveSessionId } from './session' // Prompts are parked per-session; the exported $*Request views are scoped to the // active session, so each test focuses the session it's asserting on. @@ -163,7 +163,10 @@ describe('approval prompt store', () => { $activeSessionId.set('dead-runtime') await expect( - receiveApprovalRequest({ request }, { command: 'x', description: 'd', requestId: 'r1', sessionId: 'dead-runtime' }) + receiveApprovalRequest( + { request }, + { command: 'x', description: 'd', requestId: 'r1', sessionId: 'dead-runtime' } + ) ).resolves.toBeUndefined() expect(isSessionGone('dead-runtime')).toBe(true) @@ -178,7 +181,10 @@ describe('approval prompt store', () => { setActiveSessionId('transient-runtime') await expect( - receiveApprovalRequest({ request }, { command: 'x', description: 'd', requestId: 'r2', sessionId: 'transient-runtime' }) + receiveApprovalRequest( + { request }, + { command: 'x', description: 'd', requestId: 'r2', sessionId: 'transient-runtime' } + ) ).rejects.toThrow('gateway timed out') expect(isSessionGone('transient-runtime')).toBe(false) diff --git a/apps/desktop/src/store/prompts.ts b/apps/desktop/src/store/prompts.ts index 876d37e8f9..51b6f0df7c 100644 --- a/apps/desktop/src/store/prompts.ts +++ b/apps/desktop/src/store/prompts.ts @@ -125,12 +125,10 @@ export async function receiveApprovalRequest(gateway: ApprovalGateway | null, re const ambientRequest = (method: string, params?: Record) => gateway.request(method, params ?? {}) as Promise - await requestForOwnedSession( - request.sessionId, - ambientRequest, - 'approval.received', - { request_id: request.requestId, session_id: request.sessionId } - ) + await requestForOwnedSession(request.sessionId, ambientRequest, 'approval.received', { + request_id: request.requestId, + session_id: request.sessionId + }) } catch (error) { if (isSessionGoneForBackgroundPolling(error)) { markSessionGone(request.sessionId) @@ -154,12 +152,7 @@ export async function replayPendingApproval(gateway: ApprovalGateway | null, ses const ambientRequest = (method: string, params?: Record) => gateway.request(method, params ?? {}) as Promise - rawResult = await requestForOwnedSession( - sessionId, - ambientRequest, - 'approval.pending', - { session_id: sessionId } - ) + rawResult = await requestForOwnedSession(sessionId, ambientRequest, 'approval.pending', { session_id: sessionId }) } catch (error) { if (isSessionGoneForBackgroundPolling(error)) { markSessionGone(sessionId) diff --git a/apps/desktop/src/store/runtime-gone.test.ts b/apps/desktop/src/store/runtime-gone.test.ts index 0abc60cead..6aedcdd3e9 100644 --- a/apps/desktop/src/store/runtime-gone.test.ts +++ b/apps/desktop/src/store/runtime-gone.test.ts @@ -162,9 +162,9 @@ describe('gone-latch classifier and rebind seam', () => { expect(isSessionGoneForBackgroundPolling(new JsonRpcGatewayError('gone', { code: 4001 }))).toBe(true) expect(isSessionGoneForBackgroundPolling(new JsonRpcGatewayError('session not found', { code: 5007 }))).toBe(false) expect(isSessionGoneForBackgroundPolling(new JsonRpcGatewayError('session not found'))).toBe(true) - expect(isSessionGoneForBackgroundPolling(new Error("Error invoking remote method 'x': Error: session not found"))).toBe( - true - ) + expect( + isSessionGoneForBackgroundPolling(new Error("Error invoking remote method 'x': Error: session not found")) + ).toBe(true) expect(isSessionGoneForBackgroundPolling(new Error('tool failed: upstream said session not found'))).toBe(false) }) diff --git a/apps/desktop/src/store/runtime-gone.ts b/apps/desktop/src/store/runtime-gone.ts index 41cbd383d4..c529cbb8d9 100644 --- a/apps/desktop/src/store/runtime-gone.ts +++ b/apps/desktop/src/store/runtime-gone.ts @@ -1,6 +1,4 @@ import { $activeSessionId, requestSessionResume } from './session' -import { $sessionStates, $sessionTiles, unbindTileRuntime } from './session-states' - import { healsByStoredId, isSessionGone, @@ -9,6 +7,7 @@ import { resetBackgroundPollingGuard, resetBackgroundPollingGuardAfterRebind } from './session-gone-latch' +import { $sessionStates, $sessionTiles, unbindTileRuntime } from './session-states' export { isSessionGone,