Make Cobble a local install: setup flow, bots-first admin, settings

Local, password-only auth:
- No public pages; everything outside /admin and /auth redirects in
- First run (no users) sends every page to /auth/signup, which creates
  the super admin (user #1) once and then locks
- Login is email/username + password; removed the emailed-code flow,
  /auth/sso and email password reset
- Google login kept for existing accounts only, never creates them
- seed-super-admin now requires SEED_SUPER_ADMIN_PASSWORD

Bots-first admin:
- /admin and closed sections (people, logs, backups) redirect to
  /admin/bots; only bots and settings are live (AdminSections)
- Removed the old admin layout; every /admin page uses the bots rail
- Coordinator bot created at signup/seed and by /admin/bots
  (ensureCoordinatorBot), which redirects to its chat
- bots.system_prompt (markdown) with a default coordinator prompt
- seed-bots reuses the existing coordinator

Settings:
- Sub pages general (default), profile, change-password, listed in the
  rail with a back link; unknown settings paths redirect to general
- Redesigned settings UI: pane header, grouped rows, sticky save bar
- General: System/Light/Dark theme, saved per device

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-18 17:49:25 +01:00
co-authored by Claude Opus 5.5
parent 3286b80029
commit 694c83346f
159 changed files with 1891 additions and 2964 deletions
@@ -1,13 +0,0 @@
import type { BUN_SQLITE_COBBLE_USERS } from "@/db/types/db";
import Button from "@moduletrace/twui/layout/Button";
import useFormInit from "@/src/hooks/use-form-init";
export default function AccountFormAction(
_params: ReturnType<typeof useFormInit<BUN_SQLITE_COBBLE_USERS>>,
) {
return (
<>
<Button title="Save Changes">Save Changes</Button>
</>
);
}
@@ -1,53 +0,0 @@
import Form from "@moduletrace/twui/form/Form";
import LoadingOverlay from "@moduletrace/twui/elements/LoadingOverlay";
import useFormInit from "@/src/hooks/use-form-init";
import type { BUN_SQLITE_COBBLE_USERS } from "@/db/types/db";
import submitAccountForm from "../(functions)/submit-account-form";
import AccountFormAction from "./account-form-action";
import Tag from "@moduletrace/twui/elements/Tag";
import Row from "@moduletrace/twui/layout/Row";
import UserFormName from "@/src/pages/admin/people/create/(partials)/user-form/user-form-name";
import UserFormEmail from "@/src/pages/admin/people/create/(partials)/user-form/user-form-email";
import UserFormUsername from "@/src/pages/admin/people/create/(partials)/user-form/user-form-username";
import UserFormBio from "@/src/pages/admin/people/create/(partials)/user-form/user-form-bio";
import UserFormImage from "@/src/pages/admin/people/create/(partials)/user-form/user-form-image";
import type { UserFormObject } from "@/src/types";
type Props = {
existing_user?: UserFormObject;
existing_user_full?: BUN_SQLITE_COBBLE_USERS;
};
export default function AccountForm({ existing_user, existing_user_full }: Props) {
const init = useFormInit<UserFormObject>({
existing: existing_user,
existing_full: existing_user_full,
});
const { loading, status } = init;
return (
<>
<Form
className="w-full gap-6"
onSubmit={() => {
submitAccountForm(init);
}}
>
{status?.error && <Tag color="error">{status.msg}</Tag>}
{loading && <LoadingOverlay />}
<UserFormName {...init} />
<Row className="w-full grid xl:grid-cols-2">
<UserFormEmail {...init} />
<UserFormUsername {...init} />
</Row>
<Row className="w-full grid xl:grid-cols-2 items-stretch">
<UserFormBio {...init} />
<UserFormImage {...init} />
</Row>
<AccountFormAction {...init} />
</Form>
</>
);
}
@@ -0,0 +1,34 @@
import type { ReactNode } from "react";
import Stack from "@moduletrace/twui/layout/Stack";
import H2 from "@moduletrace/twui/layout/H2";
import Span from "@moduletrace/twui/layout/Span";
type Props = {
title: string;
description?: ReactNode;
children: ReactNode;
};
/**
* One block of settings: what it is on the left, the controls on the right.
* Stacks below 768px. Blocks are separated by hairlines, never cards.
*/
export default function SettingsGroup({ title, description, children }: Props) {
return (
<Stack className="w-full gap-4! md:grid md:grid-cols-[200px_1fr] md:gap-10! py-8 border-0 border-b border-solid border-hairline last:border-b-0">
<Stack className="gap-1! min-w-0">
<H2 className="text-sm! leading-5! tracking-normal! font-bold text-ink mb-0!">
{title}
</H2>
{description ? (
<Span className="text-[13px] leading-[18px] text-ink-secondary">
{description}
</Span>
) : null}
</Stack>
<Stack className="gap-4! min-w-0 w-full items-stretch">
{children}
</Stack>
</Stack>
);
}
@@ -0,0 +1,28 @@
import Row from "@moduletrace/twui/layout/Row";
import Stack from "@moduletrace/twui/layout/Stack";
import H1 from "@moduletrace/twui/layout/H1";
import Span from "@moduletrace/twui/layout/Span";
type Props = {
title: string;
description: string;
};
/**
* Same 64px header as a conversation, so moving between bots and settings
* doesn't shift the page.
*/
export default function SettingsPaneHeader({ title, description }: Props) {
return (
<Row className="h-16 shrink-0 gap-3! flex-nowrap items-center px-6 border-0 border-b border-solid border-hairline">
<Stack className="min-w-0 gap-0!">
<H1 className="text-lg! leading-6! tracking-normal! font-bold text-ink truncate">
{title}
</H1>
<Span className="text-[13px] leading-[18px] text-ink-secondary truncate">
{description}
</Span>
</Stack>
</Row>
);
}
@@ -0,0 +1,61 @@
import Row from "@moduletrace/twui/layout/Row";
import Span from "@moduletrace/twui/layout/Span";
import Button from "@moduletrace/twui/layout/Button";
import type { ComponentProps } from "react";
import SettingsStatus from "./settings-status";
type Props = {
dirty: boolean;
loading?: boolean;
status?: ComponentProps<typeof SettingsStatus>["status"];
save_label?: string;
onDiscard?: () => void;
};
/**
* Sticks to the bottom of the pane. Save is only enabled once something
* changed, and says so; Discard puts the form back.
*/
export default function SettingsSaveBar({
dirty,
loading,
status,
save_label = "Save changes",
onDiscard,
}: Props) {
return (
<Row className="sticky bottom-0 z-10 w-full min-h-16 gap-3! flex-nowrap items-center justify-between py-3 bg-paper border-0 border-t border-solid border-hairline">
{status?.msg ? (
<SettingsStatus status={status} />
) : (
<Span className="text-[13px] leading-[18px] text-ink-secondary">
{dirty ? "You have unsaved changes." : "No changes yet."}
</Span>
)}
<Row className="gap-2! flex-nowrap shrink-0">
{dirty && onDiscard ? (
<Button
title="Discard changes"
type="button"
variant="ghost"
color="gray"
size="small"
disabled={loading}
onClick={onDiscard}
>
Discard
</Button>
) : null}
<Button
title={save_label}
type="submit"
size="small"
disabled={!dirty || loading}
loading={loading}
>
{save_label}
</Button>
</Row>
</Row>
);
}
@@ -0,0 +1,26 @@
import type { ReactNode } from "react";
import Stack from "@moduletrace/twui/layout/Stack";
import SettingsPaneHeader from "./settings-pane-header";
type Props = {
title: string;
description: string;
children: ReactNode;
};
/**
* The settings pane beside the rail: a 64px header like the conversation
* header, then one readable column that scrolls on its own.
*/
export default function SettingsShell({ title, description, children }: Props) {
return (
<Stack className="grow min-w-0 h-full gap-0! items-stretch">
<SettingsPaneHeader title={title} description={description} />
<Stack className="grow min-h-0 overflow-y-auto gap-0! items-stretch">
<Stack className="w-full max-w-[760px] mx-auto gap-0! items-stretch px-6 lg:px-10 pb-16">
{children}
</Stack>
</Stack>
</Stack>
);
}
@@ -0,0 +1,36 @@
import Span from "@moduletrace/twui/layout/Span";
import { CircleAlert, Check } from "lucide-react";
import { twMerge } from "tailwind-merge";
type Props = {
status?: {
error?: boolean;
success?: boolean;
msg?: string;
};
};
/**
* One quiet line for the result of a save. State is said in words with an
* icon, never with color alone.
*/
export default function SettingsStatus({ status }: Props) {
if (!status?.msg || (!status.error && !status.success)) {
return null;
}
const Icon = status.error ? CircleAlert : Check;
return (
<Span
role={status.error ? "alert" : "status"}
className={twMerge(
"flex items-center gap-1.5 text-[13px] leading-[18px]",
status.error ? "text-ink" : "text-ink-secondary",
)}
>
<Icon size={14} aria-hidden className="shrink-0" />
{status.msg}
</Span>
);
}