Skip to content

Commit c24a63e

Browse files
committed
feat(cli): add --ui flag to inspect command for browser-based tree explorer
The terminal tree from inspect is useful for quick lookups but hard to navigate on complex screens with deep hierarchies. When a screen has 100+ nodes, scrolling through a flat terminal dump to find the right element is slow. The --ui flag opens a browser at localhost:9325 with a two-panel UI: the left panel shows the collapsible accessibility tree, the right panel shows the selected node's properties and ready-to-use locator code that can be copied to the clipboard with one click. Auto-refresh polls the device on a configurable interval (1s/2s/5s/10s) so the tree stays live as you navigate the app — no need to re-run the command for each screen. A manual Refresh button is always available when auto-refresh is off.
1 parent 76ce74e commit c24a63e

2 files changed

Lines changed: 446 additions & 2 deletions

File tree

packages/mobilewright/src/cli.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ensureMobilecliReachable } from './server.js';
1414
import { loadConfig } from './config.js';
1515
import { gatherChecks, renderTerminal, renderJSON } from './commands/doctor.js';
1616
import { runInspect, type InspectOptions } from './commands/inspect.js';
17+
import { runInspectUI } from './commands/inspect-ui.js';
1718
import { brandReport } from './reporter.js';
1819
import { telemetry } from './telemetry.js';
1920

@@ -256,8 +257,13 @@ program
256257
.option('-d, --device <id>', 'device ID (run "mobilewright devices" to list)')
257258
.option('--url <url>', 'mobilecli server URL', DEFAULT_URL)
258259
.option('--json', 'output raw ViewNode[] JSON instead of the terminal tree')
259-
.action(async (opts: InspectOptions) => {
260-
await runInspect(opts);
260+
.option('--ui', 'open an interactive browser UI with auto-refresh and locator copy')
261+
.action(async (opts: InspectOptions & { ui?: boolean }) => {
262+
if (opts.ui) {
263+
await runInspectUI(opts);
264+
} else {
265+
await runInspect(opts);
266+
}
261267
});
262268

263269
// ── install ───────────────────────────────────────────────────────

0 commit comments

Comments
 (0)