Skip to content

fix(registry): stop theme scopes rebuilding on unrelated MediaQuery changes - #319

Open
leoafarias wants to merge 2 commits into
mainfrom
fix/registry-theme-scope-media-query
Open

leoafarias wants to merge 2 commits into
mainfrom
fix/registry-theme-scope-media-query

Conversation

@leoafarias

@leoafarias leoafarias commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

VanillaTheme and FortalTheme decided whether to supply a MediaQuery from the view by calling MediaQuery.maybeOf(context). That call subscribes to every MediaQuery field, so the scope rebuilt on unrelated changes such as keyboard insets, once per frame while the keyboard animates. With Fortal the rebuild also reached every widget that reads a Fortal token, because its shadow tokens are fresh lists that never compare equal; with Vanilla it stayed within the scope and its own wrappers.

The check now uses context.getElementForInheritedWidgetOfExactType<MediaQuery>(), which finds the ancestor without subscribing. System mode still follows platformBrightness through its own aspect lookup. The registry templates and the installed copies in the workspace apps are regenerated, and the design-system skill now names this lookup for preset authors.

Validation

  • Per preset, a const scope rebuilds 0 times on a viewInsets change and exactly once on a platformBrightness change in system mode, counted with debugOnRebuildDirtyWidget. Both fail on the old line (Expected: 0, Actual: 1).
  • Per preset, a scope under a bare RawView (no MediaQuery above it) supplies one and follows the view's brightness. This branch had no coverage before; the test fails when the branch is disabled.
  • registry_source suite: passed. dart analyze: no issues.
  • open-code:registry:build --check clean; tool/check_consumer_apps.dart: all four consumer apps mirror the registry.
  • Root dart format check and melos run ci:checks: passed.

Related Issues

None.


Checklist

  • My PR includes unit or integration tests for all changed/updated/fixed behaviors.
  • I have updated or added relevant documentation (doc comments with ///).
  • I am prepared to follow up on review comments in a timely manner.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

…hanges

The Vanilla and Fortal theme scopes checked MediaQuery.maybeOf(context)
to decide whether to supply a MediaQuery from the view. maybeOf subscribes
to every MediaQuery field, so the scope and everything it builds rebuilt on
unrelated changes such as keyboard insets, once per frame while the keyboard
moves. Use getElementForInheritedWidgetOfExactType, which does not
subscribe. System mode still follows platformBrightness through its own
aspect lookup.

Regenerates the registry templates and the installed copies in the
workspace consumer apps.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T17:49:54.607300Z 46918b8 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

The branch that supplies a MediaQuery when a scope sits above any had no
test, because View always provides one in apps and widget tests. Pump each
scope under a bare RawView and check it supplies a MediaQuery and follows
the view's brightness. Also tell preset authors which lookup avoids the
rebuild this PR fixes.

This branch has not been deployed

No deployments
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