Settings → Profile: editable particulars (name, bio, location, occupation, organization, website)

The Profile tab was a read-only avatar/name/email stub. It is now a real
form, modeled on the profile surfaces of GitHub/Slack/Nextcloud and scoped
to what a knowledge tool uses: display name, bio (280 chars with counter),
location, occupation, organization and website; email stays read-only
(sign-in identity). Copy explains where the name appears (shares) and
that public bookmark links never reveal identity.

Schema: migration 024_user_profile.sql + schema.sql add five nullable
text columns to User (db-converge green, fresh and upgraded paths).
models.User, userFromObject and the auth identity projection carry them,
so GET /api/me serves the stored truth (Go re-reads identity per request).

PATCH /api/me applies partial allowlisted edits: empty string clears to
NULL, rune-based caps (120/280/120/120/120), website <=2048 and http(s)
with a host; the answer is the fresh identity projection. User has no
version column (identity, not a collaborative collection), so this follows
the settings-save shape rather than the 409 contract; view-as writes stay
blocked by the middleware.

Session propagation: the auth.ts jwt callback gains an "update" trigger
that re-syncs name/email/image from Go via the same assertion the data
proxy signs (fail-quiet when Go is unreachable). The component calls
useSession().update({}) after a save — the {} argument is load-bearing:
in next-auth v5 a bare update() only re-fetches the session, it does not
fire the trigger (caught by the new browser regression). The top bar name
refreshes without a re-login.

Verified: full Go integration suite green incl. new TestProfileUpdate
(partial edits, clearing, rune caps, URL validation, auth gate);
db-converge green; web lint/SSR-lint/build 0 errors; full browser
regressions pass incl. the new profile round-trip (save → toast → top-bar
refresh → form values intact → Save re-disables on a clean baseline).
This commit is contained in:
Andrew S Erwin
2026-11-20 17:09:32 -06:00
parent 7a7e77e039
commit f6158f58b5
13 changed files with 447 additions and 17 deletions
+2 -11
View File
@@ -1,7 +1,6 @@
'use client'
import { useState, useEffect, useCallback, Fragment } from 'react'
import { useSession } from 'next-auth/react'
import { useSearchParams } from 'next/navigation'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
@@ -10,6 +9,7 @@ import { User, Mail, Server, Cloud, Shield, Bell, Sparkles, Bot, KeyRound, PlugZ
import { toast } from 'sonner'
import { invalidateReference } from '@/lib/reference-data'
import { NotificationsSettings } from '@/components/notifications-settings'
import { ProfileSettings } from '@/components/profile-settings'
import { AutomationsSettings } from '@/components/automations-settings'
import { AiSettings } from '@/components/ai-settings'
import { ApiKeysSettings } from '@/components/api-keys-settings'
@@ -50,7 +50,6 @@ const NAV_GROUPS = [
]
export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callbackUrl: string }) {
const { data: session } = useSession()
// ?tab=<value> deep links (email footer "Email preferences" lands on
// notifications). Unknown values fall back to profile; the Radix tab
// values stay the canonical section ids.
@@ -180,15 +179,7 @@ export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callba
</Button>
)}
<TabsContent value="profile" className="mt-0 space-y-4">
<div className="flex items-center gap-4">
<div className="h-16 w-16 rounded-full bg-primary/20 flex items-center justify-center text-2xl font-bold text-primary">
{(session?.user?.name ?? session?.user?.email ?? '?')[0]?.toUpperCase()}
</div>
<div>
<p className="font-medium">{session?.user?.name ?? 'User'}</p>
<p className="text-sm text-muted-foreground" suppressHydrationWarning>{session?.user?.email}</p>
</div>
</div>
<ProfileSettings />
</TabsContent>
<TabsContent value="oidc" className="mt-0 space-y-4">
<div className="rounded-lg border p-4 space-y-3">