2026-10-14 00:11:00 +08:00
|
|
|
import { useCallback, useState } from "react";
|
2026-06-06 19:49:33 +08:00
|
|
|
|
2026-09-12 16:32:46 +08:00
|
|
|
import type { AutomationAction } from "@/components/settings/system/AutomationsSettings";
|
2026-10-14 00:11:00 +08:00
|
|
|
import { SessionInfoPopoverView } from "@/components/thread/SessionInfoPopoverView";
|
2026-06-06 19:49:33 +08:00
|
|
|
import { useSessionAutomationJobs } from "@/hooks/useSessionAutomationJobs";
|
2026-09-12 16:32:46 +08:00
|
|
|
import { runAutomationAction, updateAutomation } from "@/lib/api";
|
|
|
|
|
import type { WebUIMutationTransport } from "@/lib/api";
|
2026-10-14 00:11:00 +08:00
|
|
|
import type { AutomationUpdatePayload, SessionAutomationJob } from "@/lib/types";
|
2026-06-06 19:49:33 +08:00
|
|
|
|
|
|
|
|
interface SessionInfoPopoverProps {
|
2026-09-12 16:32:46 +08:00
|
|
|
client: WebUIMutationTransport;
|
2026-06-06 19:49:33 +08:00
|
|
|
sessionKey: string;
|
|
|
|
|
token: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-05 17:09:20 +08:00
|
|
|
export function SessionInfoPopover({ client, sessionKey, token }: SessionInfoPopoverProps) {
|
2026-10-14 00:11:00 +08:00
|
|
|
const [surfacesOpen, setSurfacesOpen] = useState(false);
|
|
|
|
|
const { jobs, loading, loadFailed, now } = useSessionAutomationJobs(surfacesOpen, token, sessionKey);
|
|
|
|
|
const act = useCallback(async (action: AutomationAction, job: SessionAutomationJob) =>
|
|
|
|
|
(await runAutomationAction(client, action, job.id)).jobs, [client]);
|
|
|
|
|
const edit = useCallback(async (job: SessionAutomationJob, values: AutomationUpdatePayload) =>
|
|
|
|
|
(await updateAutomation(client, job.id, values)).jobs, [client]);
|
2026-11-05 17:09:20 +08:00
|
|
|
return <SessionInfoPopoverView jobs={jobs} loading={loading} loadFailed={loadFailed} now={now}
|
2026-10-14 00:11:00 +08:00
|
|
|
onAction={act} onEdit={edit} onSurfacesOpenChange={setSurfacesOpen} calendarHref="#/automations" />;
|
2026-06-06 19:49:33 +08:00
|
|
|
}
|