diff --git a/src/components/ContainerCard.tsx b/src/components/ContainerCard.tsx index c5b6a9b..5aa8285 100644 --- a/src/components/ContainerCard.tsx +++ b/src/components/ContainerCard.tsx @@ -30,12 +30,19 @@ const ContainerCard: React.FC = ({ const socketRef = useRef(null); const logBoxRef = useRef(null); - // Sync status and clear logs/eventMsg when container ID changes (new container after restart) + // Keep local status in sync whenever the parent reports a new one useEffect(() => { setStatusState(option.status); - setLogs([]); + }, [option.status]); + + useEffect(() => { setEventMsg(externalEventMsg); - }, [option.id, externalEventMsg, option.status]); + }, [externalEventMsg]); + + // Only clear logs when a new container starts (id changes) + useEffect(() => { + setLogs([]); + }, [option.id]); const handleStart = async () => { await onStart(key);