Skip to content

The agent that grows with you

refactor(desktop): move resume's pending-approval restore into its own sibling

Teknium4ec96b82c2ab
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 d60e31454d0..12fd9180ba5 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
@@ -38,7 +38,6 @@ import { clearQueuedPrompts, migrateQueuedPrompts } from '@/store/composer-queue
import { resetSessionBackground } from '@/store/composer-status'
import { $connectionRequests } from '@/store/connection-request'
import {
- $gateway,
isActivePrimary,
openGatewayForAgent,
openGatewayForProfile,
@@ -67,7 +66,7 @@ import {
} from '@/store/profile'
import { $projectScope } from '@/store/project-scope'
import { projectProfile, resolveNewSessionCwd } from '@/store/projects'
-import { clearAllPrompts, receiveApprovalRequest, replayPendingApproval } from '@/store/prompts'
+import { clearAllPrompts } from '@/store/prompts'
import { clearStoredTranscriptReadOnly, markStoredTranscriptReadOnly } from '@/store/read-only-transcript'
import {
$activeSessionStoredIdRotation,
@@ -168,6 +167,7 @@ import { captureDisplayHydration } from './display-hydration'
import { reconcilePersistedLiveTurn } from './persisted-live-turn'
import { provisionalTranscriptPaint, transcriptRestScope } from './provisional-transcript'
import { rememberedOwnerForResume } from './remembered-owner'
+import { restorePendingApproval } from './restore-pending-approval'
import { pendingClarifyToolPayload, restorePendingClarifyFromSnapshot } from './restore-pending-clarify'
import { projectPendingConnection, restorePendingConnectionFromSnapshot } from './restore-pending-connection'
import { createGatewaySession } from './session-create-request'
@@ -450,30 +450,6 @@ function livePromptStreamId(
return live ? { awaitingResponse: false, sawAssistantPayload: true, streamId: live.streamId } : {}
}
-function restorePendingApproval(response: SessionResumeResult, sessionId: string): boolean {
- const pending = response.pending_approval
-
- if (!pending) {
- return false
- }
-
- // The live `approval` server request (re-delivered from `open_requests`
- // before this ran) already parked itself with the same queue id; don't
- // clobber it with a copy that can only answer through the RPC fallback.
- void receiveApprovalRequest(null, {
- allowPermanent: pending.allow_permanent !== false,
- choices: pending.choices,
- command: pending.command ?? '',
- description: pending.description ?? 'dangerous command',
- requestId: typeof pending.request_id === 'string' ? pending.request_id : undefined,
- sessionId,
- smartDenied: pending.smart_denied === true
- })
- void replayPendingApproval($gateway.get(), sessionId).catch(() => undefined)
-
- return true
-}
-
function normalizeNewChatWorkspaceTarget(target: NewChatWorkspaceTarget): NewChatWorkspaceTarget {
return typeof target === 'string' ? target.trim() || null : target
}
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/restore-pending-approval.ts b/apps/desktop/src/app/session/hooks/use-session-actions/restore-pending-approval.ts
new file mode 100644
index 00000000000..6a3b8641b35
--- /dev/null
+++ b/apps/desktop/src/app/session/hooks/use-session-actions/restore-pending-approval.ts
@@ -0,0 +1,28 @@
+import { $gateway } from '@/store/gateway'
+import { receiveApprovalRequest, replayPendingApproval } from '@/store/prompts'
+import type { SessionResumeResult } from '@/types/hermes'
+
+/** Re-park a resume snapshot's pending approval; true when one was restored. */
+export function restorePendingApproval(response: SessionResumeResult, sessionId: string): boolean {
+ const pending = response.pending_approval
+
+ if (!pending) {
+ return false
+ }
+
+ // The live `approval` server request (re-delivered from `open_requests`
+ // before this ran) already parked itself with the same queue id; don't
+ // clobber it with a copy that can only answer through the RPC fallback.
+ void receiveApprovalRequest(null, {
+ allowPermanent: pending.allow_permanent !== false,
+ choices: pending.choices,
+ command: pending.command ?? '',
+ description: pending.description ?? 'dangerous command',
+ requestId: typeof pending.request_id === 'string' ? pending.request_id : undefined,
+ sessionId,
+ smartDenied: pending.smart_denied === true
+ })
+ void replayPendingApproval($gateway.get(), sessionId).catch(() => undefined)
+
+ return true
+}