From b30565331f2093b30cc15dfe56d15563db9557fc Mon Sep 17 00:00:00 2001 From: Merge Sim Date: Wed, 9 Sep 2026 18:49:43 -0700 Subject: [PATCH] refactor(terminal-pane): fold the fork's trust preflight onto the canonical one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `preflightForkAgentTrust` was a behavioural duplicate of `preflightAgentTrust`, whose signature now accepts a nullable agent and workspace path and so is a drop-in replacement. Its file is left holding only the launch-platform resolver — which is not a duplicate, since it returns an override rather than a default — so the file is renamed for what it now contains. --- ...nal-agent-session-fork-launch-platform.ts} | 23 ------------------- .../terminal-agent-session-fork.ts | 8 +++---- 2 files changed, 3 insertions(+), 28 deletions(-) rename src/renderer/src/components/terminal-pane/{terminal-agent-session-fork-agent-preflight.ts => terminal-agent-session-fork-launch-platform.ts} (51%) diff --git a/src/renderer/src/components/terminal-pane/terminal-agent-session-fork-agent-preflight.ts b/src/renderer/src/components/terminal-pane/terminal-agent-session-fork-launch-platform.ts similarity index 51% rename from src/renderer/src/components/terminal-pane/terminal-agent-session-fork-agent-preflight.ts rename to src/renderer/src/components/terminal-pane/terminal-agent-session-fork-launch-platform.ts index 980006593f3..33fbb193388 100644 --- a/src/renderer/src/components/terminal-pane/terminal-agent-session-fork-agent-preflight.ts +++ b/src/renderer/src/components/terminal-pane/terminal-agent-session-fork-launch-platform.ts @@ -1,5 +1,3 @@ -import { TUI_AGENT_CONFIG } from '../../../../shared/tui-agent-config' -import type { TuiAgent } from '../../../../shared/tui-agent' import { isWslUncPath } from '../../../../shared/wsl-paths' import type { ProjectExecutionRuntimeResolution } from '../../../../shared/project-execution-runtime' @@ -19,24 +17,3 @@ export function getForkAgentLaunchPlatform(args: { } return undefined } - -export async function preflightForkAgentTrust(args: { - agent: TuiAgent - workspacePath?: string | null - connectionId?: string | null -}): Promise { - const { agent, workspacePath, connectionId } = args - const preflight = TUI_AGENT_CONFIG[agent].preflightTrust - if (!preflight || !workspacePath || !window.api.agentTrust?.markTrusted) { - return - } - try { - await window.api.agentTrust.markTrusted({ - preset: preflight, - workspacePath, - ...(connectionId ? { connectionId } : {}) - }) - } catch { - // Best-effort: if the trust artifact cannot be written, keep the existing launch path. - } -} diff --git a/src/renderer/src/components/terminal-pane/terminal-agent-session-fork.ts b/src/renderer/src/components/terminal-pane/terminal-agent-session-fork.ts index 135250f513c..fc22eae6417 100644 --- a/src/renderer/src/components/terminal-pane/terminal-agent-session-fork.ts +++ b/src/renderer/src/components/terminal-pane/terminal-agent-session-fork.ts @@ -9,10 +9,8 @@ import { activateAndRevealWorktree } from '@/lib/worktree-activation' import { useAppStore } from '@/store' import { makePaneKey } from '../../../../shared/stable-pane-id' import { TUI_AGENT_CONFIG } from '../../../../shared/tui-agent-config' -import { - getForkAgentLaunchPlatform, - preflightForkAgentTrust -} from './terminal-agent-session-fork-agent-preflight' +import { getForkAgentLaunchPlatform } from './terminal-agent-session-fork-launch-platform' +import { preflightAgentTrust } from '@/lib/agent-trust-preflight' import { slugifyForWorkspaceName } from '../../../../shared/workspace-name' import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../../shared/constants' import type { TuiAgent } from '../../../../shared/tui-agent' @@ -231,7 +229,7 @@ export async function startAgentSessionFork(fork: PreparedAgentSessionFork): Pro activateAndRevealWorktree(forkWorktreeId, { sidebarRevealBehavior: 'auto' }) return copyAgentSessionForkContext(fork) } - await preflightForkAgentTrust({ + await preflightAgentTrust({ agent: fork.agent, workspacePath: created.worktree.path, connectionId: sourceRepo?.connectionId