diff --git a/src/main/runtime/orca-runtime.ts b/src/main/runtime/orca-runtime.ts index 8595f783e..c5fc22bf8 100644 --- a/src/main/runtime/orca-runtime.ts +++ b/src/main/runtime/orca-runtime.ts @@ -168,6 +168,7 @@ import { isTerminalLeafId, makePaneKey, parsePaneKey } from '../../shared/stable import { parseAppSshPtyId } from '../../shared/ssh-pty-id' import { isValidHostTerminalTabId } from '../../shared/terminal-tab-id' import { buildAgentDraftLaunchPlan, buildAgentStartupPlan } from '../../shared/tui-agent-startup' +import { repoIsRemote } from '../../shared/agent-launch-remote' import { isAgentForegroundWrapperProcess, isExpectedAgentProcess, @@ -11709,13 +11710,15 @@ export class OrcaRuntimeService { // Why: a mobile client can run on Windows while the workspace shell is // Linux over SSH. Startup command quoting must target the shell that runs it. const agentLaunchPlatform = this.getAgentLaunchPlatformForRepo(repo) + const isRemote = repoIsRemote(repo) const draftLaunchPlan = buildAgentDraftLaunchPlan({ agent, draft: content, cmdOverrides: settings.agentCmdOverrides ?? {}, agentArgs: resolveTuiAgentLaunchArgs(agent, settings.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(agent, settings.agentDefaultEnv), - platform: agentLaunchPlatform + platform: agentLaunchPlatform, + isRemote }) if (draftLaunchPlan) { return { @@ -11738,6 +11741,7 @@ export class OrcaRuntimeService { agentArgs: resolveTuiAgentLaunchArgs(agent, settings.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(agent, settings.agentDefaultEnv), platform: agentLaunchPlatform, + isRemote, allowEmptyPromptLaunch: true }) if (!startupPlan) { @@ -11779,6 +11783,7 @@ export class OrcaRuntimeService { agentArgs: resolveTuiAgentLaunchArgs(agent, settings.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(agent, settings.agentDefaultEnv), platform: agentLaunchPlatform, + isRemote: repoIsRemote(repo), allowEmptyPromptLaunch: true }) if (!startupPlan) { @@ -15375,6 +15380,9 @@ export class OrcaRuntimeService { // Why: mobile may be running on iOS while the actual terminal shell is // Windows/macOS/Linux or an SSH Linux host; quote for the host shell. const platform = this.getAgentLaunchPlatformForWorkspace(workspace) + // Why: an SSH workspace runs the CLI through the relay shim (plain `orca`), + // so the Linux-only `orca-ide` rename must not be applied. + const isRemote = workspace.repo ? repoIsRemote(workspace.repo) : repoIsRemote(workspace) const startupPlan = buildAgentStartupPlan({ agent: opts.agent, prompt: '', @@ -15382,6 +15390,7 @@ export class OrcaRuntimeService { agentArgs: resolveTuiAgentLaunchArgs(opts.agent, settings.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(opts.agent, settings.agentDefaultEnv), platform, + isRemote, allowEmptyPromptLaunch: true }) if (!startupPlan) { diff --git a/src/renderer/src/components/right-sidebar/buildSourceControlAgentDeliveryPlan.ts b/src/renderer/src/components/right-sidebar/buildSourceControlAgentDeliveryPlan.ts index 5886e8b84..d9bcf0cd1 100644 --- a/src/renderer/src/components/right-sidebar/buildSourceControlAgentDeliveryPlan.ts +++ b/src/renderer/src/components/right-sidebar/buildSourceControlAgentDeliveryPlan.ts @@ -12,6 +12,9 @@ type BuildSourceControlAgentDeliveryPlanArgs = { detectedAgents: TuiAgent[] connectionUnavailable: boolean launchPlatform?: NodeJS.Platform + /** Why: keep the previewed command label in sync with the real remote launch, + * which omits the Linux-only `orca-ide` rename for SSH hosts. */ + isRemote?: boolean } export function buildSourceControlAgentDeliveryPlan({ @@ -21,7 +24,8 @@ export function buildSourceControlAgentDeliveryPlan({ promptDelivery, detectedAgents, connectionUnavailable, - launchPlatform + launchPlatform, + isRemote }: BuildSourceControlAgentDeliveryPlanArgs): SourceControlAgentActionDeliveryPlanState { if (connectionUnavailable) { return buildSourceControlAgentConnectionErrorPlan() @@ -34,7 +38,8 @@ export function buildSourceControlAgentDeliveryPlan({ detectedAgents, disabledAgents: useAppStore.getState().settings?.disabledTuiAgents, cmdOverrides: useAppStore.getState().settings?.agentCmdOverrides, - platform: launchPlatform + platform: launchPlatform, + isRemote }) if (!result.ok) { return { status: 'error', error: result.error } diff --git a/src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts b/src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts index c3162c726..7dca868c7 100644 --- a/src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts +++ b/src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts @@ -166,6 +166,9 @@ export function useSourceControlAgentActionDialog({ groupId, promptDelivery, launchPlatform, + // Why: an SSH host runs the plain `orca` shim; keep the previewed command + // label aligned with the real remote launch (no `orca-ide` rename). + isRemote: typeof connectionId === 'string', launchSource, connectionUnavailable, refreshDetectedAgents, diff --git a/src/renderer/src/components/right-sidebar/useSourceControlAgentActionStart.ts b/src/renderer/src/components/right-sidebar/useSourceControlAgentActionStart.ts index a8fde187e..0233518a8 100644 --- a/src/renderer/src/components/right-sidebar/useSourceControlAgentActionStart.ts +++ b/src/renderer/src/components/right-sidebar/useSourceControlAgentActionStart.ts @@ -27,6 +27,9 @@ type UseSourceControlAgentActionStartArgs = { groupId?: string | null promptDelivery: 'auto-submit' | 'draft' | 'submit-after-ready' launchPlatform?: NodeJS.Platform + /** Why: SSH hosts launch the plain `orca` shim, so the previewed command must + * drop the Linux-only `orca-ide` rename to match the real launch. */ + isRemote?: boolean launchSource: LaunchSource connectionUnavailable: boolean refreshDetectedAgents: () => Promise @@ -75,6 +78,7 @@ export function useSourceControlAgentActionStart({ groupId, promptDelivery, launchPlatform, + isRemote, launchSource, connectionUnavailable, refreshDetectedAgents, @@ -100,7 +104,8 @@ export function useSourceControlAgentActionStart({ promptDelivery, detectedAgents: currentDetectedAgents, connectionUnavailable, - launchPlatform + launchPlatform, + isRemote }) }, [ @@ -110,7 +115,8 @@ export function useSourceControlAgentActionStart({ promptDelivery, refreshDetectedAgents, selectedAgent, - launchPlatform + launchPlatform, + isRemote ] ) diff --git a/src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts b/src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts index 6b5a7ab15..30719bcc5 100644 --- a/src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts +++ b/src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts @@ -69,6 +69,7 @@ function buildFolderWorkspaceLinkedStartupPlan(args: { agentArgs?: string | null agentEnv?: Record platform: NodeJS.Platform + isRemote: boolean }): AgentStartupPlan | null { const { prompt, draftPrompt } = resolveQuickCreateLinkedWorkItemPrompt( args.linkedWorkItem, @@ -82,7 +83,8 @@ function buildFolderWorkspaceLinkedStartupPlan(args: { cmdOverrides: args.agentCmdOverrides ?? {}, agentArgs: args.agentArgs, agentEnv: args.agentEnv, - platform: args.platform + platform: args.platform, + isRemote: args.isRemote }) : null if (draftLaunchPlan) { @@ -108,6 +110,7 @@ function buildFolderWorkspaceLinkedStartupPlan(args: { agentArgs: args.agentArgs, agentEnv: args.agentEnv, platform: args.platform, + isRemote: args.isRemote, allowEmptyPromptLaunch: true }) if (startupPlan && linkedDraftPrompt) { @@ -162,6 +165,9 @@ export async function submitFolderWorkspaceCreate({ ? linkedName : name.trim() || linkedName || `${projectGroup.name} workspace` const launchPlatform = getFolderWorkspaceAgentLaunchPlatform(projectGroup) + // Why: an SSH folder group runs the plain `orca` relay shim, so the Linux-only + // `orca-ide` rename must not be applied for remote launches. + const launchIsRemote = Boolean(projectGroup.connectionId) const startupPlan = quickAgent && linkedWorkItem ? buildFolderWorkspaceLinkedStartupPlan({ @@ -171,7 +177,8 @@ export async function submitFolderWorkspaceCreate({ agentCmdOverrides, agentArgs, agentEnv, - platform: launchPlatform + platform: launchPlatform, + isRemote: launchIsRemote }) : quickAgent ? buildAgentStartupPlan({ @@ -181,6 +188,7 @@ export async function submitFolderWorkspaceCreate({ agentArgs, agentEnv, platform: launchPlatform, + isRemote: launchIsRemote, allowEmptyPromptLaunch: true }) : null diff --git a/src/renderer/src/hooks/useComposerState.ts b/src/renderer/src/hooks/useComposerState.ts index 8dfce31d8..b0d5511d1 100644 --- a/src/renderer/src/hooks/useComposerState.ts +++ b/src/renderer/src/hooks/useComposerState.ts @@ -21,6 +21,7 @@ import { runBackgroundWorktreeCreation } from '@/lib/worktree-creation-flow' import type { WorktreeCreationRequest } from '@/lib/pending-worktree-creation' import { buildAgentDraftLaunchPlan, buildAgentStartupPlan } from '@/lib/tui-agent-startup' import { filterEnabledTuiAgents, isTuiAgentEnabled } from '../../../shared/tui-agent-selection' +import { repoIsRemote } from '../../../shared/agent-launch-remote' import { resolveTuiAgentLaunchArgs, resolveTuiAgentLaunchEnv @@ -649,6 +650,9 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS ) return getAgentLaunchPlatformForRepo(selectedRepo, projectRuntime) }, [activeRepoId, projects, repos, selectedRepo, settings, worktreesByRepo]) + // Why: SSH remotes deploy the CLI shim as plain `orca`, so the Linux-only + // `orca-ide` rename must not be applied to remote launch commands. + const selectedRepoIsRemote = selectedRepo ? repoIsRemote(selectedRepo) : false const selectedRepoProjectId = selectedWorkspaceTarget.status === 'ready' ? selectedWorkspaceTarget.target.projectId : null const selectedProjectId = selectedProjectGroup @@ -3196,7 +3200,8 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS cmdOverrides: settings?.agentCmdOverrides ?? {}, agentArgs: resolveTuiAgentLaunchArgs(tuiAgent, settings?.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(tuiAgent, settings?.agentDefaultEnv), - platform: selectedRepoAgentLaunchPlatform + platform: selectedRepoAgentLaunchPlatform, + isRemote: selectedRepoIsRemote }) const shouldSeedInitialAgentStatus = tuiAgent === 'command-code' && submitStartupPrompt.trim().length > 0 @@ -3365,6 +3370,7 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS resolvedInitialWorkspaceStatus, selectedRepo, selectedRepoAgentLaunchPlatform, + selectedRepoIsRemote, selectedRepoIsGit, selectedRepoRequiresConnection, showProjectRequiredError, @@ -3599,7 +3605,8 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS cmdOverrides: settings?.agentCmdOverrides ?? {}, agentArgs: resolveTuiAgentLaunchArgs(agent, settings?.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(agent, settings?.agentDefaultEnv), - platform: selectedRepoAgentLaunchPlatform + platform: selectedRepoAgentLaunchPlatform, + isRemote: selectedRepoIsRemote }) let startupPlan: ReturnType = null @@ -3623,6 +3630,7 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS agentArgs: resolveTuiAgentLaunchArgs(agent, settings?.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(agent, settings?.agentDefaultEnv), platform: selectedRepoAgentLaunchPlatform, + isRemote: selectedRepoIsRemote, allowEmptyPromptLaunch: true }) if (startupPlan && quickDraftPrompt) { @@ -3774,6 +3782,7 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS resolvedInitialWorkspaceStatus, selectedRepo, selectedRepoAgentLaunchPlatform, + selectedRepoIsRemote, selectedRepoIsGit, selectedRepoSettings, selectedRepoRequiresConnection, diff --git a/src/renderer/src/lib/command-code-prompt-status-seed.ts b/src/renderer/src/lib/command-code-prompt-status-seed.ts new file mode 100644 index 000000000..50d722219 --- /dev/null +++ b/src/renderer/src/lib/command-code-prompt-status-seed.ts @@ -0,0 +1,24 @@ +import { useAppStore } from '@/store' +import { makePaneKey } from '../../../shared/stable-pane-id' + +/** + * Why: Command Code has no prompt-submit hook, so when Orca submits a generated + * prompt after the TUI is ready, seed `working` at delivery time so sidebar and + * activity surfaces don't stay idle until the first real hook event arrives. + */ +export function seedCommandCodeSubmittedPromptStatus(tabId: string, prompt: string): void { + const state = useAppStore.getState() + const leafId = state.terminalLayoutsByTabId[tabId]?.activeLeafId + if (!leafId) { + return + } + try { + state.setAgentStatus(makePaneKey(tabId, leafId), { + state: 'working', + prompt, + agentType: 'command-code' + }) + } catch { + // Best-effort UI seed. Real hooks still own refinement/completion. + } +} diff --git a/src/renderer/src/lib/github-work-item-background-request.ts b/src/renderer/src/lib/github-work-item-background-request.ts index 22490cbab..f37c71ded 100644 --- a/src/renderer/src/lib/github-work-item-background-request.ts +++ b/src/renderer/src/lib/github-work-item-background-request.ts @@ -13,6 +13,7 @@ import type { import { CLIENT_PLATFORM, getWorkspaceIntentName, getWorkspaceSeedName } from '@/lib/new-workspace' import { getLocalRepoProjectExecutionRuntimeContext } from '@/lib/local-preflight-context' import { resolveSourceControlLaunchPlatform } from '@/lib/source-control-launch-platform' +import { repoIsRemote } from '../../../shared/agent-launch-remote' import { resolveTuiAgentLaunchArgs, resolveTuiAgentLaunchEnv @@ -180,6 +181,9 @@ export function buildGitHubWorkItemStartupPlan(args: { // Why: runtime-owned repos launch on their owner host, not on the client // desktop, so startup shell quoting must use the runtime platform. const platform = resolveGitHubWorkItemLaunchPlatform(store, repo) + // Why: SSH remotes deploy the CLI shim as plain `orca`, so the Linux-only + // `orca-ide` rename must not be applied for remote launches. + const isRemote = repoIsRemote(repo) const draftLaunchPlan = draftPrompt ? buildAgentDraftLaunchPlan({ agent, @@ -187,7 +191,8 @@ export function buildGitHubWorkItemStartupPlan(args: { cmdOverrides: store.settings?.agentCmdOverrides ?? {}, agentArgs: resolveTuiAgentLaunchArgs(agent, store.settings?.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(agent, store.settings?.agentDefaultEnv), - platform + platform, + isRemote }) : null const startupPlan = draftLaunchPlan @@ -209,6 +214,7 @@ export function buildGitHubWorkItemStartupPlan(args: { agentArgs: resolveTuiAgentLaunchArgs(agent, store.settings?.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(agent, store.settings?.agentDefaultEnv), platform, + isRemote, allowEmptyPromptLaunch: true }) if (startupPlan && draftPrompt && !draftLaunchPlan) { diff --git a/src/renderer/src/lib/launch-agent-background-session.ts b/src/renderer/src/lib/launch-agent-background-session.ts index 4bee44173..2afd71e48 100644 --- a/src/renderer/src/lib/launch-agent-background-session.ts +++ b/src/renderer/src/lib/launch-agent-background-session.ts @@ -15,6 +15,7 @@ import { resolveTuiAgentLaunchEnv } from '../../../shared/tui-agent-launch-defaults' import { TUI_AGENT_CONFIG } from '../../../shared/tui-agent-config' +import { repoIsRemote } from '../../../shared/agent-launch-remote' import { makePaneKey } from '../../../shared/stable-pane-id' import { registerEagerPtyBuffer, @@ -66,6 +67,9 @@ export async function launchAgentBackgroundSession( repo.connectionId ? undefined : getLocalProjectExecutionRuntimeContext(store, worktreeId) ) : CLIENT_PLATFORM + // Why: SSH remotes deploy the CLI shim as plain `orca`, so the Linux-only + // `orca-ide` rename must not be applied for remote launches. + const isRemote = repo ? repoIsRemote(repo) : false const trimmedPrompt = prompt?.trim() ?? '' const hasPrompt = trimmedPrompt.length > 0 const isFollowupPath = TUI_AGENT_CONFIG[agent].promptInjectionMode === 'stdin-after-start' @@ -80,6 +84,7 @@ export async function launchAgentBackgroundSession( agentArgs, agentEnv, platform: launchPlatform, + isRemote, allowEmptyPromptLaunch: true }) pasteDraftAfterLaunch = trimmedPrompt @@ -91,6 +96,7 @@ export async function launchAgentBackgroundSession( agentArgs, agentEnv, platform: launchPlatform, + isRemote, allowEmptyPromptLaunch: !hasPrompt }) } diff --git a/src/renderer/src/lib/launch-agent-in-new-tab.ts b/src/renderer/src/lib/launch-agent-in-new-tab.ts index 15f243922..738113d9b 100644 --- a/src/renderer/src/lib/launch-agent-in-new-tab.ts +++ b/src/renderer/src/lib/launch-agent-in-new-tab.ts @@ -23,7 +23,8 @@ import { resolveTuiAgentLaunchEnv } from '../../../shared/tui-agent-launch-defaults' import { TUI_AGENT_CONFIG } from '../../../shared/tui-agent-config' -import { makePaneKey } from '../../../shared/stable-pane-id' +import { repoIsRemote } from '../../../shared/agent-launch-remote' +import { seedCommandCodeSubmittedPromptStatus } from '@/lib/command-code-prompt-status-seed' import type { TuiAgent } from '../../../shared/types' import type { LaunchSource } from '../../../shared/telemetry-events' import { translate } from '@/i18n/i18n' @@ -69,23 +70,6 @@ export type LaunchAgentInNewTabResult = { pasteDraftAfterLaunch: boolean } | null -function seedCommandCodeSubmittedPromptStatus(tabId: string, prompt: string): void { - const state = useAppStore.getState() - const leafId = state.terminalLayoutsByTabId[tabId]?.activeLeafId - if (!leafId) { - return - } - try { - state.setAgentStatus(makePaneKey(tabId, leafId), { - state: 'working', - prompt, - agentType: 'command-code' - }) - } catch { - // Best-effort UI seed. Real hooks still own refinement/completion. - } -} - /** * Create a new terminal tab and queue the agent's launch command, optionally * with an initial prompt. @@ -132,6 +116,9 @@ export function launchAgentInNewTab(args: LaunchAgentInNewTabArgs): LaunchAgentI repo.connectionId ? undefined : getLocalProjectExecutionRuntimeContext(store, worktreeId) ) : CLIENT_PLATFORM) + // Why: SSH remotes deploy the CLI shim as plain `orca`, so the Linux-only + // `orca-ide` rename must not be applied for remote launches. + const isRemote = repo ? repoIsRemote(repo) : false const cmdOverrides = store.settings?.agentCmdOverrides ?? {} const effectiveAgentArgs = agentArgs !== undefined @@ -160,6 +147,7 @@ export function launchAgentInNewTab(args: LaunchAgentInNewTabArgs): LaunchAgentI prompt: '', cmdOverrides, platform: resolvedLaunchPlatform, + isRemote, agentArgs: effectiveAgentArgs, agentEnv, allowEmptyPromptLaunch: true @@ -173,6 +161,7 @@ export function launchAgentInNewTab(args: LaunchAgentInNewTabArgs): LaunchAgentI draft: trimmedPrompt, cmdOverrides, platform: resolvedLaunchPlatform, + isRemote, agentArgs: effectiveAgentArgs, agentEnv }) @@ -194,6 +183,7 @@ export function launchAgentInNewTab(args: LaunchAgentInNewTabArgs): LaunchAgentI prompt: '', cmdOverrides, platform: resolvedLaunchPlatform, + isRemote, agentArgs: effectiveAgentArgs, agentEnv, allowEmptyPromptLaunch: true @@ -206,6 +196,7 @@ export function launchAgentInNewTab(args: LaunchAgentInNewTabArgs): LaunchAgentI prompt: '', cmdOverrides, platform: resolvedLaunchPlatform, + isRemote, agentArgs: effectiveAgentArgs, agentEnv, allowEmptyPromptLaunch: true @@ -217,6 +208,7 @@ export function launchAgentInNewTab(args: LaunchAgentInNewTabArgs): LaunchAgentI prompt: hasPrompt ? trimmedPrompt : '', cmdOverrides, platform: resolvedLaunchPlatform, + isRemote, agentArgs: effectiveAgentArgs, agentEnv, allowEmptyPromptLaunch: !hasPrompt diff --git a/src/renderer/src/lib/launch-work-item-direct-agent.ts b/src/renderer/src/lib/launch-work-item-direct-agent.ts index 0f9839591..91f88520a 100644 --- a/src/renderer/src/lib/launch-work-item-direct-agent.ts +++ b/src/renderer/src/lib/launch-work-item-direct-agent.ts @@ -31,6 +31,9 @@ export function buildDirectWorkItemAgentStartupPlan(args: { | null | undefined launchPlatform: NodeJS.Platform + /** Why: SSH remotes deploy the CLI shim as plain `orca`, so the Linux-only + * `orca-ide` rename must not be applied for remote launches. */ + isRemote?: boolean }): { startupPlan: AgentStartupPlan | null draftLaunchedNatively: boolean @@ -53,6 +56,7 @@ export function buildDirectWorkItemAgentStartupPlan(args: { draft: args.draftContent, cmdOverrides: args.settings?.agentCmdOverrides ?? {}, platform: args.launchPlatform, + isRemote: args.isRemote, agentArgs: effectiveAgentArgs, agentEnv: effectiveAgentEnv }) @@ -80,6 +84,7 @@ export function buildDirectWorkItemAgentStartupPlan(args: { prompt: '', cmdOverrides: args.settings?.agentCmdOverrides ?? {}, platform: args.launchPlatform, + isRemote: args.isRemote, agentArgs: effectiveAgentArgs, agentEnv: effectiveAgentEnv, allowEmptyPromptLaunch: true diff --git a/src/renderer/src/lib/launch-work-item-direct.ts b/src/renderer/src/lib/launch-work-item-direct.ts index c3218bdea..71ed7be68 100644 --- a/src/renderer/src/lib/launch-work-item-direct.ts +++ b/src/renderer/src/lib/launch-work-item-direct.ts @@ -264,7 +264,10 @@ export async function launchWorkItemDirect(args: LaunchWorkItemDirectArgs): Prom draftContent, promptDelivery, settings, - launchPlatform + launchPlatform, + // Why: SSH hosts run the plain `orca` shim, so the Linux-only `orca-ide` + // rename must not be applied for remote launches. + isRemote: typeof launchConnectionId === 'string' })) const activation = activateAndRevealWorktree(worktreeId, { diff --git a/src/renderer/src/lib/source-control-agent-action-plan.ts b/src/renderer/src/lib/source-control-agent-action-plan.ts index d31cf7c3a..c32368836 100644 --- a/src/renderer/src/lib/source-control-agent-action-plan.ts +++ b/src/renderer/src/lib/source-control-agent-action-plan.ts @@ -36,6 +36,9 @@ export function planSourceControlAgentActionLaunch(args: { cmdOverrides?: Partial> agentArgs?: string | null platform?: NodeJS.Platform + /** Why: SSH remotes deploy the CLI shim as plain `orca`, so the Linux-only + * `orca-ide` rename must not be applied for remote launches. */ + isRemote?: boolean }): SourceControlLaunchPlanResult { const agent = args.agent if (!agent) { @@ -79,6 +82,7 @@ export function planSourceControlAgentActionLaunch(args: { const cmdOverrides = args.cmdOverrides ?? {} const platform = args.platform ?? CLIENT_PLATFORM + const isRemote = args.isRemote ?? false const shell = platform === 'win32' ? 'powershell' : 'posix' const plannedArgs = planAgentCliArgsSuffix(args.agentArgs, shell) if (!plannedArgs.ok) { @@ -93,6 +97,7 @@ export function planSourceControlAgentActionLaunch(args: { prompt: '', cmdOverrides, platform, + isRemote, agentArgs: args.agentArgs, allowEmptyPromptLaunch: true }) @@ -103,6 +108,7 @@ export function planSourceControlAgentActionLaunch(args: { draft: trimmedInput, cmdOverrides, platform, + isRemote, agentArgs: args.agentArgs }) if (draftLaunchPlan) { @@ -124,6 +130,7 @@ export function planSourceControlAgentActionLaunch(args: { prompt: '', cmdOverrides, platform, + isRemote, agentArgs: args.agentArgs, allowEmptyPromptLaunch: true }) @@ -135,6 +142,7 @@ export function planSourceControlAgentActionLaunch(args: { prompt: '', cmdOverrides, platform, + isRemote, agentArgs: args.agentArgs, allowEmptyPromptLaunch: true }) @@ -145,6 +153,7 @@ export function planSourceControlAgentActionLaunch(args: { prompt: trimmedInput, cmdOverrides, platform, + isRemote, agentArgs: args.agentArgs, allowEmptyPromptLaunch: false }) diff --git a/src/renderer/src/lib/worktree-activation.ts b/src/renderer/src/lib/worktree-activation.ts index 6cef0500f..eb523f944 100644 --- a/src/renderer/src/lib/worktree-activation.ts +++ b/src/renderer/src/lib/worktree-activation.ts @@ -44,6 +44,7 @@ import { resolveTuiAgentLaunchEnv } from '../../../shared/tui-agent-launch-defaults' import { isTuiAgent } from '../../../shared/tui-agent-config' +import { repoIsRemote } from '../../../shared/agent-launch-remote' import { resumeSleepingAgentSessionsForWorktree } from '@/lib/resume-sleeping-agent-session' import { getLocalProjectExecutionRuntimeContext } from '@/lib/local-preflight-context' import { @@ -248,6 +249,7 @@ function buildCreatedAgentReopenStartup(worktree: Worktree): WorktreeStartupPayl agentArgs: resolveTuiAgentLaunchArgs(agent, state.settings?.agentDefaultArgs), agentEnv: resolveTuiAgentLaunchEnv(agent, state.settings?.agentDefaultEnv), platform: launchPlatform, + isRemote: repo ? repoIsRemote(repo) : false, allowEmptyPromptLaunch: true }) if (!startupPlan) { diff --git a/src/shared/agent-launch-remote.ts b/src/shared/agent-launch-remote.ts new file mode 100644 index 000000000..084828158 --- /dev/null +++ b/src/shared/agent-launch-remote.ts @@ -0,0 +1,11 @@ +/** + * Why: a repo reached over SSH runs the Orca CLI through the relay shim, which + * is always deployed as plain `orca` (Unix) / `orca.cmd` (Windows). The + * Linux-only `orca-ide` rename — which exists solely to avoid shadowing the + * GNOME Orca screen reader on a local desktop — must not be applied to those + * remotes, or `orca-ide claude-teams` lands on a PATH where it does not exist. + * `connectionId` is the SSH signal; WSL and local stay false. + */ +export function repoIsRemote(repo: { connectionId?: string | null }): boolean { + return Boolean(repo.connectionId) +} diff --git a/src/shared/tui-agent-config.ts b/src/shared/tui-agent-config.ts index fd41f1916..1f0df2ddd 100644 --- a/src/shared/tui-agent-config.ts +++ b/src/shared/tui-agent-config.ts @@ -348,7 +348,14 @@ export function getTuiAgentDetectCommands(config: TuiAgentConfig): string[] { export function getTuiAgentLaunchCommand( config: TuiAgentConfig, - platform: NodeJS.Platform + platform: NodeJS.Platform, + opts?: { isRemote?: boolean } ): string { + // Why: the SSH relay shim is always named `orca` on Unix, so the local-only + // `orca-ide` rename (avoids shadowing the GNOME Orca screen reader) must not + // leak to Linux remotes — the remote has no such desktop binary on PATH. + if (opts?.isRemote && platform === 'linux') { + return config.launchCmd + } return config.launchCmdByPlatform?.[platform] ?? config.launchCmd } diff --git a/src/shared/tui-agent-startup.test.ts b/src/shared/tui-agent-startup.test.ts index 78bd7a54b..18652cc41 100644 --- a/src/shared/tui-agent-startup.test.ts +++ b/src/shared/tui-agent-startup.test.ts @@ -102,6 +102,54 @@ describe('tui agent startup plans', () => { expect(plan?.launchCommand).toBe('orca-ide claude-teams') }) + it('uses the plain orca shim for Claude Agent Teams on Linux SSH remotes', () => { + // Why: the SSH relay deploys the CLI shim as `orca` (not the local-only + // `orca-ide` GNOME-screen-reader workaround), so a remote launch must not + // emit `orca-ide claude-teams` — that name is not on the remote PATH and + // `claude-teams` is rejected by the relay's CLI switch (issue #6500). + const plan = buildAgentStartupPlan({ + agent: 'claude-agent-teams', + prompt: '', + cmdOverrides: {}, + platform: 'linux', + isRemote: true, + allowEmptyPromptLaunch: true + }) + + expect(plan?.launchCommand).toBe('orca claude-teams') + }) + + it('keeps the Windows orca.cmd shim for Claude Agent Teams on SSH remotes', () => { + // Why: the Windows remote shim is also `orca.cmd`, matching the local + // win32 override, so remoteness must not alter the Windows command. + const plan = buildAgentStartupPlan({ + agent: 'claude-agent-teams', + prompt: '', + cmdOverrides: {}, + platform: 'win32', + isRemote: true, + allowEmptyPromptLaunch: true + }) + + expect(plan?.launchCommand).toBe('orca.cmd claude-teams') + }) + + it('keeps the Linux orca-ide wrapper for local (non-remote) Claude Agent Teams', () => { + // Why: the `orca-ide` rename is still required for a local Linux desktop + // install (avoids shadowing the GNOME Orca screen reader), so an explicit + // isRemote:false must preserve it. + const plan = buildAgentStartupPlan({ + agent: 'claude-agent-teams', + prompt: '', + cmdOverrides: {}, + platform: 'linux', + isRemote: false, + allowEmptyPromptLaunch: true + }) + + expect(plan?.launchCommand).toBe('orca-ide claude-teams') + }) + it('launches OpenClaude as a distinct argv agent', () => { const plan = buildAgentStartupPlan({ agent: 'openclaude', diff --git a/src/shared/tui-agent-startup.ts b/src/shared/tui-agent-startup.ts index a5e691543..30ca71132 100644 --- a/src/shared/tui-agent-startup.ts +++ b/src/shared/tui-agent-startup.ts @@ -37,9 +37,14 @@ function resolveBaseCommand(args: { platform: NodeJS.Platform shell: AgentStartupShell agentArgs?: string | null + isRemote?: boolean }): { ok: true; command: string } | { ok: false; error: string } { const override = args.cmdOverrides[args.agent] - const command = override || getTuiAgentLaunchCommand(TUI_AGENT_CONFIG[args.agent], args.platform) + const command = + override || + getTuiAgentLaunchCommand(TUI_AGENT_CONFIG[args.agent], args.platform, { + isRemote: args.isRemote + }) const suffix = planAgentCliArgsSuffix(args.agentArgs, args.shell) if (!suffix.ok) { return suffix @@ -72,6 +77,9 @@ export function buildAgentStartupPlan(args: { allowEmptyPromptLaunch?: boolean agentArgs?: string | null agentEnv?: Record | null + /** Why: SSH remotes deploy the CLI shim as plain `orca`, so the Linux-only + * `orca-ide` rename must be skipped for remote launches. */ + isRemote?: boolean }): AgentStartupPlan | null { const { agent, prompt, cmdOverrides, platform, allowEmptyPromptLaunch = false } = args const shell = resolveStartupShell(platform, args.shell) @@ -82,7 +90,8 @@ export function buildAgentStartupPlan(args: { cmdOverrides, platform, shell, - agentArgs: args.agentArgs + agentArgs: args.agentArgs, + isRemote: args.isRemote }) if (!baseCommand.ok) { return null @@ -172,6 +181,8 @@ export function buildAgentResumeStartupPlan(args: { agentArgs?: string | null agentEnv?: Record | null agentCommand?: string | null + /** Why: see buildAgentStartupPlan — remote launches use the plain `orca` shim. */ + isRemote?: boolean }): AgentStartupPlan | null { const argv = getAgentResumeArgv(args.agent, args.providerSession) if (!argv) { @@ -187,7 +198,8 @@ export function buildAgentResumeStartupPlan(args: { cmdOverrides: args.cmdOverrides, platform: args.platform, shell, - agentArgs: args.agentArgs + agentArgs: args.agentArgs, + isRemote: args.isRemote }) if (!baseCommand.ok) { return null @@ -244,6 +256,8 @@ export function buildAgentDraftLaunchPlan(args: { shell?: AgentStartupShell agentArgs?: string | null agentEnv?: Record | null + /** Why: see buildAgentStartupPlan — remote launches use the plain `orca` shim. */ + isRemote?: boolean }): AgentDraftLaunchPlan | null { const { agent, draft, cmdOverrides, platform } = args const shell = resolveStartupShell(platform, args.shell) @@ -257,7 +271,8 @@ export function buildAgentDraftLaunchPlan(args: { cmdOverrides, platform, shell, - agentArgs: args.agentArgs + agentArgs: args.agentArgs, + isRemote: args.isRemote }) if (!baseCommand.ok) { return null