Skip to content

Commit 6fadfdd

Browse files
SunkenInTimeclaude
andcommitted
fix(server): idle shells stop reloading every project once a minute
A shell subscriber answered every project-enrichment change by re-enriching all projects. That re-requested each root whose cache entry had expired, each resolution published another change, and every subscriber reloaded every project again. Once started (the PR sync sweep restarts it each minute), the chain kept enrichment running continuously: about two thirds of the server's trace output on a real install. Build the refresh from the identities the changes already carry, for the changed roots only, so a refresh no longer requests anything. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent af7de21 commit 6fadfdd

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

‎apps/server/src/ws.ts‎

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -948,16 +948,35 @@ export const subscribeOrchestrationV2Shell = Effect.fn("ws.orchestrationV2.subsc
948948
const enrichmentRefreshes = Stream.fromSubscription(enrichmentChanges).pipe(
949949
Stream.filter((change) => change.repositoryIdentityResolved),
950950
Stream.groupedWithin(64, Duration.millis(25)),
951+
// Build the refresh from the identities the changes carry. Re-enriching
952+
// every project here re-requested each expired root, whose resolution
953+
// published again, so one expiry kept every subscriber reloading every
954+
// project's metadata once a minute.
951955
Stream.mapEffect((changes) =>
952-
applicationEvents.latestApplicationSequence.pipe(
953-
Effect.flatMap(loadProjectMetadataSnapshot),
954-
Effect.map(({ snapshot }) =>
955-
shellStreamItemFromEnrichmentRefresh({
956-
snapshot,
957-
changes: Array.from(changes),
958-
}),
959-
),
960-
),
956+
Effect.gen(function* () {
957+
const identities = new Map(
958+
Array.from(changes, (change) => [
959+
change.workspaceRoot,
960+
change.enrichment.repositoryIdentity,
961+
]),
962+
);
963+
const snapshotSequence = yield* applicationEvents.latestApplicationSequence;
964+
const changedProjects = (yield* projects.listShells()).flatMap((project) =>
965+
identities.has(project.workspaceRoot)
966+
? [{ ...project, repositoryIdentity: identities.get(project.workspaceRoot) ?? null }]
967+
: [],
968+
);
969+
return shellStreamItemFromEnrichmentRefresh({
970+
snapshot: {
971+
schemaVersion: ORCHESTRATION_V2_PROJECTION_SCHEMA_VERSION,
972+
snapshotSequence,
973+
projects: changedProjects,
974+
threads: [],
975+
archivedThreads: [],
976+
} as OrchestrationV2ShellSnapshot,
977+
changes: Array.from(changes),
978+
});
979+
}),
961980
),
962981
);
963982

0 commit comments

Comments
 (0)