feat(page-controller): refine dark mode detection heuristics by gaomeng1900 · Pull Request #544 · alibaba/page-agent · GitHub
Skip to content

feat(page-controller): refine dark mode detection heuristics#544

Merged
gaomeng1900 merged 1 commit into
mainfrom
feat/refine-dark-mode-check
Jun 9, 2026
Merged

feat(page-controller): refine dark mode detection heuristics#544
gaomeng1900 merged 1 commit into
mainfrom
feat/refine-dark-mode-check

Conversation

@gaomeng1900

@gaomeng1900 gaomeng1900 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

What

Refactor isPageDark heuristics:

  • split class/data-attribute checks into separate functions
  • extract a shared getLuminance helper
  • tighten matching (data-attr exact dark match, narrower main-content selectors)
  • reorganize utils.

Type

  • Breaking change
  • Bug fix
  • Feature / Improvement
  • Refactor / Chores
  • Documentation / Website / Demo / Testing

Testing

  • Tested in modern browsers
  • No console errors
  • Types/doc added

Requirements / 要求

  • I have read and follow the Code of Conduct and Contributing Guide . / 我已阅读并遵守行为准则。
  • This PR is NOT generated by a bot or AI agent acting autonomously. I have authored or meaningfully reviewed every change. / 此 PR 不是由 bot 或 AI 自主生成的,我已亲自编写或充分审查了每一处变更。

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

Copy link
Copy Markdown

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: 01c9cc9ea7

ℹ️ 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".

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve data-color-scheme detection

When a host page marks its theme with <html data-color-scheme="dark"> or the same attribute on <body>, this new attribute list no longer checks it even though the previous implementation did. In that scenario hasDarkModeDataAttribute() returns false and the simulator mask can be initialized in light mode unless a later background/text heuristic happens to infer darkness, so pages relying on this supported signal regress.

Useful? React with 👍 / 👎.

@gaomeng1900 gaomeng1900 merged commit 73810b3 into main Jun 9, 2026
4 checks passed
@gaomeng1900 gaomeng1900 deleted the feat/refine-dark-mode-check branch June 9, 2026 12:43
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