perf: reduce startup request fanout
Avoid repeated sidebar session and worktree refreshes Limit concurrent GitHub PR status checks Reuse cached worktree root resolution
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { create } from 'zustand';
|
||||
import { createJSONStorage, persist } from 'zustand/middleware';
|
||||
import type { GitHubPullRequestStatus, RuntimeAPIs } from '@/lib/api/types';
|
||||
import { mapWithConcurrency } from '@/lib/concurrency';
|
||||
import { getSafeStorage } from './utils/safeStorage';
|
||||
|
||||
const PR_REVALIDATE_TTL_MS = 90_000;
|
||||
@@ -10,6 +11,7 @@ const PR_BOOTSTRAP_RETRY_DELAYS_MS = [2_000, 5_000] as const;
|
||||
const PR_OPEN_BUSY_INTERVAL_MS = 60_000;
|
||||
const PR_OPEN_DEFAULT_INTERVAL_MS = 2 * 60_000;
|
||||
const PR_OPEN_STABLE_INTERVAL_MS = 5 * 60_000;
|
||||
const PR_STATUS_REFRESH_CONCURRENCY = 4;
|
||||
const PR_PERSIST_TTL_MS = 12 * 60 * 60_000;
|
||||
const PR_STATUS_STORAGE_KEY = 'openchamber.github-pr-status';
|
||||
|
||||
@@ -581,7 +583,7 @@ export const useGitHubPrStatusStore = create<GitHubPrStatusStore>()(
|
||||
.filter((key): key is string => Boolean(key)),
|
||||
));
|
||||
|
||||
await Promise.all(keys.map((key) => get().refresh(key, options)));
|
||||
await mapWithConcurrency(keys, PR_STATUS_REFRESH_CONCURRENCY, (key) => get().refresh(key, options));
|
||||
},
|
||||
|
||||
updateStatus: (key, updater) => {
|
||||
|
||||
@@ -23,7 +23,7 @@ type GlobalSessionsState = {
|
||||
archiveSessions: (ids: Iterable<string>, archivedAt?: number) => void;
|
||||
};
|
||||
|
||||
const PAGE_SIZE = 200;
|
||||
const PAGE_SIZE = 500;
|
||||
|
||||
let inflightLoad: Promise<LoadResult> | null = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user