feat: LLM 录制开关、模型列表第三方回退、命令页改为工具执行
在 review PR5 基础上的三处改进:
1. LLM 录制开关(默认关,settings.llm_record)
- 录制页数据大小下拉框旁加开关;关闭时 Recorder.Stream 直接透传,
不序列化、不累积、不写库,零开销。切换即时生效,无需重建 agent。
2. 模型列表拉取支持 Anthropic 兼容第三方
- pgListModels 改为按序尝试多个候选端点:anthropic 的 /v1/models 拿不到时,
剥掉 /anthropic 回退到 OpenAI 式 /models(自动切 Bearer 头)。
修复 DeepSeek(anthropic) 加载模型 404。
3. 命令页改为「工具执行」列表
- ListCommands 去掉 tool='Bash' 过滤,覆盖所有 tool_use;返回工具名列,
搜索匹配工具名或参数。前端加「工具」列、标题/侧边栏改为「工具执行」。
Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
10f891a21d
commit
ad9f14f140
12 files changed
+225
-83
No files matched your search
@@ -14,6 +14,7 @@ import { Card } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -74,11 +75,39 @@ export default function LLMRecordsPage() {
|
||||
const [total, setTotal] = React.useState(0);
|
||||
const [loading, setLoading] = React.useState(false);
|
||||
|
||||
// Recording on/off toggle (settings.llm_record; default off). When off the
|
||||
// backend records nothing.
|
||||
const [recEnabled, setRecEnabled] = React.useState(false);
|
||||
const [recBusy, setRecBusy] = React.useState(false);
|
||||
|
||||
// Inline detail panel (Burp-style split, not a dialog)
|
||||
const [selected, setSelected] = React.useState<LLMRecordItem | null>(null);
|
||||
const [detail, setDetail] = React.useState<LLMRecordDetail | null>(null);
|
||||
const [detailLoading, setDetailLoading] = React.useState(false);
|
||||
|
||||
// Load recording toggle state on mount.
|
||||
React.useEffect(() => {
|
||||
let alive = true;
|
||||
api
|
||||
.settings()
|
||||
.then((s) => { if (alive) setRecEnabled(!!s.llm_record); })
|
||||
.catch(() => {});
|
||||
return () => { alive = false; };
|
||||
}, []);
|
||||
|
||||
const toggleRecording = async (on: boolean) => {
|
||||
setRecBusy(true);
|
||||
setRecEnabled(on); // optimistic
|
||||
try {
|
||||
const s = await api.setSettings({ llm_record: on });
|
||||
setRecEnabled(!!s.llm_record);
|
||||
} catch {
|
||||
setRecEnabled(!on); // revert on failure
|
||||
} finally {
|
||||
setRecBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Debounce session filter.
|
||||
React.useEffect(() => {
|
||||
const t = setTimeout(() => setSessionQ(session.trim()), 300);
|
||||
@@ -168,6 +197,26 @@ export default function LLMRecordsPage() {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{/* Recording on/off — off means no LLM calls are recorded */}
|
||||
<div className="flex items-center gap-2 rounded-md border px-2.5 py-1">
|
||||
<Switch
|
||||
id="llm-rec-toggle"
|
||||
size="sm"
|
||||
checked={recEnabled}
|
||||
onCheckedChange={toggleRecording}
|
||||
disabled={recBusy}
|
||||
/>
|
||||
<label
|
||||
htmlFor="llm-rec-toggle"
|
||||
className={cn(
|
||||
"cursor-pointer text-xs font-medium select-none",
|
||||
recEnabled ? "text-foreground" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{recEnabled ? "录制中" : "已关闭"}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="ml-auto flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<span className="tabular-nums">
|
||||
{rangeStart}–{rangeEnd} / {total}
|
||||
|
||||
Reference in new issue
Block a user