diff --git a/frontend/src/contexts/ExecutionProcessesContext.tsx b/frontend/src/contexts/ExecutionProcessesContext.tsx index dfab0464..f7fa0087 100644 --- a/frontend/src/contexts/ExecutionProcessesContext.tsx +++ b/frontend/src/contexts/ExecutionProcessesContext.tsx @@ -20,7 +20,7 @@ const ExecutionProcessesContext = createContext(null); export const ExecutionProcessesProvider: React.FC<{ - attemptId: string; + attemptId: string | undefined; children: React.ReactNode; }> = ({ attemptId, children }) => { const { diff --git a/frontend/src/contexts/ReviewProvider.tsx b/frontend/src/contexts/ReviewProvider.tsx index d0855101..bf658355 100644 --- a/frontend/src/contexts/ReviewProvider.tsx +++ b/frontend/src/contexts/ReviewProvider.tsx @@ -1,5 +1,11 @@ import { SplitSide } from '@git-diff-view/react'; -import { createContext, useContext, useState, ReactNode } from 'react'; +import { + createContext, + useContext, + useState, + ReactNode, + useEffect, +} from 'react'; import { genId } from '@/utils/id'; export interface ReviewComment { @@ -40,10 +46,20 @@ export function useReview() { return context; } -export function ReviewProvider({ children }: { children: ReactNode }) { +export function ReviewProvider({ + children, + attemptId, +}: { + children: ReactNode; + attemptId?: string; +}) { const [comments, setComments] = useState([]); const [drafts, setDrafts] = useState>({}); + useEffect(() => { + return () => clearComments(); + }, [attemptId]); + const addComment = (comment: Omit) => { const newComment: ReviewComment = { ...comment, diff --git a/frontend/src/hooks/useExecutionProcesses.ts b/frontend/src/hooks/useExecutionProcesses.ts index bdc32e0a..998c0e0e 100644 --- a/frontend/src/hooks/useExecutionProcesses.ts +++ b/frontend/src/hooks/useExecutionProcesses.ts @@ -21,15 +21,19 @@ interface UseExecutionProcessesResult { * Live updates arrive at /execution_processes/ via add/replace/remove operations. */ export const useExecutionProcesses = ( - taskAttemptId: string, + taskAttemptId: string | undefined, opts?: { showSoftDeleted?: boolean } ): UseExecutionProcessesResult => { const showSoftDeleted = opts?.showSoftDeleted; - const params = new URLSearchParams({ task_attempt_id: taskAttemptId }); - if (typeof showSoftDeleted === 'boolean') { - params.set('show_soft_deleted', String(showSoftDeleted)); + let endpoint: string | undefined; + + if (taskAttemptId) { + const params = new URLSearchParams({ task_attempt_id: taskAttemptId }); + if (typeof showSoftDeleted === 'boolean') { + params.set('show_soft_deleted', String(showSoftDeleted)); + } + endpoint = `/api/execution-processes/stream/ws?${params.toString()}`; } - const endpoint = `/api/execution-processes/stream/ws?${params.toString()}`; const initialData = useCallback( (): ExecutionProcessState => ({ execution_processes: {} }), diff --git a/frontend/src/pages/ProjectTasks.tsx b/frontend/src/pages/ProjectTasks.tsx index 7e298bfd..ae2c6388 100644 --- a/frontend/src/pages/ProjectTasks.tsx +++ b/frontend/src/pages/ProjectTasks.tsx @@ -1029,36 +1029,25 @@ export function ProjectTasks() { const effectiveMode: LayoutMode = selectedSharedTask ? null : mode; - const attemptArea = - attempt && selectedTask ? ( - - - - - - - - - - ) : ( - - ); + const attemptArea = ( + + + + + + + + + + ); return (