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
+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 }