Skip to content

Fixes 6035: Make ontology graph rendering theme-aware - #32439

Merged
shah-harshit merged 9 commits into
mainfrom
issue-6035-ontology-theme-rendering
Sep 8, 2026
Merged

shah-harshit merged 9 commits into
mainfrom
issue-6035-ontology-theme-rendering

Conversation

@shah-harshit

@shah-harshit shah-harshit commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Part of open-metadata/openmetadata-collate#6035

Stack dependency: #32423. Review only commit eda14d3593; this PR will be retargeted to main after the foundation PR merges.

This makes Ontology Explorer's G6 canvas respond to light/dark theme changes without a page reload. Graph nodes, combos, edges, labels, badges, borders, halos, and shadows now use semantic color tokens resolved at the canvas boundary with concrete fallbacks.

The theme provider also applies the root theme before canvas consumers render, including the initial stored/system theme, so resolved colors cannot lag one render behind the selected theme.

The graph projection and runtime update helpers were decomposed to remove all changed-file ESLint warnings while preserving the existing layout and incremental-update behavior.

Screen.Recording.2026-09-02.at.6.25.28.PM.mov

Type of change:

  • Improvement

High-level design:

  • Subscribe graph-data construction to useTheme() so changing the theme rebuilds the resolved G6 data.
  • Apply the root theme class before notifying context consumers; canvas APIs cannot inherit later CSS cascade updates like DOM elements can.
  • Keep semantic CSS variables for DOM/SVG consumers and resolve them only when values enter G6 canvas styles.
  • Preserve concrete color fallbacks for missing tokens and keep relationship/category accent palettes unchanged for later slices.

No migration or backward-compatibility concerns.

Tests:

Use cases covered

  • Ontology node and edge canvas colors rebuild from light to dark without reload.
  • Stored and user-selected themes are applied before theme consumers render.
  • Rectangular nodes, data-mode term/asset nodes, glossary combos, and generic edge labels resolve semantic colors.
  • Shared canvas color caching continues to re-resolve across theme changes.
  • Hierarchy expansion never re-adds another graph node representing the selected term.
  • Root theme application skips DOM writes when the class and color scheme already match.

Unit tests

  • Added and updated unit tests for the changed logic.
  • Files updated: useGraphData.test.ts, graphStyles.test.ts, and theme-provider.test.tsx.
  • Focused result: 67 tests passed across four suites.

Backend integration tests

  • Not applicable; no backend API changes.

Ingestion integration tests

  • Not applicable; no ingestion changes.

Playwright (UI) tests

  • Not applicable; this slice changes canvas styling and is covered by focused theme-transition tests.

Manual testing performed

  • Verified the exact UI checkstyle sequence on all eight changed files.
  • Verified ESLint reports zero warnings across all eight changed files.
  • Verified no TypeScript diagnostics reference the changed files.
  • Verified design-token drift, token scanner tests, license headers, and whitespace checks.

UI screen recording / screenshots:

Not included in this stacked implementation slice. End-to-end visual review will cover the complete dark-mode stack.

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 hard-to-understand behavior.
  • No JSON Schema changes are included.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests and listed them above.

Improvement

  • I have added tests around the new logic.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@shah-harshit shah-harshit added the UI UI specific issues label Sep 2, 2026
@shah-harshit shah-harshit self-assigned this Sep 2, 2026
@shah-harshit shah-harshit added skip-pr-checks Bypass PR metadata validation check safe to test Add this label to run secure Github workflows on PRs labels 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: 70%
70.45% (95206/135138) 54.99% (56328/102431) 56.37% (18807/33363)

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit e10337252c7475bb51a7bf35ceca54c9de5d30a5 in Playwright run 34189145810, attempt 1.

✅ 606 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) 33m 53s

⏱️ Max setup 4m 32s · max shard execution 15m 14s · max shard-job elapsed before upload 18m 46s · reporting 5s

🌐 228.32 requests/attempt · 2.60 app boots/UI scenario · 13.24% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 228.32 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.6 per UI scenario (1711 boots / 659 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 119 0 0 0 0 0
✅ Shard chromium-02 116 0 0 0 0 0
✅ Shard chromium-03 114 0 0 0 0 0
✅ Shard chromium-04 99 0 0 0 0 0
✅ Shard data-asset-rules-01 65 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 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — merge_conflict (2026-09-03T21:12:12Z)

The entry left the queue before it was built, so no checks ran against it.

chirag-madlani
chirag-madlani previously approved these changes Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-09-04T05:12:19Z)

The entry left the queue before it was built, so no checks ran against it.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — merge_conflict (2026-09-05T01:31:29Z)

The entry left the queue before it was built, so no checks ran against it.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-09-05T11:57:35Z)

The entry left the queue before it was built, so no checks ran against it.

…heme-rendering

# Conflicts:
#	openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useGraphData.ts
#	openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useOntologyGraph.ts
#	openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/utils/graphStyles.ts
@gitar-bot

gitar-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown
Code Review ⚠️ Changes requested 1 resolved / 3 findings

Adds theme-aware rendering for the ontology graph canvas, but edge color fallbacks use unresolvable CSS variables instead of concrete hex colors, and studio node borders no longer resolve semantic tokens across theme changes. Restore concrete fallbacks in computeEdgeColor and re-enable token resolution for studio node borders in buildDefaultNodeData.

⚠️ Bug: Edge color fallback is an unresolvable CSS var, not a concrete color

📄 openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useGraphData.ts:1093-1102

In computeEdgeColor, getCanvasColor is now called with a CSS-variable string as its fallback: for asset edges the fallback is DATA_MODE_ASSET_EDGE_STROKE_COLOR (var(--color-border-secondary)) and for other edges it is EDGE_STROKE_COLOR (var(--color-border-primary)). The old code passed concrete hex fallbacks ('#D9DEED' and '#9196B1'). resolveCssColor returns the fallback verbatim when resolution fails (SSR/document undefined, detached DOM, or a missing token), so G6 would receive an unresolvable var(...) string as a canvas color instead of a safe concrete value — defeating the fallback whose contract is explicitly "callers provide a safe concrete fallback". Restore concrete hex fallbacks.

Pass concrete hex fallbacks matching the pre-refactor behavior.
return getCanvasColor(
  rawEdgeColor,
  isDataModeAssetEdge ? '#D9DEED' : '#9196B1'
);
💡 Quality: Studio node border stroke no longer theme-resolved

📄 openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useGraphData.ts:886-892

In buildDefaultNodeData, the studio-mode non-isolated node stroke is now hardcoded to '#E9EAEB', whereas the previous code used getCanvasColor(NODE_BORDER_COLOR, '#E9EAEB') which resolved the semantic border token per active theme. This drops theme awareness for studio node borders, which runs counter to this PR's goal; in dark mode the border will stay the light-theme color. If studio mode is intentionally light-only this is fine, otherwise resolve the token via getCanvasColor.

Resolve NODE_BORDER_COLOR through getCanvasColor so the studio border follows the theme.
...(ctx.studioMode && {
  label: false,
  stroke:
    node.type === 'glossaryTermIsolated'
      ? '#FEDF89'
      : getCanvasColor(NODE_BORDER_COLOR, '#E9EAEB'),
  studioLabelText: state.label,
  studioAccentColor: state.studioAccentColor ?? STUDIO_DEFAULT_ACCENT,
  studioEditMode: ctx.isEditMode,
}),
✅ 1 resolved
✅ Quality: DOM mutation runs inside useState lazy initializer

📄 openmetadata-ui/src/main/resources/ui/src/context/UntitledUIThemeProvider/theme-provider.tsx:277-285
applyThemeToRoot mutates document.documentElement (toggles the dark-mode class and sets colorScheme) from within the useState lazy initializer, which executes during the render phase. This is a side effect during render: React may invoke or discard renders (StrictMode double-invocation, concurrent/suspended renders), so the root class can be mutated without a corresponding committed state. It's idempotent here so the practical risk is low, and the approach is intentional (the class must exist before canvas consumers resolve tokens on first render, which a parent layout effect can't guarantee). Consider adding a short comment noting the render-phase side effect is deliberate, or gating it so it only writes when the current root state differs, to make the impurity explicit for future maintainers.

🤖 Prompt for agents
Code Review: Adds theme-aware rendering for the ontology graph canvas, but edge color fallbacks use unresolvable CSS variables instead of concrete hex colors, and studio node borders no longer resolve semantic tokens across theme changes. Restore concrete fallbacks in `computeEdgeColor` and re-enable token resolution for studio node borders in `buildDefaultNodeData`.

1. ⚠️ Bug: Edge color fallback is an unresolvable CSS var, not a concrete color
   Files: openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useGraphData.ts:1093-1102

   In `computeEdgeColor`, `getCanvasColor` is now called with a CSS-variable string as its fallback: for asset edges the fallback is `DATA_MODE_ASSET_EDGE_STROKE_COLOR` (`var(--color-border-secondary)`) and for other edges it is `EDGE_STROKE_COLOR` (`var(--color-border-primary)`). The old code passed concrete hex fallbacks (`'#D9DEED'` and `'#9196B1'`). `resolveCssColor` returns the fallback verbatim when resolution fails (SSR/`document` undefined, detached DOM, or a missing token), so G6 would receive an unresolvable `var(...)` string as a canvas color instead of a safe concrete value — defeating the fallback whose contract is explicitly "callers provide a safe concrete fallback". Restore concrete hex fallbacks.

   Fix (Pass concrete hex fallbacks matching the pre-refactor behavior.):
   return getCanvasColor(
     rawEdgeColor,
     isDataModeAssetEdge ? '#D9DEED' : '#9196B1'
   );

2. 💡 Quality: Studio node border stroke no longer theme-resolved
   Files: openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useGraphData.ts:886-892

   In `buildDefaultNodeData`, the studio-mode non-isolated node stroke is now hardcoded to `'#E9EAEB'`, whereas the previous code used `getCanvasColor(NODE_BORDER_COLOR, '#E9EAEB')` which resolved the semantic border token per active theme. This drops theme awareness for studio node borders, which runs counter to this PR's goal; in dark mode the border will stay the light-theme color. If studio mode is intentionally light-only this is fine, otherwise resolve the token via `getCanvasColor`.

   Fix (Resolve NODE_BORDER_COLOR through getCanvasColor so the studio border follows the theme.):
   ...(ctx.studioMode && {
     label: false,
     stroke:
       node.type === 'glossaryTermIsolated'
         ? '#FEDF89'
         : getCanvasColor(NODE_BORDER_COLOR, '#E9EAEB'),
     studioLabelText: state.label,
     studioAccentColor: state.studioAccentColor ?? STUDIO_DEFAULT_ACCENT,
     studioEditMode: ctx.isEditMode,
   }),

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

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

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.

3 participants