Skip to content

Commit 60f36ef

Browse files
authored
feat: add screenshot no-stabilize flag (#553)
1 parent 5c6c89e commit 60f36ef

24 files changed

Lines changed: 103 additions & 12 deletions

src/__tests__/cli-client-commands.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ test('screenshot forwards --overlay-refs to the client capture API', async () =>
384384
path?: string;
385385
overlayRefs?: boolean;
386386
maxSize?: number;
387+
stabilize?: boolean;
387388
}
388389
| undefined;
389390
const client = createStubClient({
@@ -408,6 +409,7 @@ test('screenshot forwards --overlay-refs to the client capture API', async () =>
408409
version: false,
409410
overlayRefs: true,
410411
screenshotMaxSize: 1024,
412+
screenshotNoStabilize: true,
411413
},
412414
client,
413415
});
@@ -417,6 +419,7 @@ test('screenshot forwards --overlay-refs to the client capture API', async () =>
417419
path: '/tmp/screenshot.png',
418420
overlayRefs: true,
419421
maxSize: 1024,
422+
stabilize: false,
420423
});
421424
});
422425

src/backend.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export type BackendFindTextResult = {
6969
export type BackendScreenshotOptions = {
7070
fullscreen?: boolean;
7171
overlayRefs?: boolean;
72+
stabilize?: boolean;
7273
surface?: 'app' | 'frontmost-app' | 'desktop' | 'menubar';
7374
};
7475

src/cli/commands/screenshot.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const screenshotCommand: ClientCommandHandler = async ({ positionals, fla
1414
path: positionals[0] ?? flags.out,
1515
overlayRefs: flags.overlayRefs,
1616
maxSize: flags.screenshotMaxSize,
17+
...(flags.screenshotNoStabilize ? { stabilize: false } : {}),
1718
...(flags.screenshotFullscreen !== undefined ? { fullscreen: flags.screenshotFullscreen } : {}),
1819
});
1920
const data = {
@@ -97,6 +98,7 @@ function createClientScreenshotBackend(
9798
session: context.session,
9899
overlayRefs: options?.overlayRefs,
99100
fullscreen: options?.fullscreen,
101+
stabilize: options?.stabilize,
100102
surface: options?.surface,
101103
});
102104
return {

src/client-normalizers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export function buildFlags(options: InternalRequestOptions): CommandFlags {
270270
snapshotRaw: options.raw,
271271
screenshotFullscreen: options.screenshotFullscreen,
272272
screenshotMaxSize: options.screenshotMaxSize,
273+
screenshotNoStabilize: options.screenshotNoStabilize,
273274
overlayRefs: options.overlayRefs,
274275
appsFilter: options.appsFilter,
275276
out: options.out,

src/client-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ export type CaptureScreenshotOptions = AgentDeviceRequestOverrides & {
331331
overlayRefs?: boolean;
332332
fullscreen?: boolean;
333333
maxSize?: number;
334+
stabilize?: boolean;
334335
surface?: 'app' | 'frontmost-app' | 'desktop' | 'menubar';
335336
};
336337

@@ -753,6 +754,7 @@ type CommandExecutionOptions = {
753754
raw?: boolean;
754755
screenshotFullscreen?: boolean;
755756
screenshotMaxSize?: number;
757+
screenshotNoStabilize?: boolean;
756758
count?: number;
757759
fps?: number;
758760
quality?: RecordingQuality;

src/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ export function createAgentDeviceClient(
333333
...options,
334334
screenshotFullscreen: options.fullscreen,
335335
screenshotMaxSize: options.maxSize,
336+
screenshotNoStabilize: options.stabilize === false ? true : undefined,
336337
});
337338
return {
338339
path: readRequiredString(data, 'path'),

src/commands/capture-definition.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ const screenshotCommandDefinition = defineCommand({
4242
name: PUBLIC_COMMANDS.screenshot,
4343
schema: {
4444
helpDescription:
45-
'Capture screenshot (macOS app sessions default to the app window; use --fullscreen for full desktop, --max-size to downscale, or --overlay-refs to annotate the image with current refs)',
45+
'Capture screenshot (macOS app sessions default to the app window; use --fullscreen for full desktop, --max-size to downscale, --overlay-refs to annotate current refs, or --no-stabilize for low-latency Android capture loops)',
4646
positionalArgs: ['path?'],
47-
allowedFlags: ['out', 'overlayRefs', 'screenshotFullscreen', 'screenshotMaxSize'],
47+
allowedFlags: [
48+
'out',
49+
'overlayRefs',
50+
'screenshotFullscreen',
51+
'screenshotMaxSize',
52+
'screenshotNoStabilize',
53+
],
4854
},
4955
capability: ALL_DEVICE_COMMAND_CAPABILITY,
5056
});

src/commands/capture-screenshot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const screenshotCommand: RuntimeCommand<
3939
{
4040
fullscreen: options.fullscreen,
4141
overlayRefs: options.overlayRefs,
42+
stabilize: options.stabilize,
4243
surface: options.surface,
4344
},
4445
);

src/commands/runtime-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type ScreenshotCommandOptions = CommandContext & {
1717
fullscreen?: boolean;
1818
overlayRefs?: boolean;
1919
maxSize?: number;
20+
stabilize?: boolean;
2021
appId?: string;
2122
appBundleId?: string;
2223
surface?: 'app' | 'frontmost-app' | 'desktop' | 'menubar';

src/core/dispatch-context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type DispatchContext = {
2626
snapshotScope?: string;
2727
snapshotRaw?: boolean;
2828
screenshotFullscreen?: boolean;
29+
screenshotNoStabilize?: boolean;
2930
count?: number;
3031
intervalMs?: number;
3132
delayMs?: number;

0 commit comments

Comments
 (0)