@@ -84,9 +84,10 @@ function projectHostAndProvider(project: OrchestrationProjectShell | undefined):
8484const resolveTarget = Effect . fn ( "PullRequestsToolkit.resolveTarget" ) ( function * (
8585 input : PullRequestTargetInput ,
8686 project : OrchestrationProjectShell | undefined ,
87+ gitHubHosts : ReadonlyArray < string > ,
8788) {
8889 if ( input . url !== undefined ) {
89- const parsed = parseChangeRequestUrl ( input . url , gitHubHostsOf ( project ? [ project ] : [ ] ) ) ;
90+ const parsed = parseChangeRequestUrl ( input . url , gitHubHosts ) ;
9091 if ( parsed === null ) {
9192 return yield * new PullRequestUrlInvalidError ( { } ) ;
9293 }
@@ -237,6 +238,13 @@ const make = Effect.gen(function* () {
237238 return thread . value ;
238239 } ) ;
239240
241+ /** Every project's GitHub hosts, so an agent's URL is read the way the web client reads it. */
242+ const knownGitHubHosts = ( project : OrchestrationProjectShell | undefined ) =>
243+ projects . listShells ( ) . pipe (
244+ Effect . map ( gitHubHostsOf ) ,
245+ Effect . orElseSucceed ( ( ) => gitHubHostsOf ( project ? [ project ] : [ ] ) ) ,
246+ ) ;
247+
240248 const projectOf = (
241249 thread : OrchestrationV2ThreadShell ,
242250 Failure :
@@ -276,7 +284,7 @@ const make = Effect.gen(function* () {
276284 ) {
277285 const thread = yield * requireThread ( PullRequestWatchFailedError , input . threadId ) ;
278286 const project = yield * projectOf ( thread , PullRequestWatchFailedError ) ;
279- const target = yield * resolveTarget ( input , project ) ;
287+ const target = yield * resolveTarget ( input , project , yield * knownGitHubHosts ( project ) ) ;
280288 const watchedLink = ( shell : OrchestrationV2ThreadShell ) =>
281289 threadPullRequestsOf ( shell ) . find (
282290 ( link ) => link . source !== "stack-dismissed" && threadPullRequestKeysEqual ( link , target ) ,
@@ -332,9 +340,10 @@ const make = Effect.gen(function* () {
332340 . listShells ( )
333341 . pipe ( Effect . mapError ( ( cause ) => new PullRequestListFailedError ( { cause } ) ) ) ;
334342 const callerProject = known . find ( ( project ) => project . id === callerThread ?. projectId ) ;
343+ const gitHubHosts = gitHubHostsOf ( known ) ;
335344 // Each target resolves on its own, so one bad URL in a batch is that entry's failure only.
336345 return yield * Effect . forEach ( targets , ( input ) =>
337- resolveTarget ( input , callerProject ) . pipe (
346+ resolveTarget ( input , callerProject , gitHubHosts ) . pipe (
338347 Effect . map ( ( target ) => ( {
339348 input,
340349 target,
@@ -373,7 +382,7 @@ const make = Effect.gen(function* () {
373382 Effect . gen ( function * ( ) {
374383 const thread = yield * requireThread ( PullRequestLinkFailedError , input . threadId ) ;
375384 const project = yield * projectOf ( thread , PullRequestLinkFailedError ) ;
376- const target = yield * resolveTarget ( input , project ) ;
385+ const target = yield * resolveTarget ( input , project , yield * knownGitHubHosts ( project ) ) ;
377386 const existing = threadPullRequestsOf ( thread ) . find ( ( link ) =>
378387 threadPullRequestKeysEqual ( link , target ) ,
379388 ) ;
@@ -404,7 +413,7 @@ const make = Effect.gen(function* () {
404413 Effect . gen ( function * ( ) {
405414 const thread = yield * requireThread ( PullRequestUnlinkFailedError , input . threadId ) ;
406415 const project = yield * projectOf ( thread , PullRequestUnlinkFailedError ) ;
407- const target = yield * resolveTarget ( input , project ) ;
416+ const target = yield * resolveTarget ( input , project , yield * knownGitHubHosts ( project ) ) ;
408417 if ( ! threadPullRequestsOf ( thread ) . some ( ( link ) => threadPullRequestKeysEqual ( link , target ) ) )
409418 return {
410419 host : target . host ,
0 commit comments