fix(acp-registry): probe commands and skills per workspace cwd #30668
Closedbhaaratkrishnan(GitHub profile, opens in a new tab)wants to merge 7 commits into
main fromrefs/pull/30668/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -607,0 +660,21 @@660+ const now = yield* Clock.currentTimeMillis;661+ const cached = (yield* Ref.get(workspaceProbeCache)).get(cwd);662+ if (cached && cached.expiresAt > now) return cached.snapshot;663+ const probed = yield* workspaceProbePermits.withPermits(2)(664+ probeAcpRegistryWorkspaceForCwd(665+ {666+ instanceId,667+ settings: effectiveConfig,668+ cwd,669+ environment: processEnvironment,670+ machineSnapshot,671+ },672+ probeAcpRegistryConfiguration,673+ ).pipe(674+ Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog),675+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),676+ Effect.provideService(SecureRandom.SecureRandom, random),677+ ),678+ );679+ if (probed.slashCommandsPending !== true) {680+ yield* Ref.update(workspaceProbeCache, (cache) => {@@ -821,3 +902,4 @@821902 ...snapshot,822903 refresh: snapshot.refresh.pipe(Effect.tap(() => controller.refreshMethods ?? Effect.void)),823904 },905+ snapshotForCwd,
- @@ -434,0 +447,21 @@447+ },448+ probeConfiguration: AcpRegistryConfigurationProbe<Requirements>,449+ ): Effect.fn.Return<ProviderWorkspaceSnapshot, never, Requirements> {450+ const { machineSnapshot } = input;451+ if (!machineSnapshot.installed) {452+ return { ...machineSnapshot, slashCommandsPending: false };453+ }454+ const probed = yield* Effect.result(455+ probeConfiguration({456+ instanceId: input.instanceId,457+ settings: input.settings,458+ cwd: input.cwd,459+ environment: input.environment,460+ }),461+ );462+ return Result.isSuccess(probed)463+ ? {464+ ...machineSnapshot,465+ slashCommands: probed.success.slashCommands,466+ skills: probed.success.skills,467+ slashCommandsPending: probed.success.slashCommands.length > 0 ? false : undefined,@@ -605,3 +653,11 @@605653 } | null;606654 }>({ generation: 0, entry: null });607655 const liveSnapshotSemaphore = yield* Semaphore.make(1);656+ const workspaceProbePermits = yield* Semaphore.make(2);657+ const snapshotForCwd = Effect.fn("AcpRegistryDriver.snapshotForCwd")(function* (cwd: string) {658+ const machineSnapshot = yield* snapshot.getSnapshot;659+ if (!effectiveConfig.enabled || !machineSnapshot.installed) return machineSnapshot;660+ const now = yield* Clock.currentTimeMillis;661+ const cached = (yield* Ref.get(workspaceProbeCache)).get(cwd);662+ if (cached && cached.expiresAt > now) return cached.snapshot;663+ const probed = yield* workspaceProbePermits.withPermits(2)(packages/provider-acp-registry/src/server/driver.ts lines 680 to 682OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -607,0 +662,21 @@662+ if (cached && cached.expiresAt > now) return cached.snapshot;663+ const probed = yield* workspaceProbePermits.withPermits(2)(664+ probeAcpRegistryWorkspaceForCwd(665+ {666+ instanceId,667+ settings: effectiveConfig,668+ cwd,669+ environment: processEnvironment,670+ machineSnapshot,671+ },672+ probeAcpRegistryConfiguration,673+ ).pipe(674+ Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog),675+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),676+ Effect.provideService(SecureRandom.SecureRandom, random),677+ ),678+ );679+ if (probed.slashCommandsPending !== true) {680+ yield* Ref.update(workspaceProbeCache, (cache) => {681+ const next = cache.size >= WORKSPACE_PROBE_CACHE_MAX ? new Map() : new Map(cache);682+ next.set(cwd, { snapshot: probed, expiresAt: now + PROBE_SUCCESS_TTL_MS });@@ -788,4 +869,4 @@788869 confirmedAuthentication789870 .set(authenticated)790871 .pipe(791- Effect.andThen(authenticated ? Effect.void : clearLiveState),872+ Effect.andThen(authenticated ? Effect.void : clearWorkspaceState),
- @@ -607,0 +667,21 @@667+ if (cached && cached.expiresAt > now) return cached.snapshot;668+ const generation = cacheState.generation;669+ const probed = yield* workspaceProbePermits.withPermits(2)(670+ probeAcpRegistryWorkspaceForCwd(671+ {672+ instanceId,673+ settings: effectiveConfig,674+ cwd,675+ environment: processEnvironment,676+ machineSnapshot,677+ },678+ probeAcpRegistryConfiguration,679+ ).pipe(680+ Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog),681+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),682+ Effect.provideService(SecureRandom.SecureRandom, random),683+ ),684+ );685+ if (probed.slashCommandsPending !== true) {686+ yield* Ref.update(workspaceProbeCache, (state) => {687+ if (state.generation !== generation) return state;@@ -607,0 +670,21 @@670+ probeAcpRegistryWorkspaceForCwd(671+ {672+ instanceId,673+ settings: effectiveConfig,674+ cwd,675+ environment: processEnvironment,676+ machineSnapshot,677+ },678+ probeAcpRegistryConfiguration,679+ ).pipe(680+ Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog),681+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),682+ Effect.provideService(SecureRandom.SecureRandom, random),683+ ),684+ );685+ if (probed.slashCommandsPending !== true) {686+ yield* Ref.update(workspaceProbeCache, (state) => {687+ if (state.generation !== generation) return state;688+ const entries =689+ state.entries.size >= WORKSPACE_PROBE_CACHE_MAX ? new Map() : new Map(state.entries);690+ entries.set(cwd, { snapshot: probed, expiresAt: now + PROBE_SUCCESS_TTL_MS });
- @@ -293,3 +293,18 @@293293 }294294 const savedAccount = carrySavedAntigravityAccount(previousProvider, nextProvider);295295 const { message: _uncheckedMessage, ...nextWithoutMessage } = nextProvider;296+ const inventory = shouldRetainMissingOpenCodeMetadata(nextProvider)297+ ? {298+ slashCommands:299+ nextProvider.slashCommands.length === 0300+ ? previousProvider.slashCommands301+ : nextProvider.slashCommands,302+ skills: nextProvider.skills.length === 0 ? previousProvider.skills : nextProvider.skills,303+ }304+ : { slashCommands: nextProvider.slashCommands, skills: nextProvider.skills };305+ // Workspace snapshots overlay the machine inventory they were scanned against;306+ // when it changes (e.g. a live session advertises commands), clients rescan.307+ const keepWorkspaceSnapshots =308+ previousProvider.workspaceSnapshots !== undefined &&309+ Equal.equals(inventory.slashCommands, previousProvider.slashCommands) &&310+ Equal.equals(inventory.skills, previousProvider.skills);
tanstack-source added labelsbug
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.

macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed