Skip to content

Fixes 6035: Add theme-aware canvas color resolution - #32423

Merged
shah-harshit merged 2 commits into
mainfrom
finish-issue-6035-switcher
Sep 3, 2026
Merged

shah-harshit merged 2 commits into
mainfrom
finish-issue-6035-switcher

Conversation

@shah-harshit

Copy link
Copy Markdown
Contributor

Describe your changes:

Part of open-metadata/openmetadata-collate#6035

This adds the OSS foundation for theme-aware non-DOM rendering. Canvas and WebGL consumers can now resolve CSS color tokens through a shared bounded resolver without retaining stale light-theme or brand colors. Ontology Explorer now uses the shared resolver through its existing getCanvasColor API.

The change also centralizes --om-page-height, restores deterministic token drift, and ensures every project token appears in the generated token reference.

Type of change:

  • Improvement

High-level design:

  • Resolve CSS custom properties through a temporary non-inherited background-color probe so invalid variables cannot fall back to unrelated inherited text colors.
  • Cache successful resolutions in a 200-entry LRU keyed by the root class list and inline styles, which are the runtime inputs for dark mode and custom branding.
  • Preserve the existing Ontology Explorer getCanvasColor API while moving its implementation into a shared utility.
  • Define the shared page-height token in tokens.css and keep scoped recomputation where shell height changes.
  • Extend the token drift gate so generated documentation must include every --om-* definition.

No migration or backward-compatibility concerns; existing concrete color inputs and fallback behavior are preserved.

Tests:

Use cases covered

  • Re-resolves canvas colors after light/dark root class changes.
  • Re-resolves colors after inline brand variable changes.
  • Returns caller fallbacks for missing, invalid, transparent, or non-color token values.
  • Bounds the color cache and evicts least-recently-used entries.
  • Ensures generated token documentation contains every project token.

Unit tests

  • Added unit tests for the new and changed logic.
  • Files added/updated: cssColor.utils.test.ts, graphStyles.test.ts, gen-token-reference.test.js.
  • Focused result: 22 tests passed.

Backend integration tests

  • Not applicable; no backend API changes.

Ingestion integration tests

  • Not applicable; no ingestion changes.

Playwright (UI) tests

  • Not applicable; this PR adds shared rendering infrastructure without a new user interaction.

Manual testing performed

No standalone visual flow is introduced in this foundation PR. Runtime theme, branding, fallback, and cache behavior are covered by focused unit tests.

UI screen recording / screenshots:

Not applicable; component-level semantic token migrations will consume this foundation in follow-up PRs.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>.
  • My PR is linked to a GitHub issue above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • No JSON Schema changes are included.
  • UI recording is not applicable for this infrastructure-only slice.
  • I have added tests and listed them above.

Improvement

  • I have added tests around the new logic.

@shah-harshit shah-harshit added UI UI specific issues safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check labels Sep 2, 2026
@shah-harshit shah-harshit self-assigned this Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 67%
67.94% (88472/130216) 52% (54447/104689) 53.63% (16658/31057)

@gitar-bot

gitar-bot Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Adds theme-aware canvas color resolution through a shared CSS token resolver with LRU caching, enabling non-DOM rendering (canvas/WebGL) to respect light/dark mode and custom branding. The color guard now accepts modern CSS color functions, and comprehensive unit tests verify theme switching, fallback behavior, cache bounds, and token documentation coverage. No issues found.

✅ 1 resolved
✅ Edge Case: Color guard rejects modern CSS color functions

📄 openmetadata-ui/src/main/resources/ui/src/utils/common/cssColor.utils.ts:15 📄 openmetadata-ui/src/main/resources/ui/src/utils/common/cssColor.utils.ts:27-30
isResolvedColor only accepts values matching /^(?:rgb|#|hsl)/. Some browsers serialize getComputedStyle().backgroundColor for wide-gamut/modern tokens as oklch(...), oklab(...), lab(...), hwb(...), or color(...). For such a token the resolver would treat a perfectly valid resolved color as unresolved and return the caller fallback instead, silently losing theme/brand color in Canvas/WebGL. Since this is positioned as a shared resolver for all canvas consumers, consider widening the accepted-format check (or inverting it to reject only the known non-colors like empty/rgba(0, 0, 0, 0)).

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 8 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 8 warning(s) across 1 changed file(s).

Count Rule
5 sonarjs/no-nested-conditional
2 sonarjs/cyclomatic-complexity
1 sonarjs/cognitive-complexity
All findings
Location Rule Message
🟡 src/components/OntologyExplorer/utils/graphStyles.ts:538:17 sonarjs/cognitive-complexity Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed.
🟡 src/components/OntologyExplorer/utils/graphStyles.ts:538:17 sonarjs/cyclomatic-complexity {"message":"Function has a complexity of 23 which is greater than 10 authorized.","cost":13,"secondaryLocations":[{"line":538,"column":16,"endLine":538,"endColu
🟡 src/components/OntologyExplorer/utils/graphStyles.ts:567:9 sonarjs/no-nested-conditional Extract this nested ternary operation into an independent statement.
🟡 src/components/OntologyExplorer/utils/graphStyles.ts:572:9 sonarjs/no-nested-conditional Extract this nested ternary operation into an independent statement.
🟡 src/components/OntologyExplorer/utils/graphStyles.ts:575:48 sonarjs/no-nested-conditional Extract this nested ternary operation into an independent statement.
🟡 src/components/OntologyExplorer/utils/graphStyles.ts:578:9 sonarjs/no-nested-conditional Extract this nested ternary operation into an independent statement.
🟡 src/components/OntologyExplorer/utils/graphStyles.ts:594:9 sonarjs/no-nested-conditional Extract this nested ternary operation into an independent statement.
🟡 src/components/OntologyExplorer/utils/graphStyles.ts:710:17 sonarjs/cyclomatic-complexity {"message":"Function has a complexity of 11 which is greater than 10 authorized.","cost":1,"secondaryLocations":[{"line":710,"column":16,"endLine":710,"endColum

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 9a18a875fad5e6dc5caefbba99dbbd5635d21317 in Playwright run 33598932045, attempt 1.

✅ 604 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 1h 18m 15s

⏱️ Max setup 4m 17s · max shard execution 19m 18s · max shard-job elapsed before upload 22m 45s · reporting 5s

🌐 211.68 requests/attempt · 2.59 app boots/UI scenario · 14.08% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 211.68 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.59 per UI scenario (1715 boots / 663 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 152 0 0 0 0 0
✅ Shard chromium-02 153 0 0 0 0 0
✅ Shard chromium-03 143 0 0 0 0 0
✅ Shard data-asset-rules-01 63 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@shah-harshit
shah-harshit added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit 3975011 Sep 3, 2026
103 checks passed
@shah-harshit
shah-harshit deleted the finish-issue-6035-switcher branch September 3, 2026 00:15
shrabantipaul-collate pushed a commit to PRADDZY/OpenMetadata that referenced this pull request Sep 3, 2026
)

* fix(ui): refresh canvas colors after theme changes

* fix(ui): support modern computed colors

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants