Skip to content

fix: deeply find themed variables#535

Merged
Brentlok merged 1 commit into
mainfrom
fix/deeply-find-themed-variables
May 14, 2026
Merged

fix: deeply find themed variables#535
Brentlok merged 1 commit into
mainfrom
fix/deeply-find-themed-variables

Conversation

@Brentlok
Copy link
Copy Markdown
Contributor

@Brentlok Brentlok commented May 14, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection of themed variable dependencies by recognizing transitive variable relationships, enabling more accurate theme-based styling adjustments.
  • Tests

    • Added comprehensive test coverage for styled metadata generation with theme variants.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

This PR adds recursive themed-variable dependency detection. A new hasThemedVarDependency helper determines whether a CSS variable ultimately depends on scoped themed variables through transitive references, replacing direct membership checks. The change enables StyleDependency.Theme to be applied to variables with indirect themed dependencies, tested via CSS fixtures.

Changes

Transitive Themed-Variable Dependency Detection

Layer / File(s) Summary
Recursive dependency checker
packages/uniwind/src/metro/addMetaToStylesTemplate.ts
hasThemedVarDependency helper recursively traverses Processor.vars to detect transitive dependencies on scoped themed variables; isUsingThemedVar switches from direct Processor.scopedVars membership checks to using this helper.
Fixture and test validation
packages/uniwind/tests/test.css, packages/uniwind/tests/native/styles-parsing/meta.test.ts
CSS test fixture wires --color-foreground from --app-foreground with dark/light variants; test suite compiles the fixture for iOS with both themes and asserts StyleDependency.Theme is present in stylesheet dependencies.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 Hops through the dependency tree with glee,
Finding themes that hide deep in vars you can't see,
Recursion prevents loops, visited checks the way,
Transitive theming now lights up your day! 🌓

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: deeply find themed variables' accurately describes the main change, which implements deep/recursive detection of themed variable dependencies.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deeply-find-themed-variables

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/uniwind/tests/native/styles-parsing/meta.test.ts (1)

29-29: 💤 Low value

Consider safer alternatives to eval() for executing compiled code.

While eval() is acceptable here since the code is internally generated (not user input) and isolated to tests, consider these alternatives for better maintainability:

  • Use new Function() with explicit parameters for slightly better scoping
  • Use Node's vm module for sandboxed execution
  • Structure the compiled output as a proper module if the format allows
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/uniwind/tests/native/styles-parsing/meta.test.ts` at line 29, The
test currently executes compiled code via eval(`(${virtualCode})`); replace this
with a safer executor such as new Function or Node's vm to avoid global scope
leakage: for example, create a function using new Function(`return
(${virtualCode})`)() to explicitly scope execution, or use
vm.Script(virtualCode) and runInNewContext(sandbox) to sandbox globals; update
the call site that uses eval(`(${virtualCode})`) in the test to use one of these
approaches and ensure any required inputs/exports are passed via explicit
parameters or the sandbox object.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/uniwind/tests/native/styles-parsing/meta.test.ts`:
- Line 29: The test currently executes compiled code via
eval(`(${virtualCode})`); replace this with a safer executor such as new
Function or Node's vm to avoid global scope leakage: for example, create a
function using new Function(`return (${virtualCode})`)() to explicitly scope
execution, or use vm.Script(virtualCode) and runInNewContext(sandbox) to sandbox
globals; update the call site that uses eval(`(${virtualCode})`) in the test to
use one of these approaches and ensure any required inputs/exports are passed
via explicit parameters or the sandbox object.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2ea0b470-ed56-4381-b5ff-37583575de4a

📥 Commits

Reviewing files that changed from the base of the PR and between faea367 and 561d0e7.

📒 Files selected for processing (3)
  • packages/uniwind/src/metro/addMetaToStylesTemplate.ts
  • packages/uniwind/tests/native/styles-parsing/meta.test.ts
  • packages/uniwind/tests/test.css

@Brentlok Brentlok merged commit 5f4d7f1 into main May 14, 2026
2 checks passed
@Brentlok Brentlok deleted the fix/deeply-find-themed-variables branch May 14, 2026 10:39
@github-actions
Copy link
Copy Markdown
Contributor

🚀 This pull request is included in v1.6.5. See Release v1.6.5 for release notes.

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