Refactor all references to computer to Superbrain
release gate / check (push) Failing after 6m55s

This commit is contained in:
Andrew S Erwin
2026-10-22 00:33:44 -05:00
parent 45aa3c80aa
commit d870eece1e
84 changed files with 438 additions and 381 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
# computer — web UI
# superbrain — web UI
This app runs inside the root Compose stack. The root [../README.md](../README.md)
is the single authoritative deployment/operations guide; [../API.md](../API.md)
+2 -2
View File
@@ -66,8 +66,8 @@ export function BookmarksClient({ initialSearch = null, initialOpen = null }: {
useEffect(() => {
const timer = setTimeout(load, search ? 250 : 0)
const reload = () => { load(); void loadShared() }
window.addEventListener('computer:bookmarks-changed', reload)
return () => { clearTimeout(timer); window.removeEventListener('computer:bookmarks-changed', reload); abortRef.current?.abort() }
window.addEventListener('superbrain:bookmarks-changed', reload)
return () => { clearTimeout(timer); window.removeEventListener('superbrain:bookmarks-changed', reload); abortRef.current?.abort() }
}, [load, loadShared, search])
useEffect(() => { const timer = setTimeout(loadShared, 0); return () => clearTimeout(timer) }, [loadShared])
// Quick Find and the dashboard redirect land here with ?search=; the prop
+1 -1
View File
@@ -64,7 +64,7 @@ export function CalendarClient() {
finally { if (seq === loadSeq.current) setLoading(false) }
}, [])
useEffect(() => { const timer = setTimeout(load, 0); window.addEventListener('computer:bookmarks-changed', load); return () => { clearTimeout(timer); window.removeEventListener('computer:bookmarks-changed', load) } }, [load])
useEffect(() => { const timer = setTimeout(load, 0); window.addEventListener('superbrain:bookmarks-changed', load); return () => { clearTimeout(timer); window.removeEventListener('superbrain:bookmarks-changed', load) } }, [load])
const days = useMemo(() => {
const start = startOfMonth(currentMonth)
+1 -1
View File
@@ -42,7 +42,7 @@ export function ContactsClient() {
useEffect(() => { const timer = setTimeout(loadContacts, 0); return () => clearTimeout(timer) }, [loadContacts])
useEffect(() => { const timer = setTimeout(() => { if (selectedContact) loadBookmarks(selectedContact) }, 0); return () => clearTimeout(timer) }, [selectedContact, loadBookmarks])
useEffect(() => { const reload = () => { loadContacts(); if (selectedContact) loadBookmarks(selectedContact) }; window.addEventListener('computer:bookmarks-changed', reload); return () => window.removeEventListener('computer:bookmarks-changed', reload) }, [loadContacts, loadBookmarks, selectedContact])
useEffect(() => { const reload = () => { loadContacts(); if (selectedContact) loadBookmarks(selectedContact) }; window.addEventListener('superbrain:bookmarks-changed', reload); return () => window.removeEventListener('superbrain:bookmarks-changed', reload) }, [loadContacts, loadBookmarks, selectedContact])
const syncContacts = async () => {
setSyncing(true)
+1 -1
View File
@@ -69,7 +69,7 @@ export function KanbanClient() {
setLoading(false)
}, [])
useEffect(() => { const timer = setTimeout(load, 0); window.addEventListener('computer:bookmarks-changed', load); return () => { clearTimeout(timer); window.removeEventListener('computer:bookmarks-changed', load) } }, [load])
useEffect(() => { const timer = setTimeout(load, 0); window.addEventListener('superbrain:bookmarks-changed', load); return () => { clearTimeout(timer); window.removeEventListener('superbrain:bookmarks-changed', load) } }, [load])
const isOwned = useCallback((b: Bookmark) => !currentUserId || b.ownerId === currentUserId, [currentUserId])
+1 -1
View File
@@ -78,7 +78,7 @@ export function TagsClient({ initialTag = null }: { initialTag?: string | null }
}, 0)
return () => clearTimeout(timer)
}, [selectedTag, loadBookmarks])
useEffect(() => { const reload = () => { loadTags(); if (selectedTag) loadBookmarks(selectedTag) }; window.addEventListener('computer:bookmarks-changed', reload); return () => window.removeEventListener('computer:bookmarks-changed', reload) }, [loadTags, loadBookmarks, selectedTag])
useEffect(() => { const reload = () => { loadTags(); if (selectedTag) loadBookmarks(selectedTag) }; window.addEventListener('superbrain:bookmarks-changed', reload); return () => window.removeEventListener('superbrain:bookmarks-changed', reload) }, [loadTags, loadBookmarks, selectedTag])
const createTag = async () => {
if (!newName) return
+1 -1
View File
@@ -62,7 +62,7 @@ export function TrashClient() {
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `computer-export-${new Date().toISOString().slice(0, 10)}.json`
a.download = `superbrain-export-${new Date().toISOString().slice(0, 10)}.json`
document.body.appendChild(a); a.click(); a.remove()
URL.revokeObjectURL(url)
toast.success('Export downloaded')
+1 -1
View File
@@ -55,7 +55,7 @@ async function proxy(request: NextRequest) {
// does). X-Forwarded-For is deliberately ignored: its leftmost entry is
// client-controlled. backendFetch adds the timestamped HMAC signature.
const clientIP = observedClientIP(request.headers)
if (clientIP) headers.set('x-computer-client-ip', clientIP)
if (clientIP) headers.set('x-superbrain-client-ip', clientIP)
if (!['GET', 'HEAD'].includes(request.method)) {
const declared = Number(request.headers.get('content-length') || 0)
if (declared > MAX_BODY_BYTES) {
+1 -1
View File
@@ -33,7 +33,7 @@ export async function POST(req: Request) {
headers: {
'Content-Type': 'application/json',
// Same short-lived assertion the data proxy signs (lib/api.ts).
Authorization: `Bearer ${jwt.sign({ uid: id, ver, typ: 'assertion' }, secret, { algorithm: 'HS256', issuer: 'computer', expiresIn: '60s' })}`,
Authorization: `Bearer ${jwt.sign({ uid: id, ver, typ: 'assertion' }, secret, { algorithm: 'HS256', issuer: 'superbrain', expiresIn: '60s' })}`,
},
cache: 'no-store',
signal: controller.signal,
+2 -2
View File
@@ -10,14 +10,14 @@ const jetbrainsMono = JetBrains_Mono({ subsets: ['latin'], variable: '--font-mon
export const metadata = {
metadataBase: new URL(process.env.NEXTAUTH_URL ?? 'http://localhost:3000'),
title: 'computer',
title: 'Superbrain',
description: 'Your personal binder of life on the web',
icons: {
icon: '/favicon.svg',
shortcut: '/favicon.svg',
},
openGraph: {
title: 'computer',
title: 'Superbrain',
description: 'Your personal binder of life on the web',
images: ['/og-image.png'],
},
+1 -1
View File
@@ -49,7 +49,7 @@ export function LoginClient({ oidcEnabled }: { oidcEnabled: boolean }) {
<Link2 className="h-7 w-7" />
</div>
</div>
<h1 className="font-display text-3xl font-bold tracking-tight">computer</h1>
<h1 className="font-display text-3xl font-bold tracking-tight">Superbrain</h1>
<p className="text-sm text-muted-foreground mt-2">Your personal binder of life on the web</p>
</div>
+1 -1
View File
@@ -16,7 +16,7 @@ export function PublicBookmarkView({ bookmark }: { bookmark: any }) {
<div className="flex h-8 w-8 items-center justify-center rounded-lg bg-primary text-primary-foreground">
<Link2 className="h-4 w-4" />
</div>
<span className="font-display font-bold">computer</span>
<span className="font-display font-bold">Superbrain</span>
<span className="text-muted-foreground text-sm">— Shared Bookmark</span>
</div>
</header>
+1 -1
View File
@@ -57,7 +57,7 @@ export function SignupClient() {
</div>
</div>
<h1 className="font-display text-3xl font-bold tracking-tight">Create Account</h1>
<p className="text-sm text-muted-foreground mt-2">Join computer to start organizing your links</p>
<p className="text-sm text-muted-foreground mt-2">Join Superbrain to start organizing your links</p>
</div>
<form onSubmit={handleSignup} className="space-y-3">
+4 -4
View File
@@ -54,9 +54,9 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
const ip = observedClientIP(request?.headers ?? new Headers())
if (ip && secret) {
const { ts, sig } = signClientIP(secret, ip)
headers['x-computer-client-ip'] = ip
headers['x-computer-client-ts'] = ts
headers['x-computer-client-sig'] = sig
headers['x-superbrain-client-ip'] = ip
headers['x-superbrain-client-ts'] = ts
headers['x-superbrain-client-sig'] = sig
}
const response = await fetch(`${process.env.API_BASE_URL || 'http://localhost:8080'}/api/auth/login`, {
method: 'POST', headers, cache: 'no-store',
@@ -124,7 +124,7 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
headers: {
'Content-Type': 'application/json',
// Same short-lived assertion the data proxy signs (lib/api.ts).
Authorization: `Bearer ${jwt.sign({ uid: id, ver, typ: 'assertion' }, secret, { algorithm: 'HS256', issuer: 'computer', expiresIn: '60s' })}`,
Authorization: `Bearer ${jwt.sign({ uid: id, ver, typ: 'assertion' }, secret, { algorithm: 'HS256', issuer: 'superbrain', expiresIn: '60s' })}`,
},
cache: 'no-store',
signal: controller.signal,
+2 -2
View File
@@ -96,7 +96,7 @@ export function AppShell({ children }: { children: React.ReactNode }) {
const id = String(a?.id ?? a?.bookmarkId ?? '')
if (!id || notifiedAlerts.current.has(id)) continue
notifiedAlerts.current.add(id)
new Notification('computer alert', { body: `${a?.title ?? 'Bookmark'} is due!`, icon: '/favicon.svg' })
new Notification('superbrain alert', { body: `${a?.title ?? 'Bookmark'} is due!`, icon: '/favicon.svg' })
}
}
}
@@ -111,7 +111,7 @@ export function AppShell({ children }: { children: React.ReactNode }) {
// an explicit user action (top-bar.tsx), not on every app mount.
const refreshPage = useCallback(() => {
window.dispatchEvent(new Event('computer:bookmarks-changed'))
window.dispatchEvent(new Event('superbrain:bookmarks-changed'))
router.refresh()
}, [router])
+4 -4
View File
@@ -32,7 +32,7 @@ const viewItems = [
// Section collapse state persists per browser. useSyncExternalStore keeps it
// hydration-safe (server snapshot uses the default; the client snapshot reads
// localStorage after mount) without setState inside an effect.
const SECTION_STORE_EVENT = 'computer:sidebar-sections'
const SECTION_STORE_EVENT = 'superbrain:sidebar-sections'
function readSection(key: string, fallback: boolean): boolean {
try {
@@ -81,7 +81,7 @@ export function Sidebar({ open, onToggle, onQuickFind, pathname, isAdmin = false
<div className="flex h-6 w-6 shrink-0 items-center justify-center rounded bg-primary text-primary-foreground">
<Link2 className="h-3.5 w-3.5" />
</div>
{open && <span className="truncate font-display text-sm font-bold tracking-tight">computer</span>}
{open && <span className="truncate font-display text-sm font-bold tracking-tight">superbrain</span>}
</Link>
</div>
<Suspense fallback={<div className="flex-1" />}>
@@ -147,8 +147,8 @@ function SidebarNav({ open, pathname, isAdmin = false }: { open: boolean; pathna
const router = useRouter()
const searchParams = useSearchParams()
const [pages, setPages] = useState<PageSummary[]>([])
const [pagesExpanded, setPagesExpanded] = usePersistentState('computer:sidebar:pages', true)
const [viewsExpanded, setViewsExpanded] = usePersistentState('computer:sidebar:views', true)
const [pagesExpanded, setPagesExpanded] = usePersistentState('superbrain:sidebar:pages', true)
const [viewsExpanded, setViewsExpanded] = usePersistentState('superbrain:sidebar:views', true)
const [renamingId, setRenamingId] = useState<string | null>(null)
const [renameValue, setRenameValue] = useState('')
const [pageDrop, setPageDrop] = useState<{ id: string; after: boolean } | null>(null)
+2 -2
View File
@@ -86,7 +86,7 @@ export function TopBar({ user, alerts, onDismissAlert, onAddBookmark, onToggleSi
return () => document.removeEventListener('mousedown', handler)
}, [])
const section = SECTION_LABELS[pathname] ?? 'computer'
const section = SECTION_LABELS[pathname] ?? 'superbrain'
const isMac = mounted && typeof navigator !== 'undefined' && /mac|iphone|ipad/i.test(navigator.userAgent)
const quickFindHint = !mounted ? '⌘K' : isMac ? '⌘K' : 'Ctrl K'
@@ -122,7 +122,7 @@ export function TopBar({ user, alerts, onDismissAlert, onAddBookmark, onToggleSi
<BreadcrumbList className="flex-nowrap">
<BreadcrumbItem>
<BreadcrumbLink asChild className="font-medium">
<Link href="/pages">computer</Link>
<Link href="/pages">superbrain</Link>
</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
+13 -13
View File
@@ -1,6 +1,6 @@
# Connecting computer to Authelia (OIDC)
# Connecting superbrain to Authelia (OIDC)
computer includes an **Authelia OpenID Connect provider scaffold**, but
superbrain includes an **Authelia OpenID Connect provider scaffold**, but
end-to-end sign-in is intentionally **stubbed**. Real credentials register
the NextAuth provider; the login button and sign-in callback still block it
until a developer implements mapping to local Go users.
@@ -62,10 +62,10 @@ docker run --rm authelia/authelia:4.39 authelia crypto hash generate pbkdf2 \
```
This prints:
- **Random Password**: the *plain* secret. It goes into computer as `OIDC_CLIENT_SECRET`.
- **Random Password**: the *plain* secret. It goes into superbrain as `OIDC_CLIENT_SECRET`.
- **Digest**: the *hashed* secret. It goes into Authelia's `client_secret`.
### 2.2 Register the computer client (`configuration.yml`)
### 2.2 Register the superbrain client (`configuration.yml`)
Merge this example into the existing OIDC provider configuration. Replace the
client secret digest and public app hostname; keep your existing provider
@@ -76,19 +76,19 @@ identity_providers:
oidc:
# jwks / hmac_secret must already be configured for OIDC to work
claims_policies:
computer:
superbrain:
# Include these identity claims in the ID token.
id_token: ['email', 'email_verified', 'name', 'preferred_username']
clients:
- client_id: 'computer'
client_name: 'computer'
- client_id: 'superbrain'
client_name: 'superbrain'
client_secret: '$pbkdf2-sha512$310000$...' # Digest from 2.1
public: false
authorization_policy: 'two_factor' # or 'one_factor'
consent_mode: 'explicit'
claims_policy: 'computer'
claims_policy: 'superbrain'
redirect_uris:
- 'https://<COMPUTER_HOST>/api/auth/callback/authelia'
- 'https://<superbrain_HOST>/api/auth/callback/authelia'
scopes: ['openid', 'profile', 'email']
grant_types: ['authorization_code']
response_types: ['code']
@@ -100,7 +100,7 @@ Validate the configuration and restart your Authelia deployment after editing.
**Redirect URI rule:** it must exactly match
`<NEXTAUTH_URL>/api/auth/callback/authelia`, including scheme, hostname, port
if present, and path. For an HTTPS deployment, use
`https://<COMPUTER_HOST>/api/auth/callback/authelia`.
`https://<superbrain_HOST>/api/auth/callback/authelia`.
The callback is handled by NextAuth on the **web app**, not the Go API.
Forward `/api/auth/*` to Next.js in your reverse proxy. The identically named
@@ -115,7 +115,7 @@ email/password account; matching an email string alone is not enough.
---
## 3. What to configure in computer
## 3. What to configure in superbrain
Set these environment variables in the **root** `.env` or hosting environment.
Compose passes the OIDC variables to the API and web containers. Replace the
@@ -123,10 +123,10 @@ sample hostnames with your actual hosts.
| Variable | Example | Notes |
|---|---|---|
| `NEXTAUTH_URL` | `https://computer.company.tld` | Public web app URL; determines the callback |
| `NEXTAUTH_URL` | `https://superbrain.company.tld` | Public web app URL; determines the callback |
| `COOKIE_SECURE` | `1` | For an HTTPS deployment |
| `OIDC_ISSUER` | `https://auth.company.tld` | Exact issuer advertised in Authelia's discovery document |
| `OIDC_CLIENT_ID` | `computer` | Must match `client_id` in Authelia |
| `OIDC_CLIENT_ID` | `superbrain` | Must match `client_id` in Authelia |
| `OIDC_CLIENT_SECRET` | *(plain secret from 2.1)* | The **plain** value, not the digest |
Keep the existing `AUTH_SECRET`: changing it makes stored IMAP passwords
+9 -9
View File
@@ -33,9 +33,9 @@ export const forwardedClientHeaders = (source: Headers): Record<string, string>
if (!ip) return {}
const { ts, sig } = signClientIP(ip)
return {
'x-computer-client-ip': ip,
'x-computer-client-ts': ts,
'x-computer-client-sig': sig,
'x-superbrain-client-ip': ip,
'x-superbrain-client-ts': ts,
'x-superbrain-client-sig': sig,
}
}
@@ -54,7 +54,7 @@ export async function backendFetch(path: string, init: RequestInit = {}) {
if (session?.user?.id) {
if (!secret) throw new Error('Missing authentication secret')
headers.set('Authorization', `Bearer ${jwt.sign({ uid: session.user.id, ver: session.user.ver, typ: 'assertion' }, secret, {
algorithm: 'HS256', issuer: 'computer', expiresIn: '60s',
algorithm: 'HS256', issuer: 'superbrain', expiresIn: '60s',
})}`)
}
// Review AUTH-RATE/SEC-2: attest the browser IP for Go's login/signup
@@ -62,14 +62,14 @@ export async function backendFetch(path: string, init: RequestInit = {}) {
// bucket. The timestamped HMAC keeps the header unforgeable and
// short-lived; Go falls back to the direct peer when it is missing or
// invalid.
const clientIP = headers.get('x-computer-client-ip')
const clientIP = headers.get('x-superbrain-client-ip')
if (clientIP && secret) {
const { ts, sig } = signClientIP(clientIP)
headers.set('x-computer-client-ts', ts)
headers.set('x-computer-client-sig', sig)
headers.set('x-superbrain-client-ts', ts)
headers.set('x-superbrain-client-sig', sig)
}
const viewAs = (await cookies()).get('computer_view_as')?.value
if (viewAs) headers.set('Cookie', `computer_view_as=${encodeURIComponent(viewAs)}`)
const viewAs = (await cookies()).get('superbrain_view_as')?.value
if (viewAs) headers.set('Cookie', `superbrain_view_as=${encodeURIComponent(viewAs)}`)
// Review M-7: bound server-side calls so a hung or blackholed backend
// cannot stall a route/server component until the platform timeout.
// Callers may provide their own signal to override this default.
+1 -1
View File
@@ -1,6 +1,6 @@
import { backendFetch } from '@/lib/api'
export const VIEW_AS_COOKIE = 'computer_view_as'
export const VIEW_AS_COOKIE = 'superbrain_view_as'
export type AuthUser = { id: string; name?: string | null; email?: string | null; image?: string | null; role: 'USER' | 'ADMIN'; actingAdminId?: string }
// Review M-6: Go distinguishes "no session" (401) from backend degradation
+1 -1
View File
@@ -43,7 +43,7 @@ export class PageAutosave {
setVersion(id: string, version: number) { this.versions.set(id, version) }
private key(id: string) { return `computer:page-draft:${id}` }
private key(id: string) { return `superbrain:page-draft:${id}` }
private store(id: string, draft: Draft | null) {
try {
if (draft === null) sessionStorage.removeItem(this.key(id))
+8 -8
View File
@@ -1,10 +1,10 @@
export const PAGES_CHANGED = 'computer:pages-changed'
export const PAGES_CHANGED = 'superbrain:pages-changed'
export const notifyPagesChanged = () => window.dispatchEvent(new Event(PAGES_CHANGED))
// Notion-style breadcrumbs: the pages workspace announces which page is open
// so the top bar can show "computer / Pages / <title>" without refetching.
export const ACTIVE_PAGE_CHANGED = 'computer:active-page-changed'
// so the top bar can show "superbrain / Pages / <title>" without refetching.
export const ACTIVE_PAGE_CHANGED = 'superbrain:active-page-changed'
export const notifyActivePage = (title: string | null) =>
window.dispatchEvent(new CustomEvent<string | null>(ACTIVE_PAGE_CHANGED, { detail: title }))
@@ -20,15 +20,15 @@ export type PageSummary = {
// Connected pages (phase 3): the same link forms the editor understands,
// shared by the page client, sidebar and Markdown preview. Page links use
// `computer:page/<id>`; /pages?id=<id> is accepted for hand-written links.
// `superbrain:page/<id>`; /pages?id=<id> is accepted for hand-written links.
export function internalPageId(href: string): string | null {
const value = href.trim().replace(/^<|>$/g, '')
let raw = ''
if (value.startsWith('computer://page/')) raw = value.slice('computer://page/'.length)
else if (value.startsWith('computer:page/')) raw = value.slice('computer:page/'.length)
if (value.startsWith('superbrain://page/')) raw = value.slice('superbrain://page/'.length)
else if (value.startsWith('superbrain:page/')) raw = value.slice('superbrain:page/'.length)
else if (value.startsWith('page/')) raw = value.slice('page/'.length)
else if (value.startsWith('/pages/')) raw = value.slice('/pages/'.length)
else if (value.startsWith('/pages?') || value.startsWith('computer:page?id=') || value.startsWith('computer://page?id=')) {
else if (value.startsWith('/pages?') || value.startsWith('superbrain:page?id=') || value.startsWith('superbrain://page?id=')) {
try {
const id = new URL(value, 'http://localhost').searchParams.get('id')
raw = id ?? ''
@@ -39,7 +39,7 @@ export function internalPageId(href: string): string | null {
}
export const pageLinkMarkdown = (page: Pick<PageSummary, 'id' | 'title'>) =>
`[${page.title.replace(/[\[\]\n]/g, ' ')}](computer:page/${page.id})`
`[${page.title.replace(/[\[\]\n]/g, ' ')}](superbrain:page/${page.id})`
export type PageEmbedMarker = { collectionId: string; viewId: string | null }
@@ -1,6 +1,6 @@
# computer: porting guide
# superbrain: porting guide
This guide lists every data object, server function, HTTP endpoint and client behavior in **computer**, so it can be rebuilt in another language or framework. It describes the code as it is today (October 2026), including the parts that are stubs or unfinished.
This guide lists every data object, server function, HTTP endpoint and client behavior in **superbrain**, so it can be rebuilt in another language or framework. It describes the code as it is today (October 2026), including the parts that are stubs or unfinished.
The guide uses neutral terms wherever possible. "Session user" means the authenticated person; "effective user" means the account a request acts on (these differ only while an admin uses *View as*).
@@ -91,7 +91,7 @@ Composite PK (`tagId`, `userId`), `createdAt`; both Cascade.
Composite PK (`pageId`, `bookmarkId`), `position` int, `createdAt`; both Cascade.
### 2.13b `PageLink` (resolved internal page link)
Composite PK (`sourcePageId`, `targetPageId`), `createdAt`; both Cascade, with a no-self check. Rebuilt from Markdown (`computer:page/<id>`) on every content save and only for pages owned by the author, so backlinks never cross accounts.
Composite PK (`sourcePageId`, `targetPageId`), `createdAt`; both Cascade, with a no-self check. Rebuilt from Markdown (`superbrain:page/<id>`) on every content save and only for pages owned by the author, so backlinks never cross accounts.
### 2.13c `PageEmbed` (live collection view inside a page)
Composite PK (`pageId`, `collectionId`), `viewId?` → CollectionView (SetNull), `position` int, `createdAt`; page and collection Cascade. Rebuilt from `{{collection:<id>|view=<viewId>}}` on every content save; only owned collections are stored. Item reads still go through the collection endpoint, so an embed displays, never publishes.
@@ -129,7 +129,7 @@ Secrets: `NEXTAUTH_SECRET` / `AUTH_SECRET` (same value) sign the cookie.
### 3.2 Authorization (`lib/auth-guard.ts`)
| Symbol | Signature | Behavior |
|---|---|---|
| `VIEW_AS_COOKIE` | const `"computer_view_as"` | Cookie holding the target user ID |
| `VIEW_AS_COOKIE` | const `"superbrain_view_as"` | Cookie holding the target user ID |
| `AuthUser` | `{id, name?, email?, image?, role: USER\|ADMIN, actingAdminId?}` | |
| `adminEmails()` | `→ string[]` | Splits env `ADMIN_EMAILS` on commas, trims, lowercases |
| `resolveRole(user)` | `→ USER\|ADMIN` | ADMIN if DB role is ADMIN; otherwise if email is in `adminEmails()`, **writes** role ADMIN to the DB and returns ADMIN |
@@ -166,13 +166,13 @@ When porting, the real email check should: decrypt the IMAP password, connect, s
Changing the secret makes saved IMAP passwords unreadable.
### 3.6 Link preview (repeated in `/api/preview`, bookmark create and bookmark update)
`fetchPreview(url)` uses an 8-second timeout and User-Agent `Mozilla/5.0 (compatible; computer/1.0)`. It reads OpenGraph `ogTitle`, `ogDescription`, the first `ogImage` URL, and the favicon. A relative favicon is made absolute against the URL's origin; if none is found it uses `<origin>/favicon.ico`. On any failure it returns all nulls and never throws. **Port tip:** make this one shared function.
`fetchPreview(url)` uses an 8-second timeout and User-Agent `Mozilla/5.0 (compatible; superbrain/1.0)`. It reads OpenGraph `ogTitle`, `ogDescription`, the first `ogImage` URL, and the favicon. A relative favicon is made absolute against the URL's origin; if none is found it uses `<origin>/favicon.ico`. On any failure it returns all nulls and never throws. **Port tip:** make this one shared function.
### 3.7 Markdown export (`lib/markdown-export.ts`)
| Function | Output |
|---|---|
| `slugify(s)` | Lowercase, runs of non `[a-z0-9]` become `-`, trim dashes, max 60 chars, fallback `untitled` |
| `pageToMarkdown(page)` | `# title`, blank line, trimmed content; if links exist, `## Links` then `- [title](url) — description` (title has `[` `]` removed; description whitespace collapsed, max 160 chars); final line `<!-- exported from computer <updatedAt ISO> -->` |
| `pageToMarkdown(page)` | `# title`, blank line, trimmed content; if links exist, `## Links` then `- [title](url) — description` (title has `[` `]` removed; description whitespace collapsed, max 160 chars); final line `<!-- exported from superbrain <updatedAt ISO> -->` |
| `bookmarkToMarkdown(b)` | `# title-or-url`, then `- URL: <url>`, `- Date: YYYY-MM-DD` (if dueDate), `- Tags: a, b` (if any), blank line, trimmed notes |
| `markdownResponse(body, name)` | Content-Type `text/markdown; charset=utf-8`, `Content-Disposition: attachment; filename="<name>.md"` |
@@ -180,7 +180,7 @@ Changing the secret makes saved IMAP passwords unreadable.
`isRealValue(v)` is false when empty or matching a placeholder pattern: `replace_me`/`replace-me`/`replaceme`, `example.com/org/net`, `changeme`, `placeholder`, `<...>`, `your_…`/`your-…`, `todo`. `getOidcStatus()` returns `{enabled, issuerSet, clientIdSet, clientSecretSet, issuer}`, with `enabled` only when all three env values are real. It never exposes the secret.
### 3.9 Seed script (`scripts/seed.ts`)
Upserts a hidden test account. If env `DEMO_PASSWORD` is set, it also upserts five demo users (maya = ADMIN, jordan, sam, priya, alex @computer.demo). Each gets default columns, tags, bookmarks and one page, created only if that user has no bookmarks yet, followed by idempotent share upserts. It never deletes anything.
Upserts a hidden test account. If env `DEMO_PASSWORD` is set, it also upserts five demo users (maya = ADMIN, jordan, sam, priya, alex @superbrain.demo). Each gets default columns, tags, bookmarks and one page, created only if that user has no bookmarks yet, followed by idempotent share upserts. It never deletes anything.
---
@@ -293,15 +293,15 @@ Moving a card = `PUT /api/bookmarks/:id {kanbanColumnId}`.
| Screen / component | Responsibilities |
|---|---|
| **App shell** | Loads session and `/api/me`; shows the View as banner with an Exit button (`POST /api/admin/view-as {userId:null}`); asks for notification permission; polls `/api/alerts/check` on load and every **5 minutes**, showing a browser `Notification("computer alert", "<title> is due!")` per alert; provides search text, the add-bookmark dialog and the bookmark detail panel to child screens |
| **Sidebar** | Pages first: full page list (pinned pages marked) plus a New page button creating the next "Untitled N", refreshing on the in-app event `computer:pages-changed`. Below, a Filters section (All Bookmarks, Calendar, Tags, Kanban, Contacts — views over the same bookmark collection) and Settings, plus Admin for admins |
| **App shell** | Loads session and `/api/me`; shows the View as banner with an Exit button (`POST /api/admin/view-as {userId:null}`); asks for notification permission; polls `/api/alerts/check` on load and every **5 minutes**, showing a browser `Notification("superbrain alert", "<title> is due!")` per alert; provides search text, the add-bookmark dialog and the bookmark detail panel to child screens |
| **Sidebar** | Pages first: full page list (pinned pages marked) plus a New page button creating the next "Untitled N", refreshing on the in-app event `superbrain:pages-changed`. Below, a Filters section (All Bookmarks, Calendar, Tags, Kanban, Contacts — views over the same bookmark collection) and Settings, plus Admin for admins |
| **Dashboard** `/dashboard` | Removed as a screen; redirects to `/bookmarks` preserving `?search=` |
| **Bookmarks** `/bookmarks` | Sortable table with Mine / Shared tabs and search (absorbed the old dashboard) |
| **Calendar** `/calendar` | Month grid of bookmarks by `dueDate`, plus shared dates |
| **Tags** `/tags` | Tag list (create, color, share) with filtered bookmarks |
| **Contacts** `/contacts` | Synced contacts and their linked bookmarks |
| **Kanban** `/kanban` | Columns from `getColumns`; cards placed with `resolveColumnId`; drag and drop moves a card (PUT `kanbanColumnId`); add, rename, recolor, reorder and delete columns |
| **Pages** `/pages` | Tab bar of pages; Markdown editor with edit/preview toggle and **autosave 800 ms** after the last keystroke (states dirty → saving → saved); link picker searching bookmarks (250 ms delay, top 8); pin/unpin, rename, delete, .md download; sends `computer:pages-changed` after changes |
| **Pages** `/pages` | Tab bar of pages; Markdown editor with edit/preview toggle and **autosave 800 ms** after the last keystroke (states dirty → saving → saved); link picker searching bookmarks (250 ms delay, top 8); pin/unpin, rename, delete, .md download; sends `superbrain:pages-changed` after changes |
| **Admin** `/admin` | User list with counts, role toggle, View as button |
| **Settings** `/settings` | Profile; IMAP form (test + save); Nextcloud sync form; Authelia status and callback URL |
| **Add bookmark dialog** | URL with live preview (`/api/preview`), title, notes, tags, dates |
@@ -1,8 +1,8 @@
# LinkOS: Requirements
# Superbrain: Requirements
## 1. Purpose
LinkOS is a web-based "computer": a personal, multi-user collection of URLs that
Superbrain: a personal, multi-user collection of URLs that
point to applications and sites. Users find links through several ways of
organizing them (calendar, tags, contacts, kanban). Clicking a URL opens the
target application or site.