Skip to content

fix(comments): undo of last tracked-change suggestion leaves orphan comment (IT-601)#2187

Closed
wasimrehman05 wants to merge 1 commit intosuperdoc-dev:mainfrom
wasimrehman05:main
Closed

fix(comments): undo of last tracked-change suggestion leaves orphan comment (IT-601)#2187
wasimrehman05 wants to merge 1 commit intosuperdoc-dev:mainfrom
wasimrehman05:main

Conversation

@wasimrehman05
Copy link

@wasimrehman05 wasimrehman05 commented Feb 26, 2026

PresentationEditor skipped emitting commentPositions when positions were empty, so undoing the last tracked-change mark never signaled the store to clear stale position data. Additionally, getFloatingComments treated tracked-change comments (which lack selection.source) as non-editor comments that bypass position filtering, and handleEditorLocationsUpdate blocked all empty position updates regardless of lifecycle state.

  • Always emit commentPositions from PresentationEditor, even when empty
  • Use isEditorBackedComment() in getFloatingComments instead of naive source check so tracked-change comments require live positions
  • Add hasReceivedPositions flag to distinguish initial-load guard from legitimate undo cleanup in handleEditorLocationsUpdate

fixed #2186

…omment in UI

PresentationEditor skipped emitting commentPositions when positions were
empty, so undoing the last tracked-change mark never signaled the store
to clear stale position data. Additionally, getFloatingComments treated
tracked-change comments (which lack selection.source) as non-editor
comments that bypass position filtering, and handleEditorLocationsUpdate
blocked all empty position updates regardless of lifecycle state.

- Always emit commentPositions from PresentationEditor, even when empty
- Use isEditorBackedComment() in getFloatingComments instead of naive
  source check so tracked-change comments require live positions
- Add hasReceivedPositions flag to distinguish initial-load guard from
  legitimate undo cleanup in handleEditorLocationsUpdate
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42e3fa304e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wasimrehman05 wasimrehman05 changed the title fix(comments): undo of last tracked-change suggestion leaves orphan c… fix(comments): undo of last tracked-change suggestion leaves orphan comment Feb 26, 2026
@wasimrehman05
Copy link
Author

Hi @harbournick @caio-pizzol
Just wanted to gently follow up on this PR.
Happy to make any adjustments if needed.

Thanks!

@wasimrehman05 wasimrehman05 changed the title fix(comments): undo of last tracked-change suggestion leaves orphan comment fix(comments): undo of last tracked-change suggestion leaves orphan comment (IT-601) Feb 26, 2026
@caio-pizzol
Copy link
Contributor

Hey @wasimrehman05, thanks for jumping on this so quickly - your analysis of the root cause is spot-on. The handleEditorLocationsUpdate guard blocking empty updates and the getFloatingComments source check bypassing tracked-change comments are exactly the right things to fix, and the hasReceivedPositions approach is a clean idea.

We had an internal fix already in progress on #2164 that addresses the same issue with a slightly different approach — it fixes the selection.source at tracked-change creation time, adds an active sync step on undo/redo, and includes behavior + visual regression tests. Since there's significant overlap between the two PRs, we're going to go with that one to avoid merge conflicts.

Really appreciate the contribution and the thorough breakdown in the PR description.

Hope to see you around on future issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undo of last tracked-change suggestion leaves orphan comment in UI

2 participants