fix: harden cron session automation flows

This commit is contained in:
chengyongru
2026-06-12 18:13:25 +08:00
parent b5f9d51b5b
commit a50b3ac0f2
30 changed files with 267 additions and 56 deletions
+12 -4
View File
@@ -43,7 +43,7 @@ import type {
} from "@/lib/types";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { fetchSessionAutomations, fetchSettings, fetchWorkspaces } from "@/lib/api";
import { fetchSettings, fetchWorkspaces } from "@/lib/api";
import {
createRuntimeHost,
getHostApi,
@@ -528,7 +528,15 @@ function Shell({
const { t, i18n } = useTranslation();
const { client, token } = useClient();
const { theme, toggle } = useTheme();
const { sessions, loading, refresh, createChat, forkChat, deleteChat } = useSessions();
const {
sessions,
loading,
refresh,
createChat,
forkChat,
deleteChat,
getSessionAutomations,
} = useSessions();
const { state: sidebarState, update: updateSidebarState } =
useSidebarState(sessions, !loading);
const initialRouteRef = useRef<ShellRoute | null>(null);
@@ -1306,12 +1314,12 @@ function Shell({
const onRequestDelete = useCallback(async (key: string, label: string) => {
let automations: SessionAutomationJob[] = [];
try {
automations = (await fetchSessionAutomations(token, key)).jobs;
automations = await getSessionAutomations(key);
} catch {
// Delete remains protected by the backend block; prefetch only improves the first prompt.
}
setPendingDelete({ key, label, automations });
}, [token]);
}, [getSessionAutomations]);
const headerTitle = activeSession
? sidebarState.title_overrides[activeSession.key] ||