Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ to avoid duplicate Mobile Dev servers. See [Cursor's plugin guide](https://curso
### Mac app

The Mac app shows the devices and tools in their own window, without a chat. Pick
a tool and the visible platforms in the sidebar. It runs the same server as the
a tool in the sidebar and devices from **+ Add device** in the tab strip. It runs the same server as the
plugins, so the device panels, logs, performance, storage, and TraceSift work the
same way. Chat actions such as Send to chat and annotations are hidden because
there is no chat to send to.
Expand Down Expand Up @@ -216,7 +216,7 @@ its device panel, inspection, logs, and performance tools.
Ask your agent to open the simulator beside this chat. In Codex, you can also
open Mobile Dev from the sidebar; in Cursor, ask **"Open Mobile Dev"** in an agent chat.
Pick a device from the toolbar; selecting a stopped simulator or AVD
boots it. Use the iOS and Android toggles to show either platform or both.
boots it. Choose additional iOS or Android devices from **+ Add device** in the tab strip to open them side by side. Drag a device tab to an edge to split the view, or into another group to collect its tabs.

Click an iOS simulator or Android screen to focus it, then press **Ctrl+V** on Windows or **Command-V** on macOS to
paste text into the device. Paste accepts up to 4,096 printable US-ASCII characters;
Expand Down
2 changes: 1 addition & 1 deletion THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Native helpers statically link [Sentry Native 0.17.1](https://github.com/getsent

This plugin also includes [agent-device 0.21.37](https://github.com/callstack/agent-device/tree/v0.21.37) by Callstack under the MIT License. Its license sits at `dist/agent-device/node_modules/agent-device/LICENSE`. The package includes the official npm release, its Apple runner source, and its bundled JavaScript dependencies. `runtimes/agent-device/package-lock.json` pins the package and its integrity hash. `dist/agent-device/release.json` records the npm archive, integrity hash, and lockfile SHA-256. The agent-device skill's workflow guide, `skills/agent-device/references/workflow.md`, is that CLI version's `help workflow` output.

The Baguette MCP server and panel bundle the Model Context Protocol SDK, MCP Apps SDK, OpenAI MCP Extensions, Zod, ws, React, Radix UI, Legend List, Sentry's React and Node SDKs, and their required JavaScript code. The panel uses shadcn/ui components under the MIT License and Tailwind CSS styles. It bundles Lucide icons under the ISC License, with Feather icons under the MIT License and Inter under the SIL Open Font License 1.1. `dist/third-party-licenses.txt` contains their licenses. The build preserves bundled license comments too.
The Baguette MCP server and panel bundle the Model Context Protocol SDK, MCP Apps SDK, OpenAI MCP Extensions, Zod, ws, React, Radix UI, Legend List, Sentry's React and Node SDKs, and their required JavaScript code. The panel uses Dockview and shadcn/ui components under the MIT License and Tailwind CSS styles. It bundles Lucide icons under the ISC License, with Feather icons under the MIT License and Inter under the SIL Open Font License 1.1. `dist/third-party-licenses.txt` contains their licenses. The build preserves bundled license comments too.

This plugin includes [serve-emu 0.0.6](https://github.com/jiunshinn/serve-emu) by jiunshinn under the Apache License 2.0. Its server source is checked in at `runtimes/serve-emu/src`; the fork, dependencies, and licenses ship in `dist/serve-emu`. `runtimes/serve-emu/upstream.json` records the copied release's npm tarball and integrity hash. `runtimes/serve-emu/package-lock.json` pins the fork’s Node dependencies and integrity hashes. `dist/serve-emu/release.json` records these hashes and the SHA-256 of the bundled [scrcpy 4.0 server](https://github.com/Genymobile/scrcpy/releases/tag/v4.0), also under the Apache License 2.0. The plugin includes a source fork with a Node.js port of serve-emu's CLI and HTTP/WebSocket server, using the bundled MIT-licensed ws library. Its scrcpy protocol, input queues, and session recovery are preserved.

Expand Down
20 changes: 8 additions & 12 deletions apps/codex-plugin/test/workspace-opening.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ for (const notification of ["input", "result"] as const) test(`workspace applies
}
if (notification === "input") {
const captured = telemetry.join("\n");
assert.match(captured, /ui\.devices\.visible/);
assert.match(captured, /"device_platform":\{"value":"android"/);
assert.match(captured, /"device_kind":\{"value":"emulator"/);
assert.match(captured, /"layout":\{"value":"android"/);
Expand All @@ -117,16 +118,11 @@ for (const notification of ["input", "result"] as const) test(`workspace applies
else send({ method: "ui/notifications/tool-result", params: { content: [], structuredContent: { panelTarget: target } } });
await until(() => calls.includes("mobile_list_android_devices"));
await until(() => {
const label = window.document.getElementById("platform-select")?.textContent ?? "";
return label.includes("Android");
const label = window.document.querySelector('[data-device-pane][data-platform="android"]')?.getAttribute("aria-label");
return label === "Pixel";
});
await setTimeout(10);
const ios = window.document.getElementById("ios-panel");
const android = window.document.getElementById("android-panel");
assert.equal(ios?.hidden, true);
assert.equal(android?.hidden, false);
const devices = android?.querySelector('[data-element="devices"]')?.textContent ?? "";
assert.match(devices, /Pixel/);
assert.equal(window.document.querySelectorAll("[data-device-pane]").length, 1);
assert.equal(window.document.querySelector('[data-platform="ios"]'), null);
const unexpected = calls.filter(name => name.endsWith("_stream_session") || name.startsWith("mobile_boot"));
assert.deepEqual(unexpected, []);
if (nativeComposer) {
Expand All @@ -142,9 +138,9 @@ for (const notification of ["input", "result"] as const) test(`workspace applies
window.dispatchEvent(new window.Event("focus"));
await until(() => reports.length === 4);
assert.deepEqual(reports[3], selected, "Refocusing restores the selection even after the server restarts");
window.document.getElementById("platform-select")?.click();
await until(() => window.document.getElementById("platform-android") !== null);
window.document.getElementById("platform-android")?.click();
const closeTab = window.document.querySelector<HTMLElement>('[role="tab"] [role="button"], [role="tab"] button');
assert.ok(closeTab);
closeTab.click();
await until(() => reports.at(-1)?.devices?.length === 0);
const cleared = reports.at(-1);
assert.deepEqual(cleared?.devices, []);
Expand Down
2 changes: 1 addition & 1 deletion apps/codex-plugin/tooling/smoke-package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ try {
assert.equal(resource.contents[0].mimeType, "text/html;profile=mcp-app");
assert.ok(resource.contents[0].text.includes('id="root"'));
// React creates these controls from the bundled script after the app mounts.
for (const control of ["canvas", "logs-drawer", "log-chat", "tool-select", "tool-performance", "tool-app-intel", "app-intelligence-panel", "tool-tracesift", "performance-drawer", "performance-app", "platform-select", "simulator-panels"]) {
for (const control of ["canvas", "logs-drawer", "log-chat", "tool-select", "tool-performance", "tool-app-intel", "app-intelligence-panel", "tool-tracesift", "performance-drawer", "performance-app", "data-device-add", "simulator-panels"]) {
assert.ok(resource.contents[0].text.includes(control), `Missing bundled UI control: ${control}`);
}
assert.ok(!resource.contents[0].text.includes("<!-- APP_SCRIPT -->"));
Expand Down
19 changes: 0 additions & 19 deletions apps/mac/Sources/MobileDev/DeviceLayout.swift

This file was deleted.

8 changes: 2 additions & 6 deletions apps/mac/Sources/MobileDev/PageBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ final class PageBridge: NSObject, WKScriptMessageHandler {
webView.evaluateJavaScript("window.mobileDevShell?.selectTool(\(argument))", completionHandler: nil)
}

func select(layout: DeviceLayout) {
webView.evaluateJavaScript("window.mobileDevShell?.selectLayout('\(layout.rawValue)')", completionHandler: nil)
}

func setTitlebarInset(_ size: CGSize) {
webView.evaluateJavaScript("window.mobileDevShell?.setTitlebarInset(\(size.width), \(size.height))", completionHandler: nil)
func setTitlebarHeight(_ height: CGFloat) {
webView.evaluateJavaScript("window.mobileDevShell?.setTitlebarHeight(\(height))", completionHandler: nil)
}

func userContentController(_ controller: WKUserContentController, didReceive message: WKScriptMessage) {
Expand Down
5 changes: 0 additions & 5 deletions apps/mac/Sources/MobileDev/ShellMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
enum ShellMessage {
/// The page connected to the server and its device panels are available.
case ready
/// The page chose a layout itself, for example after the server opened a device.
case layout(DeviceLayout)
case error(String)

init?(body: Any) {
guard let fields = body as? [String: Any], let type = fields["type"] as? String else { return nil }
switch type {
case "ready":
self = .ready
case "layout":
guard let raw = fields["layout"] as? String, let layout = DeviceLayout(rawValue: raw) else { return nil }
self = .layout(layout)
case "error":
self = .error(fields["message"] as? String ?? "The page reported an error.")
default:
Expand Down
8 changes: 0 additions & 8 deletions apps/mac/Sources/MobileDev/SidebarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ struct SidebarView: View {
Label(tool.title, systemImage: tool.systemImage).tag(tool)
}
}
Section("Devices") {
Toggle(isOn: Binding(get: { model.layout.showsIOS }, set: { model.setShowsIOS($0) })) {
Label("iOS", systemImage: "iphone")
}
Toggle(isOn: Binding(get: { model.layout.showsAndroid }, set: { model.setShowsAndroid($0) })) {
Label("Android", systemImage: "candybarphone")
}
}
}
.listStyle(.sidebar)
.safeAreaInset(edge: .bottom) { ServerStatusView(model: model) }
Expand Down
4 changes: 1 addition & 3 deletions apps/mac/Sources/MobileDev/WindowControls.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import CoreGraphics

/// The area the traffic lights and the system sidebar button cover at the top-left
/// of the detail column once the sidebar is collapsed, in points.
/// Height reserved for the native window controls when the sidebar is collapsed.
enum WindowControls {
static let width: CGFloat = 144
static let height: CGFloat = 52
}
16 changes: 1 addition & 15 deletions apps/mac/Sources/MobileDev/WorkspaceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import os
@Observable
final class WorkspaceModel {
private(set) var tool: Tool? = .logs
/// The page chooses the first layout from the devices it finds and reports it.
private(set) var layout: DeviceLayout = .none
private(set) var status: ServerStatus = .starting {
didSet { log.info("Status: \(self.status.label, privacy: .public)") }
}
Expand All @@ -33,12 +31,9 @@ final class WorkspaceModel {
/// Moves the page's top-left controls clear of the window controls while the sidebar is collapsed.
func setSidebarVisible(_ visible: Bool) {
sidebarVisible = visible
page.setTitlebarInset(visible ? .zero : CGSize(width: WindowControls.width, height: WindowControls.height))
page.setTitlebarHeight(visible ? 0 : WindowControls.height)
}

func setShowsIOS(_ shows: Bool) { select(layout: DeviceLayout(showsIOS: shows, showsAndroid: layout.showsAndroid)) }
func setShowsAndroid(_ shows: Bool) { select(layout: DeviceLayout(showsIOS: layout.showsIOS, showsAndroid: shows)) }

/// Restarts the server and reloads the page, for example after the server exits.
func restart() {
server?.stop()
Expand All @@ -48,12 +43,6 @@ final class WorkspaceModel {

func stop() { server?.stop() }

private func select(layout: DeviceLayout) {
guard layout != self.layout else { return }
self.layout = layout
page.select(layout: layout)
}

private func start() {
status = .starting
let process: ServerProcess
Expand Down Expand Up @@ -98,9 +87,6 @@ final class WorkspaceModel {
page.select(tool: tool)
setSidebarVisible(sidebarVisible)
SmokeSnapshot.capture(page.webView)
case .layout(let layout):
// The page already applied this layout; reflect it without sending it back.
self.layout = layout
case .error(let message):
status = .failed(message)
}
Expand Down
1 change: 0 additions & 1 deletion apps/mac/web/mac-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { PLUGIN_VERSION } from "@mobile-dev/shared/version.ts";

type ShellMessage =
| { type: "ready" }
| { type: "layout"; layout: string }
| { type: "tool"; tool: string }
| { type: "error"; message: string };

Expand Down
54 changes: 17 additions & 37 deletions apps/mac/web/mac-workspace.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,35 @@
import { useEffect } from "react";
import { useEffect, useSyncExternalStore } from "react";
import { useGroupRef } from "react-resizable-panels";
import type { ToolName, WorkspaceTools } from "@mobile-dev/ui/workspace-tools.ts";
import type { DeviceLayout } from "@mobile-dev/ui/device-layout.ts";
import type { DeviceWorkspace } from "@mobile-dev/ui/device-workspace.ts";
import { LogsView } from "@mobile-dev/ui/components/logs-view.tsx";
import { PerformanceView } from "@mobile-dev/ui/components/performance-view.tsx";
import { SimulatorView } from "@mobile-dev/ui/components/simulator-view.tsx";
import { DevicePicker, EmptyDeviceTabBar } from "@mobile-dev/ui/components/device-picker.tsx";
import { DevicePanes } from "@mobile-dev/ui/components/device-panes.tsx";
import { StorageView } from "@mobile-dev/ui/components/storage-view.tsx";
import { TraceSiftView } from "@mobile-dev/ui/components/tracesift-view.tsx";
import { AppIntelligenceView } from "@mobile-dev/ui/components/app-intelligence-view.tsx";
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@mobile-dev/ui/components/ui/resizable.tsx";


/**
* The Mac app's content area. The native sidebar chooses the tool and the visible
* platforms, so this view has no toolbar of its own: a tool on the left, the
* device panels on the right. Both device panels stay mounted, because their
* controllers attach to the DOM once.
*/
export function MacWorkspace({ panels, tool, layout }: { panels: WorkspaceTools; tool?: ToolName; layout: DeviceLayout }) {
export function MacWorkspace({ panels, tool, devices }: { panels: WorkspaceTools; tool?: ToolName; devices: DeviceWorkspace }) {
const workspaceGroup = useGroupRef();
const deviceGroup = useGroupRef();
const state = useSyncExternalStore(devices.subscribe, devices.getSnapshot);
const hasDevices = state.panes.length > 0;
const size = tool === undefined ? 100 : Math.min(80, state.visible.length * 40);
useEffect(() => {
const devices = layout === "none" ? 0 : tool === undefined ? 100 : 40;
workspaceGroup.current?.setLayout({ "mac-tools": 100 - devices, "mac-devices": devices });
if (layout !== "none") deviceGroup.current?.setLayout({ "mac-ios": layout === "android" ? 0 : layout === "both" ? 50 : 100, "mac-android": layout === "ios" ? 0 : layout === "both" ? 50 : 100 });
}, [tool, layout]);
const leading = tool !== undefined ? "tool" : layout === "android" ? "android" : "ios";
const leadingClass = (panel: string) => panel === leading ? "mac-leading h-full" : "h-full";
workspaceGroup.current?.setLayout({ "mac-tools": 100 - size, "mac-devices": size });
}, [size]);
const toolView = tool === "logs" ? <LogsView panel={panels.logs} />
: tool === "performance" ? <PerformanceView panel={panels.performance} />
: tool === "storage" ? <StorageView panel={panels.storage} />
: tool === "app-intel" ? <AppIntelligenceView panel={panels["app-intel"]} />
: tool === "tracesift" ? <TraceSiftView panel={panels.tracesift} />
: <EmptyTool layout={layout} />;
return <main className="flex h-dvh flex-col">
: tool === "tracesift" ? <TraceSiftView panel={panels.tracesift} /> : null;
return <DevicePicker workspace={devices}><main className="mac-workspace flex h-dvh flex-col">
{!hasDevices && <EmptyDeviceTabBar />}
<ResizablePanelGroup id="mac-workspace" groupRef={workspaceGroup} orientation="horizontal" className="min-h-0 flex-1">
<ResizablePanel id="mac-tools" defaultSize="60%" minSize="0px" collapsible collapsedSize="0px"><div className={leadingClass("tool")}>{toolView}</div></ResizablePanel>
<ResizableHandle hidden={layout === "none" || tool === undefined} aria-label="Resize tool and devices" />
<ResizablePanel id="mac-devices" defaultSize="40%" minSize="0px" collapsible collapsedSize="0px">
<ResizablePanelGroup id="mac-device-panels" groupRef={deviceGroup} orientation="horizontal" className="h-full" aria-label="Devices">
<ResizablePanel id="mac-ios" defaultSize="100%" minSize="0px" collapsible collapsedSize="0px"><div className={leadingClass("ios")}><SimulatorView platform="ios" visible={layout === "ios" || layout === "both"} /></div></ResizablePanel>
<ResizableHandle hidden={layout !== "both"} disabled={layout !== "both"} aria-label="Resize iOS and Android devices" />
<ResizablePanel id="mac-android" defaultSize="0%" minSize="0px" collapsible collapsedSize="0px"><div className={leadingClass("android")}><SimulatorView platform="android" visible={layout === "android" || layout === "both"} /></div></ResizablePanel>
</ResizablePanelGroup>
</ResizablePanel>
<ResizablePanel id="mac-tools" defaultSize="60%" minSize="0px" collapsible collapsedSize="0px">{toolView}</ResizablePanel>
<ResizableHandle hidden={!hasDevices || tool === undefined} aria-label="Resize tool and devices" />
<ResizablePanel id="mac-devices" defaultSize="40%" minSize="0px" collapsible collapsedSize="0px"><DevicePanes workspace={devices} /></ResizablePanel>
</ResizablePanelGroup>
</main>;
}

function EmptyTool({ layout }: { layout: DeviceLayout }) {
return <div className="flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground">
{layout === "none" ? "Choose a device platform or a tool in the sidebar." : "Choose a tool in the sidebar."}
</div>;
</main></DevicePicker>;
}
13 changes: 2 additions & 11 deletions apps/mac/web/mac.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
/* While the native sidebar is collapsed, the window's traffic lights and sidebar
button sit over the page's top-left corner. Swift sets --mac-titlebar-inset to
their width, and the leading panel's top row makes room for them. */
.mac-leading .panel-toolbar {
padding-left: calc(var(--mac-titlebar-inset, 0px) + 0.5rem);
transition: padding-left 150ms ease;
}
/* Views without a toolbar row, such as TraceSift, move below the controls instead. */
.mac-leading:not(:has(.panel-toolbar)) {
padding-top: var(--mac-titlebar-height, 0px);
}
/* Keep the tab strip clear of native window controls when the sidebar collapses. */
.mac-workspace { padding-top: var(--mac-titlebar-height, 0px); }
Loading
Loading