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): cloned projects no longer show the enclosing repository · pingdotgg/t3code@d1c3253

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src
    • orchestration-v2
      • DelegatedCompletionDelivery.test.ts
      • runtimeLayer.test.ts
    • project
      • ProjectEnrichmentService.test.ts
      • ProjectEnrichmentService.ts
    • ws.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const layerTest = Layer.mergeAll(RuntimeLayer.layer, RuntimeLayer.layerEventSink
125125
repositoryIdentityResolved: false,
126126
}),
127127
invalidate: () => Effect.void,
128+
refresh: () => Effect.void,
128129
subscribeChanges: Effect.never,
129130
}),
130131
),
Collapse file

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/runtimeLayer.test.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ const layerSharedApplicationDataPlaneTest = Layer.mergeAll(
463463
repositoryIdentityResolved: false,
464464
}),
465465
invalidate: () => Effect.void,
466+
refresh: () => Effect.void,
466467
subscribeChanges: Effect.never,
467468
}),
468469
),
Collapse file

‎apps/server/src/project/ProjectEnrichmentService.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/project/ProjectEnrichmentService.test.ts
+59Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
import * as NodeServices from "@effect/platform-node/NodeServices";
12
import { assert, it } from "@effect/vitest";
23
import type { RepositoryIdentity } from "@t3tools/contracts";
34
import * as Deferred from "effect/Deferred";
45
import * as Effect from "effect/Effect";
6+
import * as FileSystem from "effect/FileSystem";
57
import * as Layer from "effect/Layer";
68
import * as Logger from "effect/Logger";
9+
import * as Path from "effect/Path";
710
import * as PubSub from "effect/PubSub";
811
import * as Ref from "effect/Ref";
912
import { TestClock } from "effect/testing";
1013

14+
import * as ProcessRunner from "../processRunner.ts";
1115
import * as WorkspacePaths from "../workspace/WorkspacePaths.ts";
1216

1317
import * as ProjectEnrichment from "./ProjectEnrichmentService.ts";
@@ -486,3 +490,58 @@ it.effect(
486490
}).pipe(Effect.provide(layer(layerMetadata)));
487491
}),
488492
);
493+
494+
const git = (cwd: string, args: ReadonlyArray<string>) =>
495+
Effect.gen(function* () {
496+
const processRunner = yield* ProcessRunner.ProcessRunner;
497+
return yield* processRunner.run({ command: "git", args: ["-C", cwd, ...args] });
498+
}).pipe(Effect.provide(ProcessRunner.layer));
499+
500+
it.layer(NodeServices.layer)("ProjectEnrichmentService with Git", (it) => {
501+
it.effect("shows a clone's own repository once it lands inside another repository", () =>
502+
Effect.gen(function* () {
503+
const fileSystem = yield* FileSystem.FileSystem;
504+
const path = yield* Path.Path;
505+
const home = yield* fileSystem.makeTempDirectoryScoped({
506+
prefix: "t3-project-enrichment-clone-test-",
507+
});
508+
yield* git(home, ["init"]);
509+
yield* git(home, ["remote", "add", "origin", "[email protected]:example/dotfiles.git"]);
510+
// The clone's project and empty folder exist before git creates the repository.
511+
const destination = path.join(home, "t3code");
512+
yield* fileSystem.makeDirectory(destination);
513+
514+
const service = yield* ProjectEnrichment.ProjectEnrichmentService;
515+
const changes = yield* service.subscribeChanges;
516+
yield* service.request(destination);
517+
const duringClone = yield* PubSub.take(changes);
518+
assert.equal(
519+
duringClone.enrichment.repositoryIdentity?.canonicalKey,
520+
"github.com/example/dotfiles",
521+
);
522+
523+
yield* git(destination, ["init"]);
524+
yield* git(destination, ["remote", "add", "origin", "[email protected]:example/t3code.git"]);
525+
yield* service.refresh(destination);
526+
527+
const published = yield* PubSub.take(changes);
528+
assert.equal(
529+
published.enrichment.repositoryIdentity?.canonicalKey,
530+
"github.com/example/t3code",
531+
);
532+
const afterClone = yield* service.peek(destination);
533+
assert.equal(afterClone.repositoryIdentity?.canonicalKey, "github.com/example/t3code");
534+
}).pipe(
535+
Effect.provide(
536+
layer(
537+
Layer.merge(
538+
RepositoryIdentityResolver.layer.pipe(Layer.provide(NodeServices.layer)),
539+
Layer.succeed(ProjectFaviconResolver.ProjectFaviconResolver, {
540+
resolvePath: () => Effect.succeed(null),
541+
}),
542+
),
543+
),
544+
),
545+
),
546+
);
547+
});
Collapse file

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

Copy file name to clipboardExpand all lines: apps/server/src/project/ProjectEnrichmentService.ts
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ export class ProjectEnrichmentService extends Context.Service<
6161
readonly getAvailable: (workspaceRoot: string) => Effect.Effect<ProjectEnrichment>;
6262
/** Invalidate workspace-derived metadata. */
6363
readonly invalidate: (workspaceRoots: Iterable<string>) => Effect.Effect<void>;
64+
/**
65+
* Re-resolve a root whose repository changed on disk, such as a finished
66+
* clone, and publish the new identity.
67+
*/
68+
readonly refresh: (workspaceRoot: string) => Effect.Effect<void>;
6469
/** Subscribe to ephemeral completion notifications. */
6570
readonly subscribeChanges: Effect.Effect<
6671
PubSub.Subscription<ProjectEnrichmentChange>,
@@ -299,11 +304,22 @@ export const make = Effect.fn("ProjectEnrichmentService.make")(function* (
299304
);
300305
});
301306

307+
const refresh: ProjectEnrichmentService["Service"]["refresh"] = Effect.fn(
308+
"ProjectEnrichmentService.refresh",
309+
)(function* (workspaceRoot) {
310+
// Both caches hold the old repository: the resolver's, keyed by Git root,
311+
// and this one, keyed by workspace root.
312+
yield* repositoryIdentityResolver.resolve(workspaceRoot, { refresh: true });
313+
yield* invalidate([workspaceRoot]);
314+
yield* resolveRepositoryIdentity(workspaceRoot);
315+
});
316+
302317
return ProjectEnrichmentService.of({
303318
peek,
304319
request,
305320
getAvailable,
306321
invalidate,
322+
refresh,
307323
subscribeChanges: PubSub.subscribe(changes),
308324
});
309325
});
Collapse file

‎apps/server/src/ws.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/ws.ts
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ const layerWsRpc = (
12501250
const projectCloneTracker = yield* ProjectCloneTracker.ProjectCloneTracker;
12511251
const repositoryIdentityResolver =
12521252
yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
1253+
const projectEnrichment = yield* ProjectEnrichmentService.ProjectEnrichmentService;
12531254
const agentSessionScanner = yield* AgentSessionScanner.AgentSessionScanner;
12541255
const agentSessionImporter = yield* AgentSessionImporter.AgentSessionImporter;
12551256
const checkpointDiffQuery = yield* CheckpointDiffQuery.CheckpointDiffQuery;
@@ -2552,7 +2553,9 @@ const layerWsRpc = (
25522553
),
25532554
),
25542555
onCloned: (project) =>
2555-
repositoryIdentityResolver.resolve(project.workspaceRoot, { refresh: true }).pipe(
2556+
// Metadata resolved while the folder was empty may describe an
2557+
// enclosing repository, such as a home directory under Git.
2558+
projectEnrichment.refresh(project.workspaceRoot).pipe(
25562559
Effect.andThen(
25572560
projectService.update({
25582561
commandId: CommandId.make(`project-clone-done:${project.projectId}`),

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.