Skip to content

Commit 9d05609

Browse files
committed
fix: preserve remote config for interaction commands
1 parent c78ccea commit 9d05609

2 files changed

Lines changed: 47 additions & 2 deletions

File tree

src/__tests__/cli-config.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,51 @@ test('command-specific config defaults are ignored for commands that do not supp
134134
fs.rmSync(root, { recursive: true, force: true });
135135
});
136136

137+
test('interaction commands preserve remote config defaults', async () => {
138+
const { root, home, project } = makeTempWorkspace();
139+
fs.mkdirSync(path.join(home, '.agent-device'), { recursive: true });
140+
fs.writeFileSync(
141+
path.join(project, 'agent-device.json'),
142+
JSON.stringify({
143+
daemonBaseUrl: 'https://daemon.example.test',
144+
daemonAuthToken: 'token-123',
145+
daemonTransport: 'http',
146+
tenant: 'tenant-123',
147+
runId: 'run-123',
148+
leaseId: 'lease-123',
149+
platform: 'ios',
150+
}),
151+
'utf8',
152+
);
153+
154+
const commands = [
155+
['press', '10', '20'],
156+
['click', '10', '20'],
157+
['fill', '10', '20', 'hello'],
158+
['longpress', '10', '20'],
159+
['get', 'text', '@e1'],
160+
];
161+
162+
for (const command of commands) {
163+
const result = await runCliCapture([...command, '--json'], {
164+
cwd: project,
165+
env: { HOME: home },
166+
});
167+
168+
assert.equal(result.code, null, command.join(' '));
169+
assert.equal(result.calls.length, 1, command.join(' '));
170+
assert.equal(result.calls[0]?.flags?.daemonBaseUrl, 'https://daemon.example.test');
171+
assert.equal(result.calls[0]?.flags?.daemonAuthToken, 'token-123');
172+
assert.equal(result.calls[0]?.flags?.daemonTransport, 'http');
173+
assert.equal(result.calls[0]?.flags?.tenant, 'tenant-123');
174+
assert.equal(result.calls[0]?.flags?.runId, 'run-123');
175+
assert.equal(result.calls[0]?.flags?.leaseId, 'lease-123');
176+
assert.equal(result.calls[0]?.flags?.platform, 'ios');
177+
}
178+
179+
fs.rmSync(root, { recursive: true, force: true });
180+
});
181+
137182
test('explicit --config path overrides default config discovery', async () => {
138183
const { root, home, project } = makeTempWorkspace();
139184
fs.mkdirSync(path.join(home, '.agent-device'), { recursive: true });

src/commands/command-input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ export function optionalEnum<const T extends readonly string[]>(
437437
export function commonToClientOptions(
438438
input: CommonCommandInput,
439439
): AgentDeviceRequestOverrides & AgentDeviceSelectionOptions {
440-
return {
440+
return compactRecord({
441441
session: input.session,
442442
platform: input.platform,
443443
target: input.deviceTarget,
@@ -453,7 +453,7 @@ export function commonToClientOptions(
453453
leaseId: input.leaseId,
454454
cwd: input.cwd,
455455
debug: input.debug,
456-
};
456+
}) as AgentDeviceRequestOverrides & AgentDeviceSelectionOptions;
457457
}
458458

459459
export function toClientInteractionTarget(target: InteractionTargetInput): InteractionTarget {

0 commit comments

Comments
 (0)