Files
nanobot/webui/src/components/thread/SessionInfoPopover.tsx
T
chengyongru 30e43aec82 refactor(webui): separate presentation views and expand component gallery (#6179)
* refactor(webui): organize shared components with an internal gallery

* refactor(webui): decouple views and expand component gallery

* fix(docker): include channel sources in WebUI build

* refactor(webui): cover all channel interfaces in gallery

* docs(webui): remove manual paragraph wrapping
2026-10-14 00:11:00 +08:00

27 lines
1.4 KiB
TypeScript

import { useCallback, useState } from "react";
import type { AutomationAction } from "@/components/settings/system/AutomationsSettings";
import { SessionInfoPopoverView } from "@/components/thread/SessionInfoPopoverView";
import { useSessionAutomationJobs } from "@/hooks/useSessionAutomationJobs";
import { runAutomationAction, updateAutomation } from "@/lib/api";
import type { WebUIMutationTransport } from "@/lib/api";
import type { AutomationUpdatePayload, SessionAutomationJob } from "@/lib/types";
interface SessionInfoPopoverProps {
client: WebUIMutationTransport;
sessionKey: string;
token: string;
title: string;
}
export function SessionInfoPopover({ client, sessionKey, token, title }: SessionInfoPopoverProps) {
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]);
return <SessionInfoPopoverView title={title} jobs={jobs} loading={loading} loadFailed={loadFailed} now={now}
onAction={act} onEdit={edit} onSurfacesOpenChange={setSurfacesOpen} calendarHref="#/automations" />;
}