Skip to content

chore: code-review fixes (menu churn, split-mark range, mutex recovery)#63

Merged
sam-powers merged 1 commit into
mainfrom
chore/code-review-fixes
Jun 14, 2026
Merged

chore: code-review fixes (menu churn, split-mark range, mutex recovery)#63
sam-powers merged 1 commit into
mainfrom
chore/code-review-fixes

Conversation

@sam-powers

Copy link
Copy Markdown
Owner

A code-quality sweep following the security hardening pass (#57#62). Three substantive fixes plus cosmetic cleanups — no behavior change for users, only correctness and robustness under edge cases.

Substantive

  • App.tsx — register menu listeners once. The Tauri menu-event handlers close over document state (filePath, comments, …) and re-create on most keystrokes, so the wiring effect tore down and re-listened all ten listeners every render. Now the handlers live in a ref refreshed per render and the listeners register once ([] deps), read live through the ref.
  • TrackChanges.ts (getTrackedChanges) — guard range extension on contiguity. A tracked id is minted across a single contiguous run, so the merge now extends to only when the next node carrying that id actually abuts the accumulated range (pos === existing.to). The old unconditional Math.max would, on a malformed doc with a non-adjacent node sharing an id, widen to across unmarked text in between. New test covers the split-across-text-nodes case (bolding part of a tracked insertion splits the text node while both halves keep the id — it must still surface one contiguous change).
  • lib.rs — recover poisoned mutexes instead of panicking. The six ChildRegistry / PendingDeepLink / child-handle .lock().unwrap() sites now route through a lock_recover helper that takes the inner guard on poisoning. These guard plain data (a process handle, a registry map, a pending path) that stays valid across a panic, so recovering is correct and avoids cascading a panic out of a spawn or deep-link path. Also logs (debug) skipped non-JSON lines in the claude stream rather than dropping them silently.

Cosmetic

  • CommentLayer.tsx: deduplicate the two identical anchor-lookup helpers into one parameterized getAnchorTopBy.
  • useSuggestions.ts: drop redundant as const on status literals (already narrowed by Suggestion.status).

Checks

typecheck, eslint, prettier, vitest (255 pass — +1 new), cargo fmt --check, clippy -D warnings, cargo test (35 pass) all green locally.

🤖 Generated with Claude Code

A code-quality sweep after the security hardening pass. Three substantive
fixes plus cosmetic cleanups:

- App.tsx: register the Tauri menu-event listeners once instead of
  re-listening on every edit. The handlers close over doc state and
  re-create on most keystrokes, which tore down and re-`listen`ed all of
  them each render. Hold them in a ref refreshed per render; the effect
  deps are now empty.
- TrackChanges.ts (getTrackedChanges): only extend a tracked change's
  range when the next node carrying its id actually abuts the accumulated
  range. The old unconditional Math.max would, on a malformed doc with a
  non-adjacent node sharing an id, widen `to` across unmarked text. Adds a
  test covering the split-across-text-nodes (bold inside a tracked run)
  merge case.
- lib.rs: route the six ChildRegistry / PendingDeepLink / child-handle
  mutex locks through a `lock_recover` helper that recovers the inner
  guard on poisoning instead of panicking — these guard plain data that
  stays valid across a panic. Also log (debug) skipped non-JSON lines in
  the claude stream rather than dropping them silently.

Cosmetic: dedupe the two identical anchor-lookup helpers in
CommentLayer.tsx; drop redundant `as const` in useSuggestions.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sam-powers sam-powers merged commit a3c312c into main Jun 14, 2026
3 checks passed
@sam-powers sam-powers deleted the chore/code-review-fixes branch June 14, 2026 12:10
@sam-powers sam-powers mentioned this pull request Jun 15, 2026
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