Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/components/ContainerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ const ContainerCard: React.FC<ContainerCardProps> = ({
const socketRef = useRef<WebSocket | null>(null);
const logBoxRef = useRef<HTMLPreElement>(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);
Expand Down Expand Up @@ -128,7 +135,7 @@ const ContainerCard: React.FC<ContainerCardProps> = ({
</p>
)}

{statusState !== 'stopped' && (
{(statusState !== 'stopped' || logs.length > 0) && (
<div style={{ marginTop: 12 }}>
<strong>Live Logs:</strong>
<pre
Expand Down
Loading