Skip to content

Commit 79c7ffd

Browse files
committed
refactor: clean up some code
1 parent cc7e632 commit 79c7ffd

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

site/src/modules/resources/AgentRow.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
Template,
77
Workspace,
88
WorkspaceAgent,
9+
WorkspaceAgentLog,
910
WorkspaceAgentMetadata,
1011
} from "api/typesGenerated";
1112
import { Button } from "components/Button/Button";
@@ -79,21 +80,21 @@ export const AgentRow: FC<AgentRowProps> = ({
7980
const agentLogs = useAgentLogs(agent.id, showLogs);
8081
const logListRef = useRef<List>(null);
8182
const logListDivRef = useRef<HTMLDivElement>(null);
82-
const startupLogs = useMemo(() => {
83-
const allLogs = agentLogs || [];
84-
85-
const logs = [...allLogs];
86-
if (agent.logs_overflowed) {
87-
logs.push({
83+
const startupLogs = useMemo<readonly WorkspaceAgentLog[]>(() => {
84+
if (!agent.logs_overflowed) {
85+
return agentLogs;
86+
}
87+
return [
88+
...agentLogs,
89+
{
8890
id: -1,
8991
level: "error",
9092
output:
9193
"Startup logs exceeded the max size of 1MB, and will not continue to be written to the database! Logs will continue to be written to the /tmp/coder-startup-script.log file in the workspace.",
9294
created_at: new Date().toISOString(),
9395
source_id: "",
94-
});
95-
}
96-
return logs;
96+
},
97+
];
9798
}, [agentLogs, agent.logs_overflowed]);
9899
const [bottomOfLogs, setBottomOfLogs] = useState(true);
99100

0 commit comments

Comments
 (0)