feat: harden support, localize knowledge and add operator availability [skip ci]
Source-only publication of reviewed commit 64e96a7f423673dc29ad56485be9fc79bce8af1c.
Passed in isolation: focused frontend/backend tests, race checks, TypeScript typecheck, lint, Go compilation, Flowgram build, and deterministic SDK build/tests.
Not accepted as a production release: Next.js export/native assembly remains blocked by environment memory limits; browser interaction and MySQL staging acceptance remain unverified. No production server, database/schema, runtime configuration, deployment, release tag, or workflow execution was performed.
Expected source tree: 0a4a7528e9.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Modified by the independent AgentDesk fork for support reliability and availability.
|
||||
"use client";
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
@@ -42,26 +43,41 @@ export function KnowledgeBulkMoveDialog({
|
||||
onSubmit,
|
||||
}: KnowledgeBulkMoveDialogProps) {
|
||||
const t = useI18n();
|
||||
const [directories, setDirectories] = useState<KnowledgeDirectory[]>([]);
|
||||
const [directoryResult, setDirectoryResult] = useState<{
|
||||
knowledgeBaseId: number;
|
||||
directories: KnowledgeDirectory[];
|
||||
}>({ knowledgeBaseId, directories: [] });
|
||||
const [targetDirectoryId, setTargetDirectoryId] = useState("0");
|
||||
const [selectionScope, setSelectionScope] = useState({ knowledgeBaseId, open });
|
||||
|
||||
// A new base or dialog opening is a new selection session. Reset before the
|
||||
// children render, rather than exposing the previous target for one frame.
|
||||
if (selectionScope.knowledgeBaseId !== knowledgeBaseId || selectionScope.open !== open) {
|
||||
setSelectionScope({ knowledgeBaseId, open });
|
||||
setTargetDirectoryId("0");
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
return;
|
||||
}
|
||||
setTargetDirectoryId("0");
|
||||
let active = true;
|
||||
fetchKnowledgeDirectories(knowledgeBaseId)
|
||||
.then(setDirectories)
|
||||
.then((result) => {
|
||||
if (active) setDirectoryResult({ knowledgeBaseId, directories: result });
|
||||
})
|
||||
.catch((error) => {
|
||||
if (!active) return;
|
||||
console.error(error);
|
||||
setDirectories([]);
|
||||
setDirectoryResult({ knowledgeBaseId, directories: [] });
|
||||
});
|
||||
return () => { active = false; };
|
||||
}, [knowledgeBaseId, open]);
|
||||
|
||||
const directoryOptions = useMemo(() => [
|
||||
{ value: "0", label: t("knowledge.rootContent") },
|
||||
...flattenDirectoryOptions(directories),
|
||||
], [directories, t]);
|
||||
...flattenDirectoryOptions(directoryResult.knowledgeBaseId === knowledgeBaseId ? directoryResult.directories : []),
|
||||
], [directoryResult, knowledgeBaseId, t]);
|
||||
|
||||
return (
|
||||
<ProjectDialog
|
||||
|
||||
Reference in New Issue
Block a user