Skip to content

Commit 6aba6a8

Browse files
grimmerkclaude
andcommitted
perf: add 5s cache for active IDE project detection
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b4d75f7 commit 6aba6a8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/vscode-based-ide-utility.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,15 @@ export const deleteRecentProjectRecord = async (path: string) => {
387387
* Uses AppleScript to get window titles from the IDE process.
388388
* Returns a Set of folder names (last path component) that have open windows.
389389
*/
390+
let cachedActiveIDEFolders: Set<string> | null = null;
391+
let activeIDECacheTimestamp = 0;
392+
const ACTIVE_IDE_CACHE_TTL_MS = 5000;
393+
390394
export const detectActiveIDEProjects = async (): Promise<Set<string>> => {
395+
const now = Date.now();
396+
if (cachedActiveIDEFolders && (now - activeIDECacheTimestamp) < ACTIVE_IDE_CACHE_TTL_MS) {
397+
return cachedActiveIDEFolders;
398+
}
391399
const processName = currentIDEMode === IDEMode.Cursor ? 'Cursor' : 'Code';
392400
const execPromise = (cmd: string): Promise<string> =>
393401
new Promise((resolve) => {
@@ -427,5 +435,7 @@ end tell`;
427435
}
428436
}
429437

438+
cachedActiveIDEFolders = folderNames;
439+
activeIDECacheTimestamp = now;
430440
return folderNames;
431441
};

0 commit comments

Comments
 (0)