⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix: bound realtime task refreshes and show public board progress
Tin1e89b8313e78
diff --git a/apps/web/src/hooks/use-project-websocket-cache.test.tsx b/apps/web/src/hooks/use-project-websocket-cache.test.tsxindex 44aa566eb..3174d879d 100644--- a/apps/web/src/hooks/use-project-websocket-cache.test.tsx+++ b/apps/web/src/hooks/use-project-websocket-cache.test.tsx@@ -277,3 +277,23 @@ it("preserves newer parent progress when an earlier parent refresh finishes last).columns[0].tasks.find((task) => task.id === "a");expect(task?.subtaskCounts).toEqual({ completed: 2, total: 2 });});++it("bounds per-task reads during a thousand-event burst and reconciles once", async () => {+ vi.useFakeTimers();+ try {+ mocks.getTask.mockReset().mockImplementation(() => new Promise(() => {}));+ renderHook(() => useProjectWebSocket("p"));+ for (let i = 0; i < 1000; i++)+ Socket.current.message("TASK_UPDATED", { taskId: `task-${i}` });+ expect(mocks.getTask).toHaveBeenCalledTimes(4);+ await vi.advanceTimersByTimeAsync(200);+ expect(+ mocks.client.invalidateQueries.mock.calls.filter(+ ([options]) => options.queryKey[0] === "tasks",+ ),+ ).toHaveLength(1);+ expect(mocks.getTask).toHaveBeenCalledTimes(4);+ } finally {+ vi.useRealTimers();+ }+});diff --git a/apps/web/src/hooks/use-project-websocket.ts b/apps/web/src/hooks/use-project-websocket.tsindex 06b7d1c11..475fc5fea 100644--- a/apps/web/src/hooks/use-project-websocket.ts+++ b/apps/web/src/hooks/use-project-websocket.ts@@ -39,6 +39,18 @@ export function useProjectWebSocket(projectId: string) {let needsReconcile = false;let flushQueued = false;const taskVersions = new Map<string, number>();+ const refreshingTasks = new Set<string>();+ let burstReconcileTimer: ReturnType<typeof setTimeout> | null = null;+ function reconcileBurst() {+ if (burstReconcileTimer !== null) clearTimeout(burstReconcileTimer);+ else markBoardCacheChanged(queryClient, projectId);+ burstReconcileTimer = setTimeout(() => {+ burstReconcileTimer = null;+ if (disposed) return;+ needsReconcile = true;+ flushPending();+ }, 200);+ }const pendingMessages = new Map<string, string>();let activeSocket: WebSocket | null = null;let retries = 0;@@ -203,7 +215,14 @@ export function useProjectWebSocket(projectId: string) {(board) =>board ? (patchBoardTask(board, taskId) ?? board) : board,);+ } else if (+ refreshingTasks.size >= 4 ||+ refreshingTasks.has(taskId) ||+ burstReconcileTimer !== null+ ) {+ reconcileBurst();} else {+ refreshingTasks.add(taskId);void Promise.all([getTask(taskId, "board"),getLabelsByTask({ taskId }),@@ -281,7 +300,8 @@ export function useProjectWebSocket(projectId: string) {void queryClient.invalidateQueries({queryKey: ["tasks", projectId],});- });+ })+ .finally(() => refreshingTasks.delete(taskId));}}@@ -416,7 +436,7 @@ export function useProjectWebSocket(projectId: string) {unsubscribe();if (healthyTimeout !== null) clearTimeout(healthyTimeout);pendingMessages.clear();- if (healthyTimeout !== null) clearTimeout(healthyTimeout);+ if (burstReconcileTimer !== null) clearTimeout(burstReconcileTimer);disposed = true;clearPing();if (fallbackInterval !== null) clearInterval(fallbackInterval);diff --git a/apps/web/src/routes/public-project.$projectId.tsx b/apps/web/src/routes/public-project.$projectId.tsxindex 6d6ec794b..f34a61048 100644--- a/apps/web/src/routes/public-project.$projectId.tsx+++ b/apps/web/src/routes/public-project.$projectId.tsx@@ -55,7 +55,7 @@ function RouteComponent() {setSelectedTask(null);};- if (isLoading) {+ if (isLoading && !project) {return <LoadingSkeleton />;}