Fix remaining branding leaks: error-page logo/links + notification bell
Follow-up to client testing on the flattened (sparse-checkout) structure. - icons.tsx: swap inline OnyxLogoTypeIcon SVG (error/health pages, craft) for the AIDO wordmark asset, via a new template + anchored, idempotent patch. - Notification bell content is backend-generated (official image, not rebuilt), so rebrand it at render time: generate lib/branding-runtime.ts from config and route the notifications hook through it — sanitize 'Onyx'->brand and suppress upstream/EE product notices (permissions-migration announcement, license/trial). - Repoint hardcoded Onyx links/emails: Discord, support@onyx.app, '@onyx.app administrators' (WebResultIcon hostname logic intentionally left untouched). - .gitignore: ignore generated /web/, /data/, .onyx-sparse-tmp/ so 'make setup' output can't be committed accidentally. - README + verify updated for the new touchpoints. Verified in the flattened layout: branded web image builds, 0 stray 'Onyx', and bundle greps confirm all leaks gone.
This commit is contained in:
parent
1d650c4d30
commit
bbd9835558
6 changed files with 153 additions and 7 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
|
@ -1,5 +1,8 @@
|
||||||
# Upstream Onyx checkout — cloned by `make setup`, not part of this overlay repo.
|
# Upstream Onyx checkout — fetched by `make setup` (sparse: web/ + deployment/data/nginx),
|
||||||
# The branding overlay regenerates into it via `make apply`.
|
# not part of this overlay repo. The branding overlay regenerates into it via `make apply`.
|
||||||
|
/web/
|
||||||
|
/data/
|
||||||
|
.onyx-sparse-tmp/
|
||||||
/onyx/
|
/onyx/
|
||||||
|
|
||||||
# Local deployment secrets (copy from the *.example templates)
|
# Local deployment secrets (copy from the *.example templates)
|
||||||
|
|
|
||||||
2
Makefile
2
Makefile
|
|
@ -73,4 +73,4 @@ config:
|
||||||
verify:
|
verify:
|
||||||
@echo "Stray standalone 'Onyx' in shipping web source (expect 0):"
|
@echo "Stray standalone 'Onyx' in shipping web source (expect 0):"
|
||||||
@grep -rnE '\bOnyx\b' web/src --include='*.ts' --include='*.tsx' \
|
@grep -rnE '\bOnyx\b' web/src --include='*.ts' --include='*.tsx' \
|
||||||
| grep -vE '\.test\.|\.spec\.|\.stories\.|__tests__|__mocks__' | wc -l
|
| grep -vE '\.test\.|\.spec\.|\.stories\.|__tests__|__mocks__|branding-runtime\.ts' | wc -l
|
||||||
|
|
|
||||||
30
README.md
30
README.md
|
|
@ -156,10 +156,36 @@ images match the web build you're compiling. Two things to watch after an upgrad
|
||||||
`settings/lib.ts`) → `AIDO`; this also drives the browser tab title.
|
`settings/lib.ts`) → `AIDO`; this also drives the browser tab title.
|
||||||
- **All UI strings** — ~180 user-visible "Onyx" references across ~96 files
|
- **All UI strings** — ~180 user-visible "Onyx" references across ~96 files
|
||||||
(chat, onboarding, admin panels, modals, auth screen, error pages…).
|
(chat, onboarding, admin panels, modals, auth screen, error pages…).
|
||||||
- **Logo** — the in-app symbol + wordmark components render the AIDO assets.
|
- **Logo** — the in-app symbol + wordmark components (incl. the inline
|
||||||
|
`OnyxLogoTypeIcon` used on the error/health pages) render the AIDO assets.
|
||||||
- **Favicon** — `public/onyx.ico` replaced and `DynamicMetadata` repointed to
|
- **Favicon** — `public/onyx.ico` replaced and `DynamicMetadata` repointed to
|
||||||
`/branding/favicon.png`.
|
`/branding/favicon.png`.
|
||||||
- **Documentation links** — `DOCS_BASE_URL` and `docs.onyx.app` → Livtec portal.
|
- **Documentation & community links** — `DOCS_BASE_URL` / `docs.onyx.app`, the Onyx
|
||||||
|
Discord URL, `www.onyx.app` links and `support@onyx.app` → Livtec destinations
|
||||||
|
(see `rename.literals`).
|
||||||
|
- **Notification bell** — its text is generated by the **backend** (the official
|
||||||
|
image we don't rebuild), so it's rebranded at render time in the web image:
|
||||||
|
any "Onyx" in a notification is rewritten to the brand name, and upstream/EE
|
||||||
|
product notifications (permissions-migration announcement, license/trial warnings)
|
||||||
|
are suppressed. See [Notifications](#notifications) below.
|
||||||
|
|
||||||
|
### Notifications
|
||||||
|
|
||||||
|
Driven by `branding.config.json → notifications`:
|
||||||
|
|
||||||
|
| Key | Effect |
|
||||||
|
|-----|--------|
|
||||||
|
| `sanitize: true` | Rewrites "Onyx" → brand name in any notification title/description at render time. |
|
||||||
|
| `suppressTypes: [...]` | Hides whole categories (`feature_announcement`, `release_notes`, `license_expiry_warning`, `two_day_trial_ending`). Empty the list to show everything (still sanitized). |
|
||||||
|
|
||||||
|
Operational notifications (reindex, approvals, connector errors, scheduled tasks)
|
||||||
|
are always kept. The apply script generates `web/src/lib/branding-runtime.ts` from
|
||||||
|
these values and routes the notifications hook through it.
|
||||||
|
|
||||||
|
> Minor note: suppression hides items from the **panel**; the bell's unread *count*
|
||||||
|
> comes from a separate backend summary endpoint, so a suppressed-but-unread item can
|
||||||
|
> still nudge the counter. If you'd rather keep perfect counts, set `suppressTypes: []`
|
||||||
|
> — sanitization alone removes the "Onyx" wording with no count impact.
|
||||||
|
|
||||||
### Known limitations / notes
|
### Known limitations / notes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,83 @@ for (const [tplName, dest] of logoInstalls) {
|
||||||
ok(`installed ${tplName} → ${path.relative(WEB, dest)}`);
|
ok(`installed ${tplName} → ${path.relative(WEB, dest)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── 2b. Targeted source patches ─────────────────────────────────────────────
|
||||||
|
// Surgical, anchored edits for branding that the bulk string codemod can't reach:
|
||||||
|
// an inline SVG wordmark, and backend-generated notification content that is only
|
||||||
|
// rebrandable at render time in the web image. Each patch warns (does not fail) if
|
||||||
|
// its anchor is missing after an upstream change — same maintenance model as logos.
|
||||||
|
step("2b/4 Targeted patches");
|
||||||
|
|
||||||
|
async function patchFile(rel, edits) {
|
||||||
|
const fp = path.join(SRC, rel);
|
||||||
|
if (!existsSync(fp)) { warn(`patch target missing (upstream moved it?): ${rel}`); return; }
|
||||||
|
let src = await readFile(fp, "utf8");
|
||||||
|
let applied = 0;
|
||||||
|
for (const e of edits) {
|
||||||
|
if (e.done && src.includes(e.done)) { applied++; continue; } // idempotent: already patched
|
||||||
|
const present = e.find instanceof RegExp ? e.find.test(src) : src.includes(e.find);
|
||||||
|
if (!present) { warn(`anchor not found in ${rel}: ${e.desc}`); continue; }
|
||||||
|
src = e.find instanceof RegExp ? src.replace(e.find, e.replace) : src.split(e.find).join(e.replace);
|
||||||
|
applied++;
|
||||||
|
}
|
||||||
|
if (applied && !DRY) await writeFile(fp, src);
|
||||||
|
if (applied) ok(`patched ${rel} (${applied}/${edits.length} edit(s))`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// (a) Error page / craft wordmark: inline <OnyxLogoTypeIcon> SVG → AIDO image asset.
|
||||||
|
const onyxTypeIcon = fillTemplate(await readFile(path.join(BRANDING, "templates", "icons-OnyxLogoTypeIcon.tsx"), "utf8"));
|
||||||
|
await patchFile("components/icons/icons.tsx", [{
|
||||||
|
desc: "OnyxLogoTypeIcon inline SVG wordmark",
|
||||||
|
find: /export const OnyxLogoTypeIcon = \(\{[\s\S]*?\n\};\n/,
|
||||||
|
replace: onyxTypeIcon.endsWith("\n") ? onyxTypeIcon : onyxTypeIcon + "\n",
|
||||||
|
}]);
|
||||||
|
|
||||||
|
// (b) Notifications: their text is generated by the backend (official image we do
|
||||||
|
// NOT rebuild), so rebrand/suppress it at render time. Generate a tiny runtime
|
||||||
|
// helper from config, then route the notifications list through it.
|
||||||
|
const N = CONFIG.notifications ?? { sanitize: true, suppressTypes: [] };
|
||||||
|
const runtime = `// AUTO-GENERATED by branding/apply-branding.mjs — do not edit by hand.
|
||||||
|
// Runtime rebranding for backend-generated content (notification bell) that the
|
||||||
|
// build-time codemod cannot reach. Driven by branding.config.json → notifications.
|
||||||
|
const WORD_PAIRS: [string, string][] = ${JSON.stringify(Object.entries(CONFIG.rename.word))};
|
||||||
|
const SANITIZE = ${N.sanitize ? "true" : "false"};
|
||||||
|
const SUPPRESS_TYPES = new Set<string>(${JSON.stringify(N.suppressTypes ?? [])});
|
||||||
|
|
||||||
|
export function brandText<T extends string | null | undefined>(text: T): T {
|
||||||
|
if (!text || !SANITIZE) return text;
|
||||||
|
let out: string = text;
|
||||||
|
for (const [from, to] of WORD_PAIRS) {
|
||||||
|
out = out.replace(new RegExp(\`\\\\b\${from}\\\\b\`, "g"), to);
|
||||||
|
}
|
||||||
|
return out as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function filterBrandedNotifications<
|
||||||
|
N extends { notif_type: string; title: string; description: string | null },
|
||||||
|
>(list: N[]): N[] {
|
||||||
|
return list
|
||||||
|
.filter((n) => !SUPPRESS_TYPES.has(n.notif_type))
|
||||||
|
.map((n) => ({ ...n, title: brandText(n.title), description: brandText(n.description) }));
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
if (!DRY) await writeFile(path.join(SRC, "lib/branding-runtime.ts"), runtime);
|
||||||
|
ok(`generated lib/branding-runtime.ts (sanitize=${!!N.sanitize}, suppress=${(N.suppressTypes ?? []).length})`);
|
||||||
|
|
||||||
|
await patchFile("hooks/useNotifications.ts", [
|
||||||
|
{
|
||||||
|
desc: "import branding runtime",
|
||||||
|
done: `import { filterBrandedNotifications } from "@/lib/branding-runtime";`,
|
||||||
|
find: `import { useCallback, useMemo, useRef } from "react";`,
|
||||||
|
replace: `import { useCallback, useMemo, useRef } from "react";\nimport { filterBrandedNotifications } from "@/lib/branding-runtime";`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "route notifications list through branding filter",
|
||||||
|
done: `return filterBrandedNotifications(`,
|
||||||
|
find: ` return data.flatMap((page) =>\n page.notifications.filter((notification) => {\n if (seenNotificationIds.has(notification.id)) {\n return false;\n }\n seenNotificationIds.add(notification.id);\n return true;\n })\n );`,
|
||||||
|
replace: ` return filterBrandedNotifications(\n data.flatMap((page) =>\n page.notifications.filter((notification) => {\n if (seenNotificationIds.has(notification.id)) {\n return false;\n }\n seenNotificationIds.add(notification.id);\n return true;\n })\n )\n );`,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
// ── 3. String codemod (user-visible references) ─────────────────────────────
|
// ── 3. String codemod (user-visible references) ─────────────────────────────
|
||||||
step("3/4 String codemod");
|
step("3/4 String codemod");
|
||||||
const literals = Object.entries(CONFIG.rename.literals);
|
const literals = Object.entries(CONFIG.rename.literals);
|
||||||
|
|
@ -123,7 +200,12 @@ const ASSET_PATH_EDITS = [["/onyx.ico", `/${CONFIG.assets.favicon.dest}`]]; // f
|
||||||
const SKIP = /(\.test\.|\.spec\.|\.stories\.|__tests__|__mocks__|\/node_modules\/)/;
|
const SKIP = /(\.test\.|\.spec\.|\.stories\.|__tests__|__mocks__|\/node_modules\/)/;
|
||||||
const EXT = /\.(ts|tsx)$/;
|
const EXT = /\.(ts|tsx)$/;
|
||||||
// Never rebrand these whole files (logos handled above; types declare identifiers).
|
// Never rebrand these whole files (logos handled above; types declare identifiers).
|
||||||
const SKIP_FILES = new Set(logoInstalls.map(([, d]) => path.resolve(d)));
|
// branding-runtime.ts is excluded because it holds the "Onyx"→brand rename rule
|
||||||
|
// itself — the word pass must not rewrite its own needle.
|
||||||
|
const SKIP_FILES = new Set([
|
||||||
|
...logoInstalls.map(([, d]) => path.resolve(d)),
|
||||||
|
path.resolve(path.join(SRC, "lib/branding-runtime.ts")),
|
||||||
|
]);
|
||||||
|
|
||||||
async function* walk(dir) {
|
async function* walk(dir) {
|
||||||
for (const e of await readdir(dir, { withFileTypes: true })) {
|
for (const e of await readdir(dir, { withFileTypes: true })) {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,21 @@
|
||||||
"literals": {
|
"literals": {
|
||||||
"Open Source AI Platform": "Powered by Livtec",
|
"Open Source AI Platform": "Powered by Livtec",
|
||||||
"https://docs.onyx.app": "https://portal.livtec.cloud",
|
"https://docs.onyx.app": "https://portal.livtec.cloud",
|
||||||
"https://www.onyx.app": "https://livtec.cloud"
|
"https://www.onyx.app": "https://livtec.cloud",
|
||||||
|
"https://discord.gg/4NA5SbzrWb": "https://livtec.cloud/",
|
||||||
|
"support@onyx.app": "support@livtec.cloud",
|
||||||
|
"@onyx.app administrators": "@livtec.cloud administrators"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"notifications": {
|
||||||
|
"$comment": "The notification bell content is generated by the backend (official onyx-backend image we do NOT rebuild), so it is rebranded at render time in the web image. `sanitize` rewrites any 'Onyx' in a notification's title/description to the brand name. `suppressTypes` hides whole notification categories that are upstream/EE product messaging irrelevant to a white-labeled CE deployment (e.g. the permissions-migration announcement and license/trial warnings). Operational notifications (reindex, approvals, connector errors, scheduled tasks) are kept. Empty the list to show everything (still sanitized).",
|
||||||
|
"sanitize": true,
|
||||||
|
"suppressTypes": [
|
||||||
|
"feature_announcement",
|
||||||
|
"release_notes",
|
||||||
|
"license_expiry_warning",
|
||||||
|
"two_day_trial_ending"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
branding/templates/icons-OnyxLogoTypeIcon.tsx
Normal file
21
branding/templates/icons-OnyxLogoTypeIcon.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
export const OnyxLogoTypeIcon = ({
|
||||||
|
size = 16,
|
||||||
|
className = defaultTailwindCSS,
|
||||||
|
}: IconProps) => {
|
||||||
|
// Brand wordmark lockup. Upstream rendered an inline Onyx SVG here; the
|
||||||
|
// white-label overlay swaps it for the AIDO image asset. Aspect ratio is
|
||||||
|
// preserved from the original viewBox so existing `size` props lay out the same.
|
||||||
|
const aspectRatio = 2640 / 733;
|
||||||
|
const height = size / aspectRatio;
|
||||||
|
return (
|
||||||
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
|
<img
|
||||||
|
src="__WORDMARK_SRC__"
|
||||||
|
alt="__BRAND_NAME__"
|
||||||
|
width={size}
|
||||||
|
height={height}
|
||||||
|
style={{ width: `${size}px`, height: `${height}px` }}
|
||||||
|
className={className}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
Loading…
Add table
Reference in a new issue