Skip to content

Synchronize removed llm keywords when saving metadata #7

Description

@LostOne1000

Priority

Medium

Summary

The keyword field is initialized with the photo’s existing child keywords under the llm parent. The user can remove keywords from the field, but Save only adds entered keywords and never removes deselected keywords from the photo.

The UI therefore behaves like a replacement editor while the save logic is additive only.

Example

Existing keywords:

portrait, fashion, studio, red dress

User changes the field to:

portrait, fashion

Current saved result:

portrait, fashion, studio, red dress

Expected saved result:

portrait, fashion

Relevant code

Existing keywords are loaded:

props.keywords =
    table.concat(existingLlmKeywords, ", ")

Save only calls:

addKeywordsWithParent(
    catalog,
    selectedPhoto,
    keywordList
)

Expected behavior

The entered keyword list should become the assigned set of llm child keywords for the selected photo.

Unrelated Lightroom keywords must remain untouched.

Implementation notes

During the catalog write operation:

  1. Parse and normalize entered keywords.
  2. Determine currently assigned child keywords whose direct parent is llm.
  3. Add entered keywords that are not assigned.
  4. Remove assigned llm keywords that are absent from the entered list.
  5. Leave all keywords outside the llm hierarchy unchanged.

Consider case normalization and duplicate handling.

Acceptance criteria

  • Removing an llm keyword from the field removes it from the photo.
  • Adding a new keyword creates and assigns it under llm.
  • Existing unrelated Lightroom keywords remain assigned.
  • Duplicate entered keywords are assigned only once.
  • Leading and trailing whitespace is removed.
  • Saving an empty keyword field removes all assigned llm child keywords without deleting unrelated keywords.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions