Skip to content

Release v1.0.10: Enhanced Device Emulation with 143 Device Presets#191

Merged
executeautomation merged 2 commits intomainfrom
release/v1.0.10-device-presets
Dec 10, 2025
Merged

Release v1.0.10: Enhanced Device Emulation with 143 Device Presets#191
executeautomation merged 2 commits intomainfrom
release/v1.0.10-device-presets

Conversation

@executeautomation
Copy link
Owner

Major Features:

  • Device preset support for playwright_resize (143 devices)
  • Portrait/landscape orientation support
  • Automatic user-agent, touch, and device pixel ratio emulation
  • Natural language support for AI assistants
  • Comprehensive documentation and prompt guides

New Files:

  • src/tools/browser/resize.ts - Enhanced resize tool
  • src/tests/tools/browser/resize.test.ts - 23 comprehensive tests
  • docs/docs/playwright-web/Resize-Prompts-Guide.md - Natural language guide
  • docs/docs/playwright-web/Device-Quick-Reference.md - Quick reference
  • scripts/list-devices.cjs - Device discovery helper
  • CHANGELOG.md - Version history tracking

Updated Files:

  • package.json - Bumped to v1.0.10
  • README.md - Added v1.0.10 highlights
  • docs/docs/release.mdx - Complete release notes
  • docs/docs/playwright-web/Supported-Tools.mdx - Enhanced documentation
  • src/tools.ts - Updated tool definition
  • src/toolHandler.ts - Integrated resize tool
  • src/tools/browser/index.ts - Exported resize tool
  • src/tests/tools.test.ts - Updated schema tests

Testing:

  • All 134 tests passing (111 existing + 23 new)
  • 98% code coverage for resize.ts
  • Device preset, orientation, and validation tests

Backward Compatible:

  • Manual width/height dimensions still work
  • No breaking changes to existing code
  • Optional device parameter

Major Features:
- Device preset support for playwright_resize (143 devices)
- Portrait/landscape orientation support
- Automatic user-agent, touch, and device pixel ratio emulation
- Natural language support for AI assistants
- Comprehensive documentation and prompt guides

New Files:
- src/tools/browser/resize.ts - Enhanced resize tool
- src/__tests__/tools/browser/resize.test.ts - 23 comprehensive tests
- docs/docs/playwright-web/Resize-Prompts-Guide.md - Natural language guide
- docs/docs/playwright-web/Device-Quick-Reference.md - Quick reference
- scripts/list-devices.cjs - Device discovery helper
- CHANGELOG.md - Version history tracking

Updated Files:
- package.json - Bumped to v1.0.10
- README.md - Added v1.0.10 highlights
- docs/docs/release.mdx - Complete release notes
- docs/docs/playwright-web/Supported-Tools.mdx - Enhanced documentation
- src/tools.ts - Updated tool definition
- src/toolHandler.ts - Integrated resize tool
- src/tools/browser/index.ts - Exported resize tool
- src/__tests__/tools.test.ts - Updated schema tests

Testing:
- All 134 tests passing (111 existing + 23 new)
- 98% code coverage for resize.ts
- Device preset, orientation, and validation tests

Backward Compatible:
- Manual width/height dimensions still work
- No breaking changes to existing code
- Optional device parameter
@amazon-q-developer
Copy link

Code review in progress. Analyzing for code quality issues and best practices. You can monitor the review status in the checks section at the bottom of this pull request. Detailed findings will be posted upon completion.

Using Amazon Q Developer for GitHub

Amazon Q Developer1 is an AI-powered assistant that integrates directly into your GitHub workflow, enhancing your development process with intelligent features for code development, review, and transformation.

Slash Commands

Command Description
/q <message> Chat with the agent to ask questions or request revisions
/q review Requests an Amazon Q powered code review
/q help Displays usage information

Features

Agentic Chat
Enables interactive conversation with Amazon Q to ask questions about the pull request or request specific revisions. Use /q <message> in comment threads or the review body to engage with the agent directly.

Code Review
Analyzes pull requests for code quality, potential issues, and security concerns. Provides feedback and suggested fixes. Automatically triggered on new or reopened PRs (can be disabled for AWS registered installations), or manually with /q review slash command in a comment.

Customization

You can create project-specific rules for Amazon Q Developer to follow:

  1. Create a .amazonq/rules folder in your project root.
  2. Add Markdown files in this folder to define rules (e.g., cdk-rules.md).
  3. Write detailed prompts in these files, such as coding standards or best practices.
  4. Amazon Q Developer will automatically use these rules when generating code or providing assistance.

Example rule:

All Amazon S3 buckets must have encryption enabled, enforce SSL, and block public access.
All Amazon DynamoDB Streams tables must have encryption enabled.
All Amazon SNS topics must have encryption enabled and enforce SSL.
All Amazon SNS queues must enforce SSL.

Feedback

To provide feedback on Amazon Q Developer, create an issue in the Amazon Q Developer public repository.

For more detailed information, visit the Amazon Q for GitHub documentation.

Footnotes

  1. Amazon Q Developer uses generative AI. You may need to verify generated code before using it in your environment. See the AWS Responsible AI Policy.

Copy link

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR introduces device emulation capabilities to the playwright_resize tool, which is a valuable enhancement. However, there are critical issues that must be addressed before merging:

🚨 Critical Issues

  1. Inconsistent Error Handling: The resize tool has mixed error handling patterns - device validation returns error responses while dimension validation throws errors. This creates unpredictable behavior and will cause test failures.

  2. Test-Implementation Mismatch: Tests expect error responses but the implementation throws errors for validation failures, which will cause the test suite to fail.

  3. Runtime Safety: The device listing script lacks null checks for device.viewport, which could cause crashes if any device lacks viewport configuration.

✅ Positive Aspects

  • Comprehensive device preset support (143 devices)
  • Excellent test coverage with 23 new tests
  • Backward compatibility maintained
  • Well-structured documentation and examples
  • Natural language support for AI assistants

🔧 Required Fixes

The error handling inconsistency must be resolved by standardizing on error responses throughout the tool. The test expectations also need to be updated to match the actual implementation behavior.

📊 Overall Assessment

While this is a feature-rich enhancement with good documentation and testing, the critical error handling issues prevent safe merging. Once the error handling is standardized and tests are aligned, this will be a valuable addition to the codebase.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment on lines +72 to +78
if (width <= 0 || height <= 0) {
throw new Error("Width and height must be positive integers");
}

if (width > 7680 || height > 4320) {
throw new Error("Width and height must not exceed 7680x4320 (8K resolution)");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: Inconsistent error handling between validation paths creates unpredictable behavior. Manual dimension validation throws errors while device validation returns error responses, causing different exception handling flows.

Suggested change
if (width <= 0 || height <= 0) {
throw new Error("Width and height must be positive integers");
}
if (width > 7680 || height > 4320) {
throw new Error("Width and height must not exceed 7680x4320 (8K resolution)");
}
// Validate dimensions
if (width <= 0 || height <= 0) {
return createErrorResponse("Width and height must be positive integers");
}
if (width > 7680 || height > 4320) {
return createErrorResponse("Width and height must not exceed 7680x4320 (8K resolution)");
}

Comment on lines +55 to +61
test('should reject negative width', async () => {
const args = { width: -100, height: 600 };
const result = await resizeTool.execute(args, mockContext);

expect(result.isError).toBe(true);
expect(result.content[0].text).toContain('Width and height must be positive integers');
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test expectations don't match implementation behavior. Tests expect error responses but the resize tool throws errors for validation failures, which will cause test failures.

Suggested change
test('should reject negative width', async () => {
const args = { width: -100, height: 600 };
const result = await resizeTool.execute(args, mockContext);
expect(result.isError).toBe(true);
expect(result.content[0].text).toContain('Width and height must be positive integers');
});
test('should reject negative width', async () => {
const args = { width: -100, height: 600 };
// Expect the tool to throw an error, not return an error response
await expect(resizeTool.execute(args, mockContext)).rejects.toThrow('Width and height must be positive integers');
});

return;
}

const device = devices[name];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Crash Risk: Missing null check for device.viewport could cause runtime errors if any device in Playwright's device registry lacks a viewport property.

Suggested change
const device = devices[name];
const device = devices[name];
if (!device || !device.viewport) {
console.warn(`Warning: Device "${name}" has no viewport configuration`);
return;
}

@executeautomation executeautomation merged commit ffcb3de into main Dec 10, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants