feat: add MCP/skill tool protocol, tasks/tools pages, chat UX overhaul

Tools page: skill & MCP server management with [[skill:]]/[[mcp:]] protocol (up to 3 rounds). New Tasks and Tools pages. Chat: session snapshots, empty-session reuse, per-message model_id, unified JSON prediction suggestions. Settings: upload size limit, prediction options, model enable/disable. Schema additions with ensure_column migrations. Add FEATURES/ARCHITECTURE docs.
This commit is contained in:
xianrenge
2026-08-16 19:50:41 +08:00
parent bd3f648ccd
commit 10ecf526ec
33 changed files with 6241 additions and 390 deletions
+172 -1
View File
@@ -1,20 +1,40 @@
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { api, AppInfo } from "../api";
export default function SettingsPage() {
const [info, setInfo] = useState<AppInfo | null>(null);
const [settings, setSettings] = useState<Record<string, string>>({});
const [recommendDirDraft, setRecommendDirDraft] = useState("");
const [uploadMsg, setUploadMsg] = useState<string | null>(null);
const uploadInputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
api.appInfo().then(setInfo);
api.settingsGet().then(setSettings);
}, []);
useEffect(() => {
setRecommendDirDraft(settings.recommend_dir ?? "");
}, [settings.recommend_dir]);
async function handleSave(key: string, value: string) {
await api.settingsSet(key, value);
setSettings((prev) => ({ ...prev, [key]: value }));
}
async function handleUpload(file: File) {
setUploadMsg(null);
try {
const text = await file.text();
await api.importRecommendations(file.name, text);
setUploadMsg(`已导入 ${file.name}`);
} catch (e) {
setUploadMsg(String(e));
} finally {
if (uploadInputRef.current) uploadInputRef.current.value = "";
}
}
return (
<div className="h-full overflow-auto p-6">
<h1 className="text-xl font-semibold"></h1>
@@ -85,6 +105,131 @@ export default function SettingsPage() {
</div>
</div>
<div className="rounded-xl border border-border bg-panel p-5">
<div className="text-xs uppercase text-slate-400"></div>
<div className="mt-3 flex items-center justify-between rounded-lg border border-border bg-panel-2 px-3 py-2.5">
<div>
<div className="text-sm"></div>
<div className="mt-0.5 text-xs text-slate-400">
</div>
</div>
<Toggle
checked={settings.auto_title !== "false"}
onChange={(checked) =>
handleSave("auto_title", checked ? "true" : "false")
}
/>
</div>
<div className="mt-3 flex items-center justify-between rounded-lg border border-border bg-panel-2 px-3 py-2.5">
<div>
<div className="text-sm"></div>
<div className="mt-0.5 text-xs text-slate-400">
</div>
</div>
<Toggle
checked={settings.suggest_enabled !== "false"}
onChange={(checked) =>
handleSave("suggest_enabled", checked ? "true" : "false")
}
/>
</div>
<div className="mt-3">
<SettingInput
label="预测条数(1-5"
value={settings.suggest_count ?? "3"}
onSave={(v) => {
const n = Math.max(1, Math.min(5, Number(v) || 3));
handleSave("suggest_count", String(n));
}}
/>
</div>
</div>
<div className="rounded-xl border border-border bg-panel p-5">
<div className="text-xs uppercase text-slate-400"></div>
<div className="mt-3 space-y-3">
<div>
<span className="text-xs text-slate-400">
JSON JSON
</span>
<div className="mt-1 flex gap-2">
<input
className="input flex-1"
value={recommendDirDraft}
onChange={(e) => setRecommendDirDraft(e.target.value)}
/>
<button
className="btn-secondary"
onClick={() => handleSave("recommend_dir", recommendDirDraft)}
disabled={recommendDirDraft === settings.recommend_dir}
>
</button>
<button
className="btn-secondary"
onClick={() =>
recommendDirDraft && api.openPath(recommendDirDraft)
}
>
</button>
</div>
</div>
<div className="flex items-center gap-2">
<input
ref={uploadInputRef}
type="file"
accept=".json"
className="hidden"
onChange={(e) => {
if (e.target.files && e.target.files.length > 0) {
handleUpload(e.target.files[0]);
}
}}
/>
<button
className="btn-secondary"
onClick={() => uploadInputRef.current?.click()}
>
JSON
</button>
<span className="text-xs text-slate-500">
JSON
</span>
</div>
{uploadMsg ? (
<div className="text-xs text-slate-400">{uploadMsg}</div>
) : null}
<div className="text-xs text-slate-500">JSON </div>
<pre className="mt-1 overflow-x-auto rounded-lg bg-panel-2 p-2 text-[11px] leading-relaxed text-slate-400">
{`{
"models": [
{
"id": "Qwen/Qwen2.5-7B-Instruct-GGUF",
"source": "huggingface",
"params": "7B",
"architecture": "dense",
"vision": false,
"files": [
{
"path": "xx-q4_k_m.gguf",
"quant": "Q4_K_M",
"size_gb": 4.68,
"links": [
"https://hf-mirror.com/Qwen/Qwen2.5-7B-Instruct-GGUF/resolve/main/xx-q4_k_m.gguf",
"https://modelscope.cn/models/Qwen/Qwen2.5-7B-Instruct-GGUF/resolve/master/xx-q4_k_m.gguf"
]
}
]
}
]
}`}
</pre>
</div>
</div>
<div className="text-xs text-slate-500">
llama-server <code className="text-slate-300">scripts/fetch-llama.ps1</code>{" "}
exe
@@ -94,6 +239,32 @@ export default function SettingsPage() {
);
}
function Toggle({
checked,
onChange,
}: {
checked: boolean;
onChange: (checked: boolean) => void;
}) {
return (
<button
type="button"
role="switch"
aria-checked={checked}
onClick={() => onChange(!checked)}
className={`relative h-6 w-11 shrink-0 rounded-full transition-colors ${
checked ? "bg-accent" : "bg-panel-2"
}`}
>
<span
className={`absolute top-0.5 h-5 w-5 rounded-full bg-white shadow transition-all ${
checked ? "left-[22px]" : "left-0.5"
}`}
/>
</button>
);
}
function SettingInput({
label,
value,