This commit is contained in:
hupenglong1
2026-05-20 15:04:19 +08:00
parent c4b935692c
commit 1a94cec822
27 changed files with 4831 additions and 1693 deletions
@@ -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]);