@@ -195,6 +195,27 @@ function stripThinkingMetadata<T extends ThinkingMetadataCarrier>(value: T): T {
195195 return next ;
196196}
197197
198+ /** Same-content merge detection; row values are wire scalars/plain objects, so one level suffices. */
199+ function isShallowEqualSessionRow (
200+ incoming : GatewaySessionRow ,
201+ existing : GatewaySessionRow ,
202+ ) : boolean {
203+ const incomingKeys = Object . keys ( incoming ) ;
204+ if ( incomingKeys . length !== Object . keys ( existing ) . length ) {
205+ return false ;
206+ }
207+ return incomingKeys . every ( ( key ) => {
208+ const a = ( incoming as Record < string , unknown > ) [ key ] ;
209+ const b = ( existing as Record < string , unknown > ) [ key ] ;
210+ return (
211+ a === b ||
212+ ( a !== null && b !== null && typeof a === "object" && typeof b === "object"
213+ ? JSON . stringify ( a ) === JSON . stringify ( b )
214+ : false )
215+ ) ;
216+ } ) ;
217+ }
218+
198219function isOlderSessionSnapshot (
199220 incoming : GatewaySessionRow ,
200221 existing : GatewaySessionRow | undefined ,
@@ -551,6 +572,16 @@ export function reconcileSessionHistory(
551572 // result === state.result publish gate can skip a spurious re-render.
552573 return defaults ? { ...result , defaults : nextDefaults } : result ;
553574 }
575+ if (
576+ existing &&
577+ isShallowEqualSessionRow ( visibleSession , existing ) &&
578+ sessionMatchesArchivedFilter ( visibleSession , archivedFilter )
579+ ) {
580+ // The same event reconciled twice (capability handler + chat page) must
581+ // no-op the second pass; a fresh array here defeats every downstream
582+ // result === state.result publish gate and re-renders per event.
583+ return defaults ? { ...result , defaults : nextDefaults } : result ;
584+ }
554585 const sessions = sessionMatchesArchivedFilter ( visibleSession , archivedFilter )
555586 ? [
556587 ...result . sessions . filter ( ( candidate ) => candidate . key !== visibleKey ) ,
0 commit comments