-
Notifications
You must be signed in to change notification settings - Fork 271
fix(core): let edit_note metadata set a note's type #1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -689,18 +689,20 @@ def apply_edit_operation( | |
| raise ValueError(f"Unsupported operation: {operation}") | ||
|
|
||
|
|
||
| # title/type/permalink already have dedicated resolution paths in | ||
| # prepare_edit_entity_content (H1 title reconciliation, permalink resolver). Letting a | ||
| # metadata merge touch them would race with those paths and could be silently reverted. | ||
| _METADATA_IDENTITY_FIELDS = frozenset({"title", "type", "permalink"}) | ||
| # title and permalink get reworked after the merge in prepare_edit_entity_content — | ||
| # title by H1 reconciliation, permalink by the collision-suffixing resolver. Either can | ||
| # hand back a value the caller did not ask for, so a metadata merge that set them would | ||
| # be silently reverted. `type` has no such second opinion: prepare_edit_entity_content | ||
| # just reads it back out of the frontmatter, so writing it there is how you set it. | ||
| _METADATA_IDENTITY_FIELDS = frozenset({"title", "permalink"}) | ||
|
|
||
|
|
||
| def _merge_metadata_into_markdown(markdown_content: str, metadata: dict[str, Any]) -> str: | ||
| """Merge caller-supplied fields into a markdown string's YAML frontmatter. | ||
|
|
||
| Identity fields (title/type/permalink) are dropped from the merge; every other key | ||
| overwrites the existing frontmatter value or is added new. The note body, and any | ||
| frontmatter keys not present in ``metadata``, are left untouched. | ||
| Identity fields (title/permalink) are dropped from the merge; every other key, | ||
| ``type`` included, overwrites the existing frontmatter value or is added new. The | ||
|
Comment on lines
+703
to
+704
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an existing note receives AGENTS.md reference: AGENTS.md:L128-L129 Useful? React with 👍 / 👎. |
||
| note body, and any frontmatter keys not present in ``metadata``, are left untouched. | ||
| """ | ||
| null_keys = sorted(key for key, value in metadata.items() if value is None) | ||
| if null_keys: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
appendorprependtargets a missing note,edit_notebypasses this merge and constructs anEntitywithentity_metadata=metadatabut the defaultnote_type="note"(edit_note.py:718-724).schema_to_markdown()then explicitly removestypefrom entity metadata and writesschema.note_type(markdown/utils.py:108-117), sometadata={"type": "decision"}still silently creates anoteeven though the same request changes the type when the target already exists. Pass the metadata type as the auto-created entity'snote_type, or apply the standard edit after creation.Useful? React with 👍 / 👎.