Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions apps/desktop/src/lib/trpc/routers/changes/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -54,7 +41,7 @@ export const createStatusRouter = () => {
applyUntrackedLineCount(input.worktreePath, parsed.untracked),
]);

const result: GitChangesStatus = {
return {
branch: parsed.branch,
defaultBranch,
againstBase: branchComparison.againstBase,
Expand All @@ -68,9 +55,6 @@ export const createStatusRouter = () => {
pullCount: trackingStatus.pullCount,
hasUpstream: trackingStatus.hasUpstream,
};

statusCache.set(cacheKey, { result, timestamp: Date.now() });
return result;
}),

getCommitFiles: publicProcedure
Expand Down
Loading