Skip to content
Merged
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
25 changes: 25 additions & 0 deletions src/__tests__/cli-leased-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,31 @@ test('a macos-app remote config with a host-allocated lease needs a session and
fs.rmSync(solo.root, { recursive: true, force: true });
});

test('a command that takes no session runs while a leased connection is active', async () => {
const solo = workspace();
writeStoredConnection(solo, {
session: 'limrun-a',
tenant: 'limrun',
runId: 'run-limrun-a',
leaseBackend: 'ios-instance',
leaseProvider: 'limrun',
platform: 'ios',
});

// The active leased connection still makes a connection command name its session...
assertSessionRequired(await runAgentCommand(solo, ['snapshot']));
// ...but `auth` runs on no connection, and `--session` is not one of its flags.
const environments: Record<string, string>[] = [{}, { AGENT_DEVICE_SESSION: 'demo' }];
for (const env of environments) {
const result = await runAgentCommand(solo, ['auth', 'status'], env);
assert.equal(result.code, null, result.stdout);
assert.equal(JSON.parse(result.stdout).data.authenticated, false);
assert.deepEqual(result.calls, []);
}

fs.rmSync(solo.root, { recursive: true, force: true });
});

function writeLeasedProfile(workspace: Workspace): string {
const remoteConfig = path.join(workspace.project, 'shared.remote.json');
fs.writeFileSync(
Expand Down
8 changes: 4 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
applyDefaultPlatformBinding,
type DevicePin,
getCommandSchema,
isFlagSupportedForCommand,
readCliBatchStepsJson,
resolveBindingSettings,
} from '@agent-device/command-surface';
Expand Down Expand Up @@ -787,10 +788,9 @@ function resolveActiveConnectionDefaults(options: {
if (
options.command === 'connect' ||
options.command === 'connection' ||
options.command === 'daemon' ||
options.command === 'plugins' ||
options.command === 'device' ||
options.command === 'proxy'
// A command that cannot take a session (`auth`, `daemon`, `plugins`, `device`, `proxy`) runs
// on no connection. Reading the active one would refuse it for a session it cannot name.
!isFlagSupportedForCommand('session', options.command)
) {
return null;
}
Expand Down
Loading