Skip to content

fix(web): restore entity type colors in knowledge graphs - #21443

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
okht:codex/ragflow-entity-colors
Nov 2, 2026
Merged

JinHai-CN merged 2 commits into
infiniflow:mainfrom
okht:codex/ragflow-entity-colors

Conversation

@okht

@okht okht commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses #21375 by assigning knowledge graph nodes stable colors based on their entity type. Colors stay consistent when nodes are reordered or a graph subset is displayed. Blank types and other use gray.

Tooltips show the original entity type alongside its description, with plain text escaped before rendering. The palette has ten colors, so different types can share a color; the tooltip provides the exact type.

The change is limited to knowledge graph rendering. Wiki and session graph defaults, graph layout, and existing hover and pinned-node highlighting remain unchanged. No new dependencies or backend changes are required.

Validation

  • Four focused test suites passed: 29 tests covering color stability, fallback behavior, tooltip escaping, highlighting, and rendering scope.
  • Formatting and lint checks for changed files, git diff --check, and the pre-commit hooks passed.
  • Checked the actual components in a browser using synthetic fixtures: light and dark themes, tooltips, highlighting, reordered nodes, graph subsets, and session graph defaults.
  • Full TypeScript checking still reports 146 errors. An isolated baseline at 176e91d7 produces the same diagnostics, with no differences.
  • Browser checks used synthetic fixtures; backend end-to-end behavior and the issue author's dataset were not reproduced.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 08659e93-a70d-44fd-85c3-8e05f8d0c079
Commits

Reviewing files that changed from the base of the PR and between 8363b3d and 998118b.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5c4b0ad4-ffbd-4794-a0b9-eb8392ab4323
Commits

Reviewing files that changed from the base of the PR and between df88c61 and dad6c5c.

Files selected for processing: 3
  • web/src/components/artifact-force-graph/index.tsx
  • web/src/components/structure-graph/representation-renderer.tsx
  • web/src/components/structure-graph/use-knowledge-graph-node-style.ts
Files skipped from review as they are similar to previous changes: 3
  • web/src/components/structure-graph/representation-renderer.tsx
  • web/src/components/structure-graph/use-knowledge-graph-node-style.ts
  • web/src/components/artifact-force-graph/index.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

The graph component now accepts custom node labels and escapes them before rendering. Knowledge graph rendering supplies entity-type labels and categorical colors through new style helpers and shared CSS tokens.

Changes: Knowledge graph styling

Layer / File(s) Summary
Graph label callback and escaping
web/src/components/artifact-force-graph/types.ts, web/src/components/artifact-force-graph/index.tsx, web/src/components/artifact-force-graph/__tests__/index.test.tsx
ArtifactForceGraph accepts a label callback and defaults to entity descriptions. It escapes callback output before passing it to ForceGraph2D. Tests cover labels, graph-data identity, node colors, and zoom-fit calls.
Knowledge graph labels and color palette
web/src/components/structure-graph/use-knowledge-graph-node-style.ts, web/tailwind.css, web/src/components/structure-graph/__tests__/knowledge-graph-node-style.test.ts
The style helpers format labels and assign colors using normalized entity types and CSS palette tokens. Tests cover label formatting, palette selection, and callback stability.
Renderer callback wiring
web/src/components/structure-graph/representation-renderer.tsx, web/src/components/structure-graph/__tests__/representation-renderer.test.tsx
RepresentationRenderer passes node color and label callbacks to ArtifactForceGraph for KnowledgeGraph templates. Tests check callback identity and templates without the callbacks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related issues

Suggested reviewers: qaqadws

Merge Risk: Minimal · previous review dad6c

No actionable merge-blocking issue is established; the change is ready for normal merge checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "fix(web): restore entity type colors in knowledge graphs" matches the main change. The PR assigns stable, type-based colors to knowledge graph nodes (ten-color palette with a gray fallback …
Description check Passed The description follows the required template. It includes a "Summary" section that explains the problem context (issue #21375), the approach (stable type-based colors, ten-color palette, gray fallbac…
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.
Full details: Title check

Explanation

The title "fix(web): restore entity type colors in knowledge graphs" matches the main change. The PR assigns stable, type-based colors to knowledge graph nodes (ten-color palette with a gray fallback for blank types and other) and shows the entity type in tooltips. The title is concise, specific, and follows a conventional-commit style. The word "restore" implies the colors existed before, which the linked issue #21375 is expected to confirm. The summary does not describe the tooltip change, but the title does not need to cover every detail.

Full details: Description check

Explanation

The description follows the required template. It includes a "Summary" section that explains the problem context (issue #21375), the approach (stable type-based colors, ten-color palette, gray fallback), the tooltip behavior, and the scope limits. It also adds a "Validation" section with test, lint, and browser-check results, which goes beyond the template. The description is complete and specific.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit sees the node colors glow
Type and description join the show
Safe labels travel to the graph
Ten bright hues fill each path
The rabbit hops through data’s flow

@wangq8
wangq8 requested a review from cike8899 October 27, 2026 01:54
@wangq8
wangq8 requested a review from dcc123456 October 29, 2026 12:38
@wangq8 wangq8 added the ci Continue Integration label Oct 29, 2026
@wangq8
wangq8 removed the request for review from dcc123456 October 30, 2026 05:02
@okht
okht force-pushed the codex/ragflow-entity-colors branch from 8363b3d to 998118b Compare October 31, 2026 14:53
@JinHai-CN
JinHai-CN merged commit 30359a7 into infiniflow:main Nov 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants