Repository navigation
Conversation
The draft now reports its language as a code. The route starts the new signup in it when it has shipped to participants (localeSource: content), else in the organizer's language as before, and in none while only English has shipped. The model's value is read leniently, cut to a bare two- or three-letter code, stripped before persistDraft and the response, and only compared with SHIPPED. When it hasn't shipped, signup.created records it as draftLanguage. The privacy page and docs/telemetry.md say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Tophat: passedRan d2f5938 locally on a production build (
What the model reported, English only (as shipped), and what was kept:
On base, every one of these saved too, with no For the owner: while only English ships, nothing an organizer or participant sees changes. Magic Compose looks and behaves the same, except that a questions reply that also names a language is now shown as questions instead of being treated as malformed. Two things differ out of sight: a Before merging: the evals ( Screenshots are in https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt. Generated by Claude Code |
richshaw
left a comment
There was a problem hiding this comment.
Review: changes needed (round 1)
The PR makes a Magic Compose draft report its language, starts the signup in that language when it has shipped, and records an unshipped one as draftLanguage on signup.created. I reviewed it against #927's head 4bfca33. The route's decision, the stripping and the fallbacks are right and well tested. One thing needs changing: what counts as a language code is looser than the docs and the privacy page say. The evals have not been run, and they must be before this merges, together with #927's run.
What I checked and found right:
- Draft arm only.
FullDraftSchema, and so MCPcreate_signup, has nolanguage. No odd value fails a draft. - A questions reply carrying
languagenow passes, with the key dropped. That fits #635 ("a questions reply carries none"): the parsed reply carries none. Before, it failed as malformed and the retry turned questions into a draft the organizer wasn't asked about. - Never stored as sent.
draftedSignupLocaleonly compares the value withSHIPPED.participant, returns that list's own entry ascontent, and returns null while only English has shipped. Every fallback goes throughnewSignupLocalewith its own source. - Stripped.
languageis taken off beforepersistDraftandbuildDraftPreview, and the route tests check both on every case. - Golden. The output shape has the
languagekey, and the four worked drafts (A, B, E, F) report"en". The questions examples don't. - Privacy page. The activity-log sentence is plain and matches the code, apart from the finding below. "Last updated" is 14 November 2026, today.
- Layers. The activity write stays inside
createSignup's transaction. There's no new column, and no client code changed.
Blocking (1):
src/lib/magic-compose/prompt.ts:176-180: the reader takes the letters before the first-or_of any text, and any two or three letters. Soengis recorded as an unshipped language for an English draft,swewon't start a Swedish signup once Swedish ships, a sentence startingsv-SE,reads assv, andzzzortea(from "Tea-party helpers") reach the log. That's againstdocs/telemetry.md, the CHANGELOG, the PR's "a sentence reads as no language" and the privacy page's "never any of the draft's words". The inline comment has a fix with no mapping table (Intl.Locale, thenIntl.DisplayNames).
Optional (3):
src/services/signups.ts:121:createSignupwrites whatever string it's given asdraftLanguage. Only the route calls it with one today. Checking the shape there too (two or three letters a-z) would keep the promise at the write itself, for any later caller.scripts/lib/eval-harness.ts: the evals don't score the reportedlanguage, as the PR says. A check that it equals the case's expected language, onev_042toev_045, would show whether a real model reports a clean code. That's the one thing neither the tests nor the tophat's stub model can show.src/app/(legal)/privacy/page.tsx:111: "the language AI drafting wrote it in" is fine. The owner may prefer it placed before "the app that created the signup", since the list otherwise runs in fallback order.
Earlier threads: none. Copilot answered that it couldn't review (quota).
Checks: CI is green on this SHA (lint-type-test, e2e). The tophat passed on this same SHA, so no runtime code has changed since. Locally I ran the odd values in the inline comment through MagicComposeDraftSchema on this head, and the suggested reader on Node 22.
Gate: owner, once this passes. It changes what's recorded about organizers, a legal page and what the AI is asked for, and its description asks for the evals to be run before merging.
https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Generated by Claude Code
The reader kept the letters before the first - or _ of any text, so an English draft reporting "eng" was recorded as an unshipped language, "swe" wouldn't start a Swedish signup once Swedish ships, and a sentence starting "sv-SE," or a title like "Tea-party helpers" reached the activity log. Now the whole value must be a well-formed language tag (Intl.Locale), and its language is kept only when it's two or three letters that CLDR names as a language (Intl.DisplayNames with fallback 'none'), and isn't one of ISO 639's codes for no single language (und, mis, mul, zxx). Intl.Locale gives the canonical code, so eng, swe and deu read as en, sv and de; zzz, the, Swedish, x-klingon, 12 and sentences read as none. createSignup also checks draftLanguage's shape (two or three letters a-z) at the write, and leaves anything else out of signup.created, so a later caller can't put other text in the log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Tophat: passed (round 2)Ran 15d274e locally on a production build (
What the model reported with English only (as shipped), and what
With Swedish faked as shipped, on 15d274e (stored language /
Optional, not a failure: a word that is also a language code CLDR names still counts, so For the owner: while only English ships, nothing an organizer or participant sees changes. Magic Compose looks and behaves as in round 1. Out of sight, a Before merging: the evals ( Screenshots are in https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt. Generated by Claude Code |
richshaw
left a comment
There was a problem hiding this comment.
Review: passed (round 2)
The PR makes a Magic Compose draft report its language, starts the signup in that language when it has shipped, and records an unshipped one as draftLanguage on signup.created. I reviewed the whole PR against #927's head 4bfca33, and 15d274e against round 1. Round 1's one blocking item is fixed as asked, and the docs now say what the code keeps. The evals have not been run, and they must be before this merges, together with #927's run.
What I checked in 15d274e:
- The reader (
src/lib/magic-compose/prompt.ts:194-207) reads the whole value as a language tag and keeps only a code CLDR names. I ran about 60 values throughMagicComposeDraftSchemaundertsxon this head.eng,swe,deuandnorgiveen,sv,deandno.zzz,the,qaa,Swedish,hello,none,null,n/a,en,sv, both sentences from round 1 andTea-party helpersgive nothing. So dound,mis,mulandzxx, with a region or script after them too (und-SE,zxx-Latn). Dropping those four was a good addition: CLDR names two of them. Nothing fails a draft, including a 200,000-character string (1 ms) and one with a null byte. - Runtimes.
LANGUAGE_NAMESis built once at module load from English names, which every ICU build of Node carries, so it can't throw at import. CI and this container run Node v22.23.4 (ICU 78.3, CLDR 48), and the production image isnode:22-alpine. A self-hoster's Node with an older CLDR could name a few rare languages fewer, which only means a rare code goes unrecorded. The tests pin common ones (sv,de,fil,zh) andzzzandthe. - The write (
src/services/signups.ts:277).createSignupaddsdraftLanguageonly whenisLanguageCodepasses, and otherwise creates the signup without it. The route's own caller always passes a clean code, so no create changes. - Tests fail without the fix. Putting back the old reader fails 12 tests in
prompt.test.tsand 11 inroute.db.test.ts. WritingdraftLanguagewithout the shape check fails 9 insignups.db.test.ts. I ran each. - Docs. The code comment,
docs/telemetry.md, the CHANGELOG entry and the PR's "What counts as a code" each say the same thing, and it matches what the probe showed. The privacy sentence ("that language's short code … never any of the draft's words") is true now: what's stored is CLDR's code for the language, never text copied from the reply. - Rest of the PR. Unchanged since round 1 apart from comments: the route's decision, the stripping before
persistDraftand the preview, the questions arm, the golden, and the activity write insidecreateSignup's transaction.
Blocking (0)
Optional (2):
src/lib/magic-compose/prompt.ts:194: a value that is one bare word and also a language's code is kept:new(Newari),no,na(Nauru),no-ideaasno. I'd leave it. Only a code is stored, the model has to put that word alone in a field that asks for a code, and a list of English words to refuse would be a table of ours that goes stale. The cost is a little noise in the count, andnostarting a signup in Norwegian if Norwegian ever ships.scripts/lib/eval-harness.ts: carried over from round 1 and left on purpose, since it can't be run here. When the evals are next run, a check that the reportedlanguageequals the case's expected language onev_042toev_045would show whether a real model reports a clean code.
Earlier threads: all resolved (round 1's one thread, on prompt.ts).
Checks: CI is green on this SHA (lint-type-test, e2e). The round-2 tophat passed on this same SHA, so no runtime code has changed since. Locally on Node v22.23.4: pnpm test src/lib/magic-compose src/i18n (22 files, 535 passed, 1 expected fail), pnpm test:db on the Magic Compose route and signups.db.test.ts (3 files, 225 passed), the probe above, and the two revert checks.
Gate: owner. It changes what's recorded about organizers, a legal page and what the AI is asked for, and its description asks for the evals (pnpm eval:magic-compose, pnpm eval:mcp) to be run before merging. Worth a look: the privacy page's activity-log paragraph, the signup.created row in docs/telemetry.md, and the tophat's two tables of what each reported value records.
https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Generated by Claude Code
Brings in #928's address round (the reported-language reader, the shape check at createSignup's write, and the draftLanguage wording in docs/telemetry.md and the CHANGELOG), so this PR stays on top of #928. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
|
Closing without merging, at the owner's decision: a Magic Compose signup takes the organizer's language, like any other new signup, not the language the AI reports for its description. The reasons are simplicity and nothing hidden: an organizer can always see and change a signup's language in its Settings tab.
https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt Generated by Claude Code |
The owner decided a Magic Compose signup takes the organizer's language, like any other new signup, rather than the language the AI reports for its description. #928 is closed without merging; this restores every file it changed to #927's version, so this branch can sit on #927's directly. #927's prompt rule, which writes the draft's own text in the description's language, stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Fixes #635. This is its second part: #927 did the prompt, and this does the draft's reported language, the route's decision,
contentas alocaleSource,draftLanguagetelemetry and its privacy line.Merge after #927.
The stack
PR 35 of the localization stack (#619). Based on #927 (
claude/issue-635-prompt-language); review against that branch.The problem
Since #927 a draft is written in its description's language, but the new signup still starts in the organizer's language (#905), which until they save one is a guess from their browser. So a Swede with an English-set phone who types a Swedish description would get Swedish content on a signup whose pages and emails are English, once Swedish ships.
The fix
src/lib/magic-compose/prompt.ts). The prompt's output shape gains"language": "<code of the language the draft is written in, like en, sv or de>", and the four worked drafts (A, B, E, F) end with"language": "en", so the examples match the shape they teach. The golden is the new render.MagicComposeDraftSchema's draft arm readslanguagethroughReportedLanguageSchema: the whole string, trimmed and with_read as-, must be a well-formed language tag (Intl.Locale), and its language is kept only when it's two or three letters a-z that CLDR names as a language (Intl.DisplayNameswithfallback: 'none') and not one of ISO 639's codes for no single language (und,mis,mul,zxx). Sosv-SE,SVandsv_SEgivesv, andeng,sweanddeugiveen,svandde. Anything else (a name likeSwedish, a sentence,zzz, a number, a list) reads as no language, and the draft still goes through.FullDraftSchema, which MCPcreate_signupalso takes, is unchanged.QuestionsSchemais strict, so a questions reply with alanguagekey would have failed as malformed and, on a first call, set off the retry. It now takes the key and drops it, and still refuses questions mixed with a draft.persistDraft. The route takeslanguageoff the draft beforepersistDraftandbuildDraftPreview, so it reaches neither the signup nor the response's draft.draftedSignupLocale(reported, session, acceptLanguage)insrc/i18n/organizer.ts: the reported language when it's inSHIPPED.participant, sourcecontent; otherwise Start new signups in their organizer's language, once there's a choice #905'snewSignupLocale(the organizer's saved language, the instance default, their browser, English). It returns null while only English has shipped, likenewSignupLocale, so nothing is stored today. The model's value is only compared with the list.SignupLocaleSource(src/i18n/organizer-locale.ts) gainscontent.draftLanguageonsignup.created. When the reported code isn't inSHIPPED.participant, the route passes it throughpersistDrafttocreateSignup(a newdraftLanguageoption on both), which adds it to the payload only when it's two or three letters a-z (isLanguageCodeinsrc/i18n/organizer-locale.ts), so no caller can put other text in the log. Only the code is recorded, never the model's text. It's recorded while only English has shipped too (that's the point: which languages come after Swedish), and never for a shipped language or a missing or unreadable one.docs/telemetry.md'ssignup.createdrow documentscontentanddraftLanguage(prettier re-padded the table). The evals README's draft shape gainslanguage. CHANGELOG: A signup drafted by Magic Compose can start in a different language from its draft #635's entry under Changed replaces "The draft doesn't decide the new signup's own language yet" with what it does now.Decisions the issue didn't make
language, read as nothing, rather than failing (above). The prompt doesn't ask for it there."en". Without it the examples would teach a draft without the key the shape asks for.und,mis,mulorzxx. Three letters keep languages with no two-letter code (fil), and a three-letter code for a language with a two-letter one gives that one (eng,swe,deugiveen,sv,de), with no table of ours. A name, a sentence (even one startingsv-SE,), a private-use tag, digits and letters CLDR doesn't name (zzz,the) give none. A well-formed tag with a real language and odd subtags after it still counts (no-ideagivesno). Changed after the first review, which found the earlier cut-at-the-first-hyphen reader kepteng,zzzand the start of a sentence.draftLanguagesits besidelocaleonce a second language ships: a German draft by a Swedish organizer recordslocale: sv,localeSource: setting,draftLanguage: de.Where #635 was out of date
newSignupLocale, notgetOrganizerLocale()directly, andSignupLocaleSourcenow lives insrc/i18n/organizer-locale.ts.QuestionsSchemais strict, so "a questions reply carries none" needed the change above to hold when a model adds the key anyway.Before merging
The evals have not been run.
pnpm eval:magic-composeandpnpm eval:mcpneed theLLM_*settings, which this session doesn't have. The golden changed again here (the output-shape line and the four worked drafts), so run them before merging, together with #927's run. The evals don't score the reportedlanguageitself; the route's tests do. The first review suggested a check that it equals eachlanguagecase's expected language (ev_042toev_045), which would show whether a real model reports a clean code; I've left it for whoever runs the evals next, since it can't be run here.Tests
prompt.test.ts: the output shape asks for the code, and each worked draft reportsen(the questions examples don't); the draft arm readssv,en,de,fil,sv-SE,sv_SE,SV,zh-Hant-TW,en_GB,de,eng,swe,deuandSWE-seas their codes, and reads 24 odd values (missing, null,Swedish,svenska,e,swed, empty,x-klingon,sv; and more, a sentence, a sentence startingsv-SE,,it-depends on the slot,Tea-party helpers,zzz,the,und,mul,zxx,12,sä, a number, a list, an object,true) as none while still taking the draft;FullDraftSchemahas nolanguage; a questions reply or refusal carrying one parses and carries none; questions mixed with a draft still fail.organizer.test.ts:draftedSignupLocaleis null while only English has shipped; with Swedish shipped, the draft'ssvorenwins over the organizer's ascontent;deor none falls back to each organizer step; it checks the participant list, not the organizer one.route.db.test.ts(throughPOST, with a watched realpersistDraft): every case checkspersistDraftgot nolanguageand the response's draft has exactly title, description, fields and slots. While only English has shipped: nothing stored or recorded aslocaleforen,sv,deor none;draftLanguagerecorded assv,sv,sv,de,de,fil,sv,deforsv,sv-SE,SV,de,de_AT,fil,swe,deu; none foren,en-GB,eng, missing,Swedish, a code with text after it, a sentence startingsv-SE,,Tea-party helpers,zzz,the,x-klingon,12, a number or an object, and none of their words in the payload. With Swedish shipped viaship():sv,sv-SE,SV,swestart it in Swedish ascontentover an English organizer, with nodraftLanguage;enandengstart it in English ascontentover a Swedish one, with nodraftLanguage;de-DEfalls back to the saved language and recordsdraftLanguage: de; missing,Svenska,sv, mostly, a sentence startingsv-SE,,zzzand a number fall back to the browser;defrom a German browser falls back to English asdefault.route.questions.db.test.ts: a questions reply withlanguageis shown in one call, without it; a refusal with one is still a refusal.signups.db.test.ts:createSignuprecords a givendraftLanguagewith or without a stored language, none when not given, and none for 9 values that aren't two or three letters a-z (Swedish,sv-SE,SV,e,swed,sä,tea party,sv; and more, empty), while still creating the signup.persistDraft(24 route tests fail), ignoring the draft's language (4), removing the English-only guard for a shipped draft language (1), recordingdraftLanguageeven when shipped (5), recording the model's value without the cut (11), sending the unstripped draft to a preview that spreads it (17), and removing the questions arm'slanguagekey (1 unit test). After the review: putting back the cut-at-the-first-hyphen reader (12 unit tests, 11 route tests) and writingdraftLanguagewithout the shape check (9createSignuptests).Run and passed on this head (
15d274e):pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test(212 files, 3009 passed, 1 expected fail)pnpm test:db(43 files, 836 tests)pnpm build && pnpm budgets: every page under budget; no built client chunk contains the new codetsx(the worker's and the evals' runner): the same results for every value above.🤖 Generated with Claude Code
https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt