fix: clear structured log viewer rows on stack switch (#1448)

The structured log viewer accumulated log rows across stack switches
because the useEffect cleanup closed the old WebSocket but never
cleared the committed rows state. Reset rows, row IDs, and auto-follow
at the top of the effect before connecting to the new stack. The level
filter is intentionally preserved across switches.

Closes #1444
This commit is contained in:
Anso
2026-06-25 02:17:23 -04:00
committed by GitHub
parent cc78873e65
commit 79f840ab6e
2 changed files with 188 additions and 0 deletions
@@ -68,6 +68,13 @@ export default function StructuredLogViewer({ stackName }: StructuredLogViewerPr
useEffect(() => { followingRef.current = following; }, [following]);
useEffect(() => {
// Reset state accumulated from the previous stack before connecting.
// eslint-disable-next-line react-hooks/set-state-in-effect
setRows([]);
rowIdRef.current = 0;
setFollowing(true);
followingRef.current = true;
const cleanStackName = stackName.replace(/\.(yml|yaml)$/, '');
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const activeNodeId = localStorage.getItem('sencho-active-node') || '';