Skip to content

fix: highlight ancestor nodes whose labels match the search query#245

Open
R-Hart80 wants to merge 2 commits into
CatholicOS:devfrom
R-Hart80:fix/tree-search-highlight-matching-ancestors
Open

fix: highlight ancestor nodes whose labels match the search query#245
R-Hart80 wants to merge 2 commits into
CatholicOS:devfrom
R-Hart80:fix/tree-search-highlight-matching-ancestors

Conversation

@R-Hart80
Copy link
Copy Markdown
Contributor

Problem

Closes #209.

Searching the Class tree highlighted only the leaf nodes that the backend's search endpoint returned. If an ancestor's label also contained the query string, it was rendered without the <mark> highlight or tree-search-match class — even though it's an equally valid match from the user's perspective.

Example with query document:

> Event
  > Conflict
    > Document Collection and Production Events   ← contains "document", NOT highlighted (before)
      * Document Collection Event                 ← backend result, highlighted

Root cause

mergePathsIntoTree (lib/hooks/useFilteredTree.ts) only added IRIs from the backend response to matchIris. Ancestor nodes were inserted into the tree with isSearchMatch: false regardless of their labels.

Fix

Four files changed:

  1. lib/hooks/useFilteredTree.tsmergePathsIntoTree now accepts an optional query parameter (default ""). For every node inserted or updated, it checks item.label.toLowerCase().includes(q) in addition to matchIris.has(item.iri). Added searchQuery?: string to UseFilteredTreeOptions; the hook passes it down to the merge.

  2. components/editor/standard/StandardEditorLayout.tsx — passes searchQuery to useFilteredTree.

  3. components/editor/developer/DeveloperEditorLayout.tsx — same.

  4. __tests__/lib/hooks/useFilteredTree.test.ts — four new tests:

    • ancestor with matching label is highlighted
    • matching is case-insensitive
    • empty query leaves ancestors unhighlighted (no regression)
    • ancestor with non-matching label stays unhighlighted

Testing

  • All 26 useFilteredTree / mergePathsIntoTree tests pass (including 4 new ones)
  • Full suite: 158/159 pass (1 pre-existing failure in LanguagePicker.test.tsx, unrelated)
  • The downstream rendering in EntityTreeNode.tsx already respects node.isSearchMatch — no changes needed there

🤖 Generated with Claude Code

R-Hart80 and others added 2 commits May 11, 2026 10:54
When a project is webhook-driven, the four GitHub integration input
fields (repo owner, repo name, branch, file path) were already marked
readOnly and visually styled as disabled on the inputs themselves.
This commit extends the visual treatment to their labels by applying
opacity-60 when isWebhookDriven is true, and moves the explanatory
note ("Repository fields are managed by the GitHub integration.")
to appear after all four fields so it clearly covers the whole group.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mergePathsIntoTree now accepts a query string and marks any node
isSearchMatch when its label contains the query (case-insensitive),
not only the leaf IRIs returned by the backend. Plumbed searchQuery
from useTreeSearch through UseFilteredTreeOptions into the merge.

Four new tests cover: ancestor highlight, case-insensitivity, empty
query no-op, and non-matching ancestor stays unhighlighted. Fixes CatholicOS#209.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Warning

Rate limit exceeded

@R-Hart80 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 36 minutes and 20 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 40ecb227-da13-4098-8ad6-d812dfe24cb1

📥 Commits

Reviewing files that changed from the base of the PR and between 0233a83 and 89aee90.

📒 Files selected for processing (5)
  • __tests__/lib/hooks/useFilteredTree.test.ts
  • app/projects/[id]/settings/page.tsx
  • components/editor/developer/DeveloperEditorLayout.tsx
  • components/editor/standard/StandardEditorLayout.tsx
  • lib/hooks/useFilteredTree.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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.

Class tree search highlights only leaf-level matches; intermediate ancestors with matching labels are missed

1 participant