Skip to content

The agent that grows with you

style(desktop): eslint --fix + prettier on the salvaged files; null-guard respondToApprovalAction latch

kshitijk4poor9ed8331ced22
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 beec7415034..8c86f65d817 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 a260a0926a9..f63bbe33ca0 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<void> {
try {
const ambientRequest = <T>(method: string, params?: Record<string, unknown>) =>
gateway.request<T>(method, params ?? {})
+
const result = await requestForOwnedSession<{ processes?: GatewayProcessEntry[] }>(
sid,
ambientRequest,
@@ -474,6 +469,7 @@ export async function stopBackgroundProcess(sid: string, id: string): Promise<vo
try {
const ambientRequest = <T>(method: string, params?: Record<string, unknown>) =>
gateway.request<T>(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 = <T>(method: string, params?: Record<string, unknown>) =>
gateway.request<T>(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 cbd643f0663..b07971d13f2 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<void> {
// 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 1bd648b5257..9d846fbcafb 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<void> {
try {
const ambientRequest = <T>(method: string, params?: Record<string, unknown>) =>
gateway.request<T>(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 7bbb5cd888c..69adfb0df07 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 cfe87ce0c5e..4a76acb8a09 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 6e121c5b9ef..3b9e4ac825f 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 876d37e8f9b..51b6f0df7c2 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 = <T>(method: string, params?: Record<string, unknown>) =>
gateway.request(method, params ?? {}) as Promise<T>
- 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 = <T>(method: string, params?: Record<string, unknown>) =>
gateway.request(method, params ?? {}) as Promise<T>
- 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 0abc60ceade..6aedcdd3e9d 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 41cbd383d41..c529cbb8d9f 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,