chore: code-review fixes (menu churn, split-mark range, mutex recovery)#63
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 extendstoonly when the next node carrying that id actually abuts the accumulated range (pos === existing.to). The old unconditionalMath.maxwould, on a malformed doc with a non-adjacent node sharing an id, widentoacross 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 sixChildRegistry/PendingDeepLink/ child-handle.lock().unwrap()sites now route through alock_recoverhelper 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 parameterizedgetAnchorTopBy.useSuggestions.ts: drop redundantas conston status literals (already narrowed bySuggestion.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