"use client"; import { CROSS_ACCOUNT_PDF_TASK_KIND, crossAccountPdfHandler, } from "@/app/(prowler)/compliance/_lib/cross-account-pdf"; import { CROSS_PROVIDER_PDF_TASK_KIND, crossProviderPdfHandler, } from "@/app/(prowler)/compliance/_lib/cross-provider-pdf"; import { jiraDispatchTaskHandler } from "@/components/findings/jira-dispatch-task-handler"; import { integrationConnectionTaskHandler } from "@/components/integrations/integration-connection-task-handler"; import { registryArtifactTaskHandler } from "@/components/registry/registry-artifact-task-handler"; import { registryCredentialTaskHandler } from "@/components/registry/registry-credential-task-handler"; import { useMountEffect } from "@/hooks/use-mount-effect"; import { REGISTRY_ARTIFACT_TASK_KIND } from "@/lib/registry/artifact-execution"; import { REGISTRY_CREDENTIAL_TASK_KIND } from "@/lib/registry/credential-task"; import { registerTaskKindHandler, resumePendingTasks, } from "@/store/task-watcher/store"; import { INTEGRATION_CONNECTION_TASK_KIND, JIRA_DISPATCH_TASK_KIND, } from "@/types/integrations"; // Kind registrations happen at module scope, before any task can settle in // this tab. Adding a new watched task kind (integration tests, scan exports, // …) is one line here plus a handler next to the feature that owns it. registerTaskKindHandler(CROSS_PROVIDER_PDF_TASK_KIND, crossProviderPdfHandler); registerTaskKindHandler(CROSS_ACCOUNT_PDF_TASK_KIND, crossAccountPdfHandler); registerTaskKindHandler(JIRA_DISPATCH_TASK_KIND, jiraDispatchTaskHandler); registerTaskKindHandler( REGISTRY_ARTIFACT_TASK_KIND, registryArtifactTaskHandler, ); registerTaskKindHandler( REGISTRY_CREDENTIAL_TASK_KIND, registryCredentialTaskHandler, ); registerTaskKindHandler( INTEGRATION_CONNECTION_TASK_KIND, integrationConnectionTaskHandler, ); /** * Mounted once in the app layout (next to `Toaster`): resumes polling any * backend task persisted as pending by `@/store/task-watcher`, so completion * toasts survive a hard reload. In-session tracking needs no component at * all — `trackAndPollTask` runs its loop at module scope from the * dispatching click handler. */ export const TaskPollingWatcher = () => { useMountEffect(() => { resumePendingTasks(); }); return null; };