@@ -29,6 +29,7 @@ export const useCommentsStore = defineStore('comments', () => {
2929
3030 const isDebugging = false ;
3131 const debounceTimers = { } ;
32+ const trackedChangeResolutionSnapshots = new WeakMap ( ) ;
3233
3334 const COMMENT_EVENTS = comments_module_events ;
3435 const hasInitializedComments = ref ( false ) ;
@@ -188,6 +189,17 @@ export const useCommentsStore = defineStore('comments', () => {
188189
189190 const clearResolvedMetadata = ( comment ) => {
190191 if ( ! comment ) return ;
192+ if (
193+ comment . resolvedTime !== undefined ||
194+ comment . resolvedByEmail !== undefined ||
195+ comment . resolvedByName !== undefined
196+ ) {
197+ trackedChangeResolutionSnapshots . set ( comment , {
198+ resolvedTime : comment . resolvedTime ?? null ,
199+ resolvedByEmail : comment . resolvedByEmail ?? null ,
200+ resolvedByName : comment . resolvedByName ?? null ,
201+ } ) ;
202+ }
191203 // Sets the resolved state to null so it can be restored in the comments sidebar
192204 comment . resolvedTime = null ;
193205 comment . resolvedByEmail = null ;
@@ -981,18 +993,18 @@ export const useCommentsStore = defineStore('comments', () => {
981993 // History replay can opt in to excluding resolved tracked-change threads so
982994 // undo/redo reopens them when their marks reappear. Initial import rebuilds
983995 // keep resolved IDs in the set so resolved DOCX threads do not reopen on load.
984- const existingUnresolvedIds = new Set ( ) ;
996+ const skipIds = new Set ( ) ;
985997 commentsList . value . forEach ( ( comment ) => {
986998 if ( ! comment ?. trackedChange ) return ;
987999 if ( ! belongsToDocument ( comment , activeDocumentId ) ) return ;
9881000 if ( comment . resolvedTime && ! reopenResolved ) {
989- if ( comment . commentId != null ) existingUnresolvedIds . add ( String ( comment . commentId ) ) ;
990- if ( comment . importedId != null ) existingUnresolvedIds . add ( String ( comment . importedId ) ) ;
1001+ if ( comment . commentId != null ) skipIds . add ( String ( comment . commentId ) ) ;
1002+ if ( comment . importedId != null ) skipIds . add ( String ( comment . importedId ) ) ;
9911003 return ;
9921004 }
9931005 if ( comment . resolvedTime ) return ;
994- if ( comment . commentId != null ) existingUnresolvedIds . add ( String ( comment . commentId ) ) ;
995- if ( comment . importedId != null ) existingUnresolvedIds . add ( String ( comment . importedId ) ) ;
1006+ if ( comment . commentId != null ) skipIds . add ( String ( comment . commentId ) ) ;
1007+ if ( comment . importedId != null ) skipIds . add ( String ( comment . importedId ) ) ;
9961008 } ) ;
9971009
9981010 // Build a Map of change ID → tracked change entries for O(1) lookup per group.
@@ -1009,7 +1021,7 @@ export const useCommentsStore = defineStore('comments', () => {
10091021 // Build comment params directly from grouped changes — no PM dispatch needed
10101022 groupedChanges . forEach ( ( { insertedMark, deletionMark, formatMark } ) => {
10111023 const id = insertedMark ?. mark . attrs . id || deletionMark ?. mark . attrs . id || formatMark ?. mark . attrs . id ;
1012- if ( ! id || existingUnresolvedIds . has ( id ) ) return ;
1024+ if ( ! id || skipIds . has ( id ) ) return ;
10131025
10141026 const marks = {
10151027 ...( insertedMark && { insertedMark : insertedMark . mark } ) ,
@@ -1030,9 +1042,9 @@ export const useCommentsStore = defineStore('comments', () => {
10301042
10311043 if ( params ) {
10321044 handleTrackedChangeUpdate ( { superdoc, params } ) ;
1033- existingUnresolvedIds . add ( String ( id ) ) ;
1034- if ( params . changeId != null ) existingUnresolvedIds . add ( String ( params . changeId ) ) ;
1035- if ( params . importedId != null ) existingUnresolvedIds . add ( String ( params . importedId ) ) ;
1045+ skipIds . add ( String ( id ) ) ;
1046+ if ( params . changeId != null ) skipIds . add ( String ( params . changeId ) ) ;
1047+ if ( params . importedId != null ) skipIds . add ( String ( params . importedId ) ) ;
10361048 }
10371049 } ) ;
10381050
@@ -1096,6 +1108,15 @@ export const useCommentsStore = defineStore('comments', () => {
10961108 const hasLiveImportedId = Boolean ( importedId && liveTrackedChangeIds . has ( importedId ) ) ;
10971109
10981110 if ( ( ! commentId && ! importedId ) || hasLiveCommentId || hasLiveImportedId ) return true ;
1111+ if ( comment . resolvedTime ) return true ;
1112+
1113+ const resolutionSnapshot = trackedChangeResolutionSnapshots . get ( comment ) ;
1114+ if ( resolutionSnapshot ) {
1115+ comment . resolvedTime = resolutionSnapshot . resolvedTime ?? Date . now ( ) ;
1116+ comment . resolvedByEmail = resolutionSnapshot . resolvedByEmail ?? null ;
1117+ comment . resolvedByName = resolutionSnapshot . resolvedByName ?? null ;
1118+ return true ;
1119+ }
10991120
11001121 if ( commentId ) removedIds . add ( commentId ) ;
11011122 if ( importedId ) removedIds . add ( importedId ) ;
0 commit comments