Skip to content

Commit f1f454b

Browse files
committed
refactor(react-devtools): make react-devtools the built-in performance profiler only
1 parent 4858c54 commit f1f454b

36 files changed

Lines changed: 121 additions & 1254 deletions

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ See the [Node.js API](https://oss.callstack.com/agent-device/docs/client-api), t
118118

119119
## What agents can do
120120

121-
- **Inspect app state** through accessibility snapshots, refs, selectors, and React Native component trees.
121+
- **Inspect app state** through accessibility snapshots, refs, and selectors, and profile React Native renders to find what makes an interaction slow.
122122
- **Act on visible UI** by tapping or pressing elements, filling fields, scrolling, making gestures, waiting, asserting state, and handling alerts.
123123
- **Diagnose failures** with screenshots, video, logs, traces, network data, performance samples, crash details, and React profiles.
124124
- **Repeat workflows** by saving working steps as `.ad` scripts for local use or CI. Export strict Maestro YAML when needed.

‎docs/adr/0029-daemon-policy.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Accepted (2026-09-29).
4747
- public commands, by their own name;
4848
- internal commands with platform execution, by the public command their
4949
`catalog.servesPublicCommand` names (`install_source` as `install-from-source`), or else by
50-
their own name (`runtime`, which `react-devtools` and Maestro flows send);
50+
their own name (`runtime`, which Maestro flows send);
5151
- internal commands with no platform execution (leases, `human_control`, session bookkeeping) are
5252
protocol plumbing that no rule decides;
5353
- any other name is decided by the rules, so an allow list fails closed for it.

‎packages/command-registry/src/registry.ts‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,13 +1814,6 @@ export const RAW_COMMAND_DESCRIPTORS = [
18141814
timeoutPolicy: DEFAULT_TIMEOUT_POLICY,
18151815
batchable: false,
18161816
mcpExposed: false,
1817-
// Wave 6 residue: `react-devtools start` on a Limrun Android instance dispatches internal
1818-
// `runtime port-reverse` through the CLI-injected dispatch seam. `runtime` is itself fully
1819-
// migrated (`device-runtime`, R31), so the dispatched execution is accounted for under its
1820-
// own descriptor rather than hidden behind this one — this route owns no unmigrated platform
1821-
// execution of its own. The CLI-route dominance gate
1822-
// (`__tests__/platform-execution-cli-route.test.ts`) still rejects a `none` route whose
1823-
// CLI-injected dispatch target is still `legacy`.
18241817
platformExecution: NO_PLATFORM_EXECUTION,
18251818
},
18261819
{
@@ -1921,8 +1914,7 @@ type Equal<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;
19211914
* Compile-time literalness of {@link Command}. The `as const` on {@link RAW_COMMAND_DESCRIPTORS}
19221915
* keeps each descriptor's literal `name` through the composition and the `.map` above; an array
19231916
* that lost it would widen this union to `string`, and nothing downstream would say so:
1924-
* `COMMAND_DEFAULTS` below and `Record<DescriptorCliCommandName, …>` in
1925-
* `src/cli/injected-daemon-dispatch.ts` stop rejecting an unknown key, and the `command: Command`
1917+
* `COMMAND_DEFAULTS` below stops rejecting an unknown key, and the `command: Command`
19261918
* parameters in `src/cli/command-explain.ts` and `owner-files.ts` would stop excluding a name no
19271919
* descriptor declares. That silence is why this is a type guard and not a value comparison.
19281920
*/

‎skills/android-emulator/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ Only when the task is specialized or a command shape is unclear, read the releva
2727
agent-device help validate # engineering validation and build freshness
2828
agent-device help debugging # screenshots, logs, traces, video, and failures
2929
agent-device help react-native # React Native and Expo runtime guidance
30-
agent-device help react-devtools # render profiles, component tree, props/state/hooks
30+
agent-device help react-devtools # React Native performance profiling
3131
agent-device help scripting # durable replay and CI workflows
3232
```

‎skills/ios-simulator/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ Only when the task is specialized or a command shape is unclear, read the releva
2727
agent-device help validate # engineering validation and build freshness
2828
agent-device help debugging # screenshots, logs, traces, video, and failures
2929
agent-device help react-native # React Native and Expo runtime guidance
30-
agent-device help react-devtools # render profiles, component tree, props/state/hooks
30+
agent-device help react-devtools # React Native performance profiling
3131
agent-device help scripting # durable replay and CI workflows
3232
```

‎src/__tests__/cli-help.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ test('help react-devtools prints agent workflow topic and skips daemon dispatch'
6565
assert.equal(result.code, 0);
6666
assert.equal(result.calls.length, 0);
6767
assert.match(result.stdout, /^agent-device \S+ — react-devtools/);
68-
assert.match(result.stdout, /React Native render performance/);
69-
assert.match(result.stdout, /agent-device react-devtools status/);
68+
assert.match(result.stdout, /React Native performance profiling/);
69+
assert.match(result.stdout, /agent-device react-devtools profile start/);
7070
});
7171

7272
test('help workflow prints the compact workflow card with a version header and skips daemon dispatch', async () => {

‎src/__tests__/cli-react-devtools-session.test.ts‎

Lines changed: 4 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,12 @@ import {
1515
hashRemoteConfigFile,
1616
writeRemoteConnectionState,
1717
} from '../remote/remote-connection-state.ts';
18-
import type {
19-
DaemonRequest,
20-
DaemonResponse,
21-
sendToDaemon as SendToDaemon,
22-
} from '../daemon-client/daemon-client.ts';
18+
import type { DaemonResponse } from '../daemon-client/daemon-client.ts';
2319

2420
afterEach(() => {
2521
vi.clearAllMocks();
2622
});
2723

28-
function createLimrunConnectionFixture(): { tempRoot: string; stateDir: string } {
29-
const tempRoot = mkdtempForTestSync('agent-device-react-devtools-limrun-');
30-
const stateDir = path.join(tempRoot, 'state');
31-
const remoteConfigPath = path.join(tempRoot, 'limrun.json');
32-
fs.writeFileSync(remoteConfigPath, JSON.stringify({ platform: 'android' }));
33-
writeRemoteConnectionState({
34-
stateDir,
35-
state: {
36-
version: 1,
37-
session: 'limrun-android',
38-
remoteConfigPath,
39-
remoteConfigHash: hashRemoteConfigFile(remoteConfigPath),
40-
daemon: {},
41-
tenant: 'limrun',
42-
runId: 'run-1',
43-
leaseId: 'lease-1',
44-
leaseBackend: 'android-instance',
45-
leaseProvider: 'limrun',
46-
platform: 'android',
47-
connectedAt: new Date().toISOString(),
48-
updatedAt: new Date().toISOString(),
49-
},
50-
});
51-
return { tempRoot, stateDir };
52-
}
53-
5424
test('react-devtools uses active remote connection session after defaults are merged', async () => {
5525
const tempRoot = mkdtempForTestSync('agent-device-react-devtools-session-');
5626
const stateDir = path.join(tempRoot, 'state');
@@ -92,7 +62,9 @@ test('react-devtools uses active remote connection session after defaults are me
9262
const sendToDaemon = async (): Promise<DaemonResponse> => ({ ok: true, data: {} });
9363

9464
try {
95-
await runCli(['react-devtools', 'status', '--state-dir', stateDir], { sendToDaemon });
65+
await runCli(['react-devtools', 'profile', 'status', '--state-dir', stateDir], {
66+
sendToDaemon,
67+
});
9668
} finally {
9769
restoreEnv();
9870
process.exit = originalExit;
@@ -103,66 +75,3 @@ test('react-devtools uses active remote connection session after defaults are me
10375
assert.equal(vi.mocked(runReactDevtoolsCommand).mock.calls.length, 1);
10476
assert.equal(vi.mocked(runReactDevtoolsCommand).mock.calls[0]?.[1]?.session, 'adc-android');
10577
});
106-
107-
test('react-devtools starts Limrun port reverse through the daemon', async () => {
108-
const { tempRoot, stateDir } = createLimrunConnectionFixture();
109-
const originalExit = process.exit;
110-
let exitCode: number | undefined;
111-
const restoreEnv = installIsolatedCliTestEnv();
112-
(process as any).exit = ((code?: number) => {
113-
exitCode = code ?? 0;
114-
}) as typeof process.exit;
115-
const requests: Array<Omit<DaemonRequest, 'token'>> = [];
116-
const transportOptions: Array<Parameters<typeof SendToDaemon>[1]> = [];
117-
const sendToDaemon = async (
118-
request: Omit<DaemonRequest, 'token'>,
119-
options?: Parameters<typeof SendToDaemon>[1],
120-
): Promise<DaemonResponse> => {
121-
requests.push(request);
122-
transportOptions.push(options);
123-
return { ok: true, data: {} };
124-
};
125-
vi.mocked(runReactDevtoolsCommand).mockImplementationOnce(async (_args, options) => {
126-
assert.ok(options?.configureDirectPortReverse);
127-
await options.configureDirectPortReverse();
128-
return 0;
129-
});
130-
131-
try {
132-
await runCli(
133-
[
134-
'react-devtools',
135-
'start',
136-
'--state-dir',
137-
stateDir,
138-
'--daemon-auth-token',
139-
'synthetic-direct-token',
140-
],
141-
{ sendToDaemon },
142-
);
143-
} finally {
144-
restoreEnv();
145-
process.exit = originalExit;
146-
fs.rmSync(tempRoot, { recursive: true, force: true });
147-
}
148-
149-
assert.equal(exitCode, 0);
150-
assert.equal(requests.length, 1);
151-
const request = requests[0];
152-
assert.ok(request);
153-
assert.equal(request.command, 'runtime');
154-
assert.deepEqual(request.positionals, ['port-reverse']);
155-
assert.equal(request.session, 'limrun-android');
156-
const flags = request.flags;
157-
assert.ok(flags);
158-
assert.equal(flags.platform, 'android');
159-
assert.equal(flags.leaseId, 'lease-1');
160-
assert.equal(flags.leaseProvider, 'limrun');
161-
assert.equal(flags.devicePort, 8097);
162-
assert.equal(flags.hostPort, 8097);
163-
assert.equal(flags.portReverseName, 'react-devtools');
164-
assert.equal(Object.hasOwn(flags, 'daemonAuthToken'), false);
165-
assert.deepEqual(transportOptions, [{ authToken: 'synthetic-direct-token' }]);
166-
const commandOptions = vi.mocked(runReactDevtoolsCommand).mock.calls[0]?.[1];
167-
assert.equal(Object.hasOwn(commandOptions?.flags ?? {}, 'daemonAuthToken'), false);
168-
});

0 commit comments

Comments
 (0)