fix(server): link thread PRs without an open client #10101
Mergedt3dotgg(GitHub profile, opens in a new tab)merged 6 commits into
main fromrefs/pull/10101/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/mobile/src/features/home/HomeScreen.tsx line 842Resolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -850 +842 @@850842 onPinThread={handlePinThread}apps/server/src/git/GitManager.ts line 1281Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1252,4 +1271,4 @@12521271 }1253127212541273 const remoteUrl = yield* readConfigValueNullable(cwd, `remote.${remoteName}.url`);1255- const repositoryNameWithOwner = parseGitHubRepositoryNameWithOwnerFromRemoteUrl(remoteUrl);1274+ const repositoryNameWithOwner = parseRepositoryNameWithOwnerFromRemoteUrl(remoteUrl);apps/server/src/orchestration/Layers/OrchestrationEngine.ts line 192Resolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -187,0 +190,21 @@190+ if (envelope.command.type === "thread.pull-request.sync") {191+ for (const type of ["thread.meta-updated", "thread.created"] as const) {192+ if (193+ yield* eventStore.hasEventAfter({194+ aggregateKind: "thread",195+ aggregateId: envelope.command.threadId,196+ sequenceExclusive: envelope.command.snapshotSequence,197+ type,198+ })199+ ) {200+ return yield* new OrchestrationCommandInvariantError({201+ commandType: envelope.command.type,202+ detail: `thread ${envelope.command.threadId} changed before pull request discovery`,203+ });204+ }205+ }206+ }207+208+ if (209+ envelope.command.type === "thread.pull-request.sync" &&210+ (yield* eventStore.hasEventAfter({
- apps/server/src/orchestration/ThreadPullRequestReactor.ts line 206OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +186,21 @@186+187+ if (188+ samePullRequest(thread.branchPullRequest, branchPullRequest) &&189+ replacement === undefined190+ ) {191+ pendingBackfill.delete(thread.id);192+ return;193+ }194+ const uuid = yield* crypto.randomUUIDv4;195+ yield* engine.dispatch({196+ type: "thread.pull-request.sync",197+ commandId: CommandId.make(`server:thread-pull-request:${thread.id}:${uuid}`),198+ threadId: thread.id,199+ projectId: project.id,200+ snapshotSequence: snapshot.snapshotSequence,201+ branchPullRequest,202+ ...(replacement !== undefined ? { linkedPullRequest: replacement } : {}),203+ });204+ pendingBackfill.delete(thread.id);205+ }).pipe(206+ Effect.catchTag("OrchestrationCommandInvariantError", () => Effect.void),
- apps/server/src/orchestration/ThreadPullRequestReactor.ts line 262Resolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -0,0 +181,21 @@181+ });182+ if (linked.state === "merged" || linked.state === "closed") {183+ replacement = detectedReference;184+ }185+ }186+187+ if (188+ samePullRequest(thread.branchPullRequest, branchPullRequest) &&189+ replacement === undefined190+ ) {191+ pendingBackfill.delete(thread.id);192+ return;193+ }194+ const uuid = yield* crypto.randomUUIDv4;195+ yield* engine.dispatch({196+ type: "thread.pull-request.sync",197+ commandId: CommandId.make(`server:thread-pull-request:${thread.id}:${uuid}`),198+ threadId: thread.id,199+ projectId: project.id,200+ snapshotSequence: snapshot.snapshotSequence,201+ expected: {
- apps/server/src/git/GitManager.ts line 220OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -214,3 +213,8 @@214213 isCrossRepository: boolean;215214 }216215216+export function pullRequestRepositoryKey(value: string): string | null {217+ try {218+ const url = new URL(value);219+ const match =220+ /^(.*?)(?:\/pull\/|\/-\/merge_requests\/|\/pull-requests\/|\/pullrequest\/)\d+(?:\/.*)?$/iu.exec(docs/user/thread-sidebar.md lines 52 to 53OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -49,3 +49,5 @@49495050 ## Link a pull request515152+The server finds the PR for each thread's saved branch. Links update even when53+your apps are closed. Update the server if automatic branch links do not appear.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed