Repository navigation
Word organizer refusals through one helper - #998
Merged
Merged
Conversation
The system prompt gains a LANGUAGE rule: the title, description, field
labels, choices, slot text and whatOptions are written in the language the
description is written in, unless it asks for another, with names, places
and titles kept exactly as written and refs kept to a-z and 0-9. The
"in the prompt's language" on the whatOptions lines folds into it.
A description too short or too mixed to tell is drafted in {{LANGUAGE}},
which the route fills with the organizer's language for participants
(getOrganizerLocale), named in English. buildMessages and the follow-up
builders take it in a required PromptContext, so a caller that leaves it
out fails the type check; every call the route makes, retries included,
passes it. languageName can now name a language in another one.
The golden prompt is pinned with English as the fallback. Four new eval
cases (ev_042 to ev_045) and two checks, language_must_be and
draft_must_contain_exactly, score the rule; a case can give the
organizer's language, and eval:mcp skips such a case. The evals have not
been run. The privacy page says the language's name goes to the AI
provider with the description.
Part of #635.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
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
With TRANSLATION_SCREENSHOTS=1, which the new `pnpm translation:screenshots` sets, the Swedish e2e spec saves a screenshot of each participant screen and state it checks, at desktop width and (in a Chromium phone project the flag adds) at 390 pixels, and the email tests write each sample email's HTML and plain text, in English and Swedish. Everything goes to the gitignored translation-review/. Without the flag nothing is written, so CI is unchanged. So the screenshots cover every participant screen, the Swedish spec now also opens the sign-up sheet on a dated and an undated slot, walks every refusal the sheet words (answers stood in for), signs up without an email, shows a returning participant their spot, and visits a draft, an archived and a closed Swedish signup, the closed one's edit page and a spot cancelled before it closed. The seed gains the closed and archived signups. The Swedish email samples take their dates from formatSlotDate, so they print "lör 5 sep." as the app does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
docs/translating.md explains how the catalogs work, how to write ICU plurals, selects and tags (with examples from the catalogs), what the catalog check catches and what it misses, how CATALOG_LOCALES and SHIPPED decide when a language can be offered, how to add a language, and how translations are made and reviewed by machine. It ends with the Swedish glossary the stack used, and the open questions for #639, including where the Swedish disagrees with itself. The translate skill follows #637's four steps: list missing and stale messages (scripts/to-translate.mjs), translate, run the checks, have a different model review the result from the screenshots and email HTML (references/review.md), then fix and list every finding in the PR. CLAUDE.md and CONTRIBUTING.md say to change English only in en.json and run the skill for each shipped language in the same PR, and CLAUDE.md's test layout notes E2E_UNSHIPPED_LOCALES for a reused pnpm dev. Part of #637. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
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
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
Each language now records the English each of its messages was translated from, in src/i18n/translated-from/<language>.json, outside src/messages/ because next-intl reads every JSON file there as a language. The catalog check compares it with en.json: a message whose English changed since (stale), or one the record lacks, fails a language shipped to an audience that reads it, as a missing message does, and is a warning otherwise. An entry for a message English or the translation no longer has fails in every language. The translate skill's to-translate.mjs lists stale messages from the record, with the English they were translated from, instead of comparing with a git base, and mark-translated.mjs writes the record for messages a translator has just translated or checked. The record for sv.json is generated from today's en.json; none of its messages had English that changed after the Swedish was written. 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
The translate skill's reviewer prompt said an email's subject is the first line of the `.txt` that `TRANSLATION_SCREENSHOTS=1` writes. That line is the "OpenSignup" header: the subject was only in the HTML's hidden preview. - Each sample in scripts/lib/email-samples.ts now carries its subject, made with the same function from src/email/subjects.ts that the email's `send*` function uses, and the email test writes it as a `Subject:` line at the top of each `.txt`. - An English `reminder-changed` sample, so the reviewer has the English to set beside `reminder-changed-sv`. - The reviewer prompt says where the subject is, which English email goes with which, that the sign-in email has no translation on purpose, and names the messages that show only in a tab title, a link preview, a screen reader's name or a file or share sheet. - The guide's "Adding a language" says typecheck points at the per-language test tables, and that `emails.test.tsx`'s list is Swedish only; three more open questions for #639 from the tophat; the skill says a separate review session has to get set up and make the screenshots first. 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
The first full pass over sv.json (#639): every note collected from the stack's tophats and reviews is decided, and the glossary's open questions are settled. - "din anmälan" for the participant's own sign-up everywhere, so an email no longer shows "Visa eller ändra din plats" under an organizer's "Plats:" field; "plats" stays for a number of spots. - No sentence ends on a slot's name, so a Swedish date like "tors 3 okt." no longer gives a double full stop (the signed-up bar, the sheet's saved line, the share text). - "pass" left out where a sentence can do without it; the change emails say "Tiden har ändrats". - Closed: "Anmälan är stängd" on the signup page, "Stängt för nya anmälningar" on the edit page, "Stängt" on a row. - "(utan {label})", "Klart", "Välj"/"du valde", "Lägg till i kalendern", "Integritetspolicy", "Antal platser" in emails, "Använd knappen ovan", "Dela inte mejlet med någon", shorter unsubscribe buttons, and the unsubscribe page's sentences reworded. English is unchanged, so the translated-from record is unchanged. Tests that typed the old Swedish now type the new; the label-fit spec also measures the closed Swedish signup with a remembered sign-up, so Stängt and Ändra are covered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
docs/translating.md conflicted only in the glossary's open questions: the two #929 added (the edit page's "Du är anmäld som", the draft page's "listan") are settled here with the rest, so the settled list takes their place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
The closed Swedish signup has no sign-up sheet, so the test isn't declared for it rather than declared and skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
From the in-context review of #931 (Fable): - the invalid unsubscribe link says "Öppna länken", not "den", which read as the list; - "högst", not the calque "upp till", for the edit page's spots line; - "pass" left out of four more messages that can do without it; - "dela inte länken med någon" for "keep it private"; - "Försök en gång till." after "igen"; - "För många försök på kort tid.", since "just nu" means "right now". The glossary records each, keeps "Cookies" on purpose, and notes the aria-label a noun-less "Stäng av dem" would want. Tooling notes from #929's and #930's reviews: - the catalog test's warning names the audiences, not shipping in general; - to-translate.mjs leaves a space after "recorded:"; - the guide says a rename must name the new key to mark-translated.mjs; - review.md puts the email's preview text just before <body>; - the English confirmation sample prints 9:00 AM, as the app does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
…guage save Two flash questions for #639, each shown right after the save that prompts it, from what's stored, so nothing records that it was asked: - The Settings tab, after "Signup language" saves a language that isn't the organizer's: "Make Svenska your language for new signups?" Yes saves it with updateOrganizerLocale. - Account Settings, after "Language for new signups" saves, when any of the organizer's open signups is in another language: "Use Svenska for your open signups too?" Yes puts them in it with the new setOpenSignupsLocale. setOpenSignupsLocale takes the organizer's own open signups in workspaces they can edit, locked through locks.ts, changes them in one update and writes each the signup.updated row a Settings-tab save writes, through the new recordActivities. Both questions render only once a second language has shipped to participants, so neither is reachable yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
The English says "No one new can sign up for this slot now." The
Swedish had lost "for this slot", so under the slot's name it read as
if the whole list had closed, and the line after it ("Ladda om sidan
...") seemed to contradict it. From the second independent review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
On a phone the question could open under the Share bar or below the screen, where only "Saved" showed. Yes now takes the focus as the question appears (autoFocus, no script), so the browser scrolls it into view above the bar, with room for the box's edge. A fragment on the save's address can't do it: Next drops it from a server action's redirect. No now comes back to the form that asked, which the router focuses, rather than to the top of the page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
With Yes focused, a second Enter or Space after Save, a held key, or on a short phone a double tap on Save, pressed Yes, which on account Settings switches every open signup. No now comes first and takes the focus, as Close signup's "Not yet" does, so those land on No. No is a button in a plain GET form back to the language choices, since only a form control takes autoFocus; it saves nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
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
Three tophat rounds found a new way for a question that appears after a save to go wrong on a phone: out of sight, an accidental Yes, and finally Delete signup under the finger. At the owner's decision both questions go. The Settings tab's "Signup language" is back to a plain save and "Saved". Account Settings gets a plain button under "Language for new signups", "Switch your 3 open signups to Svenska", shown while some of the organizer's open signups are in another language. It calls setOpenSignupsLocale with the organizer's language, worked out on the server, so the form sends nothing a forged one could change, and the page then says "Saved. 3 signups now use Svenska." in its place. A second press finds nothing to switch and stays put. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
SavedNotice lays its icon and text out as flex items, so a sentence passed as children, with the language's name in its own span, came apart with gaps around the name. The text is now one item. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
The organizer's language was worked out on every visit: their saved one, else the instance's DEFAULT_LOCALE, else the top language their browser asked for, else English. Now it's stored once, when Auth.js creates the account: the top Accept-Language language of the callback request (the magic link, the six-digit code or a sign-in provider), if it has shipped to participants, else nothing. Nothing reads the browser again: new signups, Magic Compose's fallback language and account Settings take the stored language, else DEFAULT_LOCALE, else English. - chooseOrganizerLocale, getOrganizerLocale and newSignupLocale lose the Accept-Language input, and `browser` leaves OrganizerLocaleSource and signup.created's localeSource. - newOrganizerLocale (pure, beside the header parser it moved under) picks a new account's language; nothing while only one language has shipped. - The adapter reads the header like the IP (request-context.ts), stores it on the new organizer and records it on workspace.created. - Privacy page, telemetry doc, CHANGELOG, README, .env.example, CLAUDE.md and the AI-assistant and translating guides say what now happens. While only English has shipped, nothing is stored, so nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
?switched=9999 made account Settings say 9999 signups had changed, even to an organizer with no open signups. The action now comes back with a fixed flag, switched=1, and the page counts the organizer's open signups from the read it already makes: "Saved. Your 4 open signups now use Svenska.", shown only once none is left in another language and only when there is at least one. openSignupsToSwitch says how many open signups there are as well as which to switch, from the same statement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Conflicts: - src/app/app/(chrome)/settings/page.tsx: kept #933's counts ({ open, toSwitch }, switched=1 as a flag) and this branch's removal of the browser step (no headers(), getOrganizerLocale(session, audience)). - CHANGELOG.md: kept both: this branch's #627 lines and #933's reworded #639 line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
The owner decided the open question on #936: at account creation, if the instance sets DEFAULT_LOCALE, nothing is stored and the account follows it. Otherwise the browser's top language is stored only if it has shipped to participants and isn't English, the fallback anyway; in every other case nothing is stored. So a stored language is always one the account wouldn't otherwise get, and an operator who sets or changes the default later moves every account with none. - newOrganizerLocale takes the instance default; the adapter passes instanceDefaultLocale(). The "one language shipped" guard goes: with English never stored, nothing can be stored then anyway. - docs/translating.md gains "An organizer's language", a table of every site default and browser, linked from the README. A test helper reads that table from the doc, and the unit and adapter db tests run every row, so the doc and the code can't drift apart. - Tests for an existing account (kept through later sign-ins under every default and browser) and for a stored language that leaves SHIPPED. - Privacy page, CHANGELOG, README, .env.example, CLAUDE.md, telemetry and AI-assistant docs say the new rule; "account's" takes a curly apostrophe. 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
src/app/login/page.tsx conflicted in its imports: main (through #961) added ipSubject to the rate-limit import, for the per-IP login code limit, and this branch added the signInLocale and getServerTranslator imports beside the same line. Kept both. The body merged on its own: the code limit keys on ipSubject(...) as on main, and the page's text comes from the catalog as on this branch. 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
scripts/lib/email-samples.ts (the pnpm email:dev and test samples) conflicted with #931 in two places, both kept: - imports: this branch's formatDuration, and #931's formatSlotTime beside formatSlotDate; - this branch's signIn(locale) sample, then #931's nineAm for the English confirmation's time. 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
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
docs/translating.md conflicted with #931 in two places, both kept: - Style: this branch's "A channel takes via" bullet, then #931's new bullets on buttons, emails and leaving out pass. - #931's "Settled" list replaces the old open questions; this branch's addition to the old item on "listan" (the organizer help's "listans" and the "Ny lista" button) is carried into settled item 10. 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
docs/translating.md conflicted: #931 (through #976) replaced the glossary's old open questions with a "Settled" list and an "Open questions" section. This branch had added a question 10 ("Too many sign-in requests") to the old list and #980 to its closing line. Kept #931's list and moved this branch's question, word for word, under "Open questions". 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
docs/translating.md and the translate skill's references/review.md conflicted where the earlier catch-ups placed #931's settled list and the open questions. This branch already carries #931's text with the joined stack's updates (the numbered open questions, the organizer's short forms, the sign-in email's line in review.md), so every conflicting hunk takes this branch's side; outside them both files are this branch's already. 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
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
Owner
Author
|
catch-up after #997: merges only, own diff unchanged, markers on 3539282 stand https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt Generated by Claude Code |
richshaw
pushed a commit
that referenced
this pull request
Nov 16, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
richshaw
pushed a commit
that referenced
this pull request
Nov 16, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
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.
Part of #619: the second simplification after the join, one helper for wording an organizer's refusal (its server half).
Merge after #997.
The stack
Phase 2 of the localization stack (#619): the second of the two simplifications, after the join fixes. Based on #997 (
claude/issue-619-one-locale-rule); review against that branch.Summary
Every organizer screen rendered on the server now words a refusal through one chain,
refusalText(t, error, own?), and passes only the lines that are its own. Before, Publish, Close and Reopen, Remove and Connected apps each wrote their own fallback chain, and each had to remember that a viewer'sforbiddengets the line every screen gives. Getting that special case wrong is how a viewer's Publish came to be refused in English after the join (fixed in #996). Now no screen can get it wrong:forbiddenreads the same everywhere, and a screen can't even pass a line for it (the type has no such key). Nothing anyone sees changes (evidence below).What changed
refusalText(t, error, own?)(src/lib/organizer-errors.ts). A viewer'sforbiddenalways gets the line for its code. Any other refusal gets the first of:details.reason;title_too_short);other;Its two-argument calls (New signup) are unchanged. A reason that isn't one of the screen's own keys (
toStringand the like) is ignored.refusalFromQuery(t, error, own?)takes the same lines and goes throughrefusalText. Anything in?error=that isn't a code still shows nothing.statusRefusalandremoveRefusalkeep their names and signatures. Each body is now just the screen's lines passed torefusalText. They stay functions because their caller is a'use server'file, which can't export them for tests, andtests/e2e/responses.spec.tsimportsremoveRefusal.disconnectRefusalis deleted, with its test. Connected apps now callsrefusalFromQuery(errors, error, { internal: errors('disconnectFailed') }). Its test cases moved toorganizer-errors.test.ts.organizer-errors.tssays it's server-only in its header: it importserrors.ts, which imports zod.Tests.
organizer-errors.test.tsgains the rule:forbiddenline doesn't compile (@ts-expect-error);ErrorReasonshares a name with anErrorCodeorother.Word every organizer refusal from the catalog, and check both halves launch together #996's stand-in test, which checks that every organizer refusal comes from the catalog, already covered every screen. Here it only points its Connected apps row at the page's new call.
CLAUDE.md (the
errors.tsentry): the server-rendered organizer screens go throughrefusalText/refusalFromQuery, each passing only its own lines, and a viewer'sforbiddenreads the same on all of them.No catalog changes (
en.json,sv.jsonanden.d.json.tsare untouched), no client code, and no CHANGELOG entry, since nothing visible changes.Helpers, before and after
refusalTexttitle_too_short, else the code's linerefusalFromQueryrefusalTextwith the screen's own linesstatusRefusalrefusalTextremoveRefusalrefusalTextdisconnectRefusalrefusalFromQuerysaveErrorMessage(Build tab)explainDraftFailure(Magic Compose)participantErrorCopycodeRefusal(sign-in)Nine helpers become eight. On the server, five separate fallback chains become one.
How I showed English is identical
Every refusal, old against new. A throwaway test (not committed) rendered each server screen at
3e2b590and at this head, through the real English and Swedish catalogs:?error=lines on account Settings, a signup's Settings tab and Connected apps;?error=pages: every code, and 12 values that aren't codes.That's 1,594 lines per language. Identical:
?error=value, on every page;ErrorReason's doc ties each to one code), on New signup, Remove and the?error=pages;forbidden,not_found, andconflictwithstatus_changedorno_slots.71 lines per language differ, and no service can send any of them:
title_too_short. They now give the title line every screen gives, where before they said "Couldn't publish. Try again." Those actions send no title, andpublishSignup,closeSignup,reopenSignupandgetSignupForOrganizernever return it.not_foundcarryingstatus_changed. Publish, Close and Reopen used to look at the code first; now the reason comes first. This also covers New signup'sforbiddenwithtitle_too_short, which now gets the viewer's line.othergiven as a reason, which isn't anErrorReason.Existing tests, unedited. These still pass without a single edit:
status-refusal.test.ts: every English line of Publish, Close and Reopen, a viewer's included;remove-refusal.test.ts: all of Remove's;organizer-reasons.test.ts: every reason's English on every screen.Client JavaScript. I built
3e2b590and this head in the same folder. Every file under.next/staticis byte-identical: only the build id's folder name differs. The budgets table is identical line for line.Size
9 files, +123 / −115, net +8:
Without comments and blank lines, the code goes from 181 lines to 172. The comments grow by the same 9, because the rule is written out once in
refusalText's doc comment.statusRefusalhalves (29 lines of code to 17), anddisconnect-refusal.tsis gone.Left out, and why
saveErrorMessageand Magic Compose'sexplainDraftFailure. Routing them through a shared function was measured at +193 B and +149 B gzipped, on pages with 133 B and 41 B of budget left. A client helper can't importisErrorCode, sinceerrors.tsbrings zod, so the shared function needs its own copy of the codes. Both already follow reason, then code, then a general line, and both are covered by the reasons table and the stand-in test.participantErrorCopyandcodeRefusal. The first words participant copy (participant.errors, with its own shape and inputs) and stays separate on purpose. The second returns a reason for the sign-in form, not words.forbidden. A screen could have been allowed one, with the shared line only as a default. I made the shared line a rule instead: the check comes first, and the lines' type has noforbiddenkey. No screen used one.edit-form.tsx's localrefusalText. That's a client file, and this PR changes no client code.Checks
On
3539282:pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test: pass (239 files, 3,405 passed, 1 expected fail).pnpm test:db: pass (47 files, 854 tests).pnpm build && pnpm budgets: pass, and the table matches3e2b590's line for line. No budget changes.organizer-language.spec.tsandorganizer-language-story.spec.ts, 31 passed.🤖 Generated with Claude Code
https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt