fix: route Spanish targets to Spanish CBT scaffolding, not French - #38
Merged
Conversation
Before this PR (and preserved through the PR #36 consolidation), targetLang === 'es' fell into the French branch of cbtBlock and granularityBlock inside language-chat. Spanish journal entries got French Cognitive Behavioral Therapy prompts: "Quand ça s'est passé, quelle a été ta première pensée ?" That's the wrong language for the coaching, and it undercuts the emotional-granularity goal — coaching prompts have to be in the target language for the user to engage with them as language practice. Changes: - granularityBlock: new Spanish branch (mal → agotado/desanimado/ abrumado; estresado → ansioso/desbordado/tenso; bien → sereno/ agradecido/aliviado; etc.) - cbtBlock: new Spanish branch with the 6 CBT techniques fully translated (Thought Records, Cognitive Distortions, Behavioral Experiments, Downward Arrow, Evidence Gathering, Values Alignment), and an explicit "use tú not usted" instruction for the journaling/coaching register French CBT stays as the explicit default fallback. Zero behavior change for fr / zh-Hans / zh-Hant / ja targets. Latent bug, not a regression — it has existed since Spanish was added. PR #36 surfaced it during consolidation; this PR fixes it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a latent routing bug preserved through the language-* consolidation in PR #36: Spanish learners were getting French Cognitive Behavioral Therapy prompts because
targetLang === 'es'fell into the French branch oflanguage-chat'scbtBlockandgranularityBlock.A Spanish journal entry could trigger:
instead of the correct Spanish phrasing. That's an obvious quality bug for the emotional-granularity goal — coaching prompts have to be in the target language to function as language practice.
What changed
supabase/functions/language-chat/index.ts:granularityBlock— added a Spanish branch with Spanish vague-emotion examples:mal→agotado, desanimado, abrumadoestresado→ansioso, desbordado, tensobien→sereno, agradecido, aliviadotriste→melancólico, nostálgico, decepcionadocontento→encantado, aliviado, entusiasmadocansado→exhausto, agotado, vacíocbtBlock— added a Spanish branch with all 6 CBT techniques translated:"¿Cuál fue tu primer pensamiento cuando eso pasó?""Noto un patrón interesante aquí…"/"¿hay otra forma de verlo?""¿Y si lo intentaras…?""Si fuera cierto, ¿qué significaría para ti?""¿Qué evidencia tienes a favor de ese pensamiento? ¿Y en contra?""¿Por qué es importante esto para ti?"Added explicit "use tú (informal), not usted" instruction — neutral Latin-American Spanish, appropriate register for a personal journaling/coaching context.
French CBT stays as the explicit default fallback. Zero behavior change for any other language (
fr,zh-Hans,zh-Hant,ja).Test plan
npx tsc --noEmit— cleannpx vitest run— 188 passed / 189 (only pre-existinguseJournal startFreeWrite)Native review caveat
My Spanish is decent (better than my Japanese) but not native. The translations follow neutral Latin-American conventions. A native speaker pass via iTalki or r/translator is still worthwhile before high-volume Spanish users hit the app — same recommendation as the Japanese prompts. The same copy-paste critique template applies.
Out of scope
t()/bilingual()call sites (separate translation-pass PR)language-feedback(English keys are still hardcoded there; lower priority since the language NAME in the prompt is correctly interpolated)🤖 Generated with Claude Code