From 55495f16d19d76088862e82458999e54fc604a32 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Wed, 18 Feb 2026 11:41:41 -0800 Subject: [PATCH] fix(desktop): remove server-side status cache that caused stale sidebar data The 2s server-side cache in getStatus returned stale git state after mutations (stage, unstage, commit, etc.) since refetch() hit the cache before it expired. The 2.5s client-side polling interval already rate-limits queries, making the server cache unnecessary. --- .../src/lib/trpc/routers/changes/status.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/apps/desktop/src/lib/trpc/routers/changes/status.ts b/apps/desktop/src/lib/trpc/routers/changes/status.ts index 748201236c1..405c1ac84b4 100644 --- a/apps/desktop/src/lib/trpc/routers/changes/status.ts +++ b/apps/desktop/src/lib/trpc/routers/changes/status.ts @@ -11,13 +11,6 @@ import { parseNameStatus, } from "./utils/parse-status"; -/** Server-side cache to avoid re-running git commands when polled frequently */ -const STATUS_CACHE_TTL_MS = 2_000; -const statusCache = new Map< - string, - { result: GitChangesStatus; timestamp: number } ->(); - export const createStatusRouter = () => { return router({ getStatus: publicProcedure @@ -31,12 +24,6 @@ export const createStatusRouter = () => { assertRegisteredWorktree(input.worktreePath); const defaultBranch = input.defaultBranch || "main"; - const cacheKey = `${input.worktreePath}:${defaultBranch}`; - const cached = statusCache.get(cacheKey); - if (cached && Date.now() - cached.timestamp < STATUS_CACHE_TTL_MS) { - return cached.result; - } - const git = simpleGit(input.worktreePath); const status = await getStatusNoLock(input.worktreePath); @@ -54,7 +41,7 @@ export const createStatusRouter = () => { applyUntrackedLineCount(input.worktreePath, parsed.untracked), ]); - const result: GitChangesStatus = { + return { branch: parsed.branch, defaultBranch, againstBase: branchComparison.againstBase, @@ -68,9 +55,6 @@ export const createStatusRouter = () => { pullCount: trackingStatus.pullCount, hasUpstream: trackingStatus.hasUpstream, }; - - statusCache.set(cacheKey, { result, timestamp: Date.now() }); - return result; }), getCommitFiles: publicProcedure