Skip to content

Commit 6288138

Browse files
committed
fix: make record app-scoped by default
1 parent ecfe909 commit 6288138

19 files changed

Lines changed: 170 additions & 31 deletions

‎scripts/integration-progress-model.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ function summarizeProviderScenarioFlagCoverage(files) {
150150
['fps', 'recording frame-rate request'],
151151
['quality', 'recording quality scaling'],
152152
['hideTouches', 'recording without touch overlays'],
153+
['recordingScope', 'recording app vs whole-screen scope', ['scope']],
153154
['intervalMs', 'repeated press interval'],
154155
['delayMs', 'typing/fill delay'],
155156
['durationMs', 'scroll, gesture, and TV remote duration'],

‎src/cli/parser/__tests__/args-parse-interaction.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ test('parseArgs recognizes record --hide-touches flag', () => {
222222
assert.equal(parsed.flags.hideTouches, true);
223223
});
224224

225+
test('parseArgs recognizes record --scope flag', () => {
226+
const parsed = parseArgs(['record', 'start', './capture.mp4', '--scope', 'device'], {
227+
strictFlags: true,
228+
});
229+
assert.equal(parsed.command, 'record');
230+
assert.deepEqual(parsed.positionals, ['start', './capture.mp4']);
231+
assert.equal(parsed.flags.recordingScope, 'device');
232+
});
233+
225234
test('parseArgs recognizes screenshot flags', () => {
226235
const parsed = parseArgs(
227236
[

‎src/cli/parser/__tests__/cli-help-command-usage.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,9 @@ test('command usage shows record touch-overlay opt-out flag', async () => {
303303
if (help === null) throw new Error('Expected command help text');
304304
assert.match(
305305
help,
306-
/record start \[path\] \[--fps <n>\] \[--max-size <px>\] \[--quality <medium\|high>\] \[--hide-touches\] \| record stop/,
306+
/record start \[path\] \[--scope <app\|device\|system>\] \[--fps <n>\] \[--max-size <px>\] \[--quality <medium\|high>\] \[--hide-touches\] \| record stop/,
307307
);
308+
assert.match(help, /--scope <app\|device\|system>/);
308309
assert.match(help, /--max-size <px>/);
309310
assert.match(help, /--quality <medium\|high>/);
310311
assert.match(help, /--hide-touches/);

‎src/cli/parser/cli-flags.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
SCREENSHOT_SPECIFIC_FLAG_DEFINITIONS,
2828
type ScreenshotRequestFlags,
2929
} from '../../contracts/screenshot.ts';
30+
import { RECORDING_SCOPE_VALUES, type RecordingScope } from '../../core/recording-scope.ts';
3031
import { PERF_KIND_VALUES } from '../../contracts/perf.ts';
3132
import {
3233
MAESTRO_COMPAT_TRACKER_URL,
@@ -98,6 +99,7 @@ export type CliFlags = CloudProviderProfileFields &
9899
fps?: number;
99100
quality?: RecordingExportQuality | string;
100101
hideTouches?: boolean;
102+
recordingScope?: RecordingScope;
101103
intervalMs?: number;
102104
delayMs?: number;
103105
durationMs?: number;
@@ -787,6 +789,15 @@ const FLAG_DEFINITIONS: readonly FlagDefinition[] = [
787789
usageLabel: '--hide-touches',
788790
usageDescription: 'Record: skip touch-overlay post-processing for faster raw benchmark videos',
789791
},
792+
{
793+
key: 'recordingScope',
794+
names: ['--scope'],
795+
type: 'enum',
796+
enumValues: RECORDING_SCOPE_VALUES,
797+
usageLabel: '--scope <app|device|system>',
798+
usageDescription:
799+
'Record: app requires an active app session; device/system records the whole screen',
800+
},
790801
{
791802
key: 'intervalMs',
792803
names: ['--interval-ms'],

‎src/cli/parser/cli-help.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ Validation and evidence:
327327
agent-device press 124 817
328328
agent-device snapshot -i
329329
Startup/CPU/memory/frame first pass: perf metrics --json (bare perf and metrics are aliases). Focused frame/jank health: perf frames --json. Memory-only sample: perf memory sample --json returns compact JSON with bounded top offenders. Heap/memgraph artifact escalation: perf memory snapshot --out heap.artifact; use --kind android-hprof on Android or --kind memgraph on supported Apple simulator/macOS app sessions. Android native profiling: perf cpu profile start|stop|report --kind simpleperf --out <path>; Android native traces: perf trace start|stop --kind perfetto --out <path>. Artifact collectors return compact state/path/size metadata only; raw heap/profile/trace files stay on disk. Treat native perf output as the agent evidence: for example, a Perfetto stop can return state=stopped, outPath=/tmp/app.perfetto-trace, sizeBytes=5392410, and method=adb-shell-perfetto while the 5.3 MB raw trace stays in the artifact. This is better than raw dumps for agents because it is stable, bounded, and keeps large artifacts out of context. heapprofd is deferred until Perfetto plumbing is available. Replay maintenance: replay -u ./flow.ad.
330-
Recording: record start/stop. Use --max-size to cap the longest edge and --quality medium|high to choose output quality across Android and Apple targets. By default, stop burns touch overlays into the video; use record start --hide-touches for the fastest raw recording. Android record start publishes a durable device manifest. Android adb screenrecord has a 180s platform limit, so longer Android recordings are returned as multiple MP4 chunks while the daemon stays alive; after daemon restart, record stop recovers only manifest-owned chunks and warns when gesture overlays are unavailable. For gesture-heavy iOS simulator proof videos, prefer --hide-touches because overlay timing depends on a stable runner session while gestures are executing. Tracing: trace start ./trace.log, trace stop ./trace.log. Paths are positional.
330+
Recording: record start/stop. The default scope is app and expects an active session created by open <app>; this keeps app proof videos tied to the intended app session. Use record start --scope device/system to explicitly request whole-screen capture where the selected backend supports it, such as recordings that intentionally span multiple apps, home screen, settings, or app transitions. Use --max-size to cap the longest edge and --quality medium|high to choose output quality across Android and Apple targets. By default, stop burns touch overlays into the video; use record start --hide-touches for the fastest raw recording. Android record start publishes a durable device manifest. Android adb screenrecord has a 180s platform limit, so longer Android recordings are returned as multiple MP4 chunks while the daemon stays alive; after daemon restart, record stop recovers only manifest-owned chunks and warns when gesture overlays are unavailable. For gesture-heavy iOS simulator proof videos, prefer --hide-touches because overlay timing depends on a stable runner session while gestures are executing. Tracing: trace start ./trace.log, trace stop ./trace.log. Paths are positional.
331331
Stable known flow: batch ./steps.json, not workflow batch.
332332
Inline batch JSON example:
333333
agent-device batch --steps '[{"command":"open","input":{"app":"settings"}},{"command":"wait","input":{"kind":"duration","durationMs":100}}]'

‎src/client/client-normalizers.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ export function buildFlags(options: InternalRequestOptions): CommandFlags {
335335
screenshotMaxSize: options.maxSize,
336336
quality: options.quality,
337337
hideTouches: options.hideTouches,
338+
recordingScope: options.recordingScope,
338339
intervalMs: options.intervalMs,
339340
delayMs: options.delayMs,
340341
durationMs: options.durationMs,

‎src/client/client-types.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type {
2222
import type { BackMode } from '../core/back-mode.ts';
2323
import type { ClickButton } from '../core/click-button.ts';
2424
import type { RecordingExportQuality } from '../core/recording-export-quality.ts';
25+
import type { RecordingScope } from '../core/recording-scope.ts';
2526
import type { DeviceRotation } from '../core/device-rotation.ts';
2627
import type { TvRemoteButton } from '../core/tv-remote.ts';
2728
import type {
@@ -876,6 +877,7 @@ export type RecordOptions = AgentDeviceRequestOverrides & {
876877
maxSize?: number;
877878
quality?: RecordingExportQuality;
878879
hideTouches?: boolean;
880+
recordingScope?: RecordingScope;
879881
};
880882

881883
export type TraceOptions = AgentDeviceRequestOverrides & {
@@ -957,6 +959,7 @@ type CommandExecutionOptions = Partial<ScreenshotRequestFlags> & {
957959
maxSize?: number;
958960
quality?: RecordingExportQuality;
959961
hideTouches?: boolean;
962+
recordingScope?: RecordingScope;
960963
intervalMs?: number;
961964
delayMs?: number;
962965
durationMs?: number;

‎src/commands/recording/index.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('recording command interface', () => {
3737
screenshotMaxSize: 1024,
3838
quality: 'high',
3939
hideTouches: true,
40+
recordingScope: 'device',
4041
} as CliFlags),
4142
).toEqual({
4243
action: 'start',
@@ -45,6 +46,7 @@ describe('recording command interface', () => {
4546
maxSize: 1024,
4647
quality: 'high',
4748
hideTouches: true,
49+
recordingScope: 'device',
4850
});
4951
});
5052

‎src/commands/recording/index.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { RecordOptions } from '../../client/client-types.ts';
22
import { RECORDING_EXPORT_QUALITIES } from '../../core/recording-export-quality.ts';
3+
import { RECORDING_SCOPE_VALUES } from '../../core/recording-scope.ts';
34
import { AppError } from '../../kernel/errors.ts';
45
import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts';
56
import { defineCommandFacet, defineCommandFamilyFromFacets } from '../family/types.ts';
@@ -33,6 +34,7 @@ export const recordCommandMetadata = defineFieldCommandMetadata(
3334
maxSize: integerField(),
3435
quality: enumField(RECORDING_EXPORT_QUALITIES),
3536
hideTouches: booleanField(),
37+
recordingScope: enumField(RECORDING_SCOPE_VALUES),
3638
},
3739
);
3840

@@ -57,13 +59,13 @@ export const traceCommandDefinition = defineExecutableCommand(
5759

5860
const recordCliSchema = {
5961
usageOverride:
60-
'record start [path] [--fps <n>] [--max-size <px>] [--quality <medium|high>] [--hide-touches] | record stop',
62+
'record start [path] [--scope <app|device|system>] [--fps <n>] [--max-size <px>] [--quality <medium|high>] [--hide-touches] | record stop',
6163
listUsageOverride: 'record start [path] | record stop',
6264
helpDescription:
63-
'Start/stop screen recording; Android record start publishes a durable device manifest, recordings longer than the 180s adb screenrecord limit are returned as multiple MP4 chunks while the daemon stays alive, and daemon-restart recovery uses only manifest-owned chunks. Use --max-size to limit dimensions and --quality to choose medium or high export quality',
65+
'Start/stop screen recording. The default --scope app requires an active app session from open <app>; use --scope device/system to explicitly request whole-screen recording where the selected backend supports it. Android record start publishes a durable device manifest, recordings longer than the 180s adb screenrecord limit are returned as multiple MP4 chunks while the daemon stays alive, and daemon-restart recovery uses only manifest-owned chunks. Use --max-size to limit dimensions and --quality to choose medium or high export quality',
6466
summary: 'Start or stop screen recording',
6567
positionalArgs: ['start|stop', 'path?'],
66-
allowedFlags: ['fps', 'screenshotMaxSize', 'quality', 'hideTouches'],
68+
allowedFlags: ['recordingScope', 'fps', 'screenshotMaxSize', 'quality', 'hideTouches'],
6769
} as const satisfies CommandSchemaOverride;
6870

6971
const traceCliSchema = {
@@ -83,6 +85,7 @@ export const recordCliReader: CliReader = (positionals, flags) => ({
8385
maxSize: flags.screenshotMaxSize,
8486
quality: flags.quality as RecordOptions['quality'],
8587
hideTouches: flags.hideTouches,
88+
recordingScope: flags.recordingScope,
8689
});
8790

8891
export const traceCliReader: CliReader = (positionals, flags) => ({

‎src/core/recording-scope.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const RECORDING_SCOPE_VALUES = ['app', 'device', 'system'] as const;
2+
3+
export type RecordingScope = (typeof RECORDING_SCOPE_VALUES)[number];
4+
5+
export function isWholeScreenRecordingScope(scope: RecordingScope): boolean {
6+
return scope === 'device' || scope === 'system';
7+
}

0 commit comments

Comments
 (0)