feat(web-app-bluesky): build the configured title into the social app and its server pages

The title was never set: the spec only matched a substring of Bluesky's default. The patched web build now carries it: a rendered headings.ts makes every screen title '<screen> — <title>', a list of template patches next to the color patches rewrites title, application-name, og:site_name, og:title, twitter:title, the noscript heading and the 'on X' suffixes of the server templates (regexps that match whatever the element holds, the title HTML-escaped), and a rendered Logotype.tsx shows the generated text-only logotype slot as the splash wordmark.

The login broker's SSO handoff page takes its colors from the design tokens the proxy injects and its titles from SITE_TITLE. The probe for design sources a disabled design no longer wants used find contains without read_whole_file, so it matched line starts only and never triggered the re-clone; it now reads whole files and looks for each marker the configuration dropped. The spec asserts the exact screen title, the server-rendered titles and the 404 page, the wordmark, and the handoff page under sso.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-15 03:21:41 +02:00
1 parent eaa2f914dd
commit a2cf83aafe
11 files changed
+232 -14

No files matched your search

@@ -72,6 +72,7 @@ const CONFIG = {
// nocheck: env-default the broker owns its own cookie, no role renders it
handoffCookieMaxAgeSec: parseInt(process.env.HANDOFF_COOKIE_MAX_AGE || "3300", 10),
insecureTls: (process.env.INSECURE_TLS || "").toLowerCase() === "true",
siteTitle: requireEnv("SITE_TITLE"),
logoutPath: "/sso/logout"
};
@@ -371,12 +372,12 @@ function renderHandoff(session, redirectTo) {
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Bluesky SSO handoff</title>
<title>${escapeHtml(CONFIG.siteTitle)} SSO handoff</title>
<meta name="referrer" content="no-referrer" />
<style>body{font-family:sans-serif;background:#001a33;color:#eef;margin:0;padding:2em;text-align:center}</style>
<style>body{font-family:sans-serif;background:var(--design-surface-1);color:var(--design-text);margin:0;padding:2em;text-align:center}</style>
</head>
<body>
<p id="status">Signing you in to Bluesky…</p>
<p id="status">Signing you in to ${escapeHtml(CONFIG.siteTitle)}…</p>
<script>
(function(){
try {
@@ -467,7 +468,7 @@ const server = http.createServer(async (req, res) => {
const kcEmail = (req.headers["x-forwarded-email"] || "").toString();
if (!kcUsername) {
console.log(`[broker:${reqId}] missing X-Forwarded-User → 401 (${Date.now() - reqStart}ms)`);
endHtml(res, 401, `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>Bluesky login required</title></head><body><p>Missing X-Forwarded-User from oauth2-proxy. Refusing handoff.</p></body></html>`);
endHtml(res, 401, `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>${escapeHtml(CONFIG.siteTitle)} login required</title></head><body><p>Missing X-Forwarded-User from oauth2-proxy. Refusing handoff.</p></body></html>`);
return;
}
@@ -42,6 +42,10 @@ const PERSONAL_DETAILS = "app.bsky.actor.defs#personalDetailsPref";
const SHOWCASE_BIRTH_DATE = "1990-01-01T00:00:00.000Z";
const APP_PASSWORD_NAME = "design-showcase";
function htmlText(text) {
return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/{/g, "&#123;");
}
function storagePayload(account) {
const entry = { ...account, active: true };
return {
@@ -308,9 +312,25 @@ exports.register = function (shared) {
const symbolUrl = decodeDotenvQuotedValue(process.env.DESIGN_SYMBOL_URL || "");
const faviconUrl = decodeDotenvQuotedValue(process.env.DESIGN_FAVICON_URL || "");
const title = decodeDotenvQuotedValue(process.env.DESIGN_TITLE || "");
test.skip(!symbolUrl && !title, "logo and title replacement are disabled for this role");
await signIn(page, shared);
await expect(page).toHaveTitle(new RegExp(title.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")));
test.skip(!symbolUrl, "the logo replacement is disabled for this role");
if (title) {
const separator = String.fromCharCode(0x2014);
await expect(page, "the screen title ends with the configured title").toHaveTitle(
new RegExp(`^(\\(\\S+\\) )?[^${separator}]+ ${separator} ${title.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`),
);
await expect(page.locator('meta[name="application-name"]')).toHaveAttribute("content", title);
await expect(page.locator('meta[property="og:site_name"]')).toHaveAttribute("content", title);
for (const path of ["/", "/settings"]) {
const response = await apiFetchOnion(page.request, `${shared.env.baseUrl}${path}`, { method: "GET" });
expect(response.status(), `the ${path} document is served`).toBe(200);
expect((await response.text()).match(/<title>([^<]*)<\/title>/)?.[1], `the server-rendered ${path} title`).toBe(htmlText(title));
}
const missing = await apiFetchOnion(page.request, `${shared.env.baseUrl}/design/title/probe/missing`, { method: "GET" });
expect(missing.status(), "an unknown route renders the error page").toBe(404);
expect((await missing.text()).match(/<title>([^<]*)<\/title>/)?.[1], "the error page title").toBe(`Error 404 - ${htmlText(title)}`);
}
if (!symbolUrl) return;
await expect(page.locator('link[rel~="icon"]').first()).toHaveAttribute("href", faviconUrl);
const logo = page.locator('svg[viewBox="0 0 64 57"]').first();
await logo.waitFor({ timeout: resolveTimeout(30_000) });
@@ -326,6 +346,49 @@ exports.register = function (shared) {
expect(served.status(), "the generated symbol is served").toBe(200);
});
test("design: the visitor splash shows the configured title as its wordmark", async ({ page }) => {
skipUnlessServiceEnabled("design");
test.skip(isServiceEnabled("sso"), "the oauth2 gate hands every visitor a session, so the splash never renders");
const title = decodeDotenvQuotedValue(process.env.DESIGN_TITLE || "");
const logotypeUrl = decodeDotenvQuotedValue(process.env.DESIGN_LOGOTYPE_URL || "");
test.skip(!logotypeUrl, "logo or title replacement is disabled for this role");
await page.setViewportSize({ width: 1440, height: 900 });
await gotoOnion(page, `${shared.env.baseUrl}/settings`);
const wordmark = page.locator('[data-testid="noSessionView"] svg[viewBox="0 0 64 17"]').first();
await wordmark.waitFor({ timeout: resolveTimeout(30_000) });
await expect(wordmark.locator("path"), "the upstream wordmark path is gone").toHaveCount(0);
await expect(wordmark.locator("image")).toHaveAttribute("href", logotypeUrl);
await expect(wordmark, "the wordmark is named after the configured title").toHaveAttribute("aria-label", title);
const box = await wordmark.boundingBox();
expect(box.width, "the wordmark keeps its wide box").toBeGreaterThan(box.height * 3);
const served = await apiFetchOnion(page.request, logotypeUrl, { method: "GET" });
expect(served.status(), "the generated wordmark is served").toBe(200);
const xml = title.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
expect(await served.text(), "the wordmark carries the configured title").toContain(`>${xml}</text>`);
});
test("design: the SSO handoff page takes the configured title and the design tokens", async ({ page }) => {
skipUnlessServiceEnabled("design");
test.skip(!isServiceEnabled("sso"), "the login broker renders its handoff page only behind the oauth2 gate");
const title = decodeDotenvQuotedValue(process.env.DESIGN_TITLE || "");
test.skip(!title, "the title replacement is disabled for this role");
await signIn(page, shared);
await page.context().clearCookies({ name: "bsky_handoff_done" });
const response = await apiFetchOnion(page.request, `${shared.env.baseUrl}/`, { method: "GET" });
expect(response.status(), "the broker answers with its handoff page").toBe(200);
const body = await response.text();
expect(body.includes('localStorage.setItem("BSKY_STORAGE"'), "the response is the broker handoff page").toBe(true);
expect(body.match(/<title>([^<]*)<\/title>/)?.[1], "the handoff title carries the configured title").toBe(`${htmlText(title)} SSO handoff`);
const style = body.match(/<style>body\{([^<]*)\}<\/style>/)?.[1] || "";
expect(style, "the handoff page paints its surface with --design-surface-1").toContain("background:var(--design-surface-1)");
expect(style, "the handoff page writes its text with --design-text").toContain("color:var(--design-text)");
expect(style.match(/#[0-9a-f]{3,8}\b|rgba?\(/gi), "the handoff page paints no literal color").toBeNull();
expect(
body.includes("<!--infinito-inj-->") && /\/_shared\/css\/default\.css/.test(body),
"the front proxy injects the shared sheet into the handoff page",
).toBe(true);
});
test("design: the default avatar takes --design-primary and --design-on-primary", async ({ page }) => {
skipUnlessServiceEnabled("design");
await page.setViewportSize({ width: 390, height: 844 });
@@ -21,8 +21,8 @@ exports.register = function (shared) {
"broker bypass: the front-proxy MUST NOT route through the login-broker when oauth2 is disabled",
).toBe(false);
expect(
/<title>\s*Bluesky\s*<\/title>/i.test(landingBody),
"broker bypass: the front-proxy MUST route to the stock social-app (expected '<title>Bluesky</title>' in the landing body)",
/<meta name="generator" content="bskyweb">/.test(landingBody),
"broker bypass: the front-proxy MUST route to the stock social-app (expected the bskyweb generator meta in the landing body)",
).toBe(true);
const apiContext = await playwright.request.newContext({ ignoreHTTPSErrors: true });
+4
View File
@@ -110,6 +110,10 @@ design:
symbol:
width: 92
height: 82
logotype:
width: 161
height: 43
text_only: true
prometheus:
bond: 1
enabled: "{{ 'web-app-prometheus' in group_names }}"
+3
View File
@@ -44,6 +44,9 @@
and (bluesky_social_app_clone is changed
or bluesky_social_app_theme is changed
or bluesky_social_app_design_patches is changed
or bluesky_social_app_title_module is changed
or bluesky_social_app_title_patches is changed
or bluesky_social_app_logotype is changed
or bluesky_login_broker_copy is changed))
or bluesky_pdsadmin_download is changed
+40 -5
View File
@@ -8,14 +8,21 @@
check_mode: true
register: bluesky_social_app_probe
- name: 🔎 Find a corporate ALF theme left in the checkout
- name: 🔎 Find design sources the configuration no longer wants in the checkout
ansible.builtin.find:
paths: "{{ BLUESKY_ALF_THEMES_PATH | dirname }}"
patterns: "{{ BLUESKY_ALF_THEMES_PATH | basename }}"
contains: "DESIGN_THEMES"
paths:
- "{{ BLUESKY_ALF_THEMES_PATH | dirname }}"
- "{{ BLUESKY_HEADINGS_PATH | dirname }}"
- "{{ BLUESKY_LOGOTYPE_PATH | dirname }}"
patterns:
- "{{ BLUESKY_ALF_THEMES_PATH | basename }}"
- "{{ BLUESKY_HEADINGS_PATH | basename }}"
- "{{ BLUESKY_LOGOTYPE_PATH | basename }}"
contains: "{{ BLUESKY_DESIGN_MARKERS_UNWANTED | join('|') }}"
read_whole_file: true
register: bluesky_social_app_theme_left
when:
- not (BLUESKY_DESIGN_ENABLED | bool)
- BLUESKY_DESIGN_MARKERS_UNWANTED | length > 0
- bluesky_social_app_probe is not changed
- name: ⬇️ clone social app repository
@@ -59,3 +66,31 @@
label: "{{ item.path }}"
register: bluesky_social_app_design_patches
when: BLUESKY_DESIGN_ENABLED | bool
- name: 🏷️ Carry the corporate title into the social app build context
when: BLUESKY_DESIGN_TITLE_ENABLED | bool
block:
- name: 🏷️ Render the corporate screen title module
stack_host_template:
src: headings.ts.j2
dest: "{{ BLUESKY_HEADINGS_PATH }}"
mode: "0644"
register: bluesky_social_app_title_module
- name: 🏷️ Write the corporate title into the server-rendered page templates
ansible.builtin.replace:
path: "{{ [BLUESKY_SOCIAL_APP_DIR, item.path] | path_join }}"
regexp: "{{ item.regexp }}"
replace: "{{ item.replace }}"
loop: "{{ BLUESKY_DESIGN_TITLE_PATCHES }}"
loop_control:
label: "{{ item.path }}"
register: bluesky_social_app_title_patches
- name: 🏷️ Render the corporate wordmark component
stack_host_template:
src: logotype.tsx.j2
dest: "{{ BLUESKY_LOGOTYPE_PATH }}"
mode: "0644"
register: bluesky_social_app_logotype
when: BLUESKY_DESIGN_LOGOTYPE_ENABLED | bool
@@ -51,6 +51,7 @@
PDS_ADMIN_PASSWORD: "{{ BLUESKY_ADMIN_PASSWORD | replace('$', '$$') }}"
BLUESKY_BRIDGE_ENCRYPTION_KEY: "{{ BLUESKY_BRIDGE_ENCRYPTION_KEY }}"
INSECURE_TLS: "{{ MODE_DEBUG | string | lower }}"
SITE_TITLE: {{ lookup('design', application_id).label | replace('$', '$$') | to_json }}
healthcheck:
test: ["CMD", "wget", "-q", "-O-", "http://127.0.0.1:{{ BLUESKY_BROKER_INTERNAL_PORT }}/healthz"]
interval: 2m
@@ -0,0 +1,8 @@
{% set design = lookup('design', application_id) %}
const DESIGN_TITLE = {{ design.title | to_json }}
const SEPARATOR = String.fromCharCode(0x2014)
export function bskyTitle(page: string, unreadCountLabel?: string) {
const unreadPrefix = unreadCountLabel ? `(${unreadCountLabel}) ` : ''
return `${unreadPrefix}${page} ${SEPARATOR} ${DESIGN_TITLE}`
}
@@ -0,0 +1,30 @@
{% set design = lookup('design', application_id) %}
import Svg, {Image, type PathProps, type SvgProps} from 'react-native-svg'
const ratio = 17 / 64
const DESIGN_LOGOTYPE = {{ design.urls.logotype.svg | to_json }}
const DESIGN_LOGOTYPE_LABEL = {{ design.title | to_json }}
export function Logotype({
fill: _fill,
...rest
}: {fill?: PathProps['fill']} & SvgProps) {
const size = Number(rest.width ?? 32)
return (
<Svg
fill="none"
viewBox="0 0 64 17"
accessibilityLabel={DESIGN_LOGOTYPE_LABEL}
{...rest}
width={size}
height={size * ratio}>
<Image
href={DESIGN_LOGOTYPE}
width={64}
height={17}
preserveAspectRatio="xMidYMid meet"
/>
</Svg>
)
}
@@ -25,11 +25,13 @@ CANONICAL_DOMAIN={{ lookup('domain', application_id) | dotenv_quote }}
DESIGN_FAVICON_URL={{ (lookup('design', application_id).urls.favicon_ico if lookup('design', application_id).logo is string else '') | dotenv_quote }}
DESIGN_LOGOTYPE_URL={{ (lookup('design', application_id).urls.logotype.svg if BLUESKY_DESIGN_LOGOTYPE_ENABLED | bool else '') | dotenv_quote }}
DESIGN_SERVICE_ENABLED={{ lookup('config', application_id, 'services.design.enabled') | string | lower }}
DESIGN_SYMBOL_URL={{ (lookup('design', application_id).urls.symbol.svg if lookup('design', application_id).logo is string else '') | dotenv_quote }}
DESIGN_TITLE={{ lookup('design', application_id).label | dotenv_quote }}
DESIGN_TITLE={{ (lookup('design', application_id).title if BLUESKY_DESIGN_TITLE_ENABLED | bool else '') | dotenv_quote }}
# nocheck: playwright-service-gate — covered by sys-svc-mail integration tests, not the persona surface
EMAIL_SERVICE_ENABLED={{ lookup('config', application_id, 'services.email.enabled') | string | lower }}
+71
View File
@@ -6,7 +6,78 @@ BLUESKY_SOCIAL_APP_REPOSITORY: "{{ lookup('config', application_id, 'services.vi
BLUESKY_SOCIAL_APP_REF: "{{ lookup('config', application_id, 'services.view.ref') }}"
BLUESKY_GEOLOCATION_PATH: "{{ [ BLUESKY_SOCIAL_APP_DIR,'src/geolocation/index.tsx' ] | path_join }}"
BLUESKY_ALF_THEMES_PATH: "{{ [ BLUESKY_SOCIAL_APP_DIR, 'src/alf/themes.ts' ] | path_join }}"
BLUESKY_HEADINGS_PATH: "{{ [ BLUESKY_SOCIAL_APP_DIR, 'src/lib/strings/headings.ts' ] | path_join }}"
BLUESKY_LOGOTYPE_PATH: "{{ [ BLUESKY_SOCIAL_APP_DIR, 'src/view/icons/Logotype.tsx' ] | path_join }}"
BLUESKY_DESIGN_ENABLED: "{{ lookup('config', application_id, 'services.design.enabled') }}"
BLUESKY_DESIGN_TITLE_ENABLED: "{{ (BLUESKY_DESIGN_ENABLED | bool) and lookup('design', application_id).title is string }}"
BLUESKY_DESIGN_LOGOTYPE_ENABLED: "{{ (BLUESKY_DESIGN_TITLE_ENABLED | bool) and lookup('design', application_id).logo is string }}"
BLUESKY_DESIGN_MARKERS_UNWANTED: >-
{{
([] if (BLUESKY_DESIGN_ENABLED | bool) else ['DESIGN_THEMES'])
+ ([] if (BLUESKY_DESIGN_TITLE_ENABLED | bool) else ['DESIGN_TITLE'])
+ ([] if (BLUESKY_DESIGN_LOGOTYPE_ENABLED | bool) else ['DESIGN_LOGOTYPE'])
}}
BLUESKY_DESIGN_TITLE_HTML: >-
{{
(lookup('design', application_id).title | string)
| replace('&', '&amp;') | replace('<', '&lt;') | replace('>', '&gt;') | replace('"', '&quot;')
| replace('{', '&#123;') | replace('\\', '\\\\')
}}
BLUESKY_DESIGN_TITLE_PATCHES:
- path: bskyweb/templates/base.html
regexp: "(<title>[{]%- block head_title -%[}]).*?([{]%- endblock -%[}]</title>)"
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/base.html
regexp: '(<meta name="application-name" content=")[^"]*(">)'
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/base.html
regexp: '(<meta property="og:site_name" content=")[^"]*(">)'
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/home.html
regexp: "([{]% block head_title %[}]).*?([{]% endblock %[}])"
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/home.html
regexp: '(<meta (?:property="og:title"|name="twitter:title") content=")[^"]*(" />)'
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/home.html
regexp: '(<h1 lang="en">)[^<]*(</h1>)'
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/post.html
regexp: "^( @[{][{] [A-Za-z.]+ [}][}] on ).*$"
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}"
- path: bskyweb/templates/post.html
regexp: "([{]%- else -%[}]\\n ).*(\\n[{]%- endif -%[}]\\n[{]% endblock %[}])"
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/post.html
regexp: '(<meta property="og:site_name" content=")[^"]*(">)'
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/profile.html
regexp: "^( @[{][{] [A-Za-z.]+ [}][}] on ).*$"
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}"
- path: bskyweb/templates/profile.html
regexp: "([{]%- else -%[}]\\n ).*(\\n[{]%- endif -%[}]\\n[{]% endblock %[}])"
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/profile.html
regexp: '(<meta property="og:site_name" content=")[^"]*(">)'
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/feed.html
regexp: "^( [{][{] feedView\\.DisplayName [}][}] by @[{][{] feedView\\.Creator\\.Handle [}][}] [|] ).*( Feed)$"
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/feed.html
regexp: "([{]%- else -%[}]\\n ).*(\\n[{]%- endif -%[}]\\n[{]% endblock %[}])"
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/feed.html
regexp: '(<meta property="og:site_name" content=")[^"]*(">)'
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/error.html
regexp: "([{]% block head_title %[}]Error [{][{] statusCode [}][}] - ).*?([{]% endblock %[}])"
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>"
- path: bskyweb/templates/chatinvite.html
regexp: '([{]%- else -%[}]\n <meta property="og:title" content=")[^"]*(" />\n <meta name="twitter:title" content=")[^"]*(" />)'
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<3>"
- path: bskyweb/templates/starterpack.html
regexp: '([{]%- else -%[}]\n <meta property="og:title" content=")[^"]*(" />\n <meta name="twitter:title" content=")[^"]*(" />)'
replace: "\\g<1>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<2>{{ BLUESKY_DESIGN_TITLE_HTML }}\\g<3>"
BLUESKY_DESIGN_SOURCE_PATCHES:
- path: src/components/Button.tsx
regexp: "backgroundColor: t\\.palette\\.primary_600,"