RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
import { Card } from '@/components/ui/card';
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from '@/components/ui/resizable';
import { GenerateStatus } from '@/constants/knowledge';
import { useTranslation } from 'react-i18next';
import { useCompilationNav } from './hooks/use-compilation-nav';
import { NavCompilingState } from './nav-compiling-state';
import { NavTreeLeftPanel } from './nav-tree-left-panel';
export function NavTreeView() {
const { t } = useTranslation();
const {
navList,
navLoading,
navError,
keywords,
activeKeywords,
childrenMap,
childrenErrorParents,
structureMap,
selectedNode,
navRunData,
navStatus,
handleKeywordsChange,
handleNodeClick,
handleNodeExpand,
handleEntityClick,
} = useCompilationNav();
const compiling =
navStatus === GenerateStatus.Running || navStatus === GenerateStatus.Failed;
// First compile: no tree content to show yet, so replace the panels with
// the progress board. A keywords-filtered empty result keeps the panels so
// the user can keep editing the filter.
const firstCompileRunning =
compiling &&
!navLoading &&
!navError &&
!activeKeywords &&
(navList?.total ?? 0) === 0;
if (firstCompileRunning) {
return <NavCompilingState status={navStatus} data={navRunData} />;
}
return (
<Card className="flex-1 min-h-0 overflow-hidden flex border-border-button rounded-xl flex-col">
<ResizablePanelGroup direction="horizontal" className="flex-1">
<ResizablePanel defaultSize={33} minSize={20} maxSize={50}>
<NavTreeLeftPanel
navList={navList}
navLoading={navLoading}
navError={navError}
keywords={keywords}
activeKeywords={activeKeywords}
childrenMap={childrenMap}
childrenErrorParents={childrenErrorParents}
structureMap={structureMap}
traceData={navRunData}
onKeywordsChange={handleKeywordsChange}
onNodeClick={handleNodeClick}
onNodeExpand={handleNodeExpand}
onEntityClick={handleEntityClick}
/>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel className="flex flex-col">
{selectedNode ? (
<section className="flex flex-col h-full">
<header className="px-4 py-3 border-b border-border-button space-y-1">
<h3 className="text-sm font-medium text-text-primary">
{selectedNode.name}
</h3>
{selectedNode.doc_count !== undefined && (
<span className="text-xs text-text-secondary">
{t('knowledgeCompilation.navDocCount', {
count: selectedNode.doc_count,
})}
</span>
)}
</header>
<div className="flex-1 min-h-0 overflow-y-auto px-4 py-3 text-sm text-text-primary space-y-4">
<div>
<h4 className="text-xs font-medium text-text-secondary mb-1">
{t('knowledgeCompilation.description')}
</h4>
<p className="whitespace-pre-wrap">
{selectedNode.description ||
t('knowledgeCompilation.navNoDescription')}
</p>
</div>
{selectedNode.keywords && selectedNode.keywords.length > 0 && (
<div>
<h4 className="text-xs font-medium text-text-secondary mb-1">
{t('knowledgeCompilation.navKeywords')}
</h4>
<div className="flex flex-wrap gap-1">
{selectedNode.keywords.map((kw, i) => (
<span
key={i}
className="inline-block px-2 py-0.5 rounded text-xs bg-fill-quaternary text-text-secondary"
>
{kw}
</span>
))}
</div>
</div>
)}
{selectedNode.entities && selectedNode.entities.length > 0 && (
<div>
<h4 className="text-xs font-medium text-text-secondary mb-1">
{t('knowledgeCompilation.navEntities')}
</h4>
<div className="flex flex-wrap gap-1">
{selectedNode.entities.map((entity, i) => (
<span
key={i}
className="inline-block px-2 py-0.5 rounded text-xs bg-fill-quaternary text-text-secondary"
>
{entity}
</span>
))}
</div>
</div>
)}
{selectedNode.graph_content && (
<div>
<h4 className="text-xs font-medium text-text-secondary mb-1">
{t('knowledgeCompilation.navGraphContent')}
</h4>
<p className="whitespace-pre-wrap text-xs text-text-secondary">
{selectedNode.graph_content}
</p>
</div>
)}
</div>
</section>
) : (
<div className="flex-1 flex items-center justify-center text-sm text-text-secondary">
{t('knowledgeCompilation.navSelectNode')}
</div>
)}
</ResizablePanel>
</ResizablePanelGroup>
</Card>
);
}