GeezerVison is showing github.com — fix(server): refresh the project identity when a turn ends · pingdotgg/t3code@575b3af
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration/ThreadPullRequestReactor.test.ts +45Lines changed: 45 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -406,6 +406,51 @@ describe("ThreadPullRequestReactor", () => { | 406 | 406 | ), | 407 | 407 | ); | 408 | 408 |
| | 409 | + it.effect("refreshes the project identity when a turn adds the remote", () => | | 410 | + Effect.scoped( | | 411 | + Effect.gen(function* () { | | 412 | + const current = thread("new-remote"); | | 413 | + const fixture = yield* makeHarness({ | | 414 | + threads: [current], | | 415 | + project: { ...project, repositoryIdentity: null }, | | 416 | + branchPullRequest: () => Effect.succeed(branchPullRequest()), | | 417 | + resolveRepositoryIdentity: (_cwd, options) => | | 418 | + Effect.succeed(options?.refresh ? project.repositoryIdentity : null), | | 419 | + }); | | 420 | + yield* Effect.gen(function* () { | | 421 | + const reactor = yield* fixture.start(); | | 422 | + expect(yield* Ref.get(fixture.commands)).toHaveLength(0); | | 423 | + | | 424 | + yield* fixture.publish({ | | 425 | + type: "thread.turn-diff-completed", | | 426 | + sequence: 2, | | 427 | + eventId: EventId.make("checkpoint-finished"), | | 428 | + aggregateKind: "thread", | | 429 | + aggregateId: current.id, | | 430 | + occurredAt: NOW, | | 431 | + commandId: null, | | 432 | + causationEventId: null, | | 433 | + correlationId: null, | | 434 | + metadata: {}, | | 435 | + payload: { | | 436 | + threadId: current.id, | | 437 | + turnId: TurnId.make("turn"), | | 438 | + checkpointTurnCount: 1, | | 439 | + checkpointRef: CheckpointRef.make("checkpoint"), | | 440 | + status: "ready", | | 441 | + files: [], | | 442 | + assistantMessageId: null, | | 443 | + completedAt: NOW, | | 444 | + }, | | 445 | + }); | | 446 | + yield* Queue.take(fixture.reads); | | 447 | + yield* reactor.drain; | | 448 | + expect((yield* Ref.get(fixture.commands))[0]?.branchPullRequest).toEqual(reference(42)); | | 449 | + }).pipe(Effect.provide(fixture.layer)); | | 450 | + }), | | 451 | + ), | | 452 | + ); | | 453 | + | 409 | 454 | it.effect("uses live worktrees and falls back to the project for removed worktrees", () => | 410 | 455 | Effect.scoped( | 411 | 456 | Effect.gen(function* () { | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration/ThreadPullRequestReactor.ts +13-2Lines changed: 13 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -164,8 +164,19 @@ export const make = Effect.gen(function* () { | 164 | 164 | (group) => | 165 | 165 | Effect.gen(function* () { | 166 | 166 | const first = group[0]!; | 167 | | - const project = projects.get(first.projectId); | 168 | | - if (project === undefined) return finishBackfill(group); | | 167 | + const snapshotProject = projects.get(first.projectId); | | 168 | + if (snapshotProject === undefined) return finishBackfill(group); | | 169 | + // A finished turn may have added the remote this PR lives on. A failed | | 170 | + // refresh resolves to null, so keep the snapshot's identity then. | | 171 | + const project = request.refresh | | 172 | + ? { | | 173 | + ...snapshotProject, | | 174 | + repositoryIdentity: | | 175 | + (yield* repositoryIdentities.resolve(snapshotProject.workspaceRoot, { | | 176 | + refresh: true, | | 177 | + })) ?? snapshotProject.repositoryIdentity, | | 178 | + } | | 179 | + : snapshotProject; | 169 | 180 | const repository = sourceControlRepositorySelector(project.repositoryIdentity); | 170 | 181 | if (first.branch !== null && repository === null) return finishBackfill(group); | 171 | 182 | const worktreeExists = | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/project/RepositoryIdentityResolver.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,8 +14,8 @@ import * as ProcessRunner from "../processRunner.ts"; | 14 | 14 |
| 15 | 15 | const DEFAULT_REPOSITORY_IDENTITY_CACHE_CAPACITY = 512; | 16 | 16 | // Background sweeps resolve every project each minute. A long TTL keeps them | 17 | | -// from spawning git each time. Clone, publish, and PR discovery (before it | 18 | | -// saves links) resolve with `refresh: true`. | | 17 | +// from spawning git each time. Clone, publish, and PR discovery (after a turn | | 18 | +// and before it saves links) resolve with `refresh: true`. | 19 | 19 | const DEFAULT_POSITIVE_CACHE_TTL = Duration.minutes(15); | 20 | 20 | // Short, so a folder that gains a repository or a remote shows up quickly. | 21 | 21 | const DEFAULT_NEGATIVE_CACHE_TTL = Duration.minutes(1); | |
|