@@ -4151,6 +4151,18 @@ function ChatViewContent(props: ChatViewProps) {
41514151 } , [ activeThreadPr , openThreadPullRequest ] ) ;
41524152 const pullRequestSurfaceAvailable =
41534153 supportsPullRequests && activeThreadPr !== null && threadRepository !== null ;
4154+ // Primitive slice of the displayed PR for the settle-rule memos below:
4155+ // resolveDisplayedThreadPr returns a fresh object every render, so memoize
4156+ // on the fields the rules read instead of the object identity.
4157+ const activeThreadPrState = activeThreadPr ?. state ?? null ;
4158+ const activeThreadPrUpdatedAt = activeThreadPr ?. updatedAt ?? null ;
4159+ const activeThreadChangeRequest = useMemo (
4160+ ( ) =>
4161+ activeThreadPrState === null
4162+ ? null
4163+ : { state : activeThreadPrState , updatedAt : activeThreadPrUpdatedAt } ,
4164+ [ activeThreadPrState , activeThreadPrUpdatedAt ] ,
4165+ ) ;
41544166 const supportsSettlement = serverConfig ?. environment . capabilities . threadSettlement === true ;
41554167 const supportsSnooze = serverConfig ?. environment . capabilities . threadSnooze === true ;
41564168 const nowMinute = useNowMinute ( ) ;
@@ -4186,7 +4198,14 @@ function ChatViewContent(props: ChatViewProps) {
41864198 ) ;
41874199 const activeThreadWokeVisible = useMemo ( ( ) => {
41884200 if ( activeThreadWokeAt === null ) return false ;
4189- if ( changeRequestAutoSettles ( activeThreadPr ?. state , autoSettleOnMerge ) ) return false ;
4201+ if (
4202+ changeRequestAutoSettles ( activeThreadChangeRequest , {
4203+ autoSettleOnMerge,
4204+ thread : activeThreadShell ,
4205+ } )
4206+ ) {
4207+ return false ;
4208+ }
41904209 const wokeAtMs = Date . parse ( activeThreadWokeAt ) ;
41914210 if ( Number . isNaN ( wokeAtMs ) ) return false ;
41924211 // Having the thread open counts as a visit at completedAt (the effect
@@ -4206,7 +4225,8 @@ function ChatViewContent(props: ChatViewProps) {
42064225 } , [
42074226 activeLatestTurn ?. completedAt ,
42084227 activeThreadLastVisitedAt ,
4209- activeThreadPr ?. state ,
4228+ activeThreadChangeRequest ,
4229+ activeThreadShell ,
42104230 activeThreadWokeAt ,
42114231 autoSettleOnMerge ,
42124232 ] ) ;
@@ -4216,10 +4236,10 @@ function ChatViewContent(props: ChatViewProps) {
42164236 now : `${ nowMinute } :00.000Z` ,
42174237 autoSettleAfterDays,
42184238 autoSettleOnMerge,
4219- changeRequestState : activeThreadPr ?. state ?? null ,
4239+ changeRequest : activeThreadChangeRequest ,
42204240 } ) ;
42214241 } , [
4222- activeThreadPr ?. state ,
4242+ activeThreadChangeRequest ,
42234243 activeThreadShell ,
42244244 autoSettleAfterDays ,
42254245 autoSettleOnMerge ,
@@ -6245,7 +6265,7 @@ function ChatViewContent(props: ChatViewProps) {
62456265 { ...( routeKind === "draft" && draftId ? { draftId } : { } ) }
62466266 activeThreadTitle = { activeThread . title }
62476267 isServerThread = { isServerThread }
6248- changeRequestState = { activeThreadPr ?. state ?? null }
6268+ changeRequest = { activeThreadChangeRequest }
62496269 activeProjectName = { activeProject ?. title }
62506270 activeProjectCwd = { activeProject ?. workspaceRoot ?? null }
62516271 activeProjectFaviconPath = { activeProject ?. faviconPath ?? null }
0 commit comments