Skip to content

Add review note chord guards#9412

Merged
AmethystLiang merged 3 commits into
mainfrom
fix/add-review-note-chord-guards
Jul 19, 2026
Merged

Add review note chord guards#9412
AmethystLiang merged 3 commits into
mainfrom
fix/add-review-note-chord-guards

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Describe the user-visible change.

Screenshots

  • Add screenshots or a screen recording for any new or changed UI behavior.
  • If there is no visual change, say No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

AI 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.

AmethystLiang and others added 2 commits July 18, 2026 20:27
- 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>
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 85cbc76a-eb1d-4eb2-93d7-518163057d0c

📥 Commits

Reviewing files that changed from the base of the PR and between 2b567a2 and a3eff20.

📒 Files selected for processing (2)
  • src/renderer/src/components/editor/MarkdownPreview.tsx
  • src/renderer/src/components/editor/MonacoEditor.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/editor/MonacoEditor.tsx
  • src/renderer/src/components/editor/MarkdownPreview.tsx

📝 Walkthrough

Walkthrough

The 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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is only the template text and does not fill the required summary, testing, review, security, or notes sections. Replace the template with concrete details for Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes, including cross-platform checks.
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change: adding guards for the review-note chord.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/renderer/src/components/editor/MarkdownPreview.tsx (1)

640-641: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Ref mutated directly in render body.

activeAnnotationBlockKeyRef.current = activeAnnotationBlockKey runs 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 to MonacoEditor.tsx) for a proposed fix.

Source: Linters/SAST tools

src/renderer/src/components/editor/MonacoEditor.tsx (1)

209-212: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Ref mutated directly in render body.

commentPopoverRef.current = commentPopover runs unconditionally in the component body every render — same pattern flagged in MarkdownPreview.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

📥 Commits

Reviewing files that changed from the base of the PR and between ae1c943 and fc04294.

📒 Files selected for processing (12)
  • src/renderer/src/components/diff-comments/DiffCommentPopover.tsx
  • src/renderer/src/components/editor/MarkdownPreview.tsx
  • src/renderer/src/components/editor/MonacoEditor.tsx
  • src/renderer/src/components/editor/editor-shortcuts.test.ts
  • src/renderer/src/components/editor/editor-shortcuts.ts
  • src/renderer/src/components/editor/markdown-preview-annotation-shortcut.test.ts
  • src/renderer/src/components/editor/markdown-preview-annotation-shortcut.ts
  • src/renderer/src/components/editor/rich-markdown-annotation-shortcut.ts
  • src/renderer/src/components/editor/rich-markdown-key-handler.test.ts
  • src/renderer/src/components/editor/rich-markdown-selection-flush.ts
  • src/renderer/src/components/editor/useRichMarkdownReviewController.open-guard.test.ts
  • src/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>
@AmethystLiang
AmethystLiang merged commit f7c2c12 into main Jul 19, 2026
1 check passed
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