GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): refresh the project identity when a turn ends · pingdotgg/t3code@575b3af

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src
    • orchestration
      • ThreadPullRequestReactor.test.ts
      • ThreadPullRequestReactor.ts
    • project
      • RepositoryIdentityResolver.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/orchestration/ThreadPullRequestReactor.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration/ThreadPullRequestReactor.test.ts
+45Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,51 @@ describe("ThreadPullRequestReactor", () => {
406406
),
407407
);
408408

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+
409454
it.effect("uses live worktrees and falls back to the project for removed worktrees", () =>
410455
Effect.scoped(
411456
Effect.gen(function* () {
Collapse file

‎apps/server/src/orchestration/ThreadPullRequestReactor.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration/ThreadPullRequestReactor.ts
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,19 @@ export const make = Effect.gen(function* () {
164164
(group) =>
165165
Effect.gen(function* () {
166166
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;
169180
const repository = sourceControlRepositorySelector(project.repositoryIdentity);
170181
if (first.branch !== null && repository === null) return finishBackfill(group);
171182
const worktreeExists =
Collapse file

‎apps/server/src/project/RepositoryIdentityResolver.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/project/RepositoryIdentityResolver.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import * as ProcessRunner from "../processRunner.ts";
1414

1515
const DEFAULT_REPOSITORY_IDENTITY_CACHE_CAPACITY = 512;
1616
// 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`.
1919
const DEFAULT_POSITIVE_CACHE_TTL = Duration.minutes(15);
2020
// Short, so a folder that gains a repository or a remote shows up quickly.
2121
const DEFAULT_NEGATIVE_CACHE_TTL = Duration.minutes(1);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.