From 7d7ba1bb324e120aafb412d7b3f9f6f8dc342404 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Mon, 8 Jun 2026 16:47:04 -0700 Subject: [PATCH] fix: address review findings (#4920) --- .../settings/AgentSkillSetupPanel.tsx | 4 +- .../MobileEmulatorAgentControlRow.tsx | 221 ++++++++++++++++++ .../settings/MobileEmulatorExamples.tsx | 64 +++++ .../settings/MobileEmulatorSettingsPane.tsx | 3 + .../settings/mobile-emulator-search.ts | 8 + 5 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 src/renderer/src/components/settings/MobileEmulatorAgentControlRow.tsx create mode 100644 src/renderer/src/components/settings/MobileEmulatorExamples.tsx diff --git a/src/renderer/src/components/settings/AgentSkillSetupPanel.tsx b/src/renderer/src/components/settings/AgentSkillSetupPanel.tsx index f575ae269..9755b1b59 100644 --- a/src/renderer/src/components/settings/AgentSkillSetupPanel.tsx +++ b/src/renderer/src/components/settings/AgentSkillSetupPanel.tsx @@ -170,7 +170,7 @@ export function AgentSkillSetupPanel({ )} >
{leading} @@ -180,7 +180,7 @@ export function AgentSkillSetupPanel({
) : null}
-
+

{title}

{loading && !installed ? ( Checking... diff --git a/src/renderer/src/components/settings/MobileEmulatorAgentControlRow.tsx b/src/renderer/src/components/settings/MobileEmulatorAgentControlRow.tsx new file mode 100644 index 000000000..e9354b950 --- /dev/null +++ b/src/renderer/src/components/settings/MobileEmulatorAgentControlRow.tsx @@ -0,0 +1,221 @@ +import { useCallback, useEffect, useState } from 'react' +import { Import, Loader2 } from 'lucide-react' +import { toast } from 'sonner' +import type { CliInstallStatus } from '../../../../shared/cli-install-types' +import { + ORCA_CLI_SKILL_INSTALL_COMMAND, + ORCA_CLI_SKILL_NAME +} from '@/lib/agent-feature-install-commands' +import { + AGENT_SKILL_CLI_PREREQUISITE_NOTICE, + ensureOrcaCliAvailableForAgentSkillTerminal, + isOrcaCliAvailableOnPath +} from '@/lib/agent-skill-cli-prerequisite' +import { + GLOBAL_AGENT_SKILL_SOURCE_KINDS, + useInstalledAgentSkill +} from '@/hooks/useInstalledAgentSkills' +import { useMountedRef } from '@/hooks/useMountedRef' +import { AgentSkillSetupPanel } from './AgentSkillSetupPanel' +import { StepBadge } from './BrowserUseStepBadge' +import { MobileEmulatorExamples } from './MobileEmulatorExamples' +import { Button } from '../ui/button' +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip' + +const EMULATOR_CLI_COMMANDS = [ + 'orca emulator list --json', + 'orca emulator attach "iPhone 16 Pro" --json', + 'orca emulator tap 0.5 0.7 --json', + 'orca emulator type "hello" --json' +] as const + +function getCliActionLabel(status: CliInstallStatus | null, busy: boolean): string { + if (busy) { + return 'Registering...' + } + if (isOrcaCliAvailableOnPath(status)) { + return 'Enabled' + } + if (status?.state === 'installed') { + return 'Fix PATH' + } + return 'Enable' +} + +export function MobileEmulatorAgentControlRow(): React.JSX.Element { + const [cliInstallStatus, setCliInstallStatus] = useState(null) + const [cliLoading, setCliLoading] = useState(true) + const [cliBusy, setCliBusy] = useState(false) + const mountedRef = useMountedRef() + const { + installed: cliSkillInstalled, + loading: cliSkillLoading, + error: cliSkillError, + refresh: refreshCliSkill + } = useInstalledAgentSkill(ORCA_CLI_SKILL_NAME, { + sourceKinds: GLOBAL_AGENT_SKILL_SOURCE_KINDS + }) + + const refreshCliStatus = useCallback(async (): Promise => { + setCliLoading(true) + try { + setCliInstallStatus(await window.api.cli.getInstallStatus()) + } catch (error) { + if (mountedRef.current) { + toast.error(error instanceof Error ? error.message : 'Failed to load CLI status.') + } + setCliInstallStatus(null) + } finally { + if (mountedRef.current) { + setCliLoading(false) + } + } + }, [mountedRef]) + + useEffect(() => { + void refreshCliStatus() + }, [refreshCliStatus]) + + const cliEnabled = isOrcaCliAvailableOnPath(cliInstallStatus) + const cliSupported = cliInstallStatus?.supported ?? false + const completedCount = [cliEnabled, cliSkillInstalled].filter(Boolean).length + + const handleEnableCli = async (): Promise => { + setCliBusy(true) + try { + const next = await ensureOrcaCliAvailableForAgentSkillTerminal({ + onStatusChange: setCliInstallStatus + }) + if (mountedRef.current && isOrcaCliAvailableOnPath(next)) { + toast.success('Registered the Orca CLI in PATH.') + } + } finally { + if (mountedRef.current) { + setCliBusy(false) + } + } + } + + return ( +
+
+
+
+

Agent Mobile Emulator Control

+

+ Let coding agents control the active mobile emulator with Orca CLI commands. +

+
+ + {completedCount}/2 + +
+ +
+
+
+ +
+

Enable Orca CLI

+

+ Registers the Orca CLI command so agents can control the active emulator from + their shell. +

+ {cliInstallStatus?.commandPath && cliEnabled ? ( +

+ Installed at{' '} + + {cliInstallStatus.commandPath} + +

+ ) : null} + {!cliEnabled && cliInstallStatus?.detail ? ( +

{cliInstallStatus.detail}

+ ) : null} +
+ + + + + + + + {!cliSupported && !cliLoading && cliInstallStatus?.detail ? ( + + {cliInstallStatus.detail} + + ) : null} + + +
+
+ +
+ } + preInstallNotice={AGENT_SKILL_CLI_PREREQUISITE_NOTICE} + onBeforeOpenTerminal={async () => { + await ensureOrcaCliAvailableForAgentSkillTerminal({ + onStatusChange: setCliInstallStatus + }) + }} + onRecheck={refreshCliSkill} + /> +
+ +
+
+ +

Common emulator commands

+
+

+ Commands target the active emulator for the current worktree. Coordinates are + normalized from 0..1. +

+
+ {EMULATOR_CLI_COMMANDS.map((command) => ( + + {command} + + ))} +
+
+ + +
+
+
+ ) +} diff --git a/src/renderer/src/components/settings/MobileEmulatorExamples.tsx b/src/renderer/src/components/settings/MobileEmulatorExamples.tsx new file mode 100644 index 000000000..eff6d851c --- /dev/null +++ b/src/renderer/src/components/settings/MobileEmulatorExamples.tsx @@ -0,0 +1,64 @@ +import { Copy, Sparkles } from 'lucide-react' +import { toast } from 'sonner' +import { Button } from '../ui/button' +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip' + +const EMULATOR_EXAMPLE_PROMPTS = [ + 'Using Orca CLI, attach to the active iPhone simulator, sign in with the test account, complete onboarding, and tell me where the flow feels confusing.', + 'With Orca CLI, run through the mobile checkout flow from product search to confirmation, capture any broken screens, and summarize the exact step that fails.', + 'Using Orca CLI, grant camera permission, scan a test QR code or inject a camera fixture, finish the account-linking flow, and report whether the app reaches the success state.' +] as const + +async function copyPrompt(prompt: string): Promise { + try { + await window.api.ui.writeClipboardText(prompt) + toast.success('Copied prompt.') + } catch (error) { + toast.error(error instanceof Error ? error.message : 'Failed to copy prompt.') + } +} + +export function MobileEmulatorExamples(): React.JSX.Element { + return ( +
+
+ +

Try it — example prompts

+
+

+ Paste any of these into Claude Code, Codex, or another agent in a project where the Orca CLI + skill is installed. +

+
    + {EMULATOR_EXAMPLE_PROMPTS.map((prompt) => ( +
  • +

    + “{prompt}” +

    + + + + + + + Copy + + + +
  • + ))} +
+
+ ) +} diff --git a/src/renderer/src/components/settings/MobileEmulatorSettingsPane.tsx b/src/renderer/src/components/settings/MobileEmulatorSettingsPane.tsx index 68d151ab7..fb036d401 100644 --- a/src/renderer/src/components/settings/MobileEmulatorSettingsPane.tsx +++ b/src/renderer/src/components/settings/MobileEmulatorSettingsPane.tsx @@ -6,6 +6,7 @@ import { callRuntimeRpc } from '@/runtime/runtime-rpc-client' import { Badge } from '../ui/badge' import { Button } from '../ui/button' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select' +import { MobileEmulatorAgentControlRow } from './MobileEmulatorAgentControlRow' import { SearchableSetting } from './SearchableSetting' import { SettingsRow, SettingsSwitchRow } from './SettingsFormControls' import { MOBILE_EMULATOR_SEARCH_ENTRIES } from './mobile-emulator-search' @@ -210,6 +211,8 @@ export function MobileEmulatorSettingsPane({ } /> + + {enabled ? : null}
) diff --git a/src/renderer/src/components/settings/mobile-emulator-search.ts b/src/renderer/src/components/settings/mobile-emulator-search.ts index 9de97f69d..d169629cd 100644 --- a/src/renderer/src/components/settings/mobile-emulator-search.ts +++ b/src/renderer/src/components/settings/mobile-emulator-search.ts @@ -13,6 +13,9 @@ export const MOBILE_EMULATOR_SEARCH_ENTRIES: SettingsSearchEntry[] = [ 'ipad', 'xcode', 'serve-sim', + 'orca cli', + 'orca emulator', + 'emulator skill', 'default device', 'agent emulator' ] @@ -26,5 +29,10 @@ export const MOBILE_EMULATOR_SEARCH_ENTRIES: SettingsSearchEntry[] = [ title: 'Emulator Availability', description: 'Check whether Xcode, simctl, serve-sim, and emulator devices are ready.', keywords: ['availability', 'xcrun', 'simctl', 'xcode command line tools', 'runtime'] + }, + { + title: 'Agent CLI Control', + description: 'Use Orca CLI commands to list, attach, tap, and type into a mobile emulator.', + keywords: ['agent cli', 'emulator tap', 'emulator attach', 'emulator type', 'mobile skill'] } ]