Skip to content

fix(comments): clear highlight on resolve; harden window-close guard#66

Merged
sam-powers merged 2 commits into
mainfrom
fix/resolve-highlight-and-close-guard
Jun 16, 2026
Merged

fix(comments): clear highlight on resolve; harden window-close guard#66
sam-powers merged 2 commits into
mainfrom
fix/resolve-highlight-and-close-guard

Conversation

@sam-powers

Copy link
Copy Markdown
Owner

Two fixes from live bug reports.

1. Resolved-comment highlight persisted

Repro: comment on text → @claude edits with track changes → accept → resolve → highlight stays.

Cause: resolving re-stamped the comment mark as resolved (CSS dotted underline) instead of removing it. When the accepted track-change replaced the commented span, the inserted text inherited the comment mark, so the underline ended up on text that was never commented on.

Fix: resolve now removes the mark outright — the text goes fully plain (matching delete's behavior). Unresolve re-stamps it from the comment's stored from/to via a new setCommentRange command (the live mark is gone, so the stored range is the only source). Replaces setCommentResolved.

2. Red X did nothing on a dirty document

Repro: make changes (dirty doc) → click the red traffic-light X → nothing happens, window stays open, no Save dialog.

Cause: the dirty branch of onCloseRequested calls event.preventDefault() then setDiscardGuard(...) to show the Save / Don't Save / Cancel dialog. The dialog machinery itself is sound (covered by data-safety.spec.ts for Cmd+N/Cmd+O) — the X is the one untested trigger. Its async listener registration could be torn down before resolving (StrictMode double-mount), leaking a duplicate listener, and a throw in the dirty branch could prevent the close without surfacing the dialog — a dead X.

Fix: the listener is now reliably installed-or-discarded (no leaked duplicate), and a failure in the dirty path destroys the window rather than swallowing the close silently.

Note: #2 is defensive hardening against the lifecycle/race issues visible in the close handler. The native window-close path can't be driven in the Playwright harness (getCurrentWindow() throws in the dev webview), so it's verified by reasoning + the intact dirty-guard e2e, not a new automated test.

Checks

  • typecheck, eslint, prettier ✓
  • vitest 255 ✓ (Comment extension tests rewritten for the new resolve/unresolve contract)
  • data-safety.spec.ts e2e 7/7 ✓ (dirty-guard dialog intact)
  • cargo fmt + clippy ✓

🤖 Generated with Claude Code

sam-powers and others added 2 commits June 15, 2026 22:41
Resolving a comment left a dotted underline on the text — the mark was
re-stamped `resolved` rather than removed. Worse, when an accepted
track-change replaced the commented span, the inserted text inherited
the comment mark, so the underline landed on text the user never
commented on. Resolve now removes the mark outright (text goes plain);
unresolve re-stamps it from the comment's stored range via the new
`setCommentRange` command (the mark is gone, so the stored from/to is
the only range source). Replaces `setCommentResolved`.

Also harden the native window-close guard: the async onCloseRequested
registration could be torn down before it resolved (StrictMode), leaking
a duplicate listener; and a throw in the dirty branch could prevent the
close without ever showing the Save dialog — leaving the red X dead on a
dirty document. The listener is now reliably installed-or-discarded, and
a failure in the dirty path destroys the window rather than swallowing
the close silently.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The resolve fix removes the comment mark on resolve rather than
re-stamping it as resolved, so the in-text highlight is gone. Update
the e2e assertion (which still expected a lingering mark.comment-resolved)
to match: no comment mark of any kind survives resolution.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sam-powers sam-powers merged commit 9e60735 into main Jun 16, 2026
3 checks passed
@sam-powers sam-powers deleted the fix/resolve-highlight-and-close-guard branch June 16, 2026 02:51
@sam-powers sam-powers mentioned this pull request Jun 16, 2026
sam-powers added a commit that referenced this pull request Jun 16, 2026
Patch release: resolve clears the comment highlight; window-close
guard hardened for unsaved-changes prompt (#66). Bumps version in
package.json, Cargo.toml, tauri.conf.json, Cargo.lock; adds release
notes draft.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant