Skip to content

Add rendered markdown preview toggle to the file diff panel#166

Merged
pufit merged 1 commit into
mainfrom
pufit/diff-markdown-preview
Jul 6, 2026
Merged

Add rendered markdown preview toggle to the file diff panel#166
pufit merged 1 commit into
mainfrom
pufit/diff-markdown-preview

Conversation

@pufit

@pufit pufit commented Jul 5, 2026

Copy link
Copy Markdown
Member

What

In the session file-changes panel (right side panel), markdown files now get an eye toggle in the detail header that switches between the raw diff and a rendered markdown preview of the file.

How

Backendcompute_file_diff now attaches two fields to the diff response for .md/.markdown files (case-insensitive):

  • markdown_content: the post-change file content; falls back to the original content for deleted files so the preview can still show what was removed. null for non-markdown files.
  • markdown_truncated: true when the content was cut at MAX_DIFF_LINES (mirrors the patch truncation to keep payloads bounded).

FrontendFileDetailView shows an Eye toggle (same pattern as the line-wrap toggle) only when markdown_content is present. Preview mode renders through the existing MarkdownContent component (GFM tables, syntax-highlighted code blocks). The toggle resets to diff view when switching files, and a truncation notice is shown when the preview was cut.

Old-backend / new-frontend degrades gracefully: no field → no toggle, diff panel unchanged.

Testing

  • 5 new unit tests in tests/test_diff.py (md content present, case-insensitive suffix, deleted-file fallback, non-md null, truncation) — full suite 1370 passed
  • npm run build clean
  • Verified in the browser: toggle renders headings/bold/tables/code preview, switches back to raw diff, absent for non-markdown files

Generated by Nerve

@pufit pufit merged commit e9714d1 into main Jul 6, 2026
2 checks 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