@devries-cameron20 / t3code Mirror · read-only / commits / 822091e2d2
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 00:30 UTC

fix(contracts): preserve authoritative URLs on pull request links (#21575)

Julius Marminge committed Oct 19, 2026 at 16:28 UTC 822091e2d2798bf1ce0cfc1ed446158d739f02fd
4 files changed +54 -3
apps/server/src/orchestration-v2/Orchestrator.ts
+19 -1
@@ -569,6 +569,9 @@ function legacyPullRequestLink(
569 linkedAt: DateTime.formatIso(now),
570 snapshot: null,
571 stack: null,
572 + ...(existing?.repositoryWebUrl !== undefined && {
573 + repositoryWebUrl: existing.repositoryWebUrl,
574 + }),
575 ...(existing?.endedWatch && { endedWatch: existing.endedWatch }),
576 },
577 existing?.watch,
@@ -3070,10 +3073,20 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
3073 command.source !== "stack-dismissed";
3074 if (existing && !undismisses) return thread;
3075 const link = existing
3073 - ? { ...existing, source: command.source, url: command.url }
3076 + ? {
3077 + ...existing,
3078 + source: command.source,
3079 + url: command.url,
3080 + ...(command.repositoryWebUrl !== undefined && {
3081 + repositoryWebUrl: command.repositoryWebUrl,
3082 + }),
3083 + }
3084 : {
3085 ...key,
3086 url: command.url,
3087 + ...(command.repositoryWebUrl !== undefined && {
3088 + repositoryWebUrl: command.repositoryWebUrl,
3089 + }),
3090 source: command.source,
3091 linkedAt: DateTime.formatIso(now),
3092 snapshot: null,
@@ -3167,6 +3180,11 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
3180 {
3181 ...key,
3182 url: command.link.url,
3183 + ...((command.link.repositoryWebUrl ?? dismissed?.repositoryWebUrl) !==
3184 + undefined && {
3185 + repositoryWebUrl:
3186 + command.link.repositoryWebUrl ?? dismissed?.repositoryWebUrl,
3187 + }),
3188 source: command.link.source,
3189 linkedAt: startedAt,
3190 snapshot: null,
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+27 -1
@@ -5375,7 +5375,8 @@ it.layer(Layer.fresh(layerSharedApplicationDataPlaneTest))("compact PR events",
5375 worktreePath: null,
5376 });
5377 const key = { host: "github.com", repository: "pingdotgg/t3code" };
5378 - for (const number of [1, 2, 3]) {
5378 + const repositoryWebUrl = "https://github.com/pingdotgg/t3code/pull/2";
5379 + for (const number of [1, 2]) {
5380 yield* orchestrator.dispatch({
5381 type: "thread.pull-request.link",
5382 commandId: CommandId.make(`compact-pr-link-${number}`),
@@ -5384,8 +5385,31 @@ it.layer(Layer.fresh(layerSharedApplicationDataPlaneTest))("compact PR events",
5385 number,
5386 url: `https://github.com/pingdotgg/t3code/pull/${number}`,
5387 source: "manual",
5388 + ...(number === 2 ? { repositoryWebUrl } : {}),
5389 });
5390 }
5391 + const watchedLink = {
5392 + url: "https://github.com/pingdotgg/t3code/pull/3",
5393 + repositoryWebUrl: "https://github.com/pingdotgg/t3code/pull/3",
5394 + source: "manual" as const,
5395 + };
5396 + yield* orchestrator.dispatch({
5397 + type: "thread.pull-request.watch",
5398 + commandId: CommandId.make("compact-pr-watch-new"),
5399 + threadId,
5400 + ...key,
5401 + number: 3,
5402 + watching: true,
5403 + link: watchedLink,
5404 + });
5405 + yield* orchestrator.dispatch({
5406 + type: "thread.pull-request.watch",
5407 + commandId: CommandId.make("compact-pr-watch-existing"),
5408 + threadId,
5409 + ...key,
5410 + number: 2,
5411 + watching: true,
5412 + });
5413 const before = yield* orchestrator.getThreadShell(threadId);
5414 yield* orchestrator.dispatch({
5415 type: "thread.pull-request-link.sync",
@@ -5425,6 +5449,8 @@ it.layer(Layer.fresh(layerSharedApplicationDataPlaneTest))("compact PR events",
5449 assert.deepEqual(after?.pullRequests?.[0], before?.pullRequests?.[0]);
5450 assert.deepEqual(after?.pullRequests?.[2], before?.pullRequests?.[2]);
5451 assert.equal(after?.pullRequests?.[1]?.stack?.id, "updated");
5452 + assert.propertyVal(after?.pullRequests?.[1], "repositoryWebUrl", repositoryWebUrl);
5453 + assert.deepInclude(after?.pullRequests?.[2], watchedLink);
5454 assert.isTrue((yield* maintenance.rebuild).valid);
5455 assert.deepEqual(
5456 (yield* orchestrator.getThreadShell(threadId))?.pullRequests,
packages/contracts/src/orchestrationV2.ts
+6 -1
@@ -2690,6 +2690,7 @@ export const OrchestrationV2Command = Schema.Union([
2690 ...ThreadPullRequestKey.fields,
2691 url: TrimmedNonEmptyString,
2692 source: ThreadPullRequestLinkSource,
2693 + repositoryWebUrl: Schema.optional(TrimmedNonEmptyString),
2694 }),
2695 Schema.Struct({
2696 type: Schema.Literal("thread.pull-request.unlink"),
@@ -2712,7 +2713,11 @@ export const OrchestrationV2Command = Schema.Union([
2713 ...ThreadPullRequestKey.fields,
2714 watching: Schema.Boolean,
2715 link: Schema.optional(
2715 - Schema.Struct({ url: TrimmedNonEmptyString, source: ThreadPullRequestLinkSource }),
2716 + Schema.Struct({
2717 + url: TrimmedNonEmptyString,
2718 + source: ThreadPullRequestLinkSource,
2719 + repositoryWebUrl: Schema.optional(TrimmedNonEmptyString),
2720 + }),
2721 ),
2722 }),
2723 Schema.Struct({
packages/contracts/src/threadPullRequest.ts
+2
@@ -101,6 +101,8 @@ export type ThreadPullRequestWatch = typeof ThreadPullRequestWatch.Type;
101 export const ThreadPullRequestLink = Schema.Struct({
102 ...ThreadPullRequestKey.fields,
103 url: TrimmedNonEmptyString,
104 + /** An actual browser or clone URL; older agent display URLs may be synthesized. */
105 + repositoryWebUrl: Schema.optional(TrimmedNonEmptyString),
106 source: ThreadPullRequestLinkSource,
107 linkedAt: IsoDateTime,
108 snapshot: Schema.NullOr(ThreadPullRequestSnapshot),