diff --git a/web/apps/doprocess/components/processes/tasks/TaskDetails.tsx b/web/apps/doprocess/components/processes/tasks/TaskDetails.tsx index a407f78d28..4fb1fbddfa 100644 --- a/web/apps/doprocess/components/processes/tasks/TaskDetails.tsx +++ b/web/apps/doprocess/components/processes/tasks/TaskDetails.tsx @@ -15,11 +15,9 @@ import { useSearchParam } from '@signalco/hooks/useSearchParam'; import { TypographyDocumentName } from '../documents/TypographyDocumentName'; import { EditorSkeleton } from '../documents/editor/EditorSkeleton'; import { DocumentSharedWithIndicator } from '../documents/DocumentSharedWithIndicator'; -import { SharedWithIndicator } from '../../shared/SharedWithIndicator'; import { KnownPages } from '../../../src/knownPages'; import { useProcessTaskDefinitionUpdate } from '../../../src/hooks/useProcessTaskDefinitionUpdate'; import { useProcessTaskDefinition } from '../../../src/hooks/useProcessTaskDefinition'; -import { useDocument } from '../../../src/hooks/useDocument'; import TaskDetailsTypePicker from './TaskDetailsTypePicker'; import { TaskDetailsToolbar } from './TaskDetailsToolbar'; diff --git a/web/apps/doprocess/components/processes/tasks/TaskList.tsx b/web/apps/doprocess/components/processes/tasks/TaskList.tsx index 6375cbf57c..f69e2a3a2a 100644 --- a/web/apps/doprocess/components/processes/tasks/TaskList.tsx +++ b/web/apps/doprocess/components/processes/tasks/TaskList.tsx @@ -1,6 +1,7 @@ 'use client'; import { useEffect, useMemo, useState } from 'react'; +import dynamic from 'next/dynamic'; import { List } from '@signalco/ui-primitives/List'; import { NoDataPlaceholder } from '@signalco/ui/NoDataPlaceholder'; import { Loadable } from '@signalco/ui/Loadable'; @@ -15,9 +16,10 @@ import { useProcessTaskDefinitionUpdate } from '../../../src/hooks/useProcessTas import { useProcessTaskDefinitions } from '../../../src/hooks/useProcessTaskDefinitions'; import { useProcessTaskDefinitionCreate } from '../../../src/hooks/useProcessTaskDefinitionCreate'; import { useProcessRunTasks } from '../../../src/hooks/useProcessRunTasks'; -import { TaskListSuggestions } from './TaskListSuggestions'; import { TaskListItem } from './TaskListItem'; +const TaskListSuggestions = dynamic(() => import('./TaskListSuggestions').then(mod => mod.TaskListSuggestions), {ssr: false }); + type TaskListProps = { processId: string; runId?: string; @@ -34,12 +36,14 @@ export function TaskList({ processId, runId, editable }: TaskListProps) { const [showSuggestions, setShowSuggestions] = useState(false); useEffect(() => { - if ((taskDefinitions?.length ?? 0) > 0) { - setTimeout(() => { + if (!runId && (taskDefinitions?.length ?? 0) > 0) { + const timeoutId = setTimeout(() => { setShowSuggestions(true); }, 500); + + return () => clearTimeout(timeoutId); } - }, [taskDefinitions]); + }, [runId, taskDefinitions]); const taskListItems = useMemo(() => { return orderBy(taskDefinitions?.map(td => ({ diff --git a/web/apps/doprocess/components/processes/tasks/TaskListItem.tsx b/web/apps/doprocess/components/processes/tasks/TaskListItem.tsx index cd1185d961..38dbba681f 100644 --- a/web/apps/doprocess/components/processes/tasks/TaskListItem.tsx +++ b/web/apps/doprocess/components/processes/tasks/TaskListItem.tsx @@ -89,7 +89,6 @@ export function TaskListItem({ selected, taskDefinition, runId, task, taskIndex, )} (); + const aiEmptyText = 'AI'; const aiThinkingText = 'AI is thinking...'; const aiSuggestionsText = 'AI suggestions'; - const [aiText, setAiText] = useState(null); + const [aiText, setAiText] = useState(aiEmptyText); const handleRequestSuggestions = async () => { if (suggestionsLoading) return; setSuggestionsLoading(true); @@ -30,7 +32,7 @@ export function TaskListSuggestions({ processId }: { processId: string; }) { // Reset AI text (if it hasn't changed) setAiText(aiSuggestionsText); setTimeout(() => { - setAiText((current) => current === aiSuggestionsText ? null : current); + setAiText((current) => current === aiSuggestionsText ? aiEmptyText : current); }, 2000); } catch(err) { setSuggestionsError(err); @@ -64,23 +66,18 @@ export function TaskListSuggestions({ processId }: { processId: string; }) {