fix(tags): allow creating a same-named character in a different fandom
CI / lint (push) Successful in 3s
CI / frontend-build (push) Successful in 19s
CI / backend-lint-and-test (push) Successful in 26s
CI / integration (push) Successful in 3m21s

The autocomplete suppressed the Create row whenever any existing tag matched
name+kind — but characters are unique by (name, kind, fandom), so a same-named
character in a different fandom (e.g. another "Raven") is a valid distinct tag.
allowCreate now always offers Create for the character kind; the fandom picker
disambiguates and find_or_create is idempotent if the same fandom is re-picked.
The Create row reads "Create another \"Raven\" character (different fandom)" when
a same-name character already exists.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
This commit is contained in:
2026-06-29 08:38:56 -04:00
parent 1463794778
commit ad2921b4a0
@@ -72,7 +72,7 @@
</v-icon>
</template>
<v-list-item-title>
Create "{{ parsedName }}" as {{ parsedKind }}
{{ createLabel }}
</v-list-item-title>
</v-list-item>
</template>
@@ -178,14 +178,34 @@ watch(query, () => {
}, 200)
})
// A same-name character ALREADY exists. Characters are unique by
// (name, kind, fandom), so this is still a valid distinct tag in another fandom.
const sameNameCharExists = computed(() =>
parsedKind.value === 'character' &&
hits.value.some(h =>
h.kind === 'character' && h.name.toLowerCase() === parsedName.value.toLowerCase(),
),
)
const allowCreate = computed(() => {
const q = parsedName.value
if (!q) return false
// Characters disambiguate by fandom, so a same-named character in a DIFFERENT
// fandom is a valid new tag — always offer Create (the fandom picker resolves
// it; find_or_create is idempotent if you re-pick the same fandom). Other
// kinds are unique by (name, kind): an exact match means it already exists.
if (parsedKind.value === 'character') return true
return !hits.value.some(h =>
h.name.toLowerCase() === q.toLowerCase() && h.kind === parsedKind.value,
)
})
const createLabel = computed(() =>
sameNameCharExists.value
? `Create another "${parsedName.value}" character (different fandom)`
: `Create "${parsedName.value}" as ${parsedKind.value}`,
)
function scorePct (s) { return `${Math.round(s.score * 100)}%` }
// This image's suggestions that match the typed query, minus any the server