Skip to content

Commit 486dae0

Browse files
emmemsBil0000
authored andcommitted
fix(server): stop marking the catalog pending for providers that cannot scan a folder
1 parent 27cadf7 commit 486dae0

2 files changed

Lines changed: 30 additions & 21 deletions

File tree

‎apps/server/src/ws.test.ts‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,23 +1203,29 @@ it.effect("on-demand clients get provider config without workspace snapshots", (
12031203
refreshed.providers.map((entry) => [entry.workspaceSnapshots, entry.slashCommands]),
12041204
[[[snapshotFor("/b", "2026-10-25T00:00:00.000Z")], []]],
12051205
);
1206-
// A failed scan still gives a client without the machine catalog its commands.
1207-
yield* server.write(0, {
1208-
_tag: "Request",
1209-
id: RpcMessage.RequestId("refresh-failed-scan"),
1210-
tag: WS_METHODS.serverRefreshProviders,
1211-
payload: {
1212-
instanceId,
1213-
cwd: "/c",
1214-
workspaceSnapshotsOnDemand: true,
1215-
providerCatalogsOnDemand: true,
1216-
},
1217-
headers: Headers.empty,
1206+
const refreshCatalogOnDemand = Effect.fn(function* (id: string) {
1207+
yield* server.write(0, {
1208+
_tag: "Request",
1209+
id: RpcMessage.RequestId(id),
1210+
tag: WS_METHODS.serverRefreshProviders,
1211+
payload: {
1212+
instanceId,
1213+
cwd: "/c",
1214+
workspaceSnapshotsOnDemand: true,
1215+
providerCatalogsOnDemand: true,
1216+
},
1217+
headers: Headers.empty,
1218+
});
1219+
const response = (yield* Queue.take(responses)) as {
1220+
readonly providers: ReadonlyArray<ServerProvider>;
1221+
};
1222+
return response.providers[0]?.workspaceSnapshots;
12181223
});
1219-
const fallback = (yield* Queue.take(responses)) as {
1220-
readonly providers: ReadonlyArray<ServerProvider>;
1221-
};
1222-
assert.deepEqual(fallback.providers[0]?.workspaceSnapshots, [
1224+
// A provider that cannot scan already sent its machine catalog, so nothing stays pending.
1225+
assert.deepEqual(yield* refreshCatalogOnDemand("refresh-no-scan"), []);
1226+
// A failed scan still gives a client without the machine catalog its commands.
1227+
scansCwd = true;
1228+
assert.deepEqual(yield* refreshCatalogOnDemand("refresh-failed-scan"), [
12231229
{
12241230
cwd: "/c",
12251231
checkedAt: provider.checkedAt,

‎apps/server/src/ws.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,6 +2515,13 @@ export const layerWsRpc = (
25152515
if (instanceId === undefined || cwd === undefined) {
25162516
return { providers: withoutWorkspaceSnapshots(commandProviders) };
25172517
}
2518+
// An instance that cannot scan keeps its machine catalog in the config stream.
2519+
const catalogOnDemand =
2520+
input.providerCatalogsOnDemand === true &&
2521+
(yield* providerInstances.listInstances).some(
2522+
(instance) =>
2523+
instance.instanceId === instanceId && instance.snapshotForCwd !== undefined,
2524+
);
25182525
return {
25192526
providers: commandProviders
25202527
.filter((provider) => provider.instanceId === instanceId)
@@ -2524,11 +2531,7 @@ export const layerWsRpc = (
25242531
models: [],
25252532
slashCommands: [],
25262533
skills: [],
2527-
workspaceSnapshots: workspaceSnapshotOrCatalog(
2528-
provider,
2529-
cwd,
2530-
input.providerCatalogsOnDemand === true,
2531-
),
2534+
workspaceSnapshots: workspaceSnapshotOrCatalog(provider, cwd, catalogOnDemand),
25322535
})),
25332536
};
25342537
}),

0 commit comments

Comments
 (0)