Skip to content

fix(revision): persist custom frontmatter#956

Merged
perber merged 2 commits intomainfrom
fix/revision-frontmatter-history
May 1, 2026
Merged

fix(revision): persist custom frontmatter#956
perber merged 2 commits intomainfrom
fix/revision-frontmatter-history

Conversation

@perber
Copy link
Copy Markdown
Owner

@perber perber commented May 1, 2026

Store historical custom frontmatter in revisions so frontmatter-only changes create history entries and restore can rebuild custom fields without changing managed metadata ownership.

Store historical custom frontmatter in revisions so frontmatter-only changes create history entries and restore can rebuild custom fields without changing managed metadata ownership.
Copilot AI review requested due to automatic review settings May 1, 2026 15:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the revision system to persist and restore custom (non-managed) frontmatter so that frontmatter-only edits produce revision history and restores can rehydrate those custom fields while keeping LeafWiki-managed metadata owned by the live page state.

Changes:

  • Add TreeService.ReadPageRaw() to read markdown including frontmatter.
  • Extend RevisionState/Revision to store ExtraFrontmatter + ExtraFrontmatterHash, and include the hash in “did content change?” detection.
  • Update revision restore to rebuild markdown with historical extra frontmatter, plus add tests for capture/restore and legacy/backward-compat behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/core/tree/tree_service.go Adds ReadPageRaw() API for retrieving raw markdown (incl. frontmatter).
internal/core/revision/types.go Adds extra frontmatter fields/hashes to revision types for persistence/JSON.
internal/core/revision/service.go Captures extra frontmatter into revisions, compares hashes for history creation, and rebuilds markdown on restore.
internal/core/revision/service_test.go Adds coverage for capturing/restoring custom frontmatter and legacy revision behavior.
internal/core/revision/fs_store_test.go Adds backward-compat test for decoding legacy revision JSON without the new fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/core/revision/service.go Outdated
Comment thread internal/core/revision/service.go Outdated
Use the importer write path only when a revision actually carries custom frontmatter so legacy body-only restores keep YAML-looking content as plain body text.
@perber perber merged commit bef9133 into main May 1, 2026
5 checks passed
@perber perber deleted the fix/revision-frontmatter-history branch May 1, 2026 15:47
perber added a commit that referenced this pull request May 3, 2026
Store historical custom frontmatter in revisions so frontmatter-only changes create history entries and restore can rebuild custom fields without changing managed metadata ownership.
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.

2 participants