Skip to content

feat(ui): add viewport option#945

Merged
fi3ework merged 1 commit intomainfrom
viewport
Feb 6, 2026
Merged

feat(ui): add viewport option#945
fi3ework merged 1 commit intomainfrom
viewport

Conversation

@fi3ework
Copy link
Copy Markdown
Member

@fi3ework fi3ework commented Feb 5, 2026

Summary

image Google Chrome 2026-02-06 11 41 59

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@fi3ework fi3ework force-pushed the viewport branch 4 times, most recently from 4a0d0c5 to 75d14cf Compare February 6, 2026 03:27
@fi3ework fi3ework marked this pull request as ready for review February 6, 2026 03:44
Copilot AI review requested due to automatic review settings February 6, 2026 03:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a viewport configuration option for browser mode testing, allowing developers to specify iframe dimensions either through device presets (e.g., iPhone, iPad models) or custom width/height values. The feature includes a UI selector in the preview header for runtime viewport adjustments, with changes persisted to localStorage per-project. The implementation aligns device presets with Chrome DevTools standards.

Changes:

  • Added viewport configuration option to BrowserModeConfig with support for device presets and custom dimensions
  • Implemented ViewportSelector and ViewportFrame UI components for interactive viewport management
  • Refactored browser UI build from container.html to index.html for standard naming conventions

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/core/src/types/config.ts Defines DevicePreset and BrowserViewport types for configuration
packages/core/src/config.ts Adds viewport validation and merges viewport into normalized config
packages/browser/src/protocol.ts Adds viewport field to BrowserProjectRuntime protocol type
packages/browser/src/hostController.ts Updates to pass viewport config to UI and renames container.html to index.html
packages/browser-ui/src/utils/viewportPresets.ts Defines device presets aligned with Chrome DevTools specifications
packages/browser-ui/src/utils/viewport.ts Implements viewport type conversions and size calculations
packages/browser-ui/src/components/ViewportSelector.tsx Interactive UI component for selecting and configuring viewports
packages/browser-ui/src/components/ViewportFrame.tsx Wrapper component that applies viewport dimensions to iframes with resize support
packages/browser-ui/src/components/PreviewHeader.tsx Integrates ViewportSelector into the preview header
packages/browser-ui/src/main.tsx Manages viewport state per-project with localStorage persistence
packages/browser-ui/rsbuild.config.ts Renames entry point from 'container' to 'index'
e2e/browser-mode/viewport.test.ts E2E test verifying viewport configuration
e2e/browser-mode/fixtures/viewport/* Test fixture with custom viewport dimensions
scripts/dictionary.txt Adds 'Asus' and 'Zenbook' for spell checking
packages/core/tests//snapshots/.snap Updates snapshots to include viewport field

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (typeof viewport === 'string') {
if (!viewport.trim()) {
throw new Error('browser.viewport must be a non-empty preset id.');
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The validation function accepts any non-empty string as a valid preset, but doesn't verify if the string corresponds to an actual DevicePreset value. This means users could configure an invalid preset like "iPhone99" and it would pass validation at config time, only to cause a runtime error when the UI tries to use it via getPresetInfo().

Consider importing the DevicePreset list into the core package and validating that the string is one of the known presets. Alternatively, add a comment documenting that invalid presets will gracefully fall back to 'full' mode in the UI.

Suggested change
}
}
// Note: preset ids are only checked for being non-empty here.
// The UI layer (e.g. getPresetInfo) is responsible for resolving
// the preset name and will gracefully fall back to 'full' mode
// if the provided preset id is not recognized.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +13
viewport: {
width: 390,
height: 844,
},
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The test only covers viewport configuration with explicit width and height values. Consider adding a test case that uses a device preset string (e.g., viewport: 'iPhone12Pro') to verify that preset-based configuration works correctly.

Copilot uses AI. Check for mistakes.
@fi3ework
Copy link
Copy Markdown
Member Author

fi3ework commented Feb 6, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75d14cf559

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fi3ework fi3ework enabled auto-merge (squash) February 6, 2026 05:03
@fi3ework fi3ework merged commit 4aa05e0 into main Feb 6, 2026
15 of 17 checks passed
@fi3ework fi3ework deleted the viewport branch February 6, 2026 05:44
@9aoy 9aoy mentioned this pull request Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants