refactoring: Filter soft-deleted processes in the backend (#773)
This commit is contained in:
@@ -27,7 +27,7 @@ function ProcessesTab({ attemptId }: ProcessesTabProps) {
|
||||
isLoading: processesLoading,
|
||||
isConnected,
|
||||
error: processesError,
|
||||
} = useExecutionProcesses(attemptId ?? '');
|
||||
} = useExecutionProcesses(attemptId ?? '', { showSoftDeleted: true });
|
||||
const { selectedProcessId, setSelectedProcessId } = useProcessSelection();
|
||||
const [loadingProcessId, setLoadingProcessId] = useState<string | null>(null);
|
||||
const [localProcessDetails, setLocalProcessDetails] = useState<
|
||||
|
||||
@@ -55,14 +55,7 @@ export const useConversationHistory = ({
|
||||
const { executionProcesses: executionProcessesRaw } = useExecutionProcesses(
|
||||
attempt.id
|
||||
);
|
||||
// Soft-deleted (dropped) are invisible in the the conversation history
|
||||
const visibleExecutionProcesses = useMemo(
|
||||
() => executionProcessesRaw?.filter((p) => !p.dropped) ?? [],
|
||||
[executionProcessesRaw]
|
||||
);
|
||||
const executionProcesses = useRef<ExecutionProcess[]>(
|
||||
visibleExecutionProcesses
|
||||
);
|
||||
const executionProcesses = useRef<ExecutionProcess[]>(executionProcessesRaw);
|
||||
const displayedExecutionProcesses = useRef<ExecutionProcessStateStore>({});
|
||||
const loadedInitialEntries = useRef(false);
|
||||
const lastRunningProcessId = useRef<string | null>(null);
|
||||
@@ -73,8 +66,8 @@ export const useConversationHistory = ({
|
||||
|
||||
// Keep executionProcesses up to date
|
||||
useEffect(() => {
|
||||
executionProcesses.current = visibleExecutionProcesses;
|
||||
}, [visibleExecutionProcesses]);
|
||||
executionProcesses.current = executionProcessesRaw;
|
||||
}, [executionProcessesRaw]);
|
||||
|
||||
const loadEntriesForHistoricExecutionProcess = (
|
||||
executionProcess: ExecutionProcess
|
||||
@@ -408,8 +401,8 @@ export const useConversationHistory = ({
|
||||
|
||||
// Stable key for dependency arrays when process list changes
|
||||
const idListKey = useMemo(
|
||||
() => visibleExecutionProcesses?.map((p) => p.id).join(','),
|
||||
[visibleExecutionProcesses]
|
||||
() => executionProcessesRaw?.map((p) => p.id).join(','),
|
||||
[executionProcessesRaw]
|
||||
);
|
||||
|
||||
// Initial load when attempt changes
|
||||
@@ -459,11 +452,11 @@ export const useConversationHistory = ({
|
||||
|
||||
// If an execution process is removed, remove it from the state
|
||||
useEffect(() => {
|
||||
if (!visibleExecutionProcesses) return;
|
||||
if (!executionProcessesRaw) return;
|
||||
|
||||
const removedProcessIds = Object.keys(
|
||||
displayedExecutionProcesses.current
|
||||
).filter((id) => !visibleExecutionProcesses.some((p) => p.id === id));
|
||||
).filter((id) => !executionProcessesRaw.some((p) => p.id === id));
|
||||
|
||||
removedProcessIds.forEach((id) => {
|
||||
delete displayedExecutionProcesses.current[id];
|
||||
|
||||
@@ -20,9 +20,15 @@ interface UseExecutionProcessesResult {
|
||||
* Live updates arrive at /execution_processes/<id> via add/replace/remove operations.
|
||||
*/
|
||||
export const useExecutionProcesses = (
|
||||
taskAttemptId: string
|
||||
taskAttemptId: string,
|
||||
opts?: { showSoftDeleted?: boolean }
|
||||
): UseExecutionProcessesResult => {
|
||||
const endpoint = `/api/execution-processes/stream/ws?task_attempt_id=${encodeURIComponent(taskAttemptId)}`;
|
||||
const showSoftDeleted = opts?.showSoftDeleted;
|
||||
const params = new URLSearchParams({ task_attempt_id: taskAttemptId });
|
||||
if (typeof showSoftDeleted === 'boolean') {
|
||||
params.set('show_soft_deleted', String(showSoftDeleted));
|
||||
}
|
||||
const endpoint = `/api/execution-processes/stream/ws?${params.toString()}`;
|
||||
|
||||
const initialData = useCallback(
|
||||
(): ExecutionProcessState => ({ execution_processes: {} }),
|
||||
|
||||
Reference in New Issue
Block a user