fix: allow null selector in screenshot command schema (#236)

The screenshot command was failing with 'Validation error: selector: Expected string, received null' when only a path was provided (e.g., 'agent-browser screenshot ~/Desktop/test.png').

The Rust CLI serializes None values as null in JSON, but the Zod schema only allowed undefined (via .optional()), not null. Changed selector field to use .nullish() which accepts both null and undefined.

Fixes issue where screenshot command without selector fails validation.
This commit is contained in:
Zach Warunek
2026-01-23 17:50:11 -06:00
committed by GitHub
parent d10fd2d545
commit 36ea8ecb55
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -122,6 +122,13 @@ describe('parseCommand', () => {
const result = parseCommand(cmd({ id: '1', action: 'screenshot', fullPage: true }));
expect(result.success).toBe(true);
});
it('should parse screenshot with null selector', () => {
const result = parseCommand(
cmd({ id: '1', action: 'screenshot', path: 'test.png', selector: null })
);
expect(result.success).toBe(true);
});
});
describe('cookies', () => {
+1 -1
View File
@@ -693,7 +693,7 @@ const screenshotSchema = baseCommandSchema.extend({
action: z.literal('screenshot'),
path: z.string().nullable().optional(),
fullPage: z.boolean().optional(),
selector: z.string().min(1).optional(),
selector: z.string().min(1).nullish(),
format: z.enum(['png', 'jpeg']).optional(),
quality: z.number().min(0).max(100).optional(),
});