fix: reset WebSocket state when switching projects

Add state reset at the start of the project change effect in
useWebSocket hook. This clears stale progress data, agent status,
and logs when the user switches to a different project, preventing
display of outdated information from the previous project.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Auto
2026-01-11 11:46:08 +02:00
parent aede8f720e
commit b1473cdfb9

View File

@@ -125,6 +125,14 @@ export function useProjectWebSocket(projectName: string | null) {
// Connect when project changes
useEffect(() => {
// Reset state when project changes to clear stale data
setState({
progress: { passing: 0, in_progress: 0, total: 0, percentage: 0 },
agentStatus: 'stopped',
logs: [],
isConnected: false,
})
if (!projectName) {
// Disconnect if no project
if (wsRef.current) {