@@ -297,17 +297,32 @@ export const AgentRow: FC<AgentRowProps> = ({
297
297
>
298
298
{ ( { index, style } ) => {
299
299
const log = startupLogs [ index ] ;
300
- const sourceIcon : string | undefined =
301
- logSourceByID [ log . source_id ] . icon ;
300
+ // getLogSource always returns a valid log source.
301
+ // This is necessary to support deployments before `coder_script`.
302
+ // Existed that haven't restarted their agents.
303
+ const getLogSource = (
304
+ id : string ,
305
+ ) : WorkspaceAgentLogSource => {
306
+ return (
307
+ logSourceByID [ id ] || {
308
+ created_at : "" ,
309
+ display_name : "Logs" ,
310
+ icon : "" ,
311
+ id : "00000000-0000-0000-0000-000000000000" ,
312
+ workspace_agent_id : "" ,
313
+ }
314
+ ) ;
315
+ } ;
316
+ const logSource = getLogSource ( log . source_id ) ;
302
317
303
318
let assignedIcon = false ;
304
319
let icon : JSX . Element ;
305
320
// If no icon is specified, we show a deterministic
306
321
// colored circle to identify unique scripts.
307
- if ( sourceIcon ) {
322
+ if ( logSource . icon ) {
308
323
icon = (
309
324
< img
310
- src = { sourceIcon }
325
+ src = { logSource . icon }
311
326
alt = ""
312
327
width = { 16 }
313
328
height = { 16 }
@@ -324,7 +339,7 @@ export const AgentRow: FC<AgentRowProps> = ({
324
339
height : 16 ,
325
340
marginRight : 8 ,
326
341
background : determineScriptDisplayColor (
327
- logSourceByID [ log . source_id ] . display_name ,
342
+ logSource . display_name ,
328
343
) ,
329
344
borderRadius : "100%" ,
330
345
} }
@@ -336,7 +351,7 @@ export const AgentRow: FC<AgentRowProps> = ({
336
351
let nextChangesSource = false ;
337
352
if ( index < startupLogs . length - 1 ) {
338
353
nextChangesSource =
339
- logSourceByID [ startupLogs [ index + 1 ] . source_id ] . id !==
354
+ getLogSource ( startupLogs [ index + 1 ] . source_id ) . id !==
340
355
log . source_id ;
341
356
}
342
357
// We don't want every line to repeat the icon, because
@@ -346,7 +361,7 @@ export const AgentRow: FC<AgentRowProps> = ({
346
361
// same source.
347
362
if (
348
363
index > 0 &&
349
- logSourceByID [ startupLogs [ index - 1 ] . source_id ] . id ===
364
+ getLogSource ( startupLogs [ index - 1 ] . source_id ) . id ===
350
365
log . source_id
351
366
) {
352
367
icon = (
@@ -396,7 +411,7 @@ export const AgentRow: FC<AgentRowProps> = ({
396
411
< Tooltip
397
412
title = {
398
413
< >
399
- { logSourceByID [ log . source_id ] . display_name }
414
+ { logSource . display_name }
400
415
{ assignedIcon && (
401
416
< i >
402
417
< br />
0 commit comments