Skip to content

refactor(core): unify UI context parsing and screenshot handling#1994

Open
EAGzzyCSL wants to merge 1 commit intomainfrom
zzy/ui-context
Open

refactor(core): unify UI context parsing and screenshot handling#1994
EAGzzyCSL wants to merge 1 commit intomainfrom
zzy/ui-context

Conversation

@EAGzzyCSL
Copy link
Collaborator

  • Move screenshot scaling logic from Agent to commonContextParser

    • Remove screenshotScale calculation from Agent class
    • Centralize shrink factor computation in commonContextParser
    • Automatically resize screenshots to match logical dimensions
  • Remove deprecated getContext method from AbstractInterface

    • Delete getContext implementations across all platforms (web, chrome-extension, puppeteer)
    • Simplify context retrieval to use commonContextParser uniformly
  • Standardize screenshot data structure

    • Replace screenshotBase64 field usage with ScreenshotItem.create()
    • Update StaticPage to use screenshot property consistently
    • Remove legacy compatibility layer for screenshotBase64
  • Clean up type definitions

    • Remove WebUIContext type alias (use UIContext directly)
    • Delete PlaygroundWebUIContext related types
    • Update imports across packages
  • Consolidate context parsers

    • Remove WebPageContextParser (superseded by commonContextParser)
    • Update all usages to use commonContextParser from @midscene/core/agent
    • Simplify evaluation and test utilities

This refactoring unifies UI context handling across all device types, reduces code duplication, and improves maintainability by centralizing screenshot processing logic in a single location.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 12, 2026

Deploying midscene with  Cloudflare Pages  Cloudflare Pages

Latest commit: 027f97f
Status: ✅  Deploy successful!
Preview URL: https://9ba8871a.midscene.pages.dev
Branch Preview URL: https://zzy-ui-context.midscene.pages.dev

View logs

- Move screenshot scaling logic from Agent to commonContextParser
  - Remove screenshotScale calculation from Agent class
  - Centralize shrink factor computation in commonContextParser
  - Automatically resize screenshots to match logical dimensions

- Remove deprecated getContext method from AbstractInterface
  - Delete getContext implementations across all platforms (web, chrome-extension, puppeteer)
  - Simplify context retrieval to use commonContextParser uniformly

- Standardize screenshot data structure
  - Replace screenshotBase64 field usage with ScreenshotItem.create()
  - Update StaticPage to use screenshot property consistently
  - Remove legacy compatibility layer for screenshotBase64

- Clean up type definitions
  - Remove WebUIContext type alias (use UIContext directly)
  - Delete PlaygroundWebUIContext related types
  - Update imports across packages

- Consolidate context parsers
  - Remove WebPageContextParser (superseded by commonContextParser)
  - Update all usages to use commonContextParser from @midscene/core/agent
  - Simplify evaluation and test utilities

This refactoring unifies UI context handling across all device types,
reduces code duplication, and improves maintainability by centralizing
screenshot processing logic in a single location.
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.

1 participant