修改
This commit is contained in:
@@ -72,6 +72,7 @@ type ClawSessionSummary = {
|
||||
preview?: string;
|
||||
model?: string;
|
||||
usage?: UsageSummary;
|
||||
is_training?: boolean;
|
||||
};
|
||||
|
||||
type UsageSummary = {
|
||||
@@ -365,8 +366,15 @@ function SessionResultButton({
|
||||
className="flex w-full flex-col rounded-lg px-2 py-2 text-left transition-colors hover:bg-muted"
|
||||
onClick={onClick}
|
||||
>
|
||||
<span className="truncate font-medium text-sm">
|
||||
{loading ? "回放中..." : session.preview || session.session_id}
|
||||
<span className="flex items-center gap-1.5">
|
||||
<span className="truncate font-medium text-sm">
|
||||
{loading ? "回放中..." : session.preview || session.session_id}
|
||||
</span>
|
||||
{session.is_training ? (
|
||||
<span className="shrink-0 rounded bg-amber-100 px-1.5 text-[10px] text-amber-800">
|
||||
训练
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
<span className="mt-0.5 text-muted-foreground text-xs">
|
||||
{session.turns ?? 0} 轮 · {session.tool_calls ?? 0} 次工具
|
||||
@@ -382,17 +390,23 @@ function useSidebarSessions(open: boolean) {
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
let cancelled = false;
|
||||
fetch("/api/claw/sessions", { cache: "no-store" })
|
||||
.then((res) => (res.ok ? res.json() : []))
|
||||
.then((payload) => {
|
||||
if (cancelled || !Array.isArray(payload)) return;
|
||||
setSessions(dedupeSidebarSessions(payload));
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) setSessions([]);
|
||||
});
|
||||
const reload = () => {
|
||||
fetch("/api/claw/sessions", { cache: "no-store" })
|
||||
.then((res) => (res.ok ? res.json() : []))
|
||||
.then((payload) => {
|
||||
if (cancelled || !Array.isArray(payload)) return;
|
||||
setSessions(dedupeSidebarSessions(payload));
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) setSessions([]);
|
||||
});
|
||||
};
|
||||
reload();
|
||||
const handleUpdate = () => reload();
|
||||
window.addEventListener("claw-session-updated", handleUpdate);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
window.removeEventListener("claw-session-updated", handleUpdate);
|
||||
};
|
||||
}, [open]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user