From eff81e4d8d335147fc204dec3cf4522d889fcd1d Mon Sep 17 00:00:00 2001 From: Andrew S Erwin Date: Mon, 23 Nov 2026 16:09:17 -0600 Subject: [PATCH] Settings: remove the Contacts sync tab; the sync API remains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- API.md | 4 +- scripts/regressions.mjs | 5 ++ web/app/(app)/settings/client.tsx | 72 ++++++----------------------- web/app/help/page.tsx | 2 +- web/components/carddav-settings.tsx | 4 +- 5 files changed, 25 insertions(+), 62 deletions(-) diff --git a/API.md b/API.md index 0301526..db34c3a 100644 --- a/API.md +++ b/API.md @@ -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 plan gate, validation (including CardDAV's https/443 pin), caps and projections 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 | |---|---|---| diff --git a/scripts/regressions.mjs b/scripts/regressions.mjs index 6033bf3..73ce3ea 100644 --- a/scripts/regressions.mjs +++ b/scripts/regressions.mjs @@ -908,6 +908,11 @@ try { await page.goto(`${base}/settings`) 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') + // 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') // Mobile pass (390x844): the shell becomes a drawer, tables become cards, diff --git a/web/app/(app)/settings/client.tsx b/web/app/(app)/settings/client.tsx index 92e8f32..e585b25 100644 --- a/web/app/(app)/settings/client.tsx +++ b/web/app/(app)/settings/client.tsx @@ -5,9 +5,8 @@ import { useSearchParams, useRouter } from 'next/navigation' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' 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 { invalidateReference } from '@/lib/reference-data' import { NotificationsSettings } from '@/components/notifications-settings' import { ProfileSettings } from '@/components/profile-settings' import { AiSettings } from '@/components/ai-settings' @@ -36,7 +35,6 @@ const NAV_GROUPS = [ { value: 'webdav', label: 'WebDAV', icon: FolderSync }, { value: 'caldav', label: 'CalDAV', icon: CalendarDays }, { value: 'carddav', label: 'CardDAV', icon: BookUser }, - { value: 'nextcloud', label: 'Contacts sync', icon: Cloud }, { value: 'imap', label: 'IMAP', icon: Mail }, ] }, { label: 'AI & Automation', items: [ @@ -57,15 +55,23 @@ export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callba const router = useRouter() // Automations moved out of Settings to its own workspace; legacy deep // links (?tab=automations) redirect there instead of falling back to profile. - useEffect(() => { if (requestedTab === 'automations') router.replace('/automations') }, [requestedTab, router]) - const initialSection = NAV_GROUPS.some(g => g.items.some(i => i.value === requestedTab)) - ? requestedTab + // The Contacts sync tab was removed — its legacy ?tab=nextcloud deep link + // lands on the unified Nextcloud tab (the sync API itself remains). + 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' 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 [testingImap, setTestingImap] = useState(false) - const [syncingContacts, setSyncingContacts] = useState(false) const [section, setSection] = useState(initialSection) // Below md the grouped nav becomes a list -> detail flow (same // 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) } } - 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 (
@@ -223,30 +203,6 @@ export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callba - - -
-

Contacts sync (Nextcloud)

-
-
- - ) => setNcConfig(p => ({ ...p, nextcloudUrl: e.target.value }))} placeholder="https://nextcloud.example.com" /> -
-
- - ) => setNcConfig(p => ({ ...p, cardDavPath: e.target.value }))} placeholder="/remote.php/dav/addressbooks/users/USER/contacts/" /> -
-
- - ) => setNcConfig(p => ({ ...p, username: e.target.value }))} /> -
-
- - ) => setNcConfig(p => ({ ...p, password: e.target.value }))} /> -
-
- -
diff --git a/web/app/help/page.tsx b/web/app/help/page.tsx index 0e072d3..2ef575c 100644 --- a/web/app/help/page.tsx +++ b/web/app/help/page.tsx @@ -94,7 +94,7 @@ const SECTIONS = [ icon: FolderSync, title: 'Connections', 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.', ], where: 'Settings → Connections', diff --git a/web/components/carddav-settings.tsx b/web/components/carddav-settings.tsx index 4e66a8b..d17c830 100644 --- a/web/components/carddav-settings.tsx +++ b/web/components/carddav-settings.tsx @@ -167,8 +167,8 @@ export function CardDavSettings() {

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 - encrypted at rest and never shown again. (This is separate from Contacts sync, which - feeds contact-linking.) + encrypted at rest and never shown again. (This is separate from the Contacts page, + which feeds contact-linking.)

{allowed && }