@@ -73,6 +73,17 @@ function snapshotFieldsOf(summary: PullRequestSummary): SnapshotFields {
7373 } ;
7474}
7575
76+ // Hosts compute mergeability lazily and answer unknown while recomputing, so a fresh read must
77+ // not erase a known answer.
78+ function retainKnownMergeability (
79+ fields : SnapshotFields ,
80+ previous : ThreadPullRequestSnapshot | null ,
81+ ) : SnapshotFields {
82+ if ( fields . mergeability !== "unknown" ) return fields ;
83+ const known = previous ?. mergeability ;
84+ return known === undefined || known === "unknown" ? fields : { ...fields , mergeability : known } ;
85+ }
86+
7687// Rotating ghe.com avatar tokens should not make otherwise identical snapshots differ.
7788function avatarIdentity ( avatarUrl : string | null | undefined ) : string | null {
7889 if ( avatarUrl === null || avatarUrl === undefined ) return null ;
@@ -259,10 +270,11 @@ export const make = Effect.gen(function* () {
259270
260271 const syncEntry = Effect . fn ( "PullRequestSyncReactor.syncEntry" ) ( function * (
261272 entry : LinkEntry ,
262- fields : SnapshotFields ,
273+ readFields : SnapshotFields ,
263274 fetchedStack : { readonly stack : ThreadPullRequestStack | null } | null ,
264275 ) {
265276 const { thread, link } = entry ;
277+ const fields = retainKnownMergeability ( readFields , link . snapshot ) ;
266278 const nextStack = fetchedStack === null ? link . stack : fetchedStack . stack ;
267279 const changed =
268280 link . snapshot === null ||
@@ -343,7 +355,10 @@ export const make = Effect.gen(function* () {
343355 entries . some (
344356 ( entry ) =>
345357 entry . link . snapshot === null ||
346- ! snapshotFieldsEqual ( entry . link . snapshot , fields ) ||
358+ ! snapshotFieldsEqual (
359+ entry . link . snapshot ,
360+ retainKnownMergeability ( fields , entry . link . snapshot ) ,
361+ ) ||
347362 ( summary . stack !== undefined &&
348363 ( entry . link . stack ?. number ?? null ) !== ( summary . stack ?. number ?? null ) ) ,
349364 ) ;
0 commit comments