@devries-cameron20 / t3code Mirror · read-only / commits / 33c0ebbe30
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 22, 23:15 UTC

fix(server): PR sync ignores tokenized avatar URLs on ghe.com (#20352)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

fixfon committed Oct 20, 2026 at 07:27 UTC 33c0ebbe30078d8c1abb51dfb80ae8a9e3405c81
2 files changed +92 -1
apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
+80
@@ -662,6 +662,86 @@ describe("PullRequestSyncReactor", () => {
662 ),
663 );
664
665 + it.effect.each([
666 + {
667 + change: "ghe.com token rotation",
668 + host: "avatars.example.ghe.com",
669 + nextPath: "/u/1?token=new&v=4&s=40&format=png",
670 + expectedSyncs: 1,
671 + },
672 + {
673 + change: "avatar version",
674 + host: "avatars.example.ghe.com",
675 + nextPath: "/u/1?token=old&v=5&s=40&format=png",
676 + expectedSyncs: 2,
677 + },
678 + {
679 + change: "avatar size",
680 + host: "avatars.example.ghe.com",
681 + nextPath: "/u/1?token=old&v=4&s=80&format=png",
682 + expectedSyncs: 2,
683 + },
684 + {
685 + change: "another avatar query parameter",
686 + host: "avatars.example.ghe.com",
687 + nextPath: "/u/1?token=old&v=4&s=40&format=webp",
688 + expectedSyncs: 2,
689 + },
690 + {
691 + change: "avatar path",
692 + host: "avatars.example.ghe.com",
693 + nextPath: "/u/2?token=old&v=4&s=40&format=png",
694 + expectedSyncs: 2,
695 + },
696 + {
697 + change: "token outside ghe.com",
698 + host: "avatars.example.com",
699 + nextPath: "/u/1?token=new&v=4&s=40&format=png",
700 + expectedSyncs: 2,
701 + },
702 + ])("syncs avatar changes selectively: $change", ({ host, nextPath, expectedSyncs }) =>
703 + Effect.scoped(
704 + Effect.gen(function* () {
705 + yield* TestClock.setTime(Date.parse(NOW));
706 + const avatarUrl = yield* Ref.make(`https://${host}/u/1?token=old&v=4&s=40&format=png`);
707 + const fixture = yield* makeHarness({
708 + snapshot: makeSnapshot([makeThread("one", { pullRequests: [makeLink(42)] })]),
709 + summary: (input) =>
710 + Ref.get(avatarUrl).pipe(
711 + Effect.map((avatarUrl) =>
712 + makeSummary(input, {
713 + updatedAt: NOW,
714 + author: { login: "octocat", name: null, avatarUrl },
715 + }),
716 + ),
717 + ),
718 + });
719 +
720 + yield* Effect.gen(function* () {
721 + const reactor = yield* startAndSweep(fixture);
722 + const firstSweep = yield* Ref.get(fixture.syncCommands);
723 + assert.strictEqual(firstSweep.length, 1);
724 + assert.strictEqual(firstSweep[0]?.snapshot.author?.avatarUrl, yield* Ref.get(avatarUrl));
725 + yield* Ref.update(fixture.snapshots, (snapshot) => applySync(snapshot, firstSweep));
726 +
727 + yield* Ref.set(avatarUrl, `https://${host}${nextPath}`);
728 + yield* sweepAgain(fixture, reactor);
729 +
730 + assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 2);
731 + assert.strictEqual((yield* Ref.get(fixture.stackCalls)).length, expectedSyncs);
732 + const commands = yield* Ref.get(fixture.syncCommands);
733 + assert.strictEqual(commands.length, expectedSyncs);
734 + if (expectedSyncs === 2) {
735 + assert.strictEqual(
736 + commands.at(-1)?.snapshot.author?.avatarUrl,
737 + yield* Ref.get(avatarUrl),
738 + );
739 + }
740 + }).pipe(Effect.provide(fixture.layer));
741 + }),
742 + ),
743 + );
744 +
745 it.effect("refreshes closed links through each project after reopening elsewhere", () =>
746 Effect.scoped(
747 Effect.gen(function* () {
apps/server/src/orchestration-v2/PullRequestSyncReactor.ts
+12 -1
@@ -73,6 +73,17 @@ function snapshotFieldsOf(summary: PullRequestSummary): SnapshotFields {
73 };
74 }
75
76 +// Rotating ghe.com avatar tokens should not make otherwise identical snapshots differ.
77 +function avatarIdentity(avatarUrl: string | null | undefined): string | null {
78 + if (avatarUrl === null || avatarUrl === undefined) return null;
79 + const url = URL.parse(avatarUrl);
80 + if (url === null || (url.hostname !== "ghe.com" && !url.hostname.endsWith(".ghe.com"))) {
81 + return avatarUrl;
82 + }
83 + url.searchParams.delete("token");
84 + return url.href;
85 +}
86 +
87 function snapshotFieldsEqual(left: SnapshotFields, right: SnapshotFields): boolean {
88 return (
89 left.state === right.state &&
@@ -84,7 +95,7 @@ function snapshotFieldsEqual(left: SnapshotFields, right: SnapshotFields): boole
95 (left.closedAt ?? null) === (right.closedAt ?? null) &&
96 (left.mergedAt ?? null) === (right.mergedAt ?? null) &&
97 (left.author?.login ?? null) === (right.author?.login ?? null) &&
87 - (left.author?.avatarUrl ?? null) === (right.author?.avatarUrl ?? null) &&
98 + avatarIdentity(left.author?.avatarUrl) === avatarIdentity(right.author?.avatarUrl) &&
99 left.additions === right.additions &&
100 left.deletions === right.deletions &&
101 left.changedFiles === right.changedFiles &&