style(desktop): eslint --fix + prettier on the salvaged files; null-guard respondToApprovalAction latch
This commit is contained in:
@@ -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'
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user