Lighten the client shell and finish four client surfaces

- Load each settings section on its own: the section route imported all
  twenty-one statically. A preload starts the chunk beside the record
  gate's read, and the loading state paints the settings card shell.
  /settings/[section] goes from 611 to 403 KB gz.
- Take Zod out of the shell every route shares: the account-access parse
  run on each boot is plain TypeScript now, held to the published schema
  by an equivalence test over good and broken blocks. The canonical unit
  table moves to its own module, so the display transform no longer
  pulls Zod in either. Layout entry 199 to 136 KB gz; /insights 369 to
  304, /medications 428 to 365, /labs 400 to 337.
- Open a saved Coach conversation at its last answer: an instant jump
  instead of the smooth scroll that lost the end, then follow late
  layout (charts, tables) for a few seconds until the reader scrolls.
- Show the document archive as a month grid of preview tiles, two
  across on a phone and three or four on a desktop, with the month
  headings kept.
- Add the admin card for the measurement table maintenance: a status
  read on the maintenance route, one calm confirmation, and the run's
  state while it is queued, running, finished or stopped.
- Re-base the bundle budget: /insights at 304, /settings/[section]
  watched at 403, aggregate cap 4335 with the reason written down.
This commit is contained in:
Marc-André Bombeck committed 2026-10-08 11:25:11 +02:00
1 parent bb563b6506
commit 12e422c25e
38 files changed
+2505 -406

No files matched your search

+20 -66
View File
@@ -1,33 +1,14 @@
import { notFound } from "next/navigation";
import type { JSX } from "react";
import { AccessSection } from "@/components/settings/access-section";
import { AccountSection } from "@/components/settings/account-section";
import { AnamnesisSection } from "@/components/settings/anamnesis-section";
import { SecuritySection } from "@/components/settings/security-section";
import { AboutSection } from "@/components/settings/about-section";
import { AdvancedSection } from "@/components/settings/advanced-section";
import { AiSection } from "@/components/settings/ai-section";
import { ApiSection } from "@/components/settings/api-section";
import { CoachSection } from "@/components/settings/coach-section";
import { EnvironmentSection } from "@/components/settings/environment-section";
import { ExportSection } from "@/components/settings/export-section";
import { GesundheitsakteSection } from "@/components/settings/gesundheitsakte-section";
import { IntegrationsSection } from "@/components/settings/integrations-section";
import { LayoutSection } from "@/components/settings/layout-section";
import { McpSection } from "@/components/settings/mcp-section";
import { ModulesSection } from "@/components/settings/modules-section";
import { NotificationsSection } from "@/components/settings/notifications-section";
import { PrivacySection } from "@/components/settings/privacy-section";
import { ScoreSection } from "@/components/settings/score-section";
import { SourcesSection } from "@/components/settings/sources-section";
import { ThresholdsSection } from "@/components/settings/thresholds-section";
import {
SETTINGS_SECTION_SLUGS,
isSettingsSectionSlug,
type SettingsSectionSlug,
} from "@/components/settings/section-slugs";
import { SettingsShell } from "@/components/settings/settings-shell";
import {
SettingsSectionLoader,
SettingsSectionPreload,
} from "@/components/settings/settings-section-loader";
import { RecordSettingsSectionGate } from "@/components/settings/record-settings-section-gate";
import { getIntegrationCallbackUrls } from "@/lib/integrations/callback-urls";
@@ -47,44 +28,6 @@ export function generateStaticParams() {
return SETTINGS_SECTION_SLUGS.map((section) => ({ section }));
}
/**
* Integrations is the one section that needs a server-resolved value: the
* OAuth callback URL each provider registers. It is read from the runtime env
* here, per request, and handed to the client section as a prop, because a
* `NEXT_PUBLIC_*` read inside a client module is inlined at build time and the
* published image is built without it.
*/
function IntegrationsSectionWithCallbackUrls() {
return <IntegrationsSection callbackUrls={getIntegrationCallbackUrls()} />;
}
const SECTION_COMPONENTS: Record<
SettingsSectionSlug,
() => JSX.Element | null
> = {
account: AccountSection,
access: AccessSection,
security: SecuritySection,
modules: ModulesSection,
about: AboutSection,
ai: AiSection,
coach: CoachSection,
integrations: IntegrationsSectionWithCallbackUrls,
sources: SourcesSection,
notifications: NotificationsSection,
layout: LayoutSection,
environment: EnvironmentSection,
anamnesis: AnamnesisSection,
score: ScoreSection,
thresholds: ThresholdsSection,
api: ApiSection,
mcp: McpSection,
gesundheitsakte: GesundheitsakteSection,
export: ExportSection,
advanced: AdvancedSection,
privacy: PrivacySection,
};
interface PageProps {
// Next.js 16 made route `params` an async Promise. We `await` it before use.
params: Promise<{ section: string }>;
@@ -100,10 +43,13 @@ export default async function SettingsSectionPage({ params }: PageProps) {
notFound();
}
// `SECTION_COMPONENTS` is an exhaustive Record over the slug union, so a
// slug without a wired component is a compile error — the old runtime
// `<SectionPlaceholder>` fallback could never render and was removed.
const SectionComponent = SECTION_COMPONENTS[section];
// Each section is its own chunk (see `SettingsSectionLoader`), so the route
// ships the one it shows rather than all twenty-one. Integrations is the
// one section that needs a server-resolved value: the OAuth callback URL
// each provider registers, read from the runtime env here, per request,
// because a `NEXT_PUBLIC_*` read inside a client module is inlined at build
// time and the published image is built without it.
//
// v1.18.6.1 — the heading + subtitle (and the Layout-hub "← back" link)
// live in `<SettingsShell>`, which places them in their own grid row
// spanning only the content column so the left nav's first item lines up
@@ -112,12 +58,20 @@ export default async function SettingsSectionPage({ params }: PageProps) {
// `settings-section-<slug>-title` `aria-labelledby` linkage still resolves.
return (
<SettingsShell active={section}>
<SettingsSectionPreload section={section} />
<RecordSettingsSectionGate section={section}>
<section
aria-labelledby={`settings-section-${section}-title`}
className="space-y-6"
>
<SectionComponent />
<SettingsSectionLoader
section={section}
callbackUrls={
section === "integrations"
? getIntegrationCallbackUrls()
: undefined
}
/>
</section>
</RecordSettingsSectionGate>
</SettingsShell>