mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 11:49:39 +08:00
A focused cut on top of v1.4.3:
- Skill hub: install community skills from ClawHub (and any compatible
registry via settings/skill_hubs.json) — provider abstraction in
services/skill/hub.py, new `deeptutor skill search/install/list/remove`
CLI, admin-only install endpoint for multi-user (install ≠ assign).
Every import runs a security gate: hub verdict check, zip-slip/zip-bomb
guards, text/script suffix whitelist, `always:` frontmatter stripped,
provenance recorded in .hub-lock.json.
- KB previews: new /knowledge/{kb}/file-preview-text/{filename} endpoint
serving extracted plain text; KB Files tab renders real in-browser
DOCX/XLSX previews; DOCX previewer scales pages to fit narrow panels.
- Markdown previews allow safe raster data:image URLs on <img src>
(react-markdown strips all data: URLs by default); script-capable
schemes stay blocked.
- All ten localized READMEs re-synced with the English README.
- Docs (deeptutor.info): `deeptutor skill` reference, hub-install notes on
Space and multi-user pages, KB file routes in the server API table
(en + zh).
- CLI docs contract test updated for partner/skill subcommands.
Release notes: assets/releases/ver1-4-4.md
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
79 lines
2.5 KiB
TypeScript
79 lines
2.5 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useMemo, useState } from "react";
|
|
import {
|
|
knowledgeBaseFilePath,
|
|
knowledgeBaseFilePreviewTextPath,
|
|
type KnowledgeBaseFile,
|
|
} from "@/lib/knowledge-api";
|
|
import type { KnowledgeBase } from "@/lib/knowledge-helpers";
|
|
import type { TaskState } from "@/hooks/useKnowledgeProgress";
|
|
import type { FilePreviewSource } from "@/components/chat/preview/previewerFor";
|
|
import { useCollapsiblePanel } from "@/hooks/useCollapsiblePanel";
|
|
import KbDocumentList from "./KbDocumentList";
|
|
import KbFilePreview from "./KbFilePreview";
|
|
|
|
interface KbFilesTabProps {
|
|
kb: KnowledgeBase;
|
|
task?: TaskState;
|
|
}
|
|
|
|
/**
|
|
* Master-detail view for the "Files" tab: list of raw documents on the
|
|
* left, inline preview pane on the right. Both the parent KB list (in
|
|
* `/knowledge`) and this file list can be collapsed to icon-only strips
|
|
* to reclaim horizontal space for the actual preview content.
|
|
*/
|
|
export default function KbFilesTab({ kb, task }: KbFilesTabProps) {
|
|
const [selectedFile, setSelectedFile] = useState<KnowledgeBaseFile | null>(
|
|
null,
|
|
);
|
|
const fileListPanel = useCollapsiblePanel("knowledge-file-list");
|
|
|
|
// Bump refreshKey when the active create/upload task settles so newly
|
|
// indexed files appear automatically.
|
|
const taskExecuting = task?.executing === true;
|
|
const [refreshKey, setRefreshKey] = useState(0);
|
|
useEffect(() => {
|
|
if (!taskExecuting) {
|
|
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
setRefreshKey((n) => n + 1);
|
|
}
|
|
}, [taskExecuting]);
|
|
|
|
const previewSource = useMemo<FilePreviewSource | null>(() => {
|
|
if (!selectedFile) return null;
|
|
return {
|
|
filename: selectedFile.name,
|
|
mimeType: selectedFile.mime_type ?? undefined,
|
|
url: knowledgeBaseFilePath(kb.name, selectedFile.name),
|
|
extractedTextUrl: knowledgeBaseFilePreviewTextPath(
|
|
kb.name,
|
|
selectedFile.name,
|
|
),
|
|
size: selectedFile.size,
|
|
id: `${kb.name}/${selectedFile.name}`,
|
|
};
|
|
}, [kb.name, selectedFile]);
|
|
|
|
return (
|
|
<div className="flex h-full min-h-0">
|
|
<KbDocumentList
|
|
kbName={kb.name}
|
|
refreshKey={refreshKey}
|
|
selectedFile={selectedFile?.name ?? null}
|
|
onSelect={setSelectedFile}
|
|
collapsed={fileListPanel.collapsed}
|
|
onToggleCollapsed={fileListPanel.toggle}
|
|
/>
|
|
<div className="min-w-0 flex-1">
|
|
<KbFilePreview
|
|
source={previewSource}
|
|
fileListCollapsed={fileListPanel.collapsed}
|
|
onToggleFileList={fileListPanel.toggle}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|