Repository navigation
feat(annotate): per-file version diff for .md and .html (rendered HTML highlights) - #961
Merged
backnotprop merged 7 commits intoJul 7, 2026
Merged
Conversation
Annotate mode never tracked version history, so the existing Plan Diff (highlighted diff vs a previous version) only worked in plan mode. Wire per-file version history into the annotate server so the same diff UI — badge, Version Browser, block-level comments — works when annotating a standalone .md/.txt/.html file. - key history by file path (stable across edits) rather than the plan flow's heading+date slug - save the markdown (or raw HTML source) to history on each open, expose previousPlan + versionInfo + diffCurrent on /api/plan - add /api/plan/version and /api/plan/versions to the annotate server Markdown lights up end to end; HTML needs frontend follow-ups (feed the HTML source as the diff content, surface the badge on the html surface, default to source diff mode).
For --render-html files, render the version diff as the real page with inline <ins>/<del> highlights instead of a markdown/source diff: - add packages/shared/html-diff.ts: a tag-aware htmlDiff() that wraps changed text in <ins>/<del> while keeping tags balanced (script/style opaque). 9 unit tests. - annotate server computes diffHtml = rewriteHtml(htmlDiff(prev, current)) and exposes it on /api/plan - HtmlViewer: inject ins/del highlight CSS, add a 'Show/Hide changes' toggle in its action bar - App: store diffHtml, swap the iframe to the diff page when toggled, and suppress the markdown block-diff path on the HTML surface Commenting still works because the diff page renders through the same HtmlViewer iframe bridge.
Parity for the Pi (node:http) runtime: per-file version history, previousPlan/versionInfo/diffCurrent + diffHtml on /api/plan, the /api/plan/version[s] endpoints, and project wiring from the Pi CLI. Vendors @plannotator/shared/html-diff into pi-extension/generated.
…ut, hide dead version picker on HTML - apps/pi-extension/package.json: declare the 'diff' dependency — generated/html-diff.js imports it at module load, so a standalone Pi install failed to resolve it and broke every annotate session (the monorepo masked this via root hoisting) - packages/shared/html-diff.ts: tag tokenizer now consumes quoted attribute values whole, so a '>' inside title="a > b" no longer splits the tag and corrupts the diff output; 3 regression tests - annotate history is now gated by PLANNOTATOR_ANNOTATE_HISTORY / config.annotateHistory (default on) and disclosed in AGENTS.md — it writes copies of annotated files into the data dir, which users should be able to see coming and turn off - packages/editor/App.tsx: hide the sidebar Versions tab on the HTML surface — the base-version picker has nothing to drive there (the HTML diff is fixed to current-vs-previous); the viewer's Show changes toggle is unaffected
Owner
|
Great feature and genuinely well-built — the reuse of the plan-version machinery, the dual-runtime mirror, and the htmlDiff test cases all show real care. Thank you! We reviewed in depth and, to save you a round-trip, pushed the fixes directly to your branch (hope that's OK — happy to walk through any of it):
All gates green after the changes (typecheck, 1,698 tests, both app builds). Non-blocking notes for possible follow-ups, no action needed: a size cap on Merging once CI confirms — thanks again for the contribution! |
The repo/diff badge cluster is absolutely positioned in the card's top padding, sized by guesswork (py-5..py-12). One chip row fit; the diff badge's second row overflowed into the H1, and mobile wrapping made the badge sit on top of the heading. Measure the cluster (ResizeObserver) and insert exactly the clearance it needs — zero when it fits, so existing single-row layouts don't shift. Pre-existing plan-mode bug surfaced by the annotate version diff.
backnotprop
added a commit
that referenced
this pull request
Jul 10, 2026
…f failing startup QA probe: with PLANNOTATOR_DATA_DIR on a read-only mount, `plannotator annotate file.md` crashed before the UI opened — twice. (1) #961's saveToHistory call on annotate open was unguarded, so the new version-diff enhancement gated startup that was stateless at v0.22.0; now wrapped (both the Bun server and the Pi mirror) and degrades to no-version-diff with a stderr notice. (2) registerSession's mkdir/writeFileSync (pre-existing since #795) threw after the server was already listening; the session registry only powers `plannotator sessions` discovery, so it is now best-effort, and unregisterSession/listSessions tolerate an unwritable sessions dir too. Verified: read-only data dir now starts, serves /api/plan with no versionInfo, and prints the session URL. Claude-Session: https://claude.ai/code/session_01SFy9fY27SA8g5BtotWPi1G
Owner
|
This is now released in version 0.23.0 |
This was referenced Jul 21, 2026
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.
Closes #960
What
Brings the version diff (the highlighted "what changed since the last version" view that plan mode has) to annotate mode, for both Markdown and HTML files. Annotate already has the diff UI (
PlanDiffViewer, Version Browser, block-level comments) — it just never receivedpreviousPlan/versionInfo, because the annotate server didn't track history. This wires that up..md/.txt→ the existing rendered Markdown diff (clean / classic / raw), with block comments..htmlwith--render-html→ the diff is rendered as the real page with inline<ins>/<del>highlights (not a source dump), so you see where it changed, and commenting still works because it's the sameHtmlVieweriframe.How
generateSlug= first-heading + date), annotate keys history by file path —annotate-{sanitized-basename}-{hash8}— so re-opening the same file groups its versions across edits even when headings change. Dedup + sequential numbering reuse the existingsaveToHistorystorage.packages/server/annotate.ts+ Piapps/pi-extension/server/serverAnnotate.ts). On open, save the markdown (or raw HTML source) to history, then exposepreviousPlan/versionInfo/diffCurrenton/api/planand add/api/plan/version+/api/plan/versions. Both runtimes updated perAGENTS.md.packages/shared/html-diff.ts: a small, dependency-light, tag-awarehtmlDiff(old, new)that wraps changed text in<ins>/<del>while keeping tags balanced (<script>/<style>treated as opaque). The server sendsdiffHtml = rewriteHtml(htmlDiff(prev, current));HtmlViewerinjectsins/delhighlight CSS and shows a "Show changes" toggle;Appswaps the iframe to the diff page when toggled and suppresses the Markdown block-diff path on the HTML surface (wheremarkdownis empty).Testing
packages/shared/html-diff.test.ts— 9 unit tests (text change, word replace, added element, script/style opacity, identical-input no-op, structural balance).tsc --noEmitclean forpackages/shared,packages/server,packages/ui; frontend build clean./api/planreturnsrenderAs: html+diffHtml, and/api/plan/versionslists the stored versions.Notes
🤖 Generated with Claude Code