Skip to content

Commit 6a0a64e

Browse files
mpstatonclaude
andcommitted
fix(strategy-curator): split tags on commas instead of fusing them — Fixes #76
Add splitTags(raw) next to toDashed: commas and newlines are tag separators, spaces within a segment stay word-joiners (toDashed). Route both entry points through it — applyTag (source edit) loops one tag.apply per new tag; StrategyPicker.addTag appends every split result to pendingTags. Suggestion clicks pass a single token, which splitTags returns unchanged, so no regression. Verified with `rsbuild build` — green. "Quantum Computing, Computational Biology" now yields two chips (Quantum-Computing, Computational-Biology) instead of one fused mega-tag. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018UYTYu4MAFZ7iyr2VTo2kq
1 parent 1252534 commit 6a0a64e

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

apps/strategy-curator/src/StrategyPicker.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { curation, slugify, toDashed } from './curation.svelte';
2+
import { curation, slugify, splitTags } from './curation.svelte';
33
44
// Mirrors content-ingest's DOMAIN_FOLDERS (services/content-ingest/src/
55
// corpus.ts) so the "writes to" preview below matches the actual folder
@@ -32,8 +32,10 @@
3232
slug = slugify(v);
3333
}
3434
function addTag(t: string): void {
35-
const tt = toDashed(t);
36-
if (tt && !pendingTags.includes(tt)) pendingTags = [...pendingTags, tt];
35+
// Commas split into multiple tags; append each new one, deduped.
36+
for (const tt of splitTags(t)) {
37+
if (!pendingTags.includes(tt)) pendingTags = [...pendingTags, tt];
38+
}
3739
tagInput = '';
3840
}
3941
function removeTag(t: string): void {

apps/strategy-curator/src/curation.svelte.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ export function toDashed(s: string): string {
4646
.join('-');
4747
}
4848

49+
// Split a raw tag entry into one-or-more dashed tags. Commas and newlines are
50+
// tag SEPARATORS; spaces within a segment stay word-joiners (handled by
51+
// toDashed). "Quantum Computing, Computational Biology" →
52+
// ["Quantum-Computing", "Computational-Biology"]. A single token (e.g. a
53+
// suggestion click) returns a one-element array unchanged.
54+
export function splitTags(raw: string): string[] {
55+
return raw
56+
.split(/[,\n]+/)
57+
.map(toDashed)
58+
.filter(Boolean);
59+
}
60+
4961
type ConnStatus = 'idle' | 'connecting' | 'open' | 'closed' | 'error' | 'auth_required';
5062

5163
class CurationState {
@@ -447,11 +459,14 @@ class CurationState {
447459

448460
async applyTag(raw: string): Promise<void> {
449461
const f = this.focused;
450-
const tag = toDashed(raw);
451-
if (!f || !tag) return;
452-
await this.call('tag.apply', { source_uuid: f.source_uuid, domain_type: this.domainType, domain_slug: this.activeSlug, client_slug: this.clientSlug, tag, op: 'add' });
453-
f.tags = Array.from(new Set([...(f.tags ?? []), tag]));
454-
if (!this.tagVocab.includes(tag)) this.tagVocab = [...this.tagVocab, tag];
462+
if (!f) return;
463+
// Commas split into multiple tags; add each new one, deduped, in order.
464+
for (const tag of splitTags(raw)) {
465+
if ((f.tags ?? []).includes(tag)) continue;
466+
await this.call('tag.apply', { source_uuid: f.source_uuid, domain_type: this.domainType, domain_slug: this.activeSlug, client_slug: this.clientSlug, tag, op: 'add' });
467+
f.tags = Array.from(new Set([...(f.tags ?? []), tag]));
468+
if (!this.tagVocab.includes(tag)) this.tagVocab = [...this.tagVocab, tag];
469+
}
455470
}
456471

457472
async removeTag(tag: string): Promise<void> {

0 commit comments

Comments
 (0)