Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: The Go version of the artifact tree also needs to display build logs. (#19841)

balibabu48e9215f5638
diff --git a/web/src/components/next-markdown-content/index.tsx b/web/src/components/next-markdown-content/index.tsx
index 385c32c792..a165c245da 100644
--- a/web/src/components/next-markdown-content/index.tsx
+++ b/web/src/components/next-markdown-content/index.tsx
@@ -395,7 +395,7 @@ function MarkdownContent({
[renderPopoverContent, t],
);
- const dir = getDirAttribute(content.replace(citationMarkerReg, ''));
+ const dir = getDirAttribute(content?.replace(citationMarkerReg, ''));
const showLoadingDots = useLoadingPause(loading, content);
return (
diff --git a/web/src/hooks/use-dataset-generate.ts b/web/src/hooks/use-dataset-generate.ts
index 4cfad4bcf4..37cc75f57c 100644
--- a/web/src/hooks/use-dataset-generate.ts
+++ b/web/src/hooks/use-dataset-generate.ts
@@ -156,9 +156,9 @@ const TraceTypeMap: Record<GenerateType, TraceType> = {
[GenerateType.SessionGraph]: TraceType.SessionGraph,
};
-export const useTraceRunData = (type: GenerateType) => {
+export const useTraceRunData = (type: GenerateType, open = true) => {
const { id } = useParams();
- return useTraceQuery(type, TraceTypeMap[type], true, id);
+ return useTraceQuery(type, TraceTypeMap[type], open, id);
};
export const useUnBindTask = () => {
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index 3570c7ff8a..21a1e17d07 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -2511,6 +2511,7 @@ Example: Virtual Hosted Style`,
skillDeleteTitle: 'Delete skill',
skillDeleteDescription: 'Are you sure you want to delete this skill?',
navTitle: 'Navigation tree',
+ navLogTitle: 'Navigation tree log',
navEmpty: 'No navigation nodes',
navLoadFailed: 'Failed to load the navigation tree',
navChildLoadFailed: 'Failed to load child nodes',
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index 125cea2773..07c5cf9468 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -2121,6 +2121,7 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取 Entities 和 R
skillDeleteTitle: '删除 Skill',
skillDeleteDescription: '确定要删除该 Skill 吗?',
navTitle: 'PageIndex',
+ navLogTitle: '导航树日志',
navEmpty: '暂无导航节点',
navLoadFailed: '加载目录树失败',
navChildLoadFailed: '加载子节点失败',
diff --git a/web/src/pages/dataset/compilation/compile-progress-board.tsx b/web/src/pages/dataset/compilation/compile-progress-board.tsx
new file mode 100644
index 0000000000..311fdbfb9d
--- /dev/null
+++ b/web/src/pages/dataset/compilation/compile-progress-board.tsx
@@ -0,0 +1,61 @@
+import { IconFontFill } from '@/components/icon-font';
+import { GenerateStatus } from '@/constants/knowledge';
+import { ITraceInfo } from '@/hooks/use-dataset-generate';
+import { useTranslation } from 'react-i18next';
+
+import { ProgressLogPanel } from './progress-log-panel';
+
+type CompileProgressBoardProps = {
+ status: GenerateStatus;
+ data?: ITraceInfo;
+ label: string;
+};
+
+// Go-backend compile progress board: the scheduler exposes no stable
+// percentage and no scheduler cancel, so the center shows the MySQL
+// inflight/backlog counts (or the error diagnostic) above the product label,
+// and the right column streams the bounded phase log.
+export function CompileProgressBoard({
+ status,
+ data,
+ label,
+}: CompileProgressBoardProps) {
+ const { t } = useTranslation();
+
+ return (
+ <div className="grid h-full w-full grid-cols-[1fr_auto_1fr] items-center gap-8 p-6">
+ <div />
+ <div className="flex flex-col items-center gap-5">
+ {status === GenerateStatus.Failed ? (
+ <div className="flex flex-col items-center gap-2 text-state-error">
+ <IconFontFill name="reparse" className="size-8" />
+ <span className="text-text-primary">
+ {data?.compilationError || t('message.operated')}
+ </span>
+ </div>
+ ) : (
+ <div className="flex flex-col items-center gap-2 text-text-secondary">
+ <span className="text-4xl font-medium text-accent-primary">
+ {t('knowledgeCompilation.compiling', {
+ defaultValue: 'Compiling…',
+ })}
+ </span>
+ <span>
+ {t('knowledgeCompilation.compilingCounts', {
+ inflight: data?.inflight ?? 0,
+ backlog: data?.backlog ?? 0,
+ defaultValue: '{{inflight}} processing / {{backlog}} queued',
+ })}
+ </span>
+ </div>
+ )}
+ <div className="flex items-center gap-2 text-text-primary">
+ <span>{label}</span>
+ </div>
+ </div>
+ <div className="flex min-h-0 h-full justify-end">
+ <ProgressLogPanel progressMsg={data?.progress_msg} />
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/pages/dataset/compilation/empty-state.tsx b/web/src/pages/dataset/compilation/empty-state.tsx
index 38771846b4..1b877769e1 100644
--- a/web/src/pages/dataset/compilation/empty-state.tsx
+++ b/web/src/pages/dataset/compilation/empty-state.tsx
@@ -17,6 +17,7 @@ import {
ViewModeGenerateTypeMap,
ViewModeLabelKeyMap,
} from './constants';
+import { CompileProgressBoard } from './compile-progress-board';
import { ProgressLogPanel } from './progress-log-panel';
import { ProgressRing } from './progress-ring';
@@ -80,51 +81,27 @@ export function CompilationEmptyState({
</p>
)}
</div>
+ ) : isGo ? (
+ <CompileProgressBoard
+ status={status}
+ data={data}
+ label={t(ViewModeLabelKeyMap[type])}
+ />
) : (
<div className="grid h-full w-full grid-cols-[1fr_auto_1fr] items-center gap-8 p-6">
<div />
<div className="flex flex-col items-center gap-5">
- {isGo ? (
- // Go: no stable percentage and no scheduler cancel, so show
- // the MySQL inflight/backlog counts (or the error diagnostic).
- status === 'failed' ? (
- <div className="flex flex-col items-center gap-2 text-state-error">
- <IconFontFill name="reparse" className="size-8" />
- <span className="text-text-primary">
- {data?.compilationError || t('message.operated')}
- </span>
- </div>
- ) : (
- <div className="flex flex-col items-center gap-2 text-text-secondary">
- <span className="text-4xl font-medium text-accent-primary">
- {t('knowledgeCompilation.compiling', {
- defaultValue: 'Compiling…',
- })}
- </span>
- <span>
- {t('knowledgeCompilation.compilingCounts', {
- inflight: data?.inflight ?? 0,
- backlog: data?.backlog ?? 0,
- defaultValue:
- '{{inflight}} processing / {{backlog}} queued',
- })}
- </span>
- </div>
- )
- ) : (
- <ProgressRing percent={percent} failed={status === 'failed'} />
- )}
+ <ProgressRing percent={percent} failed={status === 'failed'} />
<div className="flex items-center gap-2 text-text-primary">
<span>{t(ViewModeLabelKeyMap[type])}</span>
- {!isGo && status === 'failed' && (
+ {status === 'failed' ? (
<span className="cursor-pointer" onClick={handleGenerate}>
<IconFontFill
name="reparse"
className="text-accent-primary"
/>
</span>
- )}
- {!isGo && status !== 'failed' && (
+ ) : (
<span
className="text-state-error cursor-pointer"
onClick={handlePause}
diff --git a/web/src/pages/dataset/compilation/hooks/use-compilation-nav.ts b/web/src/pages/dataset/compilation/hooks/use-compilation-nav.ts
index 43ca0a61ef..82c35e8e0f 100644
--- a/web/src/pages/dataset/compilation/hooks/use-compilation-nav.ts
+++ b/web/src/pages/dataset/compilation/hooks/use-compilation-nav.ts
@@ -1,4 +1,10 @@
+import { GenerateType } from '@/constants/knowledge';
import {
+ useGenerateStatus,
+ useTraceRunData,
+} from '@/hooks/use-dataset-generate';
+import {
+ DatasetNavKeys,
useDeleteDatasetNav,
useDeleteDatasetNavNode,
useFetchDatasetNav,
@@ -8,10 +14,14 @@ import { useFetchDocumentStructureGraphById } from '@/hooks/use-document-request
import { useKnowledgeBaseId } from '@/hooks/use-knowledge-request';
import { DatasetNavNode } from '@/interfaces/database/dataset-nav';
import { IStructureGraphTemplate } from '@/interfaces/database/document-structure';
+import { useIsGoBackend } from '@/utils/backend-variant';
+import { useQueryClient } from '@tanstack/react-query';
import { useDebounce } from 'ahooks';
import { trim } from 'lodash';
import { useCallback, useEffect, useState } from 'react';
+import { useRunEndEffect } from './use-run-end-effect';
+
export interface SelectedNavNode {
parentName: string | null;
name: string;
@@ -128,6 +138,24 @@ export function useCompilationNav() {
clearExpandedData();
}, [activeKeywords, clearExpandedData]);
+ const queryClient = useQueryClient();
+ const isGo = useIsGoBackend();
+ // Go: the nav tree is a by-product of tree/structure knowledge compilation.
+ // Poll the Tree-scoped scheduler status (kind "raptor" normalizes to "Tree")
+ // so the view can surface compile progress/logs and refresh the tree when a
+ // run ends. Python keeps the read-only behavior (no polling, no log UI).
+ const { data: navRunData } = useTraceRunData(GenerateType.Raptor, isGo);
+ const { status: navStatus } = useGenerateStatus(navRunData);
+
+ const handleCompileRunEnd = useCallback(() => {
+ queryClient.invalidateQueries({ queryKey: DatasetNavKeys.all(kbId) });
+ // Children/structure data cached in local state predates the compile, and
+ // invalidation cannot refetch their inactive queries — drop the maps so
+ // re-expansion fetches fresh data.
+ clearExpandedData();
+ }, [queryClient, kbId, clearExpandedData]);
+ useRunEndEffect(navStatus, handleCompileRunEnd);
+
const loadChildren = useCallback(
(name: string) => {
setChildrenErrorParents((prev) => {
@@ -305,6 +333,8 @@ export function useCompilationNav() {
selectedNode,
deleteNavLoading,
deleteNodeLoading,
+ navRunData,
+ navStatus,
handleKeywordsChange,
handleNodeClick,
handleNodeExpand,
diff --git a/web/src/pages/dataset/compilation/nav-compiling-state.tsx b/web/src/pages/dataset/compilation/nav-compiling-state.tsx
new file mode 100644
index 0000000000..b81d30b8ff
--- /dev/null
+++ b/web/src/pages/dataset/compilation/nav-compiling-state.tsx
@@ -0,0 +1,28 @@
+import { GenerateStatus } from '@/constants/knowledge';
+import { ITraceInfo } from '@/hooks/use-dataset-generate';
+import { useTranslation } from 'react-i18next';
+
+import { CompileProgressBoard } from './compile-progress-board';
+
+type NavCompilingStateProps = {
+ status: GenerateStatus;
+ data?: ITraceInfo;
+};
+
+// Full-view placeholder while the Go backend compiles the dataset navigation
+// tree and there is no tree content to show yet (the first compile). Once a
+// tree exists, incremental compiles surface through the left panel's log
+// entry instead of replacing the view.
+export function NavCompilingState({ status, data }: NavCompilingStateProps) {
+ const { t } = useTranslation();
+
+ return (
+ <div className="flex-1 min-h-0 flex flex-col items-center justify-center border border-dashed border-border-button rounded-xl">
+ <CompileProgressBoard
+ status={status}
+ data={data}
+ label={t('knowledgeCompilation.navTree')}
+ />
+ </div>
+ );
+}
diff --git a/web/src/pages/dataset/compilation/nav-tree-left-panel.test.tsx b/web/src/pages/dataset/compilation/nav-tree-left-panel.test.tsx
index b159a66fb7..4dac2a3302 100644
--- a/web/src/pages/dataset/compilation/nav-tree-left-panel.test.tsx
+++ b/web/src/pages/dataset/compilation/nav-tree-left-panel.test.tsx
@@ -1,4 +1,6 @@
-import { render, screen } from '@testing-library/react';
+import { fireEvent, render, screen } from '@testing-library/react';
+
+import { GenerateStatus } from '@/constants/knowledge';
import { NavTreeLeftPanel } from './nav-tree-left-panel';
@@ -32,6 +34,21 @@ jest.mock('react-i18next', () => ({
useTranslation: () => ({ t: (key: string) => key }),
}));
+jest.mock('@/utils/backend-variant', () => ({
+ useIsGoBackend: () => true,
+}));
+
+const mockCompileStatus = { value: GenerateStatus.Start };
+
+jest.mock('@/hooks/use-dataset-generate', () => ({
+ useGenerateStatus: () => ({ status: mockCompileStatus.value }),
+}));
+
+jest.mock('./update-log-sheet', () => ({
+ UpdateLogSheet: ({ open, title }: { open: boolean; title: string }) =>
+ open ? <div data-testid="nav-log-sheet">{title}</div> : null,
+}));
+
const NavItem = {
name: 'cluster-a',
description: '',
@@ -50,6 +67,10 @@ const PanelHandlers = {
};
describe('NavTreeLeftPanel', () => {
+ beforeEach(() => {
+ mockCompileStatus.value = GenerateStatus.Start;
+ });
+
it('keeps cached nodes visible when a later nav load fails', () => {
render(
<NavTreeLeftPanel
@@ -93,4 +114,70 @@ describe('NavTreeLeftPanel', () => {
).toBeInTheDocument();
expect(screen.queryByTestId('nav-tree')).not.toBeInTheDocument();
});
+
+ it('shows no compile log entry when no Go compile is running', () => {
+ render(
+ <NavTreeLeftPanel
+ navList={{ total: 1, items: [NavItem] }}
+ navLoading={false}
+ keywords=""
+ activeKeywords=""
+ childrenMap={{}}
+ structureMap={{}}
+ deleteNavLoading={false}
+ deleteNodeLoading={false}
+ {...PanelHandlers}
+ />,
+ );
+
+ expect(
+ screen.queryByTestId('nav-compile-log-trigger'),
+ ).not.toBeInTheDocument();
+ });
+
+ it('opens the log sheet from the compile log entry while a Go compile runs', () => {
+ mockCompileStatus.value = GenerateStatus.Running;
+ render(
+ <NavTreeLeftPanel
+ navList={{ total: 1, items: [NavItem] }}
+ navLoading={false}
+ keywords=""
+ activeKeywords=""
+ childrenMap={{}}
+ structureMap={{}}
+ deleteNavLoading={false}
+ deleteNodeLoading={false}
+ traceData={{ compilationState: 'running' } as any}
+ {...PanelHandlers}
+ />,
+ );
+
+ fireEvent.click(screen.getByTestId('nav-compile-log-trigger'));
+
+ expect(screen.getByTestId('nav-log-sheet')).toHaveTextContent(
+ 'knowledgeCompilation.navLogTitle',
+ );
+ });
+
+ it('shows the error diagnostic on the log entry when a Go compile failed', () => {
+ mockCompileStatus.value = GenerateStatus.Failed;
+ render(
+ <NavTreeLeftPanel
+ navList={{ total: 1, items: [NavItem] }}
+ navLoading={false}
+ keywords=""
+ activeKeywords=""
+ childrenMap={{}}
+ structureMap={{}}
+ deleteNavLoading={false}
+ deleteNodeLoading={false}
+ traceData={{ compilationError: 'embed boom' } as any}
+ {...PanelHandlers}
+ />,
+ );
+
+ expect(screen.getByTestId('nav-compile-log-trigger')).toHaveTextContent(
+ 'embed boom',
+ );
+ });
});
diff --git a/web/src/pages/dataset/compilation/nav-tree-left-panel.tsx b/web/src/pages/dataset/compilation/nav-tree-left-panel.tsx
index 610a6773f2..f725ba476d 100644
--- a/web/src/pages/dataset/compilation/nav-tree-left-panel.tsx
+++ b/web/src/pages/dataset/compilation/nav-tree-left-panel.tsx
@@ -3,15 +3,19 @@ import { Button } from '@/components/ui/button';
import { SearchInput } from '@/components/ui/input';
import { Spin } from '@/components/ui/spin';
import { TreeView } from '@/components/ui/tree-view';
+import { GenerateStatus } from '@/constants/knowledge';
+import { ITraceInfo, useGenerateStatus } from '@/hooks/use-dataset-generate';
import {
DatasetNavList,
DatasetNavNode,
} from '@/interfaces/database/dataset-nav';
import { IStructureGraphTemplate } from '@/interfaces/database/document-structure';
+import { cn } from '@/lib/utils';
import { useIsGoBackend } from '@/utils/backend-variant';
-import { FileText, Folder, Trash2 } from 'lucide-react';
-import { useCallback, useMemo } from 'react';
+import { CircleX, FileText, Folder, Loader2, Trash2 } from 'lucide-react';
+import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { UpdateLogSheet } from './update-log-sheet';
import { buildNavTreeData, NavEntityClickHandler } from './utils/nav-tree';
type NavNodeDeleteActionProps = {
@@ -84,6 +88,7 @@ type NavTreeLeftPanelProps = {
structureMap: Record<string, IStructureGraphTemplate[]>;
deleteNavLoading: boolean;
deleteNodeLoading: boolean;
+ traceData?: ITraceInfo;
onKeywordsChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
onNodeClick: (node: DatasetNavNode, parentName: string | null) => void;
onNodeExpand: (node: DatasetNavNode) => void;
@@ -103,6 +108,7 @@ export function NavTreeLeftPanel({
structureMap,
deleteNavLoading,
deleteNodeLoading,
+ traceData,
onKeywordsChange,
onNodeClick,
onNodeExpand,
@@ -113,6 +119,21 @@ export function NavTreeLeftPanel({
const { t } = useTranslation();
const isGo = useIsGoBackend();
+ const { status: compileStatus } = useGenerateStatus(traceData);
+ const [logSheetOpen, setLogSheetOpen] = useState(false);
+ // Go: an incremental compile is running while a tree is already on screen —
+ // surface it as a log entry point in the header (the full-view placeholder
+ // covers the first compile, when no tree exists).
+ const compiling =
+ isGo &&
+ (compileStatus === GenerateStatus.Running ||
+ compileStatus === GenerateStatus.Failed);
+ const compileFailed = compiling && compileStatus === GenerateStatus.Failed;
+
+ const handleOpenLogSheet = useCallback(() => {
+ setLogSheetOpen(true);
+ }, []);
+
const renderNavActions = useCallback(
(node: DatasetNavNode, parentName: string | null) => (
<NavNodeDeleteAction
@@ -175,6 +196,25 @@ export function NavTreeLeftPanel({
</Button>
</ConfirmDeleteDialog>
)}
+ {compiling && (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={handleOpenLogSheet}
+ data-testid="nav-compile-log-trigger"
+ className={cn({ 'text-state-error': compileFailed })}
+ >
+ {compileFailed ? <CircleX /> : <Loader2 className="animate-spin" />}
+ <span
+ className="max-w-56 truncate"
+ title={compileFailed ? traceData?.compilationError : undefined}
+ >
+ {compileFailed
+ ? traceData?.compilationError || t('message.operated')
+ : t('knowledgeCompilation.compiling')}
+ </span>
+ </Button>
+ )}
</section>
<div className="px-3 pt-2">
@@ -211,6 +251,13 @@ export function NavTreeLeftPanel({
</>
)}
</div>
+
+ <UpdateLogSheet
+ open={logSheetOpen}
+ onOpenChange={setLogSheetOpen}
+ data={traceData}
+ title={t('knowledgeCompilation.navLogTitle')}
+ />
</aside>
);
}
diff --git a/web/src/pages/dataset/compilation/nav-tree-view.tsx b/web/src/pages/dataset/compilation/nav-tree-view.tsx
index f998faf46d..d99f076c23 100644
--- a/web/src/pages/dataset/compilation/nav-tree-view.tsx
+++ b/web/src/pages/dataset/compilation/nav-tree-view.tsx
@@ -4,13 +4,17 @@ import {
ResizablePanel,
ResizablePanelGroup,
} from '@/components/ui/resizable';
+import { GenerateStatus } from '@/constants/knowledge';
+import { useIsGoBackend } from '@/utils/backend-variant';
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 isGo = useIsGoBackend();
const {
navList,
navLoading,
@@ -23,6 +27,8 @@ export function NavTreeView() {
selectedNode,
deleteNavLoading,
deleteNodeLoading,
+ navRunData,
+ navStatus,
handleKeywordsChange,
handleNodeClick,
handleNodeExpand,
@@ -31,6 +37,24 @@ export function NavTreeView() {
handleDeleteNode,
} = useCompilationNav();
+ const compiling =
+ isGo &&
+ (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">
@@ -46,6 +70,7 @@ export function NavTreeView() {
structureMap={structureMap}
deleteNavLoading={deleteNavLoading}
deleteNodeLoading={deleteNodeLoading}
+ traceData={navRunData}
onKeywordsChange={handleKeywordsChange}
onNodeClick={handleNodeClick}
onNodeExpand={handleNodeExpand}