Skip to content

Commit bf64256

Browse files
thymikeeclaude
andcommitted
refactor(provider-webdriver): one inactive-session fact shared by the runtime and deployment facts
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent c754951 commit bf64256

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

‎packages/provider-webdriver/src/platform-runtime.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import type { Interactor, RunnerContext } from '@agent-device/contracts/interact
7171
import { readRecentNetworkTrafficFromText } from '@agent-device/capture-kit';
7272
import type { DeviceInfo } from '@agent-device/kernel/device';
7373
import { AppError } from '@agent-device/kernel/errors';
74-
import type { WebDriverDeploymentRuntime } from './runtime-deployment.ts';
74+
import { type WebDriverDeploymentRuntime, webDriverInactiveSession } from './runtime-deployment.ts';
7575
import { bindWebDriverApplicationLifecycle } from './lifecycle.ts';
7676
import {
7777
capabilitySupported,
@@ -107,10 +107,7 @@ const pushUnavailable = unavailableFact(
107107
'unsupported-provider-mode',
108108
'Push notifications are unavailable for WebDriver provider-owned devices.',
109109
);
110-
const inactiveSession = unavailableFact(
111-
'owner-capability-missing',
112-
'The WebDriver provider session is no longer active for this device.',
113-
);
110+
const inactiveSession = webDriverInactiveSession;
114111
const snapshotUnavailable = unavailableFact(
115112
'unsupported-provider-mode',
116113
'This WebDriver provider runtime does not expose snapshot capture for this device.',

‎packages/provider-webdriver/src/runtime-deployment.ts‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ import type {
77
AppDeploymentResult,
88
DeployMaterializedAppInput,
99
} from '@agent-device/contracts/app-deployment-runtime';
10-
import type { RuntimeOperationFact } from '@agent-device/contracts/platform-runtime';
10+
import {
11+
type RuntimeOperationFact,
12+
unavailableFact,
13+
} from '@agent-device/contracts/platform-runtime';
14+
15+
/** The refusal every WebDriver cell reports once the provider session is gone. */
16+
export const webDriverInactiveSession = unavailableFact(
17+
'owner-capability-missing',
18+
'The WebDriver provider session is no longer active for this device.',
19+
);
1120
import { publicPlatformString, type DeviceInfo } from '@agent-device/kernel/device';
1221
import { AppError } from '@agent-device/kernel/errors';
1322
import { capabilitySupported, unsupportedCapabilityMessage } from './capabilities.ts';
@@ -117,19 +126,12 @@ export function createWebDriverDeploymentRuntime(
117126
}
118127

119128
function deploymentFact(session: WebDriverProviderSession | undefined): RuntimeOperationFact {
120-
if (!session) {
121-
return Object.freeze({
122-
available: false,
123-
reason: 'owner-capability-missing',
124-
hint: 'The WebDriver provider session is no longer active for this device.',
125-
} as const);
126-
}
129+
if (!session) return webDriverInactiveSession;
127130
if (!capabilitySupported(session.capabilities, 'install')) {
128-
return Object.freeze({
129-
available: false,
130-
reason: 'owner-capability-missing',
131-
hint: unsupportedCapabilityMessage(session.capabilities, 'install'),
132-
} as const);
131+
return unavailableFact(
132+
'owner-capability-missing',
133+
unsupportedCapabilityMessage(session.capabilities, 'install'),
134+
);
133135
}
134136
return Object.freeze({ available: true } as const);
135137
}

0 commit comments

Comments
 (0)