Skip to content

Commit 987955a

Browse files
committed
fix(cli): quote stale status selectors
1 parent e3be0cd commit 987955a

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎src/__tests__/cli-device-status.test.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ test('keeps normal status compact while retaining proven-stale claims for explic
3939
JSON.stringify({
4040
schemaVersion: 1,
4141
deviceKey: 'local:android:none:stale',
42-
device: { platform: 'android', id: 'stale', name: 'Stale Pixel', kind: 'emulator' },
42+
device: {
43+
platform: 'android',
44+
id: 'stale',
45+
name: 'Stale Pixel; echo no',
46+
kind: 'emulator',
47+
},
4348
session: 'stale-session',
4449
workspace: '/worktrees/stale',
4550
stateDir: process.cwd(),
@@ -70,13 +75,16 @@ test('keeps normal status compact while retaining proven-stale claims for explic
7075
assert.equal(stale.calls.length, 0);
7176
const payload = JSON.parse(stale.stdout);
7277
assert.equal(payload.data.claims.length, 1);
73-
assert.equal(payload.data.claims[0].device.name, 'Stale Pixel');
78+
assert.equal(payload.data.claims[0].device.name, 'Stale Pixel; echo no');
7479
assert.equal(payload.data.claims[0].recovery, undefined);
7580

76-
const scoped = await runCliCapture(['device', 'status', '--serial', 'stale'], {
81+
const scoped = await runCliCapture(['device', 'status', '--device', 'Stale Pixel; echo no'], {
7782
env: { AGENT_DEVICE_CLAIMS_DIR: claimsDir },
7883
});
79-
assert.match(scoped.stdout, /inspect with: agent-device device status --serial stale --stale/);
84+
assert.match(
85+
scoped.stdout,
86+
/inspect with: agent-device device status --device 'Stale Pixel; echo no' --stale/,
87+
);
8088
} finally {
8189
fs.rmSync(claimsDir, { recursive: true, force: true });
8290
}

‎src/cli/commands/device.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
inspectDeviceClaims,
44
type InspectedDeviceClaim,
55
} from '../../daemon/device-claim-inspection.ts';
6+
import { shellQuoteIfNeeded } from '../../utils/shell-quote.ts';
67
import { writeCommandOutput } from './shared.ts';
78
import type { ClientCommandHandler } from './router-types.ts';
89

@@ -104,10 +105,10 @@ function buildStaleInspectionCommand(flags: {
104105
serial?: string;
105106
}): string {
106107
const selectors = [
107-
flags.platform ? `--platform ${flags.platform}` : null,
108-
flags.device ? `--device ${flags.device}` : null,
109-
flags.udid ? `--udid ${flags.udid}` : null,
110-
flags.serial ? `--serial ${flags.serial}` : null,
108+
flags.platform ? `--platform ${shellQuoteIfNeeded(flags.platform)}` : null,
109+
flags.device ? `--device ${shellQuoteIfNeeded(flags.device)}` : null,
110+
flags.udid ? `--udid ${shellQuoteIfNeeded(flags.udid)}` : null,
111+
flags.serial ? `--serial ${shellQuoteIfNeeded(flags.serial)}` : null,
111112
].filter((part): part is string => Boolean(part));
112113
return ['agent-device device status', ...selectors, '--stale'].join(' ');
113114
}

0 commit comments

Comments
 (0)