feat(KB-129): dashboard performance optimizations

- Fix SSE hook cleanup to prevent memory leaks and stale connections
- Cap agent log memory and optimize batch log processing
- Memoize Board, Column, and TaskCard with custom comparator to reduce re-renders
- Stabilize column task arrays and preserve pagination across live updates
- Add TaskCardBadge component for PR/issue state display
- Remove deprecated GitHub polling code and archive functionality from core store
This commit is contained in:
gsxdsm
2026-03-30 11:26:55 -07:00
parent 753bec19df
commit 50cd478f2e
21 changed files with 1269 additions and 276 deletions

View File

@@ -2,6 +2,14 @@ import { useState, useEffect, useRef, useCallback } from "react";
import type { AgentLogEntry } from "@kb/core";
import { fetchAgentLogs } from "../api";
export const MAX_LOG_ENTRIES = 500;
function capLogEntries(entries: AgentLogEntry[]): AgentLogEntry[] {
return entries.length > MAX_LOG_ENTRIES
? entries.slice(-MAX_LOG_ENTRIES)
: entries;
}
/**
* Hook that manages agent log fetching and live SSE streaming for a task.
*
@@ -33,9 +41,9 @@ export function useAgentLogs(taskId: string | null, enabled: boolean) {
async function init() {
setLoading(true);
try {
const historical = await fetchAgentLogs(taskId!);
const historical = await fetchAgentLogs(taskId);
if (cancelled) return;
setEntries(historical);
setEntries(capLogEntries(historical));
} catch {
if (cancelled) return;
setEntries([]);
@@ -51,14 +59,14 @@ export function useAgentLogs(taskId: string | null, enabled: boolean) {
if (cancelled) return;
try {
const entry: AgentLogEntry = JSON.parse(e.data);
setEntries((prev) => [...prev, entry]);
setEntries((prev) => capLogEntries([...prev, entry]));
} catch {
// skip malformed events
}
});
}
init();
void init();
return () => {
cancelled = true;