cc-haha/desktop/src/lib/recentProjectsCache.ts
程序员阿江(Relakkes) 35f43e8289 fix: resolve post-release semantic conflicts
Fix cross-issue regressions found during post-0.4.4 merge review:\n\n- preserve permission mode across clear and empty-session replacement flows\n- keep provider effort passthrough and context-window estimates aligned with runtime metadata\n- invalidate recent project caches and trace message signatures when sessions change\n- recognize Windows ARM64 unpacked package-smoke output\n\nTested: bun test scripts/quality-gate/package-smoke/index.test.ts scripts/quality-gate/runner.test.ts\nTested: bun run check:desktop\nTested: bun run check:server\nConfidence: high\nScope-risk: moderate
2026-07-02 22:11:43 +08:00

21 lines
566 B
TypeScript

import type { RecentProject } from '../api/sessions'
let cachedProjects: RecentProject[] | null = null
let cacheTimestamp = 0
const CACHE_TTL = 30_000
export function getCachedRecentProjects(): RecentProject[] | null {
if (!cachedProjects || Date.now() - cacheTimestamp >= CACHE_TTL) return null
return cachedProjects
}
export function setCachedRecentProjects(projects: RecentProject[]): void {
cachedProjects = projects
cacheTimestamp = Date.now()
}
export function invalidateRecentProjectsCache(): void {
cachedProjects = null
cacheTimestamp = 0
}