@@ -163,6 +163,8 @@ export interface PullRequestsSearch extends PullRequestListPreferences {
163163 readonly repository ?: string ;
164164 readonly number ?: number ;
165165 readonly selectedProjectId ?: ProjectId ;
166+ /** Host of the open review; changing tabs must not narrow the list host filter. */
167+ readonly selectedHost ?: string ;
166168 /**
167169 * Which server the selected pull request was read from. A project id only names a project on
168170 * its own server, so this is what tells two servers holding one project apart. Optional: a
@@ -263,6 +265,9 @@ export const Route = createFileRoute("/_chat/pull-requests")({
263265 ...( typeof raw . selectedProjectId === "string" && raw . selectedProjectId
264266 ? { selectedProjectId : raw . selectedProjectId as ProjectId }
265267 : { } ) ,
268+ ...( typeof raw . selectedHost === "string" && raw . selectedHost
269+ ? { selectedHost : raw . selectedHost . slice ( 0 , 200 ) }
270+ : { } ) ,
266271 ...( typeof raw . selectedEnvironmentId === "string" && raw . selectedEnvironmentId
267272 ? { selectedEnvironmentId : raw . selectedEnvironmentId as EnvironmentId }
268273 : { } ) ,
@@ -367,6 +372,7 @@ function PullRequestsRouteView() {
367372
368373 // A link from a thread or the sidebar only knows the repository, so the owning project is
369374 // resolved here; an explicit `projectId` in the URL still wins.
375+ const selectedHost = search . selectedHost ?? search . host ;
370376 const projectIdForRepository = useMemo ( ( ) => {
371377 const repository = search . repository ?. toLowerCase ( ) ;
372378 if ( repository === undefined ) return undefined ;
@@ -378,14 +384,14 @@ function PullRequestsRouteView() {
378384 repository &&
379385 // The same `owner/name` can exist on two hosts. Without this the first match wins, and
380386 // a link that named its host opens the pull request from the other one.
381- ( search . host === undefined ||
387+ ( selectedHost === undefined ||
382388 pullRequestHostOf (
383389 project . repositoryIdentity ,
384390 project . repositoryIdentity . provider as SourceControlProviderKind ,
385- ) === search . host . toLowerCase ( ) ) ,
391+ ) === selectedHost . toLowerCase ( ) ) ,
386392 ) ;
387393 return identity ?. id ;
388- } , [ projects , search . host , search . repository ] ) ;
394+ } , [ projects , selectedHost , search . repository ] ) ;
389395
390396 // The selection is resolved the same way the scope is: an id no connected environment has can
391397 // never be read here, and one that arrived before the projects did is not yet wrong.
@@ -472,6 +478,7 @@ function PullRequestsRouteView() {
472478 ...( next . projectId ? { projectId : next . projectId } : { } ) ,
473479 ...( next . environmentId ? { environmentId : next . environmentId } : { } ) ,
474480 ...( next . host ? { host : next . host } : { } ) ,
481+ ...( next . selectedHost ? { selectedHost : next . selectedHost } : { } ) ,
475482 ...( next . selectedProjectId ? { selectedProjectId : next . selectedProjectId } : { } ) ,
476483 ...( next . selectedEnvironmentId
477484 ? { selectedEnvironmentId : next . selectedEnvironmentId }
@@ -494,6 +501,7 @@ function PullRequestsRouteView() {
494501 number : undefined ,
495502 selectedProjectId : undefined ,
496503 selectedEnvironmentId : undefined ,
504+ selectedHost : undefined ,
497505 } ;
498506 // List controls change the rows behind the detail, not the independent selected surface. The
499507 // reader can keep working in that panel while narrowing, sorting, or switching projects.
@@ -1412,9 +1420,10 @@ function PullRequestsRouteView() {
14121420 repository : search . repository ,
14131421 number : search . number ,
14141422 projectId : selectedProject . id ,
1423+ ...( selectedHost ? { host : selectedHost } : { } ) ,
14151424 }
14161425 : null ,
1417- [ search . number , search . repository , selectedProject ] ,
1426+ [ search . number , search . repository , selectedProject , selectedHost ] ,
14181427 ) ;
14191428 const rightPanelAvailable = selectedPullRequestSurface !== null ;
14201429 useEffect ( ( ) => {
@@ -1429,6 +1438,7 @@ function PullRequestsRouteView() {
14291438 repository : activePullRequestSurface . repository ,
14301439 number : activePullRequestSurface . number ,
14311440 projectId : activePullRequestSurface . projectId as ProjectId ,
1441+ ...( activePullRequestSurface . host ? { host : activePullRequestSurface . host } : { } ) ,
14321442 }
14331443 : null ;
14341444
@@ -1440,6 +1450,7 @@ function PullRequestsRouteView() {
14401450 repository : surface . repository ,
14411451 number : surface . number ,
14421452 selectedProjectId : surface . projectId as ProjectId ,
1453+ selectedHost : surface . host ,
14431454 ...( surface . environmentId === undefined
14441455 ? { }
14451456 : { selectedEnvironmentId : surface . environmentId as EnvironmentId } ) ,
@@ -1512,6 +1523,7 @@ function PullRequestsRouteView() {
15121523 number : entry . number ,
15131524 selectedProjectId : entry . projectId ,
15141525 selectedEnvironmentId : entry . environmentId ,
1526+ selectedHost : entry . host ,
15151527 } ) ;
15161528 } ,
15171529 [ rightPanelRef , updateSearch ] ,
@@ -1950,7 +1962,7 @@ function PullRequestsRouteView() {
19501962 updateSearch ( {
19511963 repository : reference . repository ,
19521964 number : reference . number ,
1953- host : reference . host ,
1965+ selectedHost : reference . host ,
19541966 selectedProjectId : reference . projectId ,
19551967 selectedEnvironmentId : panelEnvironmentId ,
19561968 } ) ;
0 commit comments