@@ -205,6 +205,18 @@ export function createPullRequestEnvironmentAtoms<R, E>(
205205 refreshTrigger : ( { environmentId } ) => refreshes ( { environmentId, input : { } } ) ,
206206 } ) ,
207207 ) ;
208+ // Hover cards read their own atoms, so a pending or failed hover read never decides where a
209+ // click on the same link goes.
210+ const previewCard = writableQueryFamily (
211+ createEnvironmentRpcQueryAtomFamily ( runtime , {
212+ label : "environment-data:pull-requests:preview-card" ,
213+ persistence : persistQuery ( PullRequestPreview ) ,
214+ tag : WS_METHODS . pullRequestsPreview ,
215+ execute : ( input ) => routedRequest ( WS_METHODS . pullRequestsPreview , input ) ,
216+ staleTimeMs : 60_000 ,
217+ refreshTrigger : ( { environmentId } ) => refreshes ( { environmentId, input : { } } ) ,
218+ } ) ,
219+ ) ;
208220 const labelCandidates = writableQueryFamily (
209221 createEnvironmentRpcQueryAtomFamily ( runtime , {
210222 label : "environment-data:pull-requests:label-candidates" ,
@@ -319,14 +331,7 @@ export function createPullRequestEnvironmentAtoms<R, E>(
319331 } ) ,
320332 detail,
321333 preview,
322- // Its own request per click: a pending or failed hover read of `preview` must not decide where
323- // a click goes.
324- resolvePreview : createEnvironmentRpcCommand ( runtime , {
325- label : "environment-data:pull-requests:resolve-preview" ,
326- tag : WS_METHODS . pullRequestsPreview ,
327- execute : ( input ) => routedRequest ( WS_METHODS . pullRequestsPreview , input ) ,
328- scheduler : commandScheduler ,
329- } ) ,
334+ previewCard,
330335 checks : createEnvironmentRpcQueryAtomFamily ( runtime , {
331336 label : "environment-data:pull-requests:checks" ,
332337 persistence : persistQuery ( Schema . NullOr ( PullRequestChecks ) ) ,
@@ -411,7 +416,10 @@ export function createPullRequestEnvironmentAtoms<R, E>(
411416 // every preceding action, and preparing outside the lane could reorder the clicks.
412417 execute : runAction ,
413418 onSuccess : ( { environmentId, input } , registry ) =>
414- Effect . sync ( ( ) => registry . refresh ( preview ( { environmentId, input } ) ) ) ,
419+ Effect . sync ( ( ) => {
420+ registry . refresh ( preview ( { environmentId, input } ) ) ;
421+ registry . refresh ( previewCard ( { environmentId, input } ) ) ;
422+ } ) ,
415423 scheduler : commandScheduler ,
416424 concurrency : serialPerEnvironment ,
417425 } ) ,
@@ -609,6 +617,7 @@ export function createPullRequestEnvironmentAtoms<R, E>(
609617 Effect . sync ( ( ) => {
610618 if ( input . reference !== undefined ) {
611619 registry . refresh ( preview ( { environmentId, input : input . reference } ) ) ;
620+ registry . refresh ( previewCard ( { environmentId, input : input . reference } ) ) ;
612621 }
613622 } ) ,
614623 scheduler : commandScheduler ,
0 commit comments