@@ -99,7 +99,10 @@ export interface PullRequestMergeEvent extends PullRequestRef {
9999 readonly mergedAt : string ;
100100}
101101
102- type PullRequestReading = Pick < PullRequestSummary , "state" | "updatedAt" | "observedAt" > ;
102+ type PullRequestReading = Pick <
103+ PullRequestSummary ,
104+ "state" | "updatedAt" | "observedAt" | "mergeability"
105+ > ;
103106
104107/** Whether `next` is a newer reading of a pull request than `current`. Merged is final. */
105108function supersedesReading ( current : PullRequestReading | undefined , next : PullRequestReading ) {
@@ -239,8 +242,8 @@ export class PullRequestService extends Context.Service<
239242 Scope . Scope
240243 > ;
241244 /**
242- * Pull requests a detail read saw for the first time or with changed overview fields ,
243- * so thread links can catch up before the next sync sweep. Best effort.
245+ * Pull requests a detail read saw for the first time or changed (state, host update time ,
246+ * mergeability), so thread links can catch up before the next sync sweep. Best effort.
244247 */
245248 readonly subscribeStateChanges : Effect . Effect <
246249 Stream . Stream < ThreadPullRequestKey > ,
@@ -3132,40 +3135,36 @@ export const make = Effect.gen(function* () {
31323135 } ) ;
31333136 const shouldReplaceHeldSummary = ( key : string , next : PullRequestSummary ) =>
31343137 supersedesReading ( lastGoodSummary . peek ( key ) , next ) ;
3135- // The newest overview a detail read found per pull request, whatever cache epoch or credential
3138+ // The newest state a detail read found per pull request, whatever cache epoch or credential
31363139 // it read under. Summary reads stay out: they would hide a change from the detail read after.
3137- const detailReadings = new Map < string , PullRequestSummary > ( ) ;
3140+ const detailStates = new Map < string , PullRequestReading > ( ) ;
31383141 /**
3139- * Announces changed link fields a detail read already knows , so thread badges and actions
3140- * follow the open detail without waiting for the next sync sweep. Read timestamps alone
3141- * do not announce unchanged host data .
3142+ * Announces a pull request a detail read sees first or changed , so a client showing a fresh
3143+ * merge, edit, or conflict brings the thread's link and its settlement along, rather than
3144+ * leaving them to the next sync sweep .
31423145 */
31433146 const noteDetailReading = ( ref : PullRequestRef , next : PullRequestSummary ) =>
31443147 Effect . suspend ( ( ) => {
31453148 const scope = refScope ( ref ) ;
3146- const current = detailReadings . get ( scope ) ;
3149+ const current = detailStates . get ( scope ) ;
31473150 if ( ! supersedesReading ( current , next ) ) return Effect . void ;
3148- detailReadings . delete ( scope ) ;
3149- if ( detailReadings . size >= REF_EPOCH_CAPACITY ) {
3150- const oldest = detailReadings . keys ( ) . next ( ) . value ;
3151- if ( oldest !== undefined ) detailReadings . delete ( oldest ) ;
3151+ detailStates . delete ( scope ) ;
3152+ if ( detailStates . size >= REF_EPOCH_CAPACITY ) {
3153+ const oldest = detailStates . keys ( ) . next ( ) . value ;
3154+ if ( oldest !== undefined ) detailStates . delete ( oldest ) ;
31523155 }
3153- detailReadings . set ( scope , next ) ;
3156+ detailStates . set ( scope , {
3157+ state : next . state ,
3158+ updatedAt : next . updatedAt ,
3159+ observedAt : next . observedAt ,
3160+ mergeability : next . mergeability ,
3161+ } ) ;
3162+ // Hosts bump `updatedAt` for title, branch, draft, and diff changes; mergeability moves
3163+ // with the base branch instead.
31543164 const changed =
31553165 current === undefined ||
31563166 current . state !== next . state ||
3157- current . title !== next . title ||
3158- current . headBranch !== next . headBranch ||
3159- current . baseBranch !== next . baseBranch ||
3160- current . isDraft !== next . isDraft ||
31613167 current . updatedAt !== next . updatedAt ||
3162- ( current . closedAt ?? null ) !== ( next . closedAt ?? null ) ||
3163- ( current . mergedAt ?? null ) !== ( next . mergedAt ?? null ) ||
3164- ( current . author ?. login ?? null ) !== ( next . author ?. login ?? null ) ||
3165- ( current . author ?. avatarUrl ?? null ) !== ( next . author ?. avatarUrl ?? null ) ||
3166- current . additions !== next . additions ||
3167- current . deletions !== next . deletions ||
3168- current . changedFiles !== next . changedFiles ||
31693168 current . mergeability !== next . mergeability ;
31703169 return changed && ref . host !== undefined
31713170 ? PubSub . publish ( stateChanges , {
@@ -3175,7 +3174,7 @@ export const make = Effect.gen(function* () {
31753174 } )
31763175 : Effect . void ;
31773176 } ) ;
3178- // The last state each routed read reported, kept apart from `detailReadings `: an unverified report
3177+ // The last state each routed read reported, kept apart from `detailStates `: an unverified report
31793178 // must never outrank a reading this environment made itself.
31803179 const reportedStates = new Map <
31813180 string ,
0 commit comments