Skip to content

Commit 7c19d2c

Browse files
khaliqgantclaude
andcommitted
fix: prevent empty screen flash when team data temporarily unavailable
When agents.json is being rewritten by the daemon, getTeamData() returns null and getAllData() was returning empty arrays. This payload would get broadcast to all WebSocket clients, wiping their UI with a blank screen. Now getAllData() returns null when team data is unavailable, and broadcastData() skips the broadcast entirely—preserving the last valid payload on clients. Initial WebSocket connects still send a fallback empty structure so new clients render immediately. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 74b2c51 commit 7c19d2c

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

packages/dashboard-server/src/server.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,7 @@ export async function startDashboard(
19891989

19901990
const getAllData = async () => {
19911991
const team = getTeamData();
1992-
if (!team) return { agents: [], messages: [], activity: [], sessions: [], summaries: [] };
1992+
if (!team) return null; // Signal that team data is temporarily unavailable
19931993

19941994
const agentsMap = new Map<string, AgentStatus>();
19951995
const allMessages: Message[] = await getMessages(team.agents);
@@ -2297,6 +2297,14 @@ export async function startDashboard(
22972297
const broadcastData = async () => {
22982298
try {
22992299
const data = await getAllData();
2300+
2301+
// Skip broadcast when team data is temporarily unavailable (e.g., agents.json
2302+
// being rewritten by daemon). Preserves the last valid payload so clients
2303+
// don't see an empty screen flash.
2304+
if (!data) {
2305+
return;
2306+
}
2307+
23002308
const rawPayload = JSON.stringify(data);
23012309

23022310
// Guard against empty/invalid payloads
@@ -2449,7 +2457,11 @@ export async function startDashboard(
24492457

24502458
try {
24512459
const data = await getAllData();
2452-
const payload = JSON.stringify(data);
2460+
2461+
// If team data is temporarily unavailable, send empty-but-valid structure
2462+
// so the client at least renders (better than sending nothing on first connect)
2463+
const safeData = data ?? { agents: [], messages: [], activity: [], sessions: [], summaries: [] };
2464+
const payload = JSON.stringify(safeData);
24532465

24542466
// Guard against empty/invalid payloads
24552467
if (!payload || payload.length === 0) {

0 commit comments

Comments
 (0)