diff --git a/src/main/ai/AiWorker.ts b/src/main/ai/AiWorker.ts index ecf47c3..ae4306d 100644 --- a/src/main/ai/AiWorker.ts +++ b/src/main/ai/AiWorker.ts @@ -187,22 +187,24 @@ export class AiWorker { // v0.2.3 #3 — per-tag vocab hit/miss 분류 (updateAiResult 후 → tagId 보장) // dedup: AI 응답에 같은 태그 중복 가능 — INSERT OR IGNORE 와 정합한 1-emit/태그 보장 const vocabSet = new Set(vocab.map((v) => v.toLowerCase())); - for (const tagName of new Set(res.tags)) { - if (vocabSet.has(tagName.toLowerCase())) { - const tagId = this.repo.getTagIdByName(tagName); - if (tagId !== null) { + await Promise.all( + Array.from(new Set(res.tags)).map(async (tagName) => { + if (vocabSet.has(tagName.toLowerCase())) { + const tagId = this.repo.getTagIdByName(tagName); + if (tagId !== null) { + await this.telemetry.emit({ + kind: 'tag_vocab_hit', + payload: { tagId, vocabSize: vocab.length } + }).catch(() => {}); + } + } else { await this.telemetry.emit({ - kind: 'tag_vocab_hit', - payload: { tagId, vocabSize: vocab.length } + kind: 'tag_vocab_miss', + payload: { vocabSize: vocab.length } }).catch(() => {}); } - } else { - await this.telemetry.emit({ - kind: 'tag_vocab_miss', - payload: { vocabSize: vocab.length } - }).catch(() => {}); - } - } + }) + ); } this.emit(job.noteId); return;