feat: implement note mode for general codebase commenting#19
Merged
Conversation
Add note mode that allows commenting on any files without requiring diff/review context. Implements all core functionality: Core modules: - notes.lua: In-memory note storage with set management - note_persistence.lua: JSON persistence to .diff-review/notes/ - note_mode.lua: Mode state management and auto-commands - note_ui.lua: Virtual text rendering with separate namespace - note_actions.lua: User interaction handlers Features: - Multiple named note sets for different purposes - Automatic save on changes - Session persistence and auto-restore - Works in normal buffers without special layout - Reuses existing keymaps and UI styling - 6 new user commands for note management Commands added: - :DiffReviewNoteEnter [set_name] - :DiffReviewNoteExit - :DiffReviewNoteToggle [set_name] - :DiffReviewNoteClear - :DiffReviewNoteList - :DiffReviewNoteSwitch <set_name> Related to #5
All 21 tests passing for core note CRUD operations
Add comprehensive documentation for note mode feature including: - Feature overview and benefits - All available commands - Usage workflow - Storage structure - Configuration options - Example workflows - Coexistence with diff review
9 tests covering save/load, list, delete, and auto-save operations
- Save notes explicitly when exiting note mode - Save notes before saving session state on VimLeavePre - Add comprehensive persistence integration tests (6 tests) Fixes issue where notes would disappear when reopening Vim
Adds :DiffReviewNoteCopy command with two export modes: - notes: Simple markdown with line numbers - full: Includes code context around notes Features: - Exports notes grouped by file - Supports both single and range notes - Includes metadata header with set name and date - Sorts files alphabetically and notes by line number - Copy to clipboard via multiple backends (pbcopy, xclip, wl-copy) Includes 9 comprehensive tests covering all export scenarios
- Guard against nil config in setup_buffer_keymaps - Make list_sets test more resilient to concurrent test runs - Initialize config in export tests before entering note mode All 45 tests now passing
BREAKING CHANGE: Command structure simplified Before (15+ commands): - DiffReview, DiffReviewClose, DiffReviewToggle, DiffReviewList, etc. - DiffReviewNoteEnter, DiffReviewNoteExit, DiffReviewNoteClear, etc. After (2 main commands + 1 shortcut): - :DiffReview [subcommand] - all diff review operations - :DiffNote [subcommand] - all note mode operations - :DiffReviewToggle - shortcut for most common operation Subcommands: DiffReview: close, toggle, list, copy, submit, health DiffNote: enter, exit, toggle, clear, list, switch, copy Benefits: - Cleaner namespace (2 commands vs 15+) - Better discoverability via tab completion - Matches patterns from popular plugins (Telescope, Lazy) - Groups related functionality logically Documentation updated throughout README
Now correctly handles refs like 'main', 'develop', 'origin/main' by checking against known subcommands instead of pattern matching. Fixes error: 'Unknown subcommand: main'
- Create shared utility modules (git_utils, storage_utils, clipboard_utils) - Add comprehensive error handling for all file I/O operations - Fix silent pcall failures in note_ui (5 locations) - Wrap auto-save hooks with error handling in notes module - Migrate note_persistence to use new storage utilities - Replace git command calls with git_utils in note_mode and note_actions - Fix API inconsistency: use linehl instead of line_hl_group with hl_mode=combine - Extract magic numbers to constants (sign and extmark priorities) - Add line number validation in notes.add() - Replace emoji with markdown quote style (💬 -> >) - Consolidate clipboard operations using shared utility Test coverage: - Add 20 new tests for utility modules - Add line validation tests for notes module - Update note_export test for emoji change - All critical functionality tests passing (74 tests) Note: One pre-existing flaky test in note_persistence remains
- Rename shadowing variables (notes -> notes_api, state -> note_state) - Simplify restore_session control flow with early returns - Add proper test cleanup in note_export_spec - Fix list_sets verification in note_persistence_spec - Add edge case test files for note_mode and storage
7d57e2c to
6461dea
Compare
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.
Summary
Implements note mode (#5) - a feature for adding comments to any files in the codebase without requiring diff or review context.
Features
.diff-review/notes/with JSON formatImplementation
Core Modules (5 new files)
notes.lua- In-memory storage with set managementnote_persistence.lua- JSON persistence layernote_mode.lua- Mode state management and auto-commandsnote_ui.lua- Virtual text rendering with separate namespacenote_actions.lua- User interaction handlers (add/edit/delete)Commands (6 new)
:DiffReviewNoteEnter [set_name]- Enter note mode:DiffReviewNoteExit- Exit note mode:DiffReviewNoteToggle [set_name]- Toggle mode:DiffReviewNoteClear- Clear all notes in current set:DiffReviewNoteList- List and switch note sets:DiffReviewNoteSwitch <set_name>- Switch to different setConfiguration
Testing
Documentation
Changes
Demo Workflow
Closes #5