Skip to content

Chapter content is deleted when editing chapter metadata #264

Description

@philxb

What happened?

When editing a chapter's metadata (summary, notes, etc.) via the metadata dialog, the chapter's prose content is wiped out — both in the editor view and persisted to the backend.

Steps to reproduce:

  1. Open a project with a chapter that has content
  2. Click the chapter to select it
  3. Click the "Edit Metadata" button for that chapter
  4. Edit the summary (or any metadata field)
  5. Close the metadata dialog
  6. The chapter content is now empty

Disclosure: The following was diagnosed with the help of AI, so take this with a grain of salt, but testing it did seem to fix the issue.

Potential Root cause:

ChapterList.tsx is passing the entire Chapter object as initialData, which always has content: '' due to chaptersStructuralEqual() intentionally excluding content to avoid sidebar re-renders on every keystroke. This empty content then gets spread into the chapter state during saveMetadata.

Potential Fix:

Build an explicit MetadataParams-shaped literal from the Chapter data (containing only title, summary, notes, private_notes, conflicts) instead of passing the whole object. That way an empty content can't leak into the metadata flow.

Hopefully this makes sense!
Really enjoying this app by the way. Great work!

Relevant log output

OS and version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions