Repository navigation
feat: choose the language an instrument opens in - #1936
Open
thomasbeaudry wants to merge 9 commits into
Open
thomasbeaudry wants to merge 9 commits into
thomasbeaudry wants to merge 9 commits into
Conversation
Each card on Administer Instrument carries a Language dropdown where the instrument offers more than one, set to the interface language, so the clinician changes it in place and the instrument still starts on one click. Only the languages the instance has active are offered, and a card with no choice to make carries no dropdown. - Administering: the chosen language applies to the instrument only, interactive instruments included, so the application interface keeps its own language and a switch from inside the instrument no longer moves the interface with it. - Assigning: the create dialog asks for the language, and the assignment carries it on the link as ?lang=, which the gateway already honours, so the copied link, the QR code and the emailed link all open in the same language. The email language changes only the email text; a link created without a language still takes the email's. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…er asks for A link is created before anyone knows what its reader speaks, so most carry no language of their own. Until now one of those opened in the instance's first active language whatever the reader's browser asked for; it now negotiates Accept-Language and falls back to that first active language only when the browser asks for none the instance has. Resolved server-side, like the ?lang= it falls back from, so the server-rendered pass and the hydration pass agree rather than rendering one language and swapping. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ser by default The create dialog now offers the subject's browser language, which it starts on, beside one option per language the instrument offers. Choosing the default stores no language on the link, so the gateway reads the browser; choosing a language pins the link to it. Emailing no longer sets a language on a link that has none: with the browser default that is the common case, and setting it would override the subject's own browser from the sender's choice of email language. The email language now only ever changes the email text, and a confirmation asks before sending an email in a language the link does not open in. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…eader asks for A `?lang=` naming a language the instance no longer offers short-circuited the negotiation and rendered the first active language, so a link pinned to a language an administrator later turned off ignored the reader's browser entirely — while a link naming an unparseable language honoured it. Only an active requested language now settles the matter. The negotiated HTML also declares `Vary: Accept-Language`, without which a shared cache may serve one subject the language of another, and the suite pins `locale: 'en-US'` so an assertion on English copy no longer depends on the locale of the machine running it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The datahub's email form defaulted to the clinician's own interface language, so emailing an assignment pinned to another one warned about a mismatch every time rather than only when the two genuinely diverge. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…eached `allowedLanguages` is required where every caller already passed it, `pick` no longer returns a choice its caller discards, and `withLinkLanguage` is inlined at its one call site, which composes the link a line earlier and so can never hand it the existing query the helper existed to replace. Also waits out libui's `suspendWhileSubmitting` window in the remote-assignment tests: the link renders before the form clears its own submitting state, so a test ending on the link left that update to land after teardown. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…olve it The confirmation fired whenever the email's language differed from the link's, including when no template was authored in the link's language at all — where "Send anyway" was the only way through, on every send. It now asks only when the sender could have picked that language, which is when the mismatch is a choice rather than the only option. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
HTTP does not distinguish the case of a parameter name, so `fr;Q=0.1,en;Q=0.9` gave both tags the default quality and served French — the language the client least wanted. A quality the header names but that cannot be read is now taken as the default of 1, as the documented rule always said, rather than as 0, which the filter then dropped. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`InteractiveContent` took `language` and `onChangeLanguage` as an optional pair and fell back to the interface language, though both call sites pass what `useInstrumentLanguage` always returns; the absent variant had no caller but its own test. The dialog's `isCreateModalOpen && choice !== null` loses an operand that cannot be false, two `waitFor`s whose assertion never throws are plain assertions again, the pinned-locale comment moves beside the locale, and the administer spec starts its session through `getPageModel` like its siblings. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
thomasbeaudry
force-pushed
the
feat/administer-language
branch
from
November 20, 2026 20:52
6c3667d to
3509c78
Compare
|
This pull request was closed because its body does not meet
Fix the body with |
This branch has not been deployed
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.
A clinician can now choose which language an instrument opens in, at the moment they pick it, and a
remote assignment can be left for the subject's own browser to decide. Before this, both opened in
whatever language the clinician's own interface happened to be in, and a patient who read neither
had no way to change it.
Changes
interface language, and opens the instrument in the language chosen. A card for an instrument
with one language shows no dropdown.
instrument supports, plus "The subject's browser language", which is the default. Choosing a
language pins it onto the link as
?lang=; leaving the default creates a link with no language.Accept-Language, server-side, so the first paint is already in their language instead ofswapping after hydration. A link naming an active language still wins over the header.
?lang=naming a language the instance does not have active falls through to the header andthen to the first active language, rather than silently rendering the first active one.
Vary: Accept-Language.before sending when the email's language and the link's language differ — but only when a template
authored in the link's language exists, since otherwise the sender has nothing to resolve.
off cannot be chosen.
locale: 'en-US'; a test about browser negotiation opts into its own locale.Decisions
created before anyone knows what the subject reads, so the clinician's interface language is a
guess, and a wrong guess is pinned into the link for good. Defaulting to unset lets the subject's
own browser decide and keeps the clinician's explicit choice meaningful. The cost is that the
stored
urlfor most assignments carries no language, so nothing in the record says whichlanguage the subject will see.
sitting with the subject and is the one reading the screen. The two pages differ deliberately.
language does not rewrite the link, since the link may already have been copied, QR-coded or sent.
The mismatch is surfaced as a confirmation instead.
instrument's edition here; picking a stale edition by accident is a data-quality problem with no
obvious ceiling, so the API's existing behaviour — newest edition unless
allEditionsis askedfor — stands untouched.
Vary: Accept-Languagerather thanCache-Control: no-store. The pages stay cacheable; ashared cache simply has to key on the header the body now depends on.
Risks
lang, so it now opens in the languagethe subject's browser asks for rather than the instance's first active language. That is the
intended behaviour for such links, but it is a visible change for links already in the wild.
InteractiveContentnow requireslanguageandonChangeLanguage. It is not exported frompackages/react-core's barrel and both call sites already pass them, so nothing outside this repocan be broken by it.
Varycould serve one subject thelanguage of another. Nothing in this repo's Caddy config caches gateway HTML, so the exposure is
to an operator's own infrastructure.
Notes
The gateway negotiation was checked against a real browser locale rather than a crafted header: a
fr-CAcontext receives French in the server's firstresponse body, not after hydration, and a link naming
enstill arrives in English from that samecontext.
The language a subject actually sees is still not recorded on
InstrumentRecord; the record keepsonly the instrument and the data. Worth doing, and out of scope here.
Adversarial review
Reviewed at commit 3509c78. pnpm check: green.
Findings
languageOptions.localeis pinned is attached tofullyParallel, not to thelocaleit describes — move it above thechromiumproject entry that carrieslocale: 'en-US'.waitForsettles the form's submit cycle; it settles nothing, and the submit cycle it names is never entered, because both tests are validation failures that return beforesetIsSubmitting(true)— restore the plain assertion and drop the comment.??fallbacks it exists for, are reachable only from this component's own tests — makelanguageandonChangeLanguagerequired, delete the union and the fallbacks, and drop the test for the absent variant.open={isCreateModalOpen && choice !== null}adds a condition that can never be false while the dialog is open — restoreopen={isCreateModalOpen}and keep the inner{choice && …}guard.qdoes not match the code, and an RFC-legal uppercaseQ=is silently read as the strongest preference, sofr;Q=0.1,en;Q=0.9returns the least-wanted language — match the parameter case-insensitively and treat a matched-but-unreadable quality as 1, keepingq=0as the only drop.openAdministerWithSessionre-implements an existing spec helper and bypasses thegetPageModelfixture for no stated reason — takegetPageModeland reuse the existing shape.Vary: Accept-Languagedoes not deliver the property its test claims, because the same response is heuristically cacheable and carries the per-assignment bearer token — setCache-Control: no-storealongsideVaryand assert it.emailLanguage ?? linkLanguageis a fallback for a state in which the text is not shown, and it makes the sentence name one language twice if it ever is — give the dialog a non-nullableemailLanguageand render it only while confirming.Fixed
chromiumproject'suse, where the pinned locale is.expectcalls again; only the submitting helper keeps its explicit wait.??fallbacks are gone, the story holds a language, and the tests render through one helper that supplies the host's pair.open={isCreateModalOpen}, with the inner guard left as the only narrowing.q=.andQ=.getPageModel, so it authenticates and navigates the way the suite documents.emailLanguageand is rendered only while confirming.Declined
Varyis what the test claims it is: RFC 9111 §4.1 forbids a cache from reusing a stored response unless the selecting header fields match, so a language-wrong hit is impossible with the header and possible without it. The absence ofCache-Controlis unchanged from the base commit rather than introduced here, and the token-bearing page is served from a per-assignment URL, so a shared-cache hit requires already holding that subject's link. Tightening the gateway's cache directives is worth doing on its own terms, not as part of this change.Attestation
I, Claude Opus 5, attest that the review block above reports the adversarial review as it ran on the
commit named, with every finding it returned.
🤖 Generated with Claude Code