Fix dashboard race condition in initial_state handler

When a new session's initial_state arrives, we now set the output
before calling renderSessions() rather than after. This prevents
renderSessionOutput() from being called before the DOM exists.
This commit is contained in:
Jared Miller 2026-01-31 12:00:23 -05:00
parent 1b72d1e4e4
commit 22c5c3d102
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -1169,7 +1169,7 @@
id: data.session_id, id: data.session_id,
cwd: '', cwd: '',
command: 'claude', command: 'claude',
output: '', output: data.html,
outputRenderedLength: 0, outputRenderedLength: 0,
expanded: false, expanded: false,
state: 'ready', state: 'ready',
@ -1186,12 +1186,14 @@
git_files_json: null, git_files_json: null,
}; };
state.sessions.set(data.session_id, session); state.sessions.set(data.session_id, session);
// renderSessions() will render both the session and its output
renderSessions(); renderSessions();
} } else {
// Replace output with current terminal state // Session already exists, update output and re-render it
session.output = data.html; session.output = data.html;
session.outputRenderedLength = 0; // Force re-render session.outputRenderedLength = 0; // Force re-render
renderSessionOutput(data.session_id); renderSessionOutput(data.session_id);
}
}); });
es.addEventListener('output', (e) => { es.addEventListener('output', (e) => {