feat: highlight, annotate, and copy passages as agent-ready changelist (#5)#9
Open
JohnnyBonk wants to merge 3 commits intoGRVYDEV:mainfrom
Open
feat: highlight, annotate, and copy passages as agent-ready changelist (#5)#9JohnnyBonk wants to merge 3 commits intoGRVYDEV:mainfrom
JohnnyBonk wants to merge 3 commits intoGRVYDEV:mainfrom
Conversation
…v1) Adds the v1 cutline of issue GRVYDEV#5: select text in the rendered markdown, pick a colour, then copy a single item or whole list to the clipboard in a format coding agents can act on directly. What's in v1 - Selection in the article surfaces a small popover with five colour swatches (yellow / orange / pink / blue / purple) plus a "Copy" shortcut. Keyboard 1-5 applies the matching colour, Esc dismisses. - A right-side review panel (toolbar toggle) lists the current file's highlights grouped by colour. Each list and each item has its own copy button. Clicking an item scrolls the source highlight into view. - Highlights are anchored by source-line range + passage text + occurrence index, leveraging the data-source-map attributes that markdown-it already emits. Re-applied as wrapping spans on every render, so they survive Shiki / Mermaid replacement passes. - Persistence is a single highlights.json under app_data_dir, keyed by absolute file path. New Tauri commands: load_highlights and save_highlights_for_file. - Code blocks are not highlightable in v1 (selection inside <pre> hides the popover). - IBM colorblind-safe palette, distinguishable to protanopes. Tests - 24 new Vitest cases for the pure helpers (anchoring, occurrence counting, agent export formatting). - 5 new Rust tests for the persistence module (round trip, missing file, corrupt file, camelCase JSON keys for the frontend). - Pre-existing failures in src/lib/markdown.test.ts and src/lib/theme.test.tsx also fail on main and are unrelated to this change. Deferred to v2 (kept the diff focused) - Annotations on highlights and named/described lists. - Edit history with archive/restore. - Multi-select copy. - Customisable palette and JSON / markdown-blockquote export formats. - Sidecar JSON next to source files (current store is global, which follows the project convention of not writing user data outside app_data_dir). Closes the highlighting half of GRVYDEV#5. The folder-disambiguation half is owned by the maintainer.
- Optional `note` field on Highlight, rendered as `Note:` in agent exports. Older highlights.json files load via serde default. - Click an existing highlight to open an edit popover (recolour, edit note, copy, delete). Delete / Backspace also deletes the targeted highlight while the popover is open or the cursor is inside one. - Annotate button on the new-selection popover swaps the row to an inline note input; Enter / Save commits with the active colour. - Centralised toast / notification system. Inline checkmark flash on Copy and Delete buttons for local confirmation; bottom-right toast for global confirmation; Undo (5s) on every delete path. - Panel: filter pills per colour, per-item note display and edit, copy-visible button in the header. - `]` / `[` cycles the active colour at any time. - Welcome tab supports highlighting via a synthetic `:welcome` storage key. - Save and restore scrollTop around highlight re-application so the browser does not snap scroll back to the top when the wrapper used as the scroll-anchor is removed during delete. - Tests: 3 new Vitest cases (note in formatItem / formatFile); 2 new Rust tests (legacy-without-note loads cleanly, note absent from JSON when unset).
Per-folder expansion state defaults to collapsed when no explicit state has been set, so the sidebar opens quietly and the user expands what they want to scan. Repo-group headers still default open so the outline stays visible at a glance. Toggle handler now flips the resolved visual state rather than the raw stored value, so the first click after the default change correctly opens the folder.
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.
Implements the highlight + annotate + agent-export workflow from #5, plus a small unrelated UX change for the sidebar.
Summary
app_data_dir/highlights.json.Scope
Highlights — capture
1–5apply the matching colour while the popover is open.]/[cycle it without opening the popover.<pre>hides the popover).:welcomestorage key.Highlights — re-engage
Delete/Backspacedeletes the targeted highlight while the popover is open or the cursor is inside one.Review panel
Agent-ready export format
Single item:
Whole list (per-list Copy) groups by colour:
Anchoring
Highlights store
(sourceStartLine, sourceEndLine, passage, occurrenceIndex), leveraging thedata-source-mapattributes markdown-it already emits on block-level tokens. Re-applied as wrapping spans on every render, so they survive Shiki / Mermaid replacement passes. If a passage cannot be relocated after an upstream edit, the highlight is silently skipped (orphaned). Scroll position is saved and restored around the re-application pass to prevent browser scroll-anchoring from snapping to the top when the wrapper used as the anchor is removed during delete.Persistence
highlights.jsonunderapp_data_dir, keyed by absolute file path.notefield usesserde(default, skip_serializing_if)so older files load cleanly and unannotated highlights stay compact.load_highlightsandsave_highlights_for_file.Sidebar folders default to collapsed
Per-folder expansion state defaults to collapsed; the sidebar opens quietly each session and the user expands what they want. Repo-group headers (when grouping by repo) still default open so the outline stays visible.
Tests
note) loads cleanly, andnoteomitted from JSON when unset.pnpm typecheckandpnpm buildclean.src/lib/markdown.test.tsandsrc/lib/theme.test.tsxalso fail onmainand are unrelated to this change.Deferred (for follow-ups)
app_data_dir).Test plan
pnpm install(the repo currently importsmarkdown-it-front-matter; this branch has it in the lockfile).pnpm tauri dev, open a markdown file with multiple paragraphs and headings.1–5.Delete; same flow.]and[to cycle the active colour.~/Library/Application Support/marky/highlights.jsonon macOS).