Skip to content

Feat: Search for timeline nodes. - #17996

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
cike8899:fix-search-required
Aug 7, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
cike8899:fix-search-required

Conversation

@cike8899

@cike8899 cike8899 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Feat: Search for timeline nodes.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code labels Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Search state now lives in useGraphEntitySearch, which debounces non-graph searches and controls graph fetching. RepresentationRenderer no longer filters tree data by keyword. Template selection validates the selected ID before rendering.

Changes

Representation search and rendering

Layer / File(s) Summary
Centralize search state and fetching
web/src/pages/chunk/representation/hooks/use-graph-entity-search.ts
The hook manages debounced search input, graph fetching, reset behavior, and search handlers.
Wire page search state
web/src/pages/chunk/representation/index.tsx
Representation uses the hook’s search state and passes its handler to ExpandableSearchInput. It no longer passes searchKeyword to RepresentationRenderer.
Render unfiltered template trees
web/src/components/structure-graph/representation-renderer.tsx, web/src/components/structure-graph/adapters.ts
RepresentationRenderer removes keyword filtering and passes adapted template data directly to TreeView. The filtering helper is removed.
Validate template selection and clarify pruning
web/src/pages/chunk/representation/hooks/use-selected-template.ts, web/src/pages/dataset/compilation/utils/skill-tree.ts
Template selection validates IDs against available templates. The skill-tree comment documents pruning and ancestor retention.

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

Sequence Diagram(s)

sequenceDiagram
  participant ExpandableSearchInput
  participant Representation
  participant useGraphEntitySearch
  participant DocumentGraphFetch
  ExpandableSearchInput->>Representation: change search keyword
  Representation->>useGraphEntitySearch: handleSearchKeywordChange
  useGraphEntitySearch->>DocumentGraphFetch: fetch with debounced keyword
  DocumentGraphFetch-->>useGraphEntitySearch: return graph results
Loading

Possibly related PRs

  • infiniflow/ragflow#17444: Both changes modify structure-graph search and rendering through RepresentationRenderer and useGraphEntitySearch.

Poem

A rabbit hops through trees so wide,
No keyword pruning hides the side.
The search hook keeps each query neat,
While valid templates guide its feet.
“Unfiltered branches!” the rabbit sings,
And wiggles both its fluffy wings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the Summary section and states the feature, but it does not provide the requested background context. Add background context that explains the problem, user need, and how the timeline-node search addresses it.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main change: adding search for timeline nodes.

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.

@cike8899 cike8899 added the ci Continue Integration label Aug 7, 2026
@cike8899
cike8899 requested a review from wangq8 August 7, 2026 08:36
@cike8899
cike8899 marked this pull request as draft August 7, 2026 08:36
@cike8899
cike8899 marked this pull request as ready for review August 7, 2026 08:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@web/src/pages/chunk/representation/hooks/use-graph-entity-search.ts`:
- Around line 17-23: Update the keyword selection around useDebounce and
useFetchDocumentStructureGraph to use raw searchKeyword for choosing the active
source, so clearing free-text immediately falls back to graphKeywords instead of
the stale debounced value. When searchKeyword becomes non-empty, clear
graphKeywords, and revise the nearby keyword-source comment to describe these
transitions accurately.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 822c1625-8650-474b-9ec5-fa61daca25e3

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa4e3c and 4ac9cbc.

📒 Files selected for processing (6)
  • web/src/components/structure-graph/adapters.ts
  • web/src/components/structure-graph/representation-renderer.tsx
  • web/src/pages/chunk/representation/hooks/use-graph-entity-search.ts
  • web/src/pages/chunk/representation/hooks/use-selected-template.ts
  • web/src/pages/chunk/representation/index.tsx
  • web/src/pages/dataset/compilation/utils/skill-tree.ts
💤 Files with no reviewable changes (1)
  • web/src/components/structure-graph/adapters.ts

Comment on lines +17 to +23
// Non-graph kinds search server-side with the same ?keywords= query the
// graph-kind Enter search uses; the two inputs never show at once, and the
// handlers below keep at most one of the two keyword sources non-empty.
const debouncedSearchKeyword = useDebounce(searchKeyword, { wait: 500 });
const { data, loading } = useFetchDocumentStructureGraph(
debouncedSearchKeyword || graphKeywords,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Confirm the return-value timing of [email protected] useDebounce(value, { wait: 500 }) when value changes from a non-empty string to an empty string.

💡 Result:

In [email protected], when the input value of useDebounce(value, { wait: 500 }) changes from a non-empty string to an empty string, the returned value will update to the empty string exactly 500 milliseconds after the change occurred [1][2]. This behavior occurs because useDebounce leverages useDebounceFn internally [1][2]. When the input value changes, the useEffect hook triggers the debounced function (run), which is configured with a 500ms delay [1][2]. The state holding the returned debounced value is only updated inside the debounced callback, meaning it waits for the specified wait period to elapse without further changes to the value before finalizing the update [1][3]. If the input remains an empty string for the duration of the wait, the update will execute at the end of that 500ms interval [4][3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== file outline"
ast-grep outline web/src/pages/chunk/representation/hooks/use-graph-entity-search.ts || true

echo "=== relevant source"
cat -n web/src/pages/chunk/representation/hooks/use-graph-entity-search.ts | sed -n '1,150p'

echo "=== package ahooks version"
if [ -f web/package.json ]; then
  node -e 'const p=require("./web/package.json"); console.log(p.dependencies?.ahooks ?? p.devDependencies?.ahooks ?? "not found in web/package.json")'
fi
if [ -f package.json ]; then
  node -e 'const p=require("./package.json"); console.log(p.dependencies?.ahooks ?? p.devDependencies?.ahooks ?? "not found in package.json")'
fi

echo "=== useFetchDocumentStructureGraph usages"
rg -n "useFetchDocumentStructureGraph|keepPreviousData" web/src -S | head -n 120

Repository: infiniflow/ragflow

Length of output: 6461


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== use-document-request relevant function"
cat -n web/src/hooks/use-document-request.ts | sed -n '730,776p'

echo "=== component consumers using returned searchKeyword / graphSelectValue"
rg -n "searchKeyword|graphSelectValue|handleSearchKeywordChange|handleNoMatchEnter|handleSelectEntity|handleTemplateChange|handleNodeClick" web/src/pages/chunk/representation -S

Repository: infiniflow/ragflow

Length of output: 4734


Switch the active keyword source when free-text search is cleared.

useDebounce(searchKeyword, { wait: 500 }) keeps the previous non-empty term for up to 500 ms. If that source is cleared at lines 60, 81, or 106 while graphKeywords is set, debouncedSearchKeyword || graphKeywords still sends the stale free-text term and preserves the prior cached result via keepPreviousData. Select the active source from raw searchKeyword; clear graphKeywords when searchKeyword starts non-empty; and update the keyword-source comment at lines 17-19 to match the actual state transitions.

🤖 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 `@web/src/pages/chunk/representation/hooks/use-graph-entity-search.ts` around
lines 17 - 23, Update the keyword selection around useDebounce and
useFetchDocumentStructureGraph to use raw searchKeyword for choosing the active
source, so clearing free-text immediately falls back to graphKeywords instead of
the stale debounced value. When searchKeyword becomes non-empty, clear
graphKeywords, and revise the nearby keyword-source comment to describe these
transitions accurately.

Source: Coding guidelines

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good refactor — moving tree search from client-side to server-side is the right approach for scalability. Architecture review:

What works well:

  • Removing the client-side filterTreeDataByKeyword and relying on useFetchDocumentStructureGraph with keyword parameters unifies the search path. Clean separation.
  • The 500ms debounce via useDebounce prevents hammering the API during fast typing.
  • The useSelectedTemplate fallback fix (checking if selectedTemplateId is still in the current templates array before using it, falling back to templates[0]) is important — without it, search results that don't include the previously selected template would render a blank representation.
  • Moving searchKeyword state and its handler into useGraphEntitySearch keeps the hook as the single source of truth for all search-related state. Good cohesion.
  • Mutual exclusivity between graphKeywords (entity dropdown) and searchKeyword (ExpandableSearchInput) is handled properly through the callbacks — at most one is non-empty at a time.

Minor observations (non-blocking):

  • In use-graph-entity-search.ts, handleSearchKeywordChange only sets searchKeyword but doesn't explicitly clear graphKeywords. The safety relies on callers (the dropdown handlers) clearing searchKeyword. This is fine for the current UX where the two inputs never show simultaneously, but a future refactor that adds both inputs at once could hit a subtle conflict. Consider adding a comment noting this assumption, or clearing graphKeywords in handleSearchKeywordChange for defense-in-depth.
  • The comment cleanup in skill-tree.ts is a nice touch — stale references to deleted code are worse than removed code.

LGTM overall. 👍

@wangq8
wangq8 merged commit ec09d4e into infiniflow:main Aug 7, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants