Skip to content

Latest commit

 

History

History
45 lines (23 loc) · 11 KB

File metadata and controls

45 lines (23 loc) · 11 KB

Using devices

Back to README · Contributing

Platform setup

The plugin uses Codex's bundled Node runtime. iOS needs an Apple Silicon Mac with Xcode 26 or later and an installed simulator runtime. Baguette uses Apple's simulator frameworks. agent-device builds its bundled XCTest runner with Xcode on its first interaction and caches it under ~/.agent-device/apple-runner. The plugin carries all three runtimes, their npm dependencies, and the Apple runner source. It does not download code at runtime.

Physical iOS discovery requires Xcode 27 or later. It uses the selected Xcode installation's xcrun devicectl JSON output and needs no additional native library. Pair the phone with Xcode and enable wireless connectivity there to discover it over Wi-Fi.

The native panel targets Codex desktop, iOS simulators, and Android emulators or attached devices. The active Mobile Dev MCP server also works through stdio in a local MCP client. Use the selected UDID for iOS tools and the selected running serial for Android tools. This plugin does not build the user's app. Codex's permission and confirmation rules still apply to tool calls.

Android logs need adb from an installed Android SDK. The reader checks ANDROID_HOME, ANDROID_SDK_ROOT, ~/Library/Android/sdk, then PATH. Metro logs need an existing local Metro server and an app with an inspector target. The log tools connect to that server without starting it.

Device panel

Open a new chat after installing. Open Mobile Dev in the sidebar or call mobile_open_workspace for the fullscreen view. Call mobile_open_simulator for the panel beside a chat. iOS opens by default, including when an iOS device and an Android device are both running. Android opens instead when it has the only running device. Enable both platforms from the platform menu to show the panels side by side. Each panel has a device dropdown, Home, App Switcher, and Screenshot. Pick a device in each panel. In the sidebar panel, the bar under the simulators holds the tools menu on the left and the platform menu on the right; fullscreen shows them above the tools. Use the platform menu to show either, both, or neither simulator. Selecting a device boots it if needed, then connects its screen. A selected running device connects automatically. The panel uses Apple’s device bezel and screen mask from the installed DeviceKit assets, with a simple frame as a fallback when assets are unavailable. Use the settings button at the bottom right for appearance, text size, location, and the device frame. iOS also offers contrast; Android offers rotation. The menu shows only settings supported by the bundled backend. Click the screen to type or drag. Closing the panel closes its stream.

Use Select in the simulator toolbar to pause the screen. Hover to outline a component, then click to add a note. React Native development apps can supply runtime elements when accessibility omits a view. Drag to mark a region when neither source exposes it. Saved notes leave numbered blue bubbles. Notes attach text and available element details to your next chat message. The captured screen stays local for editing; annotations never attach screenshots. Click a bubble to edit or remove a note, or use Send to chat to send all notes for that device. If chat is unavailable, the panel keeps the notes and retries when you return. A sent or cleared batch starts again at 1.

The iOS dropdown shows Connected devices first, with USB or Wi-Fi labels, then Simulators. It refreshes every three seconds while the iOS panel is visible, and when opening the dropdown. Selecting a physical device opens interactive screen mirroring through its paired developer connection. The phone sends HEVC video; a bundled native Node-API addon assembles compressed frames and transfers them into Node without copying the frame payload, then the panel decodes them through WebCodecs. MCP serializes the compressed bytes as base64, so the full path is not zero copy. The capture queue is limited to eight frames or 4 MiB and requests a keyframe after overflow. Physical iOS supports pointer taps, long presses, and drags through CoreDevice UniversalHID on the same developer tunnel. Input starts after a fresh video frame, uses normalized touchscreen coordinates, and releases held touches when the stream closes or resets. Screenshot captures the displayed mirrored frame as a PNG, attaches it to chat, and copies the same image to the macOS clipboard. Select annotates screen regions using the mirrored frame's pixel coordinates; native accessibility component names are unavailable. Both controls require a connected device and a ready video frame. Keyboard and hardware-button controls remain disabled. CPU and memory monitoring can attach to an already running development app on a paired iOS 17.4+ device. Mirroring requires Developer Mode and a host with HEVC WebCodecs support. mobile_list_ios_devices also returns remembered disconnected devices with their connection state; the picker shows connected devices only. Discovery errors remain visible while available simulators continue to work.

Panels in multiple chats share one physical iOS capture through a local, per-user service. Each panel has an independent queue limited to eight frames or 4 MiB. Opening another panel requests a fresh keyframe without resetting the hardware stream or other panels’ decoders. A slow panel drops its own backlog and requests recovery when it resumes reading; other panels continue receiving frames. Closing a panel removes only its subscription. The final subscription closes the native capture, and the service exits after 30 idle seconds. Concurrent gestures are serialized, and a held touch belongs to the panel that started it. Device Hub runs its own hardware capture and cannot subscribe to this service; close its mirroring window while using Mobile Dev.

Physical iOS mirroring uses the same Apple DeviceKit bezel and framebuffer mask as the matching simulator model. Discovery preserves the hardware product type, which selects the installed Xcode device profile. The bundled Baguette CLI renders its bezel without starting a simulator, and macOS rasterizes its mask. These assets are cached per model outside the video path. A missing device profile or failed render reports an error before capture starts.

Ask the agent to inspect or control the app on the selected device. The panel shares both visible device IDs and platforms with the chat. Click a device panel to make it the active device for logs. Hiding a simulator keeps the current log source and buffered logs. Use Mobile Dev's screenshot, accessibility and input tools for the selected platform. Baguette streams iOS and serve-emu streams Android in the panel.

For mobile app development, the bundled skill tells the agent to open the panel beside the chat before the first device launch, or reuse an open panel. It covers iOS, Android, Expo, React Native, and SwiftUI work. The agent follows your device choice, reuses a suitable running device, or chooses and boots an installed simulator or AVD. It asks only when the choice changes what the task needs. The app project's own tools build, install, and launch the app on that device; the agent reuses an existing app dev server.

You can request fullscreen or a tool-only workflow. Planning, docs, code review, and compilation-only requests do not need a panel. Skill matching depends on the prompt and project context; the workflow cases cover the expected behavior in fresh chats.

Android

Install Android SDK platform-tools and emulator. Create an AVD in Android Studio or connect an Android device and authorize adb access. The Android panel lists devices without booting one. Selecting an AVD boots it if needed, then starts the bundled Node.js serve-emu CLI on a private loopback port. Home, Back, Recents, Lock, pointer gestures, and typing use scrcpy's control socket. Closing the panel leaves the emulator running. AVDs start without a separate emulator window. A failed emulator process reports its exit right away instead of waiting for the boot timeout.

The Android dropdown shows Connected devices first, with USB or Wi-Fi labels, then Emulators. It refreshes every three seconds while the Android panel is visible, and when opening the dropdown. Physical devices use ADB discovery: enable USB debugging and authorize the computer, or pair the device for wireless debugging. Offline and unauthorized devices remain visible with their state. Emulators keep their AVD name while unauthorized. An emulator restored from a quick-boot snapshot can stay unauthorized because adb does not repeat the key exchange; the panel reconnects adb at most every 5 seconds while an AVD boots, and for up to 15 seconds after you select an already running emulator. Selecting an authorized phone connects its screen and shares its serial and transport with the chat. Bundled scrcpy mirrors and controls the phone without installing a companion app. Physical Android devices support the existing screen, input, screenshot, native log, and performance tools; emulator boot and stop controls do not apply to them.

Android H.264 packets travel through MCP resource reads. The panel decodes them with WebCodecs, so the host must support H.264 VideoDecoder. Each device gets its own backend and each panel gets its own stream session. Decoder errors and video backlog request a fresh keyframe on the same connection. The panel drops delta frames until it can decode that keyframe. Requests have a cooldown, and stale decoder callbacks cannot repaint a closed stream. The plugin reuses a matching serve-emu server at port 3300. Set SERVE_EMU_URL to reuse another loopback HTTP server; it must already stream the selected serial. Closing MCP stops only backends the plugin started.

For tool use, call mobile_list_android_devices. It returns serials for connected devices and avd:<name> IDs for stopped AVDs. Boot a selected AVD with mobile_boot_android_emulator and use its returned running serial for later calls. mobile_shutdown_android_emulator stops an emulator. mobile_android_screenshot, mobile_android_describe_ui, and mobile_android_send_input inspect and control running devices. Gesture coordinates use screen pixels and matching screen width and height. Use the selected running serial with the Mobile Dev Android tools.

vendor:serve-emu installs the source fork’s pinned Node.js dependencies with package scripts disabled and checks the bundled scrcpy 4.0 server's SHA-256. build compiles the checked-in CLI for Node.js, copies the runtime, and records package integrity, lockfile hash, CLI hash, and scrcpy hash in dist/serve-emu/release.json. Starting Android requires no npm install or runtime download.

Click the camera button in either simulator toolbar to add a PNG to the chat input and copy it to the macOS clipboard. Each click adds another screenshot and keeps any attached log. Remove screenshots from the chat input to clear them. The button works while the selected simulator runs, including when the stream is paused. Physical iOS captures the displayed mirrored frame and requires a ready stream. It does not send a message.