Add review note chord guards#9412
Conversation
- Scoped guards consume chord at composer level to prevent remount and leakage - Handle OS key-repeat: ignore when no draft, consume when one is mounted - Clear stale block keys in markdown preview when content renumbers - Flush pending selection before reading targets to fix timing races
…hord gaps - Update the product-B guard tests to the Mod+Shift+A default binding (#9257 retired Mod+Alt+N as AltGr-unsafe); they asserted the old chord, so seven landed red and the rich-editor repeat test passed vacuously. - Monaco: recompute the annotation target from the live selection at keydown instead of the render-lagged ref, so a chord right after a drag cannot open on the previous selection or miss a fresh one. - Preview: key the stale-block-key cleanup on renderedContent (the DOM the block keys live in), which can lag content during external-edit section preservation. Co-authored-by: Orca <help@stably.ai>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe change updates add-review-note shortcut handling across markdown preview, rich markdown, Monaco, and diff-comment surfaces. Preview shortcut resolution now distinguishes opening, consuming, ignoring, and clearing stale annotation composers. Draft targets are synchronized with live selections and claimed before state updates. Capture-phase guards consume matching chords within mounted draft subtrees, including repeated key events. Tests cover shortcut outcomes, repeat behavior, draft preservation, selection flushing, and guard disposal. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/renderer/src/components/editor/MarkdownPreview.tsx (1)
640-641: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winRef mutated directly in render body.
activeAnnotationBlockKeyRef.current = activeAnnotationBlockKeyruns unconditionally in the component body every render. React Doctor flags this because React can replay/discard render work, letting the mutation leak from a commit that never lands. See the consolidated comment (also applies toMonacoEditor.tsx) for a proposed fix.Source: Linters/SAST tools
src/renderer/src/components/editor/MonacoEditor.tsx (1)
209-212: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winRef mutated directly in render body.
commentPopoverRef.current = commentPopoverruns unconditionally in the component body every render — same pattern flagged inMarkdownPreview.tsx. See consolidated comment for a proposed fix.Source: Linters/SAST tools
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 56cd46ab-4254-491a-b2ae-b5b727c5dd6f
📒 Files selected for processing (12)
src/renderer/src/components/diff-comments/DiffCommentPopover.tsxsrc/renderer/src/components/editor/MarkdownPreview.tsxsrc/renderer/src/components/editor/MonacoEditor.tsxsrc/renderer/src/components/editor/editor-shortcuts.test.tssrc/renderer/src/components/editor/editor-shortcuts.tssrc/renderer/src/components/editor/markdown-preview-annotation-shortcut.test.tssrc/renderer/src/components/editor/markdown-preview-annotation-shortcut.tssrc/renderer/src/components/editor/rich-markdown-annotation-shortcut.tssrc/renderer/src/components/editor/rich-markdown-key-handler.test.tssrc/renderer/src/components/editor/rich-markdown-selection-flush.tssrc/renderer/src/components/editor/useRichMarkdownReviewController.open-guard.test.tssrc/renderer/src/components/editor/useRichMarkdownReviewController.ts
…body CodeRabbit on #9412: render-body ref writes can leak from a render pass React replays and discards. Move the state->ref mirrors for commentPopoverRef / shouldShowMarkdownAnnotationsRef (MonacoEditor) and activeAnnotationBlockKeyRef (MarkdownPreview) into effects; same-tick keydown paths keep their eager event-handler writes. Co-authored-by: Orca <help@stably.ai>
Summary
Describe the user-visible change.
Screenshots
No visual change.Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAI Review Report
Summarize the code review you ran with your AI coding agent. Include the main risks it checked, what it flagged, and what you changed or verified as a result.
Confirm that the review explicitly checked cross-platform compatibility for macOS, Linux, and Windows, including shortcuts, labels, paths, shell behavior, and any Electron-specific platform differences touched by this PR.
Security Audit
Provide a basic security audit summary from your AI coding agent. Call out any input handling, command execution, path handling, auth, secrets, dependency, or IPC risks that were reviewed, plus any follow-up needed.
Notes
Call out any platform-specific behavior, risks, or follow-up work.