Settings: remove the Contacts sync tab; the sync API remains

The single-config Nextcloud Contacts sync tab is gone — the unified
Nextcloud tab is the UI path for connecting an account. POST
/api/contacts/sync is untouched (Contact rows still feed contact-linking;
the handler is stateless, so no persisted config orphans). Legacy
?tab=nextcloud deep links map to the unified tab on first render and clean
the URL; CardDAV/help wording follows. Regression asserts the tab is gone
and the legacy deep link lands on the Nextcloud form.
This commit is contained in:
Andrew S Erwin
2026-11-23 16:09:17 -06:00
parent ec78b2cf7f
commit eff81e4d8d
5 changed files with 25 additions and 62 deletions
+3 -1
View File
@@ -242,7 +242,9 @@ against each protocol (parallel netguard-pinned probes sharing the siblings'
that passes. This is orchestration, not a fourth connector: every sibling's that passes. This is orchestration, not a fourth connector: every sibling's
plan gate, validation (including CardDAV's https/443 pin), caps and projections plan gate, validation (including CardDAV's https/443 pin), caps and projections
apply unchanged, and materialization stays on the siblings' `/sync` surfaces. apply unchanged, and materialization stays on the siblings' `/sync` surfaces.
The separate Contacts sync is untouched. The separate Contacts sync API (`POST /api/contacts/sync`) is untouched, but
its settings tab was removed — the unified Nextcloud tab is the UI path, and
legacy `?tab=nextcloud` deep links redirect to it.
| Method | Path | Returns / behavior | | Method | Path | Returns / behavior |
|---|---|---| |---|---|---|
+5
View File
@@ -908,6 +908,11 @@ try {
await page.goto(`${base}/settings`) await page.goto(`${base}/settings`)
await page.getByRole('tab', { name: 'Profile' }).click() await page.getByRole('tab', { name: 'Profile' }).click()
assert.equal(await page.getByRole('tab', { name: 'Automations', exact: true }).count(), 0, 'Automations tab still present in Settings') assert.equal(await page.getByRole('tab', { name: 'Automations', exact: true }).count(), 0, 'Automations tab still present in Settings')
// The Contacts sync tab is removed too; its legacy deep link lands on the
// unified Nextcloud tab (the sync API itself remains).
assert.equal(await page.getByRole('tab', { name: 'Contacts sync' }).count(), 0, 'Contacts sync tab still present in Settings')
await page.goto(`${base}/settings?tab=nextcloud`)
await page.getByPlaceholder('https://cloud.example.com').waitFor()
console.log('PASS: Automations lives in the sidebar with a task dropdown, deep-links to /automations, and the legacy settings tab redirects') console.log('PASS: Automations lives in the sidebar with a task dropdown, deep-links to /automations, and the legacy settings tab redirects')
// Mobile pass (390x844): the shell becomes a drawer, tables become cards, // Mobile pass (390x844): the shell becomes a drawer, tables become cards,
+14 -58
View File
@@ -5,9 +5,8 @@ import { useSearchParams, useRouter } from 'next/navigation'
import { Button } from '@/components/ui/button' import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input' import { Input } from '@/components/ui/input'
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs' import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'
import { User, Mail, Server, Cloud, CloudCog, Shield, Bell, Bot, KeyRound, PlugZap, FolderSync, CalendarDays, BookUser, ArrowLeft, Check, X, AlertTriangle } from 'lucide-react' import { User, Mail, Server, CloudCog, Shield, Bell, Bot, KeyRound, PlugZap, FolderSync, CalendarDays, BookUser, ArrowLeft, Check, X, AlertTriangle } from 'lucide-react'
import { toast } from 'sonner' import { toast } from 'sonner'
import { invalidateReference } from '@/lib/reference-data'
import { NotificationsSettings } from '@/components/notifications-settings' import { NotificationsSettings } from '@/components/notifications-settings'
import { ProfileSettings } from '@/components/profile-settings' import { ProfileSettings } from '@/components/profile-settings'
import { AiSettings } from '@/components/ai-settings' import { AiSettings } from '@/components/ai-settings'
@@ -36,7 +35,6 @@ const NAV_GROUPS = [
{ value: 'webdav', label: 'WebDAV', icon: FolderSync }, { value: 'webdav', label: 'WebDAV', icon: FolderSync },
{ value: 'caldav', label: 'CalDAV', icon: CalendarDays }, { value: 'caldav', label: 'CalDAV', icon: CalendarDays },
{ value: 'carddav', label: 'CardDAV', icon: BookUser }, { value: 'carddav', label: 'CardDAV', icon: BookUser },
{ value: 'nextcloud', label: 'Contacts sync', icon: Cloud },
{ value: 'imap', label: 'IMAP', icon: Mail }, { value: 'imap', label: 'IMAP', icon: Mail },
] }, ] },
{ label: 'AI & Automation', items: [ { label: 'AI & Automation', items: [
@@ -57,15 +55,23 @@ export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callba
const router = useRouter() const router = useRouter()
// Automations moved out of Settings to its own workspace; legacy deep // Automations moved out of Settings to its own workspace; legacy deep
// links (?tab=automations) redirect there instead of falling back to profile. // links (?tab=automations) redirect there instead of falling back to profile.
useEffect(() => { if (requestedTab === 'automations') router.replace('/automations') }, [requestedTab, router]) // The Contacts sync tab was removed — its legacy ?tab=nextcloud deep link
const initialSection = NAV_GROUPS.some(g => g.items.some(i => i.value === requestedTab)) // lands on the unified Nextcloud tab (the sync API itself remains).
? requestedTab useEffect(() => {
if (requestedTab === 'automations') router.replace('/automations')
if (requestedTab === 'nextcloud') router.replace('/settings?tab=nextcloud-connect')
}, [requestedTab, router])
// The Contacts sync tab was removed — its legacy ?tab=nextcloud deep link
// lands on the unified Nextcloud tab (the sync API itself remains). Map the
// legacy value BEFORE deriving the initial section so the tab is selected
// on first render; the effect above only cleans the URL.
const mappedTab = requestedTab === 'nextcloud' ? 'nextcloud-connect' : requestedTab
const initialSection = NAV_GROUPS.some(g => g.items.some(i => i.value === mappedTab))
? mappedTab
: 'profile' : 'profile'
const [imapConfig, setImapConfig] = useState({ host: '', port: 993, tls: true, username: '', password: '', folder: 'INBOX' }) const [imapConfig, setImapConfig] = useState({ host: '', port: 993, tls: true, username: '', password: '', folder: 'INBOX' })
const [ncConfig, setNcConfig] = useState({ nextcloudUrl: '', cardDavPath: '', username: '', password: '' })
const [savingImap, setSavingImap] = useState(false) const [savingImap, setSavingImap] = useState(false)
const [testingImap, setTestingImap] = useState(false) const [testingImap, setTestingImap] = useState(false)
const [syncingContacts, setSyncingContacts] = useState(false)
const [section, setSection] = useState(initialSection) const [section, setSection] = useState(initialSection)
// Below md the grouped nav becomes a list -> detail flow (same // Below md the grouped nav becomes a list -> detail flow (same
// master-detail pattern as collections/tags/contacts); at md+ the // master-detail pattern as collections/tags/contacts); at md+ the
@@ -113,32 +119,6 @@ export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callba
finally { setTestingImap(false) } finally { setTestingImap(false) }
} }
const syncContacts = async () => {
if (!ncConfig.nextcloudUrl || !ncConfig.username || !ncConfig.password) {
toast.error('Fill in Nextcloud URL, username, and password')
return
}
setSyncingContacts(true)
try {
const res = await fetch('/api/contacts/sync', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(ncConfig),
})
const data = await res.json().catch(() => null)
if (res.ok && data?.synced !== undefined) {
// Review CR-07: the sync mirrors the address book — remotely deleted
// contacts are removed too (scoped to this source, never from partial
// responses). Surface both counts so the policy is visible.
const removed = typeof data.removed === 'number' && data.removed > 0 ? `, removed ${data.removed} deleted on the server` : ''
toast.success(`Synced ${data.synced} contacts${removed}`)
invalidateReference('contacts')
}
else toast.error(data?.error ?? 'Sync failed')
} catch { toast.error('Sync failed') }
finally { setSyncingContacts(false) }
}
return ( return (
<div className="max-w-5xl space-y-6"> <div className="max-w-5xl space-y-6">
<div> <div>
@@ -223,30 +203,6 @@ export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callba
</TabsContent> </TabsContent>
<TabsContent value="carddav" className="mt-0 space-y-4"> <TabsContent value="carddav" className="mt-0 space-y-4">
<CardDavSettings /> <CardDavSettings />
</TabsContent>
<TabsContent value="nextcloud" className="mt-0 space-y-4">
<div className="rounded-lg border p-4 space-y-3">
<h3 className="font-medium flex items-center gap-2"><Cloud className="h-4 w-4" /> Contacts sync (Nextcloud)</h3>
<div className="grid grid-cols-2 gap-3">
<div className="col-span-2">
<label className="text-xs font-medium text-muted-foreground">Nextcloud URL</label>
<Input value={ncConfig.nextcloudUrl} onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNcConfig(p => ({ ...p, nextcloudUrl: e.target.value }))} placeholder="https://nextcloud.example.com" />
</div>
<div className="col-span-2">
<label className="text-xs font-medium text-muted-foreground">CardDAV Path (optional)</label>
<Input value={ncConfig.cardDavPath} onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNcConfig(p => ({ ...p, cardDavPath: e.target.value }))} placeholder="/remote.php/dav/addressbooks/users/USER/contacts/" />
</div>
<div>
<label className="text-xs font-medium text-muted-foreground">Username</label>
<Input value={ncConfig.username} onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNcConfig(p => ({ ...p, username: e.target.value }))} />
</div>
<div>
<label className="text-xs font-medium text-muted-foreground">App Password</label>
<Input type="password" value={ncConfig.password} onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNcConfig(p => ({ ...p, password: e.target.value }))} />
</div>
</div>
<Button onClick={syncContacts} loading={syncingContacts}>Sync Contacts Now</Button>
</div>
</TabsContent> </TabsContent>
<TabsContent value="imap" className="mt-0 space-y-4"> <TabsContent value="imap" className="mt-0 space-y-4">
<div className="rounded-lg border p-4 space-y-3"> <div className="rounded-lg border p-4 space-y-3">
+1 -1
View File
@@ -94,7 +94,7 @@ const SECTIONS = [
icon: FolderSync, icon: FolderSync,
title: 'Connections', title: 'Connections',
body: [ body: [
'Settings connects Superbrain to your services: WebDAV shares, CalDAV calendars, CardDAV address books, Nextcloud contacts sync, and IMAP mailboxes. Credentials are stored encrypted and are write-only — the app never shows them back to you.', 'Settings connects Superbrain to your services: a unified Nextcloud connect (files, calendars & contacts), WebDAV shares, CalDAV calendars, CardDAV address books, and IMAP mailboxes. Credentials are stored encrypted and are write-only — the app never shows them back to you.',
'On Core deployments with Nextcloud, the connection forms offer a one-click prefill for your account.', 'On Core deployments with Nextcloud, the connection forms offer a one-click prefill for your account.',
], ],
where: 'Settings → Connections', where: 'Settings → Connections',
+2 -2
View File
@@ -167,8 +167,8 @@ export function CardDavSettings() {
<p className="text-sm text-muted-foreground mt-1"> <p className="text-sm text-muted-foreground mt-1">
Connect an address book from any CardDAV service. Each book becomes a Collection, one Connect an address book from any CardDAV service. Each book becomes a Collection, one
bookmark per contact, re-checked in the background every 30 minutes. Passwords are bookmark per contact, re-checked in the background every 30 minutes. Passwords are
encrypted at rest and never shown again. (This is separate from Contacts sync, which encrypted at rest and never shown again. (This is separate from the Contacts page,
feeds contact-linking.) which feeds contact-linking.)
</p> </p>
</div> </div>
{allowed && <Button size="sm" onClick={openCreate}><Plus className="h-4 w-4 mr-1" /> Connect address book</Button>} {allowed && <Button size="sm" onClick={openCreate}><Plus className="h-4 w-4 mr-1" /> Connect address book</Button>}