Commit Graph
4 Commits
Author SHA1 Message Date
CatoandClaude Opus 5 faf5370225 feat(voice): Heidi can be heard, and can hear you — with the gate that has to come with it (#70)
* feat(listening): where you can actually hear Zurich German, as a register

The recordings §9 waits on do not exist yet, and the largest source of
dialect exposure in the world does: the media the Swiss already make for
themselves. Pointing at it needs no corpus and no licence.

What makes this more than a list of Swiss channels is the variety label on
every row. Switzerland is diglossic and Swiss media splits along that seam
in a way nobody tells a learner — the evening bulletin is read in Standard
German and the magazine after it is in dialect. Someone sent to Tagesschau
to "practise Swiss German" gets an hour of the German they already have,
concludes this is easy, and is no closer to the lunch table. That is the
same lemons problem §6 built the variety gate for, one level up: the
learner cannot audit the label, because not being able to tell the two
apart by ear is why they are here.

So `basis` is required on every row and `listened` is claimed nowhere,
because nobody here has sat down with these forty-odd programmes and
written down what they heard. A test fails the moment a row claims it, so
the day somebody does that afternoon's work, the page copy has to change
with it rather than quietly keeping the old sentence.

No difficulty number anywhere: "3 out of 5 chillis" is the false precision
§8 forbids. What is written down is observable — how many voices at once,
read or spontaneous, whether publisher subtitles exist — and demand() in
flow.ts derives an ordering from it, so an argument about the ordering is
an argument about four weights in one place.

Films and series link to a page ABOUT them rather than a play button:
streaming rights to Swiss films move every few months, and a register that
rots is worse than one that admits what it can promise. Noticeable as a
group, and worth a learner knowing: the famous Swiss films are mostly
BERNESE, so working through them gives a Zurich learner an ear for the
wrong dialect.

Every url was fetched and its page title checked against the name. The
sweep has three verdicts, not two — a Cloudflare challenge is not a dead
link, and only GONE fails the run. It caught two things worth keeping:
youtube.com/@srf3 answers 200 and is called SRF Unterhaltung, and its own
normaliser called TeleZüri a mismatch because it decomposed the umlaut to
a bare `u` where the publisher writes `ue`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(voice): the spoken channel, and the variety gate that has to come with it

Speaking and listening are the half of this language nobody can practise
alone, and the half the product has never had. This is the layer under it.

THE GATE APPLIES TO SOUND, and that is the whole design. §6 built a
deterministic check over generated TEXT because a model asked for Zurich
German returns Bernese fluently and the learner cannot tell. Every word of
that survives being read aloud and gets worse, because speech is gone the
moment it is said.

And the failure is already on our own record: §7 says most synthesis sold
as "Swiss German" is Swiss STANDARD German, the written language read
aloud in a Swiss accent. `de-CH` on a voice is the accent, not the
dialect. So `lib/voice/variety.ts` has no code path that returns
"dialect" — not an omission to be filled in by widening a condition later,
but the claim it exists to refuse. A test feeds it voices named
"Züritüütsch" and "Schweizerdeutsch Mundart" and asserts it is not fooled.
The consequence is the point: every control that speaks can say what it is
speaking, and does.

CORRECTION IS A SETTING WITH THREE RULES ABOVE IT. Spelling is never
corrected, because Zurich German has no standard orthography and enforcing
one would be inventing an authority. Pronunciation is never scored, and
that is structural rather than principled — this module takes no audio, no
confidence and no alignment, so a number would have to be invented.

And the one that is easy to get wrong and silently ruins the feature: a
transcript's forms belong to the machine, not the speaker. Swiss German
recognition writes Standard German whatever was said, so running the gate
over a transcript flags the recogniser and bills it to the learner — they
would be corrected, in detail, for saying something correctly. So speech
is never corrected for its variety at any level, and the three silences
(you turned this off / this cannot be judged / you made no mistakes) are
distinguishable rather than collapsed into a blank space.

That leaves a real gap and the copy names it in seven languages: Heidi
cannot tell you whether your accent is right. Nothing can, reliably. What
she can do is understand you and answer.

Also /listen, which renders the register — the diglossia warning above the
list, because a reader who scrolls to the links and picks the name they
recognise picks the Tagesschau.

The gsw copy passes Heidi's own dialect gate, and the German copy had to
learn to name the sharp S without typing it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(voice): Heidi speaks, and says what she is speaking with

A speak button beside every copy button — on the dialect line and on each
suggestion, which are the lines a learner has to produce and the ones
"what does this sound like" was unanswerable for.

The claim rides along in the flow rather than in a tooltip: phones have no
hover, screen readers announce it last, and the whole point is that the
learner cannot hear the difference between a Swiss Standard German voice
and the dialect they came for. On a dialect line the caveat is stronger,
and `dialect` is a prop rather than an inference — a Swiss Standard German
suggestion read by a Standard German voice needs no warning, and attaching
one anyway would train people to ignore it on the line that does need it.

Auto-speak is seeded on mount. The obvious version speaks whenever the
last message is Heidi's, and then opening a saved conversation reads the
last thing she said three days ago at somebody who came back to look one
word up. Only a message that ARRIVES is spoken, and only the prose — never
the dialect line, which is something to ask for deliberately.

Settings carries both the voice and the correction level, because both are
decisions about how you want to be treated rather than about this message.
What the device can actually speak is shown from the same function the
audio will come from, so the page cannot promise a voice the speaker does
not have. And the limit is stated beside the setting rather than
discovered: somebody turning corrections up is exactly the person about to
assume the highest setting also judges their accent.

The React Compiler rejected the ref-assignment-during-render idiom, which
was right: a render that gets thrown away would still have changed it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs: the spoken channel, in the definition, the register and the record

HEIDI.md §1 said what Heidi is without mentioning that the language is
one people HEAR. It has no standard orthography, the lunch table that
prompted this product is audio, and a learner who can only read Zurich
German has solved a version of the problem that does not occur. So the
spoken channel is named as the subject, arrived at late, rather than as a
feature tier — with the one-sentence honest summary attached: Heidi can
speak to you and understand you speaking; she cannot tell you whether you
sound right, and neither can anything else.

§6 gains the sound gate, which is stricter than the text one because
written text can be stared at and looked up while speech is gone the
moment it is said. §8 gains five new refusals, each of which was a
plausible sentence somebody could have shipped this week: that Heidi
speaks Zurich German, that she corrects pronunciation, that a transcript's
forms are the speaker's, that a machine reading dialect spelling is a
model to imitate, and that a Swiss channel is a dialect channel.

§9 records both builds and gives "next" three concrete steps in cost
order. The cheapest is the best: listening to the register and flipping
`basis` from `format` to `listened` needs no corpus, no licence and no
model, and turns forty careful inferences into forty facts.

The site's own roadmap said the product handles text, in seven languages,
which stopped being true today. The vision's closing line now carries the
spoken half too — every language this method could travel to is heard far
more often than it is written, and for every one of them there is media
nobody has sorted into dialect and standard.

And a CHANGELOG, which did not exist. HEIDI.md is the present tense and
must never contradict itself; a changelog is the past tense, which is the
only place that can say a thing used to be otherwise. Derived from the
merge history rather than written from memory, so the entries about
dictation failing five separate times in September are the record rather
than a confession.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs(voice): name the seam between the two correction surfaces

#69 landed a speaking take while this branch was open, and it decides
what may be corrected too. The two are not a duplication and collapsing
them would break one of them, so both files now say why.

`feedback.ts` judges a spoken take the learner WROTE DOWN and keeps only
`foreign` findings, because an `unattested` finding is orthographic and
there is no way to say a `ß`. `correction.ts` judges typed text, where
orthography is exactly what the learner produced and `unattested` is the
most certain judgement available. Same gate, two surfaces, two defensible
mappings.

The third input is named in a comment rather than added as a value:
speech the learner transcribes themselves is neither of this module's
cases, and routing it to `spoken` would silence the one surface where a
spoken take can honestly be commented on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 07:15:29 -07:00
CatoandClaude Opus 5 92b023af19 feat: speaking rounds, and a take that is measured rather than scored (#69)
* feat(speaking): rounds people propose, and a take that is measured rather than scored

Study groups were a thread with more than one human in it. This is the same
social object with the medium changed, which is the half a diglossic variety
otherwise gives away for free.

WHAT IS HERE

Webinars (one voice, an audience) and circles (everyone in turn, eight max),
on topics proposed by the people who would come. "Regularly" is a field, which
made this a time-zone problem rather than a scheduling one: a round is an
absolute instant and a repeat is a wall-clock promise, and those disagree twice
a year. Adding seven days of milliseconds to a Tuesday in March produces a
Tuesday at 20:00 and an empty room, so the recurrence is computed in the zone's
calendar and the tests cross both Swiss changeovers in both directions.
Sittings are computed, never stored.

Heidi does not carry the meeting: `meetingUrl` is an https room the host
already has, and https only, because that string is rendered as a link for
every attendee and accepting the scheme as given would accept `javascript:`.

WHAT THE EVALUATION REFUSES TO DO

The obvious build for "AI evaluates your speaking" is a pronunciation score.
The overclaim register bans it by name, and no system transcribes Zurich German
reliably — the state of the art translates the dialect into Standard German on
the way, which is the exact information a learner needs. A score on top of that
is a number with nothing underneath it, handed to the one person who cannot
check it.

So: the signal is measured in the browser (durations, counts, mic clipping —
arithmetic over samples, no model, no ASR, and no speech rate because
syllables need a transcript); the learner writes down what they said, with the
reason on screen; and their own words go through the deterministic gate, then
one model suggestion over text they confirmed. Only `foreign` findings survive
— a `ß` is not something anybody pronounced, and flagging it would be
correcting spelling in a variety that has no standard spelling.

Two tests pin the ban: no field of the measurement reads as a rating, and no
speaking copy in any of the seven languages offers a score.

PRIVACY

The audio never leaves the page that recorded it and the takes are device-local
under `heidi.takes.v1` — no audio table, no upload endpoint for takes, no
transcript of anybody's speech. A table of how somebody sounds when they are
bad at a language is worse than a table of the words they looked up, and the
cheapest way to honour that is to never hold one.

Mobile first: one big record target, a live level so a dead microphone is
visible in the first second, single-column forms that pair up from `sm`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(speaking): the page now reads in the order its own lead promises

Four things found by looking at the running page rather than at the tests.

THE ORDER. The lead says "webinars and circles on topics you propose, and IN
BETWEEN practise out loud", and the page rendered practice first. The original
reasoning was real — practice is the half that works signed out, alone, with an
empty calendar above it — but it loses to a simpler test: read the lead, then
look at the page. A reader resolves that disagreement by deciding the page is
about something other than what it says it is about.

A HYDRATION MISMATCH. `recordingSupported()` reads `window`, so calling it in
the render body made the server draw the button disabled with "this browser
cannot record" underneath and the client draw it enabled. React threw the
server HTML away and said so in the console. It goes through `useClientValue`
now, the same primitive `useStorageReady` uses, with an optimistic server
value.

A ROUND IN PROGRESS FELL OFF THE LIST. "The next sitting at now" excludes one
that started five minutes ago, which is exactly when somebody running late
opens this page looking for the link — and for a weekly round it was worse than
vanishing, because the list would advertise next week while the thing was
happening. The question is asked from one duration ago now, and the answer
carries `live` so the row can say so. Computed server-side: a client-side
comparison is a hydration mismatch whose answer depends on the visitor's device
clock. Two regression tests.

AN UNCLICKABLE CALL TO ACTION. "Make a round of it" rendered as flat grey
caption text beside the interest count, reading as a button that was not one.

Also: `/de/speaking` joins the post-deploy smoke check, whose own rule is every
page a visitor can reach by name; and the third loop is written into the
canonical doc, ending in a room with other people rather than in a mark out of
ten.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(privacy): the voice recording is named on the page that enumerates flows

The privacy page landed in #68 while this branch was open, and it works by
listing every place data goes with the storage key beside it, so a reader can
open their own dev tools and check. Speaking rounds landed at the same time and
were not on it.

That omission is the worst one available. The page's whole value is being
exhaustive, and the flow it was missing is the voice recording — which §10
itself names among the most private things a person owns. A privacy page that
enumerates nine flows and silently skips the microphone is worse than one that
never claimed to be complete.

Two flows now:

  speakingTakes       device, `heidi.takes.v1`, leavesDevice: false.
                      The audio is decoded and measured in the page that
                      recorded it and then dropped. No audio table, no upload
                      endpoint for takes, no transcript of anybody's speech.
  speakingSuggestion  vendor, `/api/speaking/take`, the confirmed sentence only.
                      Never the audio, never stored — one request, answered and
                      forgotten, exactly like a signed-out chat.

The existing test that every named `heidi.*` key still appears in the code now
covers `heidi.takes.v1` too, so renaming it would fail the build rather than
turn the page's invitation into a dead end.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 06:51:48 -07:00
CatoandClaude Opus 5 2d2357ebe0 fix(middleware): a rewrite behind Caddy dialled TLS at an http socket (#55)
* fix(middleware): a rewrite behind Caddy dialled TLS at an http socket

Production 500'd for every signed-in visitor on the locale root. Signed-out
visitors were fine, which is why it shipped.

    Failed to proxy https://localhost:4025/de/portal
    EPROTO ... tls_validate_record_header: wrong version number

`request.nextUrl.clone()` inherits the EXTERNAL protocol behind the reverse
proxy, so the cloned URL reads `https://localhost:4025/...` while the app
itself listens on plain http at that port. Next does not recognise that origin
as its own, treats the rewrite as an external proxy target, and opens a TLS
connection to an http socket.

Nothing in the test suite could have caught it, and that is the part worth
recording rather than the one-line cause. The DECISION was extracted into a
pure, tested function precisely so it could be covered — and it was, including
the self-rewrite loop — but the decision was never wrong. The MECHANISM was,
and the mechanism only misbehaves with a real reverse proxy in front of it.
Neither CI nor `pnpm start` has one, and the branch only ran when a session
cookie was present, so a production build exercised in a browser was green too.

The rewrite goes. "Show a different page at the same address" is still the
right idea — it is a decision for the PAGE to make, where no URL is
reconstructed and no protocol is guessed. `lib/i18n/landing.ts` goes with it
rather than sitting unwired, which is the same defect as a health check nobody
calls.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FzYBD3sZroCAYeRgTYrpfT

* test(deploy): smoke the live site, signed in and signed out

A green deploy is not a working site, and this outage proved it in the most
expensive way available: 339 tests, lint, typecheck and a production build
exercised in a browser, all green, while the locale root returned 500 to every
signed-in visitor.

The thing that would have caught it takes one second:

    curl -H "Cookie: __Secure-authjs.session-token=x" /de   → 500

A cookie being PRESENT is enough. That is the whole trick, because the code
paths this class of bug lives in — routing, rewrites, redirects — branch on
the cookie long before anyone validates it.

So `scripts/smoke.sh` requests every page a visitor can reach by name, twice,
once each way round, and runs as a job after the deploy. A release that cannot
serve its own home page now turns the Deploy run red instead of waiting to be
noticed.

What the cookie does NOT prove, stated in the script so nobody mistakes it for
more than it is: it is not a real session. `auth()` rejects it and the page
renders signed-out. It exercises "is a session cookie present", not "is this
person authenticated". A genuinely authenticated end-to-end test needs a test
account and a real login flow, and is worth doing separately.

Also checks that `/` stays a 307 and not a 308 — caching the locale
negotiation as permanent would pin every later visitor to whoever asked first —
and reads `/api/health`'s schema verdict rather than its status code, since a
deploy that cannot use its own tables still answers 200 by design.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FzYBD3sZroCAYeRgTYrpfT

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 05:56:14 -07:00
CatoandClaude Opus 5 372558570e feat(design): a real map, a fluid type scale, and a composer you can reach (#22)
* feat(design): an actual map, a fluid type scale, and a phone that fits

Four things a user hits in the first ten seconds, three of them broken.

THE PICTURE. The site had one figure and it was a black blob crossed by a
red squiggle. Its own comment explained why: a real map of Switzerland
would be "a cartographic claim" and the patches were not where those
dialects are. The worry was right and the conclusion was backwards — the
answer to "an inaccurate map misleads" is an accurate map, not an abstract
one nobody can read. So: a real border (Natural Earth, generated by
scripts/build-region.mjs, not drawn until it looked Swiss), dialects as
POINTS rather than territories because isoglosses do not follow cantonal
borders, Zurich filled and the rest open rings — the same distinction the
gate enforces, in the same figure.

Still generated from the pack, which was the point of the old one. Nobody
opens a component to ship a Bern pack, and Lesya draws Ukraine by adding
one region file. The seam: a pack says WHERE a dialect is spoken (a fact
about the dialect); lib/geo says how to draw the world (a fact about maps).

THE PHONE. At 390px the headline ran off the right edge, because
`text-[2.75rem] sm:text-7xl lg:text-8xl` is three hand-picked sizes and two
guesses about what happens between them. clamp() removes the guess; one
token per role in globals.css, so the scale is decided once.

THE HEADER. brand · gear · Anmelden · DE · MENÜ — five controls in 390px,
none of them what anyone came for. The account controls move into the menu
sheet, leaving what must be one tap: what language this is, where else to go.

THE COMPOSER. Its placeholder was a full sentence, which also appeared as
the hero subtitle and again in the intro paragraph directly above it —
three times on one screen, and on a phone it wrapped the input into an
unreadable stub. Short visible placeholder, full sentence kept as the
accessible label. The send button's disabled state was the accent at 30%,
a pale pink that read as broken rather than inactive.

Tests: cities must land inside the outline and north must be up (a
projection that drifts from the generator puts Zurich in Lake Constance and
still renders); every planned dialect must have a place and vice versa (a
name in one list and not the other silently vanishes from the map).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FzYBD3sZroCAYeRgTYrpfT

* fix(chat): the composer was below the fold, and sticky over the intro

Three bugs found by opening the site on a 390px phone and reading it.

THE INPUT WAS LAST. The empty panel rendered a heading, a paragraph and
three examples, and only then the box you type in — about 700px down a
phone screen. Someone arrives with a message they cannot read; they had to
scroll past three examples of the problem to reach the thing that solves
it. Examples are a prompt for a visitor with nothing to paste. Someone who
has something should meet the box first, so the box comes first and the
examples sit under it.

THE COMPOSER COVERED THE INTRO. `sticky bottom-0` with nothing to scroll
pinned the input over the panel above it and cut the last line of the
intro in half. It is sticky only once a transcript exists — which is the
only time sticking means anything.

IDS COULD COLLIDE. Messages were keyed `local-${Date.now()}`, which is not
unique: a reply landing in the same millisecond as a send produces two
React keys that are equal, and React then reuses the wrong DOM node. A
counter cannot collide.

The last two surfaced because the React Compiler lint had been bailing out
of this component entirely — it reports the first problem it can see, and
each fix let it see one step further. The stale `attached.length` captured
in `accept`'s closure is the same story: downscaling is async, so a count
read before the await is already wrong by the time the write happens. Only
the count inside the updater is true.

Also moves the correspondences (Kind → Chind) directly under the chat.
It is the one thing on the page that teaches something in a single glance,
and it was six screens down, below the argument for why you should believe
us. The payoff should come before the argument.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FzYBD3sZroCAYeRgTYrpfT

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 10:52:52 -07:00