merge: 同步上游 dev 并增强人物画像查询

This commit is contained in:
DawnARC
2026-05-04 22:43:03 +08:00
103 changed files with 11456 additions and 4389 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -31,6 +31,7 @@ import type {
import { IMPORT_CHUNK_PAGE_SIZE, IMPORT_KIND_OPTIONS, RUNNING_IMPORT_STATUS } from '../constants'
import {
formatImportTime,
formatProgressPercent,
getImportStatusLabel,
getImportStatusVariant,
getImportStepLabel,
@@ -871,7 +872,7 @@ export function ImportTab(props: ImportTabProps) {
</div>
<div className="mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground">
<span>{getImportStepLabel(String(task.current_step ?? 'running'))}</span>
<span>{Number(task.progress ?? 0).toFixed(1)}%</span>
<span>{formatProgressPercent(task.progress)}</span>
</div>
<Progress value={normalizeProgress(task.progress)} className="mt-2 h-1.5" />
</button>
@@ -966,7 +967,7 @@ export function ImportTab(props: ImportTabProps) {
</div>
<div className="mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground">
<span></span>
<span>{Number(task.progress ?? 0).toFixed(1)}%</span>
<span>{formatProgressPercent(task.progress)}</span>
</div>
<Progress value={normalizeProgress(task.progress)} className="mt-2 h-1.5" />
</button>
@@ -1155,11 +1156,11 @@ export function ImportTab(props: ImportTabProps) {
</div>
<div className="mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground">
<span>{getImportStepLabel(String(file.current_step ?? ''))}</span>
<span>{Number(file.progress ?? 0).toFixed(1)}%</span>
<span>{formatProgressPercent(file.progress)}</span>
</div>
<Progress value={normalizeProgress(file.progress)} className="mt-2 h-1.5" />
<div className="mt-2 text-xs text-muted-foreground">
{Number(file.progress ?? 0).toFixed(1)}% · {Number(file.done_chunks ?? 0)} / {Number(file.total_chunks ?? 0)}
{formatProgressPercent(file.progress)} · {Number(file.done_chunks ?? 0)} / {Number(file.total_chunks ?? 0)}
</div>
{file.error ? (
<div className="mt-2 truncate text-xs text-destructive">{file.error}</div>
@@ -1230,7 +1231,7 @@ export function ImportTab(props: ImportTabProps) {
<TableCell>{chunk.index}</TableCell>
<TableCell>{getImportStatusLabel(String(chunk.status ?? ''))}</TableCell>
<TableCell>{getImportStepLabel(String(chunk.step ?? ''))}</TableCell>
<TableCell>{Number(chunk.progress ?? 0).toFixed(1)}%</TableCell>
<TableCell>{formatProgressPercent(chunk.progress)}</TableCell>
<TableCell className="max-w-[360px]">
<div className="space-y-2">
{String(chunk.error ?? '').trim() ? (

View File

@@ -20,13 +20,18 @@ export function normalizeProgress(value: number | string | null | undefined): nu
if (!Number.isFinite(numeric)) {
return 0
}
if (numeric < 0) {
const percent = numeric > 0 && numeric <= 1 ? numeric * 100 : numeric
if (percent < 0) {
return 0
}
if (numeric > 100) {
if (percent > 100) {
return 100
}
return numeric
return percent
}
export function formatProgressPercent(value: number | string | null | undefined): string {
return `${normalizeProgress(value).toFixed(1)}%`
}
export function parseOptionalPositiveInt(input: string): number | undefined {

View File

@@ -206,7 +206,12 @@ function buildParagraphFromMetadata(
}
}
export function KnowledgeGraphPage() {
interface KnowledgeGraphPageProps {
embedded?: boolean
onOpenConsole?: () => void
}
export function KnowledgeGraphPage({ embedded = false, onOpenConsole }: KnowledgeGraphPageProps = {}) {
const navigate = useNavigate()
const { toast } = useToast()
const [loading, setLoading] = useState(false)
@@ -731,17 +736,26 @@ export function KnowledgeGraphPage() {
const activeGraph = viewMode === 'entity' ? graphData : evidenceGraph
const canShowEvidence = Boolean(selectedNodeData || selectedEdgeData || nodeDetail || edgeDetail)
const openConsole = useCallback(() => {
if (onOpenConsole) {
onOpenConsole()
return
}
void navigate({ to: '/resource/knowledge-base' })
}, [navigate, onOpenConsole])
return (
<div className="flex h-full flex-col">
<div className="flex-none border-b bg-card/60 px-6 py-4 backdrop-blur">
<div className={embedded ? 'flex-none border-b bg-card/60 px-4 py-4 backdrop-blur' : 'flex-none border-b bg-card/60 px-6 py-4 backdrop-blur'}>
<div className="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
<div>
<h1 className="text-2xl font-bold"></h1>
<p className="mt-1 text-sm text-muted-foreground">
A_Memorix
</p>
</div>
{!embedded && (
<div>
<h1 className="text-2xl font-bold"></h1>
<p className="mt-1 text-sm text-muted-foreground">
A_Memorix
</p>
</div>
)}
<div className="flex flex-wrap gap-2">
<Badge variant="outline" className="gap-1">
@@ -791,7 +805,7 @@ export function KnowledgeGraphPage() {
<RefreshCw className={`mr-2 h-4 w-4 ${loading ? 'animate-spin' : ''}`} />
</Button>
<Button variant="outline" onClick={() => navigate({ to: '/resource/knowledge-base' })}>
<Button variant="outline" onClick={openConsole} className={embedded ? 'hidden' : undefined}>
<SlidersHorizontal className="mr-2 h-4 w-4" />
</Button>
@@ -873,7 +887,7 @@ export function KnowledgeGraphPage() {
<p className="mt-2 text-sm text-muted-foreground">
</p>
<Button className="mt-4" onClick={() => navigate({ to: '/resource/knowledge-base' })}>
<Button className="mt-4" onClick={openConsole}>
</Button>
</>