From 4c5774f2e7e0201079e2192bdaaaf2ccdadf520f Mon Sep 17 00:00:00 2001 From: jstet Date: Fri, 25 Sep 2026 14:29:08 +0200 Subject: [PATCH] wizard: disable formal/informal for English surveys; fix toggle transition (#43) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two unrelated UI papercuts that came up while testing #39. * **English hides the Sie/Du toggle.** The form-of-address choice is a German-only concept, so when surveyLanguage is English the buttons are disabled with a small hint, and the generator receives 'you' instead of 'du'/'Sie' (English has no formal/informal split). The persisted value is left alone, so switching back to German restores the user's previous choice. * **Toggle-button transition.** The selected state changed both background and font-weight under `transition: all 0.2s`. Colour fades smoothly but font-weight can't be interpolated, so it snapped at the start — the two felt out of sync. Now only background-color and border-color transition; font-weight snaps as it always did. formOfAddress() gains a surveyLanguage parameter (defaults to 'de' for backwards compat) and the SIGNATURE description mentions the new value. --- src/lib/agents/lead.ts | 2 +- src/lib/agents/repair_agent.ts | 2 +- src/lib/agents/survey_generator.ts | 13 +++++++++---- src/lib/i18n.ts | 2 ++ src/routes/+page.svelte | 17 ++++++++++++++++- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/lib/agents/lead.ts b/src/lib/agents/lead.ts index 8595abc..518811c 100644 --- a/src/lib/agents/lead.ts +++ b/src/lib/agents/lead.ts @@ -218,7 +218,7 @@ export class LeadAgent { ] .map((m) => `- ${m}`) .join('\n'), - formOfAddress: formOfAddress(input.language) + formOfAddress: formOfAddress(input.language, input.surveyLanguage) }, signal ); diff --git a/src/lib/agents/repair_agent.ts b/src/lib/agents/repair_agent.ts index 4f60b6a..d58cf54 100644 --- a/src/lib/agents/repair_agent.ts +++ b/src/lib/agents/repair_agent.ts @@ -5,7 +5,7 @@ import { numberResearchQuestions, type Question } from './types.js'; import { extractQuestions } from './question_parser.js'; const SIGNATURE = - 'researchQuestions:string "numbered", previousQuestions:json, validationFeedback:string, formOfAddress:string "du or Sie; keep it" -> generatedQuestions:json'; + 'researchQuestions:string "numbered", previousQuestions:json, validationFeedback:string, formOfAddress:string "du, Sie (German) or you (English); keep it" -> generatedQuestions:json'; /** Built from the registry, so the repair prompt can never drift from what the * validator accepts. */ diff --git a/src/lib/agents/survey_generator.ts b/src/lib/agents/survey_generator.ts index b182600..39cbf5a 100644 --- a/src/lib/agents/survey_generator.ts +++ b/src/lib/agents/survey_generator.ts @@ -8,10 +8,15 @@ import generateInstructions from '../../../skills/xlsform/generate-instructions. // runs "language: informal" still produced "Sie", and "demographics: age" // made the model write its own age question. const SIGNATURE = - 'researchQuestions:string "numbered; cover every one and tag each question with the numbers it serves", targetGroup?:string, useOfResults?:string, furtherNotes?:string "free-form guidance from the user: things to keep short, terms to avoid, topics to focus on", formOfAddress:string "du or Sie: how every question addresses respondents", surveyLanguage:string "de or en: language of every question, label, hint, title and reasoning", demographicsAddedSeparately?:string "already in the questionnaire; do not ask about these", questionBank?:string "qwac bank questions that matched a keyword search, one per line: id | study | concept | question | answer type" -> title:string "short questionnaire title in the language of the questions", reasoning:string, generatedQuestions:json'; + 'researchQuestions:string "numbered; cover every one and tag each question with the numbers it serves", targetGroup?:string, useOfResults?:string, furtherNotes?:string "free-form guidance from the user: things to keep short, terms to avoid, topics to focus on", formOfAddress:string "du, Sie (German) or you (English): how every question addresses respondents", surveyLanguage:string "de or en: language of every question, label, hint, title and reasoning", demographicsAddedSeparately?:string "already in the questionnaire; do not ask about these", questionBank?:string "qwac bank questions that matched a keyword search, one per line: id | study | concept | question | answer type" -> title:string "short questionnaire title in the language of the questions", reasoning:string, generatedQuestions:json'; -/** "du" or "Sie", as the prompt and the model expect it. */ -export function formOfAddress(language: AgentInput['language']): string { +/** "du" or "Sie" for German, "you" for English (no formal/informal split in + * English), as the prompt and the model expect it. */ +export function formOfAddress( + language: AgentInput['language'], + surveyLanguage: AgentInput['surveyLanguage'] = 'de' +): string { + if (surveyLanguage === 'en') return 'you'; return language === 'informal' ? 'du' : 'Sie'; } @@ -45,7 +50,7 @@ export class SurveyGeneratorAgent { targetGroup: input.targetGroup, useOfResults: input.useOfResults, furtherNotes: input.furtherNotes, - formOfAddress: formOfAddress(input.language), + formOfAddress: formOfAddress(input.language, input.surveyLanguage), surveyLanguage: input.surveyLanguage, demographicsAddedSeparately: input.selectedDemographics.join(', ') || undefined, questionBank: bankHits.length ? renderBankHits(bankHits) : undefined diff --git a/src/lib/i18n.ts b/src/lib/i18n.ts index 43b8a81..e36d77a 100644 --- a/src/lib/i18n.ts +++ b/src/lib/i18n.ts @@ -70,6 +70,7 @@ const translations: Record> = { 'wizard.languageLabel': 'Language & Tone', 'wizard.formal': 'Formal (Sie)', 'wizard.informal': 'Informal (Du)', + 'wizard.formHintEnglish': 'Form of address only applies to German.', 'wizard.surveyLanguageLabel': 'Survey language', 'wizard.surveyLanguageGerman': 'German', 'wizard.surveyLanguageEnglish': 'English', @@ -231,6 +232,7 @@ const translations: Record> = { 'wizard.languageLabel': 'Sprache & Tonalität', 'wizard.formal': 'Förmlich (Sie)', 'wizard.informal': 'Informell (Du)', + 'wizard.formHintEnglish': 'Die Anrede gilt nur für deutsche Umfragen.', 'wizard.surveyLanguageLabel': 'Sprache der Umfrage', 'wizard.surveyLanguageGerman': 'Deutsch', 'wizard.surveyLanguageEnglish': 'Englisch', diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index f7d37f8..8e7b0c8 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -352,10 +352,14 @@
{$t('wizard.languageLabel')} + {#if surveyLanguage === 'en'} +

{$t('wizard.formHintEnglish')}

+ {/if}