/** * Standalone task page for orphan tasks (`/tmp/:taskId`). These are tasks * with no directive attachment — the document-mode sidebar surfaces them * under the `tmp/` pseudo-folder. We render `TaskPage` directly without * the directive sidebar selection, framed by the masthead so users still * have global navigation. */ import { useEffect, useState } from "react"; import { useNavigate, useParams } from "react-router"; import { Masthead } from "../components/Masthead"; import { TaskPage } from "../components/directives/TaskPage"; import { useAuth } from "../contexts/AuthContext"; import { getTask, type Task } from "../lib/api"; export default function TmpTaskPage() { const { isAuthenticated, isAuthConfigured, isLoading: authLoading } = useAuth(); const navigate = useNavigate(); const { taskId } = useParams<{ taskId: string }>(); const [task, setTask] = useState(null); const [error, setError] = useState(null); useEffect(() => { if (!authLoading && isAuthConfigured && !isAuthenticated) { navigate("/login"); } }, [authLoading, isAuthConfigured, isAuthenticated, navigate]); useEffect(() => { if (!taskId) return; let cancelled = false; getTask(taskId) .then((t) => { if (cancelled) return; const directiveId = (t as Task & { directiveId?: string | null }) .directiveId ?? null; // If this task actually IS attached to a directive, redirect // there — /tmp/ is reserved for genuine orphans. if (directiveId) { navigate(`/directives/${directiveId}?task=${taskId}`, { replace: true, }); return; } setTask(t); }) .catch((e) => { if (!cancelled) setError(e instanceof Error ? e.message : String(e)); }); return () => { cancelled = true; }; }, [taskId, navigate]); if (authLoading) { return (

Loading...

); } return (
{/* Breadcrumb echoing the document-mode header style. */}
tmp / {taskId ? taskId.slice(0, 8) : ""} {task && — {task.name}}
{error ? (

{error}

) : taskId ? ( ) : null}
); }