Skip to content

Commit 52c336a

Browse files
Bil0000claude
andauthored
fix(server): merged PRs update and auto-settle threads again (#13476)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent c121adc commit 52c336a

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

‎apps/server/src/pullRequest/PullRequestService.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { PullRequestOperationError } from "@t3tools/contracts";
2222
import * as ProjectionSnapshotQuery from "../orchestration/Services/ProjectionSnapshotQuery.ts";
2323
import { SqlitePersistenceMemory } from "../persistence/Layers/Sqlite.ts";
2424
import * as PullRequestFilesViewed from "../persistence/PullRequestFilesViewed.ts";
25+
import * as RepositoryIdentityResolver from "../project/RepositoryIdentityResolver.ts";
2526
import * as SourceControlProviderRegistry from "../sourceControl/SourceControlProviderRegistry.ts";
2627
import * as SourceControlRateLimit from "../sourceControl/SourceControlRateLimit.ts";
2728
import { ForgejoCli } from "../sourceControl/ForgejoCli.ts";
@@ -402,6 +403,7 @@ function makeService(input: {
402403
readonly projects: ReadonlyArray<OrchestrationProjectShell>;
403404
readonly providers: ReadonlyArray<PullRequestProviderApi>;
404405
readonly resolveHandle?: SourceControlProviderRegistry.SourceControlProviderRegistry["Service"]["resolveHandle"];
406+
readonly resolveRepositoryIdentity?: RepositoryIdentityResolver.RepositoryIdentityResolver["Service"]["resolve"];
405407
}) {
406408
// Built into the test's own scope rather than provided call by call: the marks store owns a
407409
// database, and `Effect.provide` would close it the moment the service was handed back.
@@ -422,6 +424,9 @@ function makeService(input: {
422424
getProjectShellById: (projectId) =>
423425
Effect.succeed(Option.fromNullishOr(input.projects.find((p) => p.id === projectId))),
424426
}),
427+
Layer.mock(RepositoryIdentityResolver.RepositoryIdentityResolver)({
428+
resolve: input.resolveRepositoryIdentity ?? (() => Effect.succeed(null)),
429+
}),
425430
SourceControlRateLimit.layer,
426431
// The real store over a database of its own, so the environment-kept marks are exercised
427432
// through the SQL that holds them rather than through a stand-in that agrees with itself.
@@ -2184,6 +2189,33 @@ it.effect("rejects a different Forgejo HTTP port for an HTTP checkout", () =>
21842189
}),
21852190
);
21862191

2192+
it.effect("resolves a project's repository identity when its shell has none cached", () =>
2193+
Effect.gen(function* () {
2194+
const resolved = project({
2195+
id: "web",
2196+
title: "web",
2197+
workspaceRoot: "/web",
2198+
repository: "acme/web",
2199+
});
2200+
const service = yield* makeService({
2201+
projects: [{ ...resolved, repositoryIdentity: null }],
2202+
providers: [
2203+
fakeProvider("github", {
2204+
getChangeRequestSummary: () => Effect.succeed(changeRequest(7, "2026-07-02T00:00:00Z")),
2205+
}),
2206+
],
2207+
resolveRepositoryIdentity: () => Effect.succeed(resolved.repositoryIdentity ?? null),
2208+
});
2209+
2210+
const summary = yield* service.summary(
2211+
{ projectId: "web" as ProjectId, host: "github.com", repository: "acme/web", number: 7 },
2212+
{ recoverTransientFailure: false },
2213+
);
2214+
2215+
assert.strictEqual(summary.number, 7);
2216+
}),
2217+
);
2218+
21872219
it.effect("routes a hosted reference to another repository through a project on that host", () =>
21882220
Effect.gen(function* () {
21892221
const seen: Array<{ cwd: string; repository: string; host: string }> = [];

‎apps/server/src/pullRequest/PullRequestService.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import { detectSourceControlProviderFromRemoteUrl } from "@t3tools/shared/source
7676
import { AllowGitHubReserve } from "../sourceControl/GitHubCli.ts";
7777
import * as ProjectionSnapshotQuery from "../orchestration/Services/ProjectionSnapshotQuery.ts";
7878
import * as PullRequestFilesViewed from "../persistence/PullRequestFilesViewed.ts";
79+
import * as RepositoryIdentityResolver from "../project/RepositoryIdentityResolver.ts";
7980
import * as SourceControlProviderRegistry from "../sourceControl/SourceControlProviderRegistry.ts";
8081
import * as SourceControlRateLimit from "../sourceControl/SourceControlRateLimit.ts";
8182
import {
@@ -629,6 +630,7 @@ export const make = Effect.gen(function* () {
629630
const pullRequestRefreshes = yield* SubscriptionRef.make(0);
630631
const registry = yield* PullRequestProviderRegistry;
631632
const projections = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery;
633+
const repositoryIdentities = yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
632634
const sourceControlProviders = yield* SourceControlProviderRegistry.SourceControlProviderRegistry;
633635
const rateLimits = yield* SourceControlRateLimit.SourceControlRateLimit;
634636
const filesViewedStore = yield* PullRequestFilesViewed.PullRequestFilesViewedRepository;
@@ -726,6 +728,18 @@ export const make = Effect.gen(function* () {
726728
cause: error,
727729
}),
728730
),
731+
Effect.flatMap((projects) =>
732+
Effect.forEach(
733+
projects,
734+
(project) =>
735+
project.repositoryIdentity != null
736+
? Effect.succeed(project)
737+
: repositoryIdentities
738+
.resolve(project.workspaceRoot)
739+
.pipe(Effect.map((repositoryIdentity) => ({ ...project, repositoryIdentity }))),
740+
{ concurrency: REPOSITORY_CONCURRENCY },
741+
),
742+
),
729743
Effect.flatMap((projects) =>
730744
refineUnknownProjectKinds(projects, filter).pipe(
731745
Effect.map((refinedProviders) => ({ refinedProviders, projects })),

0 commit comments

Comments
 (0)