Skip to content

feat(annotate): manual refresh rendered HTML from disk - #1232

Open
leoreisdias wants to merge 1 commit into
backnotprop:mainfrom
leoreisdias:feat/html-refresh
Open

feat(annotate): manual refresh rendered HTML from disk#1232
leoreisdias wants to merge 1 commit into
backnotprop:mainfrom
leoreisdias:feat/html-refresh

Conversation

@leoreisdias

Copy link
Copy Markdown
Contributor

Context

Markdown annotate sessions already reflect agent edits as soon as the underlying file changes, but rendered HTML sessions keep showing the snapshot loaded at startup. That makes the review surface look stale after an agent updates the source file.

This PR adds the first, deliberately manual checkpoint: local HTML annotate sessions get a Refresh action beside Hide tools. The user stays in control while we validate the refresh and annotation-restoration behavior before considering filesystem-driven automatic refresh.

What Changed

  • Add a Refresh action for local .html / .htm annotate sessions.
  • Fetch the current rendered document through the existing /api/doc route and remount the sandboxed HTML viewer, including when the HTML text is unchanged.
  • Reapply existing annotations after the iframe reload and report anchors that no longer match, while retaining their comments in the annotations panel.
  • Reset stale HTML diff and share state after a successful refresh.
  • Ignore refresh responses that belong to an older request or a document the user has already left.
  • Invalidate asynchronous share results against the complete sharing context so an older request cannot restore a link that omits newer HTML, annotations, or attachments.
  • Keep the refresh lifecycle in useHtmlRefresh; App only supplies the active path, capability flag, and successful-snapshot transition.

Contracts Preserved

  • Refresh is available only for local rendered HTML in active annotate mode. URL annotations, archive views, Markdown-converted HTML, and non-HTML documents are unchanged.
  • HTML source saving remains disabled; this only reloads the rendered source from disk.
  • Annotation comments survive even when their original text anchor disappears.
  • The existing sandboxed iframe bridge remains the only path used to restore HTML annotations.

Review Focus

The important areas are:

  1. Request and navigation races in useHtmlRefresh.
  2. Annotation restoration acknowledgements across the iframe bridge.
  3. Share-request invalidation when content changes during an asynchronous request.
  4. The capability check that keeps Refresh off unsupported or read-only surfaces.

Verification

  • Default test invocation cleanly skips the new DOM-gated tests.
  • 14 focused DOM tests pass, covering the action UI, source snapshot handling, annotation restoration, and stale share requests.
  • Full TypeScript project-reference matrix passes.
  • Review and hook production bundles build successfully.
  • Manual browser check against a local rendered HTML file confirms the document mounts and Refresh reloads it with a success notification.

@leoreisdias leoreisdias changed the title feat(annotate): refresh rendered HTML from disk feat(annotate): manual refresh rendered HTML from disk Aug 7, 2026
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