mirror of
https://github.com/bitbaum/heidi.git
synced 2026-12-03 15:19:16 +01:00
* fix(privacy): never show an email address as a person's public name Sign-up asks for no name, so requireActor's `name || email` made the email the display name of nearly every account. It was stored on speaking topics, rounds, attendance and group members, and the topics board is readable signed out: GET /api/speaking/topics returned the proposer's address. - publicName(): the chosen name, else a stable '#XXXX' handle from the actor id - migration 0011 writes the same handle over stored addresses (UPDATE only) - public topic/round lists return an account id only to its owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(auth): account mail in the reader's language The shared template is English only. Through accountkit's render slot, the verify / sign-in link / reset mails are written in the language of the page the link lands on (its callbackURL); locales without copy use German. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * fix(header): render the account control at request time in every build authEnabled is read at module load, so a build without BETTER_AUTH_SECRET prerendered every page with no sign-in control, and CI's layout audit measured a header narrower than production's. connection() + authStatus() make the header the same in every build; CI now starts with a throwaway secret so the audits see the real header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * fix(ui): one primary action on the home fold; dock off phone auth forms - 'Jetzt testen' jumps to the chat, which on desktop is the column beside it: shown on phones only, leaving one primary button in the desktop fold - the floating dock launcher covered the sign-in form's buttons at 390px; hidden on phone-sized account forms only (guarded list updated) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * fix(security): outbound fetches, feed parsing and upload limits - channels: every feed/redirect/audio/transcript fetch goes through publicFetch (ai-kit validateFetchTarget per hop, 8 MB body ceiling); a signed-in user could previously make the box fetch internal addresses - push: subscribe only accepts real browser push service endpoints - sweep: one channel that throws is recorded as failed instead of failing the whole hourly sweep forever; entity decoder no longer throws or emits NUL - a pasted transcript never replaces the publisher's/platform's - feeds write at most 200 newest items (Postgres parameter limit) - synced progress kept for at most 10 devices per learner - transcribe routes refuse a declared oversize body before parsing it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * chore(packages): chatkit 0.23, plan bindings, experience ceiling, proxy.ts - @bitbaum/chatkit ^0.23.0 (the registered release) - package-plan: bindings matched to the code (createAuthMailer in mail.ts, ChatApp in workspace.tsx); experience ceiling set at zero - the five dialect/transcript text boxes carry experience-exempt reasons: dictation would turn dialect into Standard German (HEIDI.md §6) or compete with the page's own recorder - middleware.ts -> proxy.ts (Next 16 deprecation) - drop the dead limitkit git allowBuilds entry (limitkit is on npm) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * docs(changelog): 2026-11-09 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(design): adopt @bitbaum/design-tokens faces and composition grammar The type stack asked for Helvetica Neue, which only Apple ships: Windows drew Arial and Android Roboto. Inter and IBM Plex Mono are now self-hosted from the package (app/fonts.ts, generated by design-tokens-next-fonts, latin, latin-ext and cyrillic), and composition.css is loaded. Heidi keeps its own palette, as the package README asks of a product with its own brand. Also the keyframes for the sitting celebration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(practice): ask what the learner needs Swiss German for 'Meine Situationen': a learner picks the situations they actually face, and every practise button (Today, the dock, the welcome-back card) draws from them through a new multi-scene scope (?scenes=a,b). One choice is the ordinary scene scope; none is everything. Device-only, declared on the privacy page. The signed-in home leads with it; the warm-up invite is a quieter line under it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(home): shorter first screen, welcome back, a finish worth reaching - home at 390px: 10,415px -> 7,270px; the personal moments stay without their paragraphs, society's moments move to /organisations - a returning signed-out learner gets their next step above the intro - the end of a sitting shows the day earned and the week filling (no score) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(voice): server voice when the device has no German voice Read-aloud only used the browser synthesiser, so most Windows/Linux machines said 'no voice'. /api/speak reads the line with a German Gemini voice (GEMINI_API_KEY, already on the box): generateContent on gemini-2.5-flash-preview-tts, then the interactions route on gemini-3.8-flash-lite-tts; PCM wrapped as WAV; rate-limited, 600 chars, small cache. The device's own voice is still tried first, the label stays 'german', and a failed server call reads exactly as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * fix(chat): 'sign in to keep it' keeps it without asking twice Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * docs(changelog): situations, voice, home Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(practice): choose your situations on /practice too A signed-out learner has no signed-in home, so /practice is where they say what they need Swiss German for. The tiles drop their decorative checkbox: at 390px it left 94px for «Treppenhaus» and «Вечернее беспокойство»; the fill and aria-pressed carry the state. responsive audit: 1386 renders, 0 overflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(practice): instant, unmistakable feedback on every answer The right answer used to turn black whether or not it was picked, and 'wrong' had no colour, so a learner had to read the bar to know. Now: the tapped option turns green with a tick or red with a cross (pop/shake, off with reduced motion), the right one is outlined green, and the verdict is a tinted strip with a varied word of encouragement. A right answer moves on by itself after 1.3s (countdown on 'Weiter'; 'Warum?' holds it); a wrong one keeps its explanation. A short vibration on phones. '3 in Folge' when true. New correct/incorrect colour roles in light and dark. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(practice): no two sittings alike orderSession takes a seeded random and uses it only where the order was arbitrary (the alphabetical tie-break between equally due, equally weak, equally fresh questions and kinds); every new sitting gets a fresh seed. Options, word banks and matching columns are laid out afresh each time a question is shown (present.ts), answers remapped. Same seed = same sitting, no seed = the old order; due and weak items still come first (tested). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(practice): build the sentence, 'Stimmt das?', and a recognise-then-produce ladder - build: the Zurich words of a line the learner says (3-9 words), shuffled with one stranger from the same scene, tapped into order, marked by the app (134 items). Production that is objectively checkable. - verify: a heard line with a meaning beside it, true or not, one tap; false meanings come from the same scene (275 items). - ladderOf: until a line is recognised reliably, recognition forms come first; afterwards production forms. A tie-break after schedule and pressure, never before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * docs(changelog): practice rebuilt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * style(practice): answer feedback in Heidi's own colours No green: it belonged to no other screen. The feedback roles now alias the palette: right is ink (the action colour, black / white in dark) with a tick; wrong is the flag red the theme reserves for errors, as an outline on the existing pale red tint rather than a red slab; the revealed answer is outlined in ink. The verdict strip is neutral grey or pale red; the end-of- sitting check and week cells are ink. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(practice): one measure of distance from German, and a level on every exercise lib/domain/vocabulary/distance.ts classifies a Zurich word against its German as same/close (incl. a dropped -ch/-n: au, no), rule (free once one of the pack's sound correspondences is applied: Chind, chaufe), far (nöd, öppis) or trap (the pack's mistakenFor: Estrich). The vocabulary page's 'guessable' now delegates to it. levels.ts gives every generated item a level (1 like German, 2 by a rule, 3 different) on source.level, server-side: 400 / 593 / 1964 of 2957. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(practice): skills and levels tracked; sittings move up a level as it holds - kinds/meta.ts: what each kind tests (understand, words, sounds, forms, articles, produce) and its rung, in one Record typed against the kinds; the ladder's private list of kind names is gone. - the learner model gains skills and levels axes (old records load); its axes are one MODEL_AXES list that observing, decoding and device sums read. - frontierOf: level 1 until it holds (>=12 answers, <=20% missed), then 2, then 3; stretch ranks after schedule, pressure and ladder. Skills and levels report; they do not add pressure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(home): 'Was sitzt' — answers by skill and by distance from German Right/missed counts per skill and per level, 'holds' on the same bar as the level frontier, and the level the learner is working at. Counts, not a score. Seven languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(listening): dialect podcasts get a labelled German rendering and questions Measured 2026-11-09: no product or public model writes spoken Zurich German in dialect spelling reliably (best ~46% words right); Whisper renders it into Standard German at ~23% WER, mostly rewordings. So a dialect episode with no publisher transcript is no longer refused: the opening minutes are rendered by the existing recogniser and stored as transcript.source 'rendering', labelled on every screen as German 'sinngemäss — nicht der Dialekt, wie er klingt' (lang=de); questions are asked about content only. Nothing reads a dialect form from it (HEIDI.md updated). - channels followed by feed/app are matched to the register by name on the publisher's domain (lib/channels/spoken.ts), also at request time for channels followed before - migration 0012 re-offers episodes stored as 'none' (UPDATE only) - question prompt stays variety-neutral (leak test) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * fix(practice): what a walkthrough of every exercise found Played a sitting end to end in a browser at 390px and fixed what read wrong: - Self-check cloze said "which word is missing?" with nowhere to answer; it now says to answer aloud or in your head, then reveal. - A word's "Why?" was the same advice for every word. It now follows the distance classification: close to German, a named sound rule with the pack's example (ruleBehind), or a word to learn. - Match grids could be solved by shape (four "add an n" verbs) and could offer one meaning twice (Hoi/Salü = Hallo). Grids now mix closeness and hold at least two words German does not give away; tests pin both. - A checked sentence build kept tile padding, scattering the words; it is now one line with misplaced words marked. - Writing "nid" now notes the pack's house form "nöd" (preferredForms on the display projection; no component imports the full pack). - The finish recap printed the German answer as the missed dialect word; recapOf gives both sides. "1 kommen nochmals" is pluralised in 7 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(account): ask once about progress sync; finish the walkthrough fixes Signed up and used a new account on two browsers: - A new account synced nothing and said nothing; the switch lived only in settings. The signed-in home asks once (SyncOffer), either answer is kept; sync stays off until chosen. turnSyncOn/keepSyncOff are shared with the settings switch. - «Meine Situationen» joins synced progress as the `focus` key, decoded on the server like every other key, and adopted on a device only where nothing is chosen. Privacy register and sync copy say so in 7 languages. Two-device check: device two shows the situations, is not asked again. - Verification mail no longer says it "finishes" sign-up for an account that already works. The OrangeCat one-click sentence shows only where the button is (methods.signin). - Chat footer shows the model's name (modelLabel), not the route id; a German reader's gloss is not repeated; chat asks ai-kit for light reasoning so the first words come sooner. - compareWords no longer offers a typed word that matches one pack word as another's near miss. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(mail): account mail as laid-out HTML through mail-kit 0.3.0 The verify, sign-in-link and reset mails were plain text. They now carry the fleet's one layout (@bitbaum/mail-kit renderMail): Heidi's red and cow mark, a heading, one button, the sign-in code to type on another device, a note, and a footer that says why the mail arrived. Dark mode follows the reader's client. The plain-text version is unchanged and still sent alongside. Security mail carries no unsubscribe (footer.unsubscribe: null), by design. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * feat(mail): an opt-in evening reminder that is quiet by construction One email when questions are due, off until the learner switches it on in the settings (offered with progress sync on, since the server reads what is due only from a syncing device). - lib/mail/reminder-policy.ts decides, and errs toward silence: opted in, verified address, not on day one, 18:00 in their own zone, at most every other day, five or more due, not if they practised today, and none after three in a row went unanswered. Pure, with tests. - The mail uses the fleet layout (@bitbaum/mail-kit renderMail): count, the streak only from two days, one real due line from the pack, one button, the reason it came, preferences and unsubscribe. Six languages; worded as a good moment, never as loss (HEIDI.md §3), with a test on loss words. - One-click unsubscribe: List-Unsubscribe + -Post headers (RFC 8058) and a footer link to a page with one button (a GET changes nothing, so a link scanner cannot unsubscribe anyone). Signed, non-expiring token. - mail_preferences (migration 0013), /api/mail/preferences, /api/mail/unsubscribe, /api/cron/reminders (hourly, CRON_SECRET). - Privacy register: the preference row and the mail vendor. - Checked end to end against local Postgres: sends once at 18:00, refuses a duplicate hour, refuses the next day, counts an unanswered one, unsubscribes from the page and from the one-click POST, rejects forged tokens. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * fix(account): deleting an account deletes the person; 404s lead home Found by using Heidi as its users do (64-scenario run, then deleting a test account and counting rows): - Deleting an account removed the login but left the person's synced progress, reminder setting, language, conversations, group memberships, follows, push subscriptions and certificates in the database, attached to nobody. lib/domain/account/erase.ts now removes them in one transaction after the deletion succeeded (a wrong password erases nothing). A group they made passes to its longest-standing member; their group messages stay for the others, unattributed. erase.test.ts walks the schema and fails when a table with a person column is not handled. Verified against Postgres: wrong password 400 and nothing erased; right password, every row gone. - Most unknown URLs (a typo, a removed page, /xx/…) showed Next's bare English "404" with no header and no way home, because the root layout lives under [locale]. app/global-not-found.tsx answers in the URL's or the browser's language and links home (experimental.globalNotFound). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * fix(settings): no reminder switch for accounts that share no address A person who signs in with Google or GitHub through the shared sign-in shares no email address with Heidi by design, so a reminder could never reach them, yet Settings offered the switch and it did nothing. It is not offered now. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvF6Smf3iMYnGBqi12 * fix(dock): the bar never lies on a control, and the page ends clear of it The Practise / Ask Heidi pill covered Start on /practice at 390px, the password field on sign-in and the warm-up's Try it at 768px. It now checks what is under its resting place and slides away while that is a control, at every width. The footer ends one pill, its offset and the safe-area inset higher, so the last row of links is never under it. The lists the feedback widget's button sat on are marked data-fc-avoid, which the widget honours. Claude-Session: https://claude.ai/code/session_019MDtmsubNtjznXC5pMf4fD * fix(mail): send as Heidi's own domain once it is verified, and say which sender is in use Account mail carried the retired FleetCrown name in its From line. A sender cannot be renamed on faith: mail from a domain the key has not verified is refused. Heidi now asks the mail service which domains this deployment's key may send from and uses heidi.orangecat.ch, then orangecat.ch, as soon as one is verified; until then the shared sender stays. /api/health reports the From line in use and the domains the key knows. Claude-Session: https://claude.ai/code/session_019MDtmsubNtjznXC5pMf4fD * fix(legal): the Impressum names the Heidi project, privacy gives each vendor's company and country, and the offer to care homes says where it stops - Impressum: operated by the Heidi project (bitbaum), with the contact address; no person, no postal address, and no promise of one. - Privacy: each company that answers messages is listed with its legal entity and country, linked to the page that states it; no row names a company twice. - Organisations: a paragraph beside the offer says Heidi is for practising, not for the bedside, and that no personal or health details belong in it. Claude-Session: https://claude.ai/code/session_019MDtmsubNtjznXC5pMf4fD * docs(changelog): keep main's 10 November entries beside this branch's Claude-Session: https://claude.ai/code/session_019MDtmsubNtjznXC5pMf4fD * docs: the recipe for cloning Heidi into a sibling language app, and one source for the product name docs/clone-a-language-app.md: what is config, what is content and what stays in packages, in the order the steps happen. The product name was written in five places; the share card, the title template, the landing config, the manifest and the account mail now read ASSISTANT_NAME, so a clone changes it once. Claude-Session: https://claude.ai/code/session_019MDtmsubNtjznXC5pMf4fD * fix(mail): the reminder carries the same verified sender as account mail Claude-Session: https://claude.ai/code/session_019MDtmsubNtjznXC5pMf4fD --------- Co-authored-by: Claude <noreply@anthropic.com>
77 lines
3.0 KiB
TypeScript
77 lines
3.0 KiB
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
import { DEFAULT_LOCALE, LOCALES, isLocale, negotiate } from "./lib/i18n/locales";
|
|
|
|
/**
|
|
* Every page lives under a locale segment, so a bare path has to pick one.
|
|
*
|
|
* The choice is the visitor's browser preference, falling back to German —
|
|
* which is the point: this is a site about a German-speaking city, and
|
|
* defaulting to English would quietly concede that you never really arrive.
|
|
*
|
|
* A visitor who has chosen a language gets that choice remembered, so the
|
|
* Italian reader who lands on a shared `/` link is not thrown back to German
|
|
* on every visit.
|
|
*/
|
|
|
|
const COOKIE = "heidi_locale";
|
|
const ONE_YEAR = 60 * 60 * 24 * 365;
|
|
|
|
/**
|
|
* NOTHING HERE REWRITES. Read this before adding one.
|
|
*
|
|
* A rewrite of the locale root to the dashboard for signed-in visitors took
|
|
* the site down in production, and every test passed — including a production
|
|
* build exercised in a browser, because the failure needs a real reverse proxy
|
|
* to appear.
|
|
*
|
|
* `request.nextUrl.clone()` inherits the EXTERNAL protocol behind Caddy, so
|
|
* the cloned URL reads `https://localhost:4025/...` while the app itself
|
|
* listens on plain http at that port. Next sees an origin it does not consider
|
|
* its own, treats the rewrite as an external proxy target, and dials TLS at an
|
|
* http socket:
|
|
*
|
|
* Failed to proxy https://localhost:4025/de/portal
|
|
* EPROTO ... tls_validate_record_header: wrong version number
|
|
*
|
|
* Every signed-out visitor was fine, which is why it reached production: the
|
|
* rewrite only ran when a session cookie was present, and neither CI nor a
|
|
* local `pnpm start` has a reverse proxy in front of it.
|
|
*
|
|
* "Show a different page at the same address" is still the right idea — it is
|
|
* just a decision for the PAGE to make, where no URL is reconstructed and no
|
|
* protocol is guessed.
|
|
*/
|
|
|
|
|
|
export function proxy(request: NextRequest) {
|
|
const { pathname } = request.nextUrl;
|
|
|
|
const first = pathname.split("/")[1] ?? "";
|
|
if (isLocale(first)) {
|
|
// Already localised. Remember it, so a later bare path lands here again.
|
|
const response = NextResponse.next();
|
|
if (request.cookies.get(COOKIE)?.value !== first) {
|
|
response.cookies.set(COOKIE, first, { maxAge: ONE_YEAR, sameSite: "lax", path: "/" });
|
|
}
|
|
return response;
|
|
}
|
|
|
|
const remembered = request.cookies.get(COOKIE)?.value;
|
|
const locale =
|
|
remembered && isLocale(remembered) ? remembered : negotiate(request.headers.get("accept-language"));
|
|
|
|
const url = request.nextUrl.clone();
|
|
url.pathname = `/${locale}${pathname === "/" ? "" : pathname}`;
|
|
// 307: the right locale for the next visitor may differ, so this must never
|
|
// be cached as permanent by a proxy or a browser.
|
|
return NextResponse.redirect(url, 307);
|
|
}
|
|
|
|
export const config = {
|
|
// Everything except API routes, Next internals, and the crawler files that
|
|
// must stay at the root — a redirected robots.txt is a robots.txt nobody reads.
|
|
matcher: ["/((?!api|_next|favicon.ico|robots.txt|sitemap.xml|opengraph-image|.*\\..*).*)"],
|
|
};
|
|
|
|
export { LOCALES, DEFAULT_LOCALE };
|