fix: composer picks up new project skills without a server restart #16750
Mergedjuliusmarmingemerged 1 commit into
main fromrefs/pull/16750/headmerged by juliusmarminge View on GitHubjuliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -2237,10 +2241,8 @@22372241 useEffect(() => {22382242 if (!gitCwd || !selectedProviderEntry) return;22392243 const key = `${environmentId}:${selectedProviderEntry.instanceId}:${gitCwd}`;2240- const hasWorkspaceSnapshot = hasCompleteProviderWorkspaceSnapshot(2241- selectedProviderStatus,2242- gitCwd,2243- );2244- if (workspaceRefreshKeyRef.current === key) return;2245- if (hasWorkspaceSnapshot) {2246- workspaceRefreshKeyRef.current = key;2244+ const now = Date.now();2245+ const lastRequest = workspaceRefreshKeyRef.current;2246+ if (2247+ lastRequest?.key === key &&2248+ now - lastRequest.requestedAt < PROVIDER_WORKSPACE_SNAPSHOT_TTL_MS@@ -131,3 +131,15 @@131131 });132132 export type ServerProviderWorkspaceSnapshot = typeof ServerProviderWorkspaceSnapshot.Type;133133134+/**135+ * How long a workspace's skill and command scan stays current. Nothing watches136+ * skill directories, so a composer opened after this rescans on use, and the137+ * server answers repeat requests inside the window from its cache.138+ */139+export const PROVIDER_WORKSPACE_SNAPSHOT_TTL_MS = 5 * 60_000;140+141+export function isProviderWorkspaceSnapshotCurrent(142+ snapshot: Pick<ServerProviderWorkspaceSnapshot, "checkedAt">,143+ nowMs: number,144+): boolean {145+ return nowMs - Date.parse(snapshot.checkedAt) < PROVIDER_WORKSPACE_SNAPSHOT_TTL_MS;
juliusmarminge merged thisa183091
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes