Skip to content

Commit df1edbb

Browse files
committed
fix(platform-linux): launch through an injected executor unless a launcher is given
A caller that injected runCommand but no launchDetached got the host-local detached runner, which silently bypassed its executor. The detached runner is now the default only beside the default runCmd; otherwise launches go through the injected executor. Also: the upload deadline comment now says it is a total deadline, the activation test no longer splits the #1774 comment from its test, and the unread `error` field on AgentBrowserBatchEntry is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
1 parent beb299d commit df1edbb

5 files changed

Lines changed: 42 additions & 7 deletions

File tree

‎packages/platform-linux/src/__tests__/tool-provider.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,22 @@ test('local Linux desktop provider reports nothing for a launched app that exits
266266
assert.deepEqual(await launchDiagnostics({ pid: 4, exitCode: 0 }), []);
267267
});
268268

269+
test('local Linux desktop provider launches through an injected executor when it injects no launcher', async () => {
270+
const commands: Array<[string, string[], boolean | undefined]> = [];
271+
const provider = createLocalLinuxToolProvider({
272+
host: { env: process.env, cwd: process.cwd() },
273+
whichCommand: async (cmd) => cmd === 'demo-app',
274+
runCommand: async (cmd, args, options) => {
275+
commands.push([cmd, args, options?.allowFailure]);
276+
return { exitCode: 0, stdout: '', stderr: '' };
277+
},
278+
});
279+
280+
await provider.desktop.openTarget('demo-app');
281+
282+
assert.deepEqual(commands, [['demo-app', [], true]]);
283+
});
284+
269285
test('local Linux desktop provider falls back to pkill when wmctrl is unavailable', async () => {
270286
const commands: Array<[string, string[], boolean | undefined]> = [];
271287
const provider = createLocalLinuxToolProvider({

‎packages/platform-linux/src/tool-provider.ts‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ type LinuxToolProviderParts = { display: LinuxDisplayConfig } & Partial<LinuxToo
109109
function completeLocalLinuxToolProvider(provider: LinuxToolProviderParts): LinuxToolProvider {
110110
const runCommand = provider.runCommand ?? runCmd;
111111
const whichCommand = provider.whichCommand ?? whichOnPath;
112-
const launchDetached = provider.launchDetached ?? runCmdDetachedMonitored;
112+
// A caller that injected its own executor also owns app launches: the host-local detached
113+
// runner is the default only beside the host-local `runCmd`.
114+
const launchDetached =
115+
provider.launchDetached ??
116+
(provider.runCommand === undefined
117+
? runCmdDetachedMonitored
118+
: launchThroughExecutor(provider.runCommand));
113119
const display = provider.display;
114120
return {
115121
runCommand,
@@ -183,6 +189,19 @@ export async function runLinuxToolCommand(
183189
return await resolveLinuxToolProvider().runCommand(cmd, args, options);
184190
}
185191

192+
/** A launcher over an injected executor, settling `exited` from the command's own result. */
193+
function launchThroughExecutor(runCommand: LinuxToolCommandExecutor): LinuxToolDetachedLauncher {
194+
return (cmd, args) => ({
195+
exited: runCommand(cmd, args, { allowFailure: true }).then(
196+
(result): ExecDetachedExit => ({ pid: 0, exitCode: result.exitCode }),
197+
(error: unknown): ExecDetachedExit => ({
198+
pid: 0,
199+
error: error instanceof Error ? error.message : String(error),
200+
}),
201+
),
202+
});
203+
}
204+
186205
/** What a launched app's exit says went wrong: a start failure, a non-zero exit, or a signal. */
187206
function describeLaunchExit(exit: ExecDetachedExit): Record<string, unknown> | undefined {
188207
if (exit.error !== undefined) return { error: exit.error };

‎packages/platform-web/src/agent-browser-provider.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ type AgentBrowserBatchEntry = {
457457
command?: unknown;
458458
success?: unknown;
459459
result?: unknown;
460-
error?: unknown;
461460
};
462461

463462
/**

‎packages/provider-webdriver/src/webdriver-client.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ test('source aborts an in-flight provider request when its binding is cancelled'
129129
assert.equal(requestSignal?.aborted, true);
130130
});
131131

132-
// #1774: `POST /session` is the one non-idempotent request, and a retry after a
133-
// failed create is a second billed device session. A 5xx that the transport
134-
// would retry on any other route must reach the caller unretried here.
135132
// App activation falls back to `mobile: activateApp` only on the driver's own refusal of the route.
136133
test('app activation falls back on a W3C unknown command but not on a gateway 404 page', async () => {
137134
for (const [first, fallsBack] of [
@@ -158,6 +155,9 @@ test('app activation falls back on a W3C unknown command but not on a gateway 40
158155
}
159156
});
160157

158+
// #1774: `POST /session` is the one non-idempotent request, and a retry after a
159+
// failed create is a second billed device session. A 5xx that the transport
160+
// would retry on any other route must reach the caller unretried here.
161161
test('createSession does not retry a transient create failure', async () => {
162162
let calls = 0;
163163
globalThis.fetch = async () => {

‎packages/provider-webdriver/src/webdriver-utils.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ export async function appFileUploadForm(
9393
}
9494

9595
/**
96-
* The longest one app upload may run. Builds of a few hundred MB on a slow uplink take minutes, so
97-
* this bounds a stalled transfer, not a slow one.
96+
* The total deadline for one app upload, from request start to answer. It is not an idle timeout:
97+
* a healthy upload that is still sending after 15 minutes is aborted too. Builds of a few hundred
98+
* MB on a slow uplink take minutes, so it is set well above that.
9899
*/
99100
const HUB_APP_UPLOAD_TIMEOUT_MS = 15 * 60_000;
100101

0 commit comments

Comments
 (0)