Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): render logo in OG images (#549)
Gener1e6792c31554
diff --git a/src/web/src/app/(auth)/layout.tsx b/src/web/src/app/(auth)/layout.tsxindex f5d1fd665..1831e95dd 100644--- a/src/web/src/app/(auth)/layout.tsx+++ b/src/web/src/app/(auth)/layout.tsx@@ -8,9 +8,6 @@ export const metadata: Metadata = {description: BRAND_SLOGAN,robots: { index: false, follow: true },alternates: { canonical: "/sign-in" },- openGraph: {- images: [{ url: "/og?title=Sign In", width: 1200, height: 630 }],- },};export default async function AuthLayout({diff --git a/src/web/src/app/(auth)/opengraph-image.tsx b/src/web/src/app/(auth)/opengraph-image.tsxnew file mode 100644index 000000000..c1938827c--- /dev/null+++ b/src/web/src/app/(auth)/opengraph-image.tsx@@ -0,0 +1,13 @@+import {+ OG_IMAGE_CONTENT_TYPE,+ OG_IMAGE_SIZE,+ renderOgImage,+} from "@/app/_og/render-og-image";++export const alt = "Sign In — Alook";+export const size = OG_IMAGE_SIZE;+export const contentType = OG_IMAGE_CONTENT_TYPE;++export default function OpenGraphImage() {+ return renderOgImage("Sign In");+}diff --git a/src/web/src/app/(auth)/twitter-image.tsx b/src/web/src/app/(auth)/twitter-image.tsxnew file mode 100644index 000000000..8f726ce33--- /dev/null+++ b/src/web/src/app/(auth)/twitter-image.tsx@@ -0,0 +1 @@+export { alt, contentType, default, size } from "./opengraph-image";diff --git a/src/web/src/app/(home)/opengraph-image.tsx b/src/web/src/app/(home)/opengraph-image.tsxnew file mode 100644index 000000000..d66daf2bf--- /dev/null+++ b/src/web/src/app/(home)/opengraph-image.tsx@@ -0,0 +1,14 @@+import { BRAND_SLOGAN, BRAND_TITLE } from "@/lib/brand-copy";+import {+ OG_IMAGE_CONTENT_TYPE,+ OG_IMAGE_SIZE,+ renderOgImage,+} from "@/app/_og/render-og-image";++export const alt = BRAND_TITLE;+export const size = OG_IMAGE_SIZE;+export const contentType = OG_IMAGE_CONTENT_TYPE;++export default function OpenGraphImage() {+ return renderOgImage(BRAND_SLOGAN);+}diff --git a/src/web/src/app/page.tsx b/src/web/src/app/(home)/page.tsxsimilarity index 82%rename from src/web/src/app/page.tsxrename to src/web/src/app/(home)/page.tsxindex abee71945..7f443bcdd 100644--- a/src/web/src/app/page.tsx+++ b/src/web/src/app/(home)/page.tsx@@ -8,8 +8,6 @@ import { getSession } from "@/lib/session";const title = LANDING_META_TITLE;const description = LANDING_META_DESCRIPTION;-const image = "/og?title=Share%20your%20agents%20with%20people%20you%20trust";-export const metadata: Metadata = {title: { absolute: title },description,@@ -20,14 +18,12 @@ export const metadata: Metadata = {title,description,url: "https://alook.ai",- images: [{ url: image, width: 1200, height: 630, alt: title }],},twitter: {card: "summary_large_image",site: "@alook_ai",title,description,- images: [image],},};diff --git a/src/web/src/app/(home)/twitter-image.tsx b/src/web/src/app/(home)/twitter-image.tsxnew file mode 100644index 000000000..8f726ce33--- /dev/null+++ b/src/web/src/app/(home)/twitter-image.tsx@@ -0,0 +1 @@+export { alt, contentType, default, size } from "./opengraph-image";diff --git a/src/web/src/app/_og/og-title.ts b/src/web/src/app/_og/og-title.tsnew file mode 100644index 000000000..4494c04df--- /dev/null+++ b/src/web/src/app/_og/og-title.ts@@ -0,0 +1,107 @@+export const OG_TITLE_MAX_LINES = 2+export const OG_TITLE_LINE_CLAMP = `${OG_TITLE_MAX_LINES} "…"`+export const OG_TITLE_MAX_INPUT_GRAPHEMES = 240++type OgTitleFontSize = 38 | 44 | 52++export const OG_TITLE_MAX_DISPLAY_UNITS: Record<OgTitleFontSize, number> = {+ 52: 50,+ 44: 60,+ 38: 68,+}++const OG_TITLE_LINE_UNITS: Record<OgTitleFontSize, number> = {+ 52: 25,+ 44: 30,+ 38: 34,+}++const GRAPHEME_SEGMENTER = new Intl.Segmenter("en", { granularity: "grapheme" })+const FULL_WIDTH_GRAPHEME = /[\u1100-\u115f\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff]|[\u{1f300}-\u{1faff}]/u+const WIDE_DISPLAY_GRAPHEME = /[A-Zmw]|[\u1100-\u115f\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff]|[\u{1f300}-\u{1faff}]/u++export type OgTitlePresentation = {+ displayTitle: string+ fontSize: number+ lineClamp: string+ maxHeight: number+}++function splitGraphemes(value: string): string[] {+ return Array.from(GRAPHEME_SEGMENTER.segment(value), ({ segment }) => segment)+}++export function normalizeOgTitle(title: string): string {+ const compact = title.trim().replace(/\s+/gu, " ")+ const graphemes = splitGraphemes(compact)+ if (graphemes.length <= OG_TITLE_MAX_INPUT_GRAPHEMES) return compact++ return `${graphemes.slice(0, OG_TITLE_MAX_INPUT_GRAPHEMES - 1).join("")}…`+}++export function getOgTitleVisualUnits(title: string): number {+ return splitGraphemes(title).reduce(+ (total, grapheme) => total + (WIDE_DISPLAY_GRAPHEME.test(grapheme) ? 2 : 1),+ 0,+ )+}++function getOgTitleSizingUnits(title: string): number {+ return splitGraphemes(title).reduce(+ (total, grapheme) => total + (FULL_WIDTH_GRAPHEME.test(grapheme) ? 2 : 1),+ 0,+ )+}++function fitsOgTitle(title: string, fontSize: OgTitleFontSize): boolean {+ const lineUnits = OG_TITLE_LINE_UNITS[fontSize]+ let lines = 1+ let usedUnits = 0++ for (const word of title.split(" ")) {+ const wordUnits = getOgTitleVisualUnits(word)+ const separatorUnits = usedUnits > 0 ? 1 : 0+ if (separatorUnits + wordUnits <= lineUnits - usedUnits) {+ usedUnits += separatorUnits + wordUnits+ continue+ }++ if (usedUnits > 0) {+ lines += 1+ usedUnits = 0+ }++ lines += Math.floor(Math.max(0, wordUnits - 1) / lineUnits)+ usedUnits = wordUnits === 0 ? 0 : ((wordUnits - 1) % lineUnits) + 1+ if (lines > OG_TITLE_MAX_LINES) return false+ }++ return lines <= OG_TITLE_MAX_LINES+}++function truncateOgTitleForDisplay(title: string, fontSize: OgTitleFontSize): string {+ if (fitsOgTitle(title, fontSize)) return title++ const kept: string[] = []+ for (const grapheme of splitGraphemes(title)) {+ const candidate = `${kept.join("")}${grapheme}`.trimEnd()+ if (!fitsOgTitle(`${candidate}…`, fontSize)) break+ kept.push(grapheme)+ }++ return `${kept.join("").trimEnd()}…`+}++export function getOgTitlePresentation(title: string): OgTitlePresentation {+ const normalizedTitle = normalizeOgTitle(title)+ const sizingUnits = getOgTitleSizingUnits(normalizedTitle)+ let fontSize: OgTitleFontSize = sizingUnits <= 56 ? 52 : sizingUnits <= 112 ? 44 : 38+ if (fontSize === 52 && !fitsOgTitle(normalizedTitle, 52)) fontSize = 44++ return {+ displayTitle: truncateOgTitleForDisplay(normalizedTitle, fontSize),+ fontSize,+ lineClamp: OG_TITLE_LINE_CLAMP,+ maxHeight: Math.ceil(fontSize * 1.15 * OG_TITLE_MAX_LINES),+ }+}diff --git a/src/web/src/app/_og/render-og-image.test.ts b/src/web/src/app/_og/render-og-image.test.tsnew file mode 100644index 000000000..ba25bd2a3--- /dev/null+++ b/src/web/src/app/_og/render-og-image.test.ts@@ -0,0 +1,366 @@+import { inflateSync } from "node:zlib"+import { readFileSync } from "node:fs"+import { describe, expect, it } from "vitest"+import {+ getOgTitleVisualUnits,+ getOgTitlePresentation,+ normalizeOgTitle,+ OG_TITLE_LINE_CLAMP,+ OG_TITLE_MAX_DISPLAY_UNITS,+ OG_TITLE_MAX_INPUT_GRAPHEMES,+ OG_TITLE_MAX_LINES,+} from "./og-title"+import { renderOgImage } from "./render-og-image"++type DecodedPng = {+ width: number+ height: number+ rgba: Uint8Array+}++type PixelBounds = {+ minX: number+ maxX: number+ minY: number+ maxY: number+ count: number+}++function paeth(left: number, above: number, upperLeft: number): number {+ const estimate = left + above - upperLeft+ const leftDistance = Math.abs(estimate - left)+ const aboveDistance = Math.abs(estimate - above)+ const upperLeftDistance = Math.abs(estimate - upperLeft)+ if (leftDistance <= aboveDistance && leftDistance <= upperLeftDistance) return left+ return aboveDistance <= upperLeftDistance ? above : upperLeft+}++function decodeRgbaPng(png: Uint8Array): DecodedPng {+ expect(Buffer.from(png.subarray(0, 8))).toEqual(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))++ let offset = 8+ let width = 0+ let height = 0+ const idat: Buffer[] = []+ while (offset < png.length) {+ const length = Buffer.from(png.subarray(offset, offset + 4)).readUInt32BE()+ const type = Buffer.from(png.subarray(offset + 4, offset + 8)).toString("ascii")+ const data = png.subarray(offset + 8, offset + 8 + length)+ if (type === "IHDR") {+ width = Buffer.from(data).readUInt32BE(0)+ height = Buffer.from(data).readUInt32BE(4)+ expect(data[8]).toBe(8)+ expect(data[9]).toBe(6)+ expect(data[12]).toBe(0)+ } else if (type === "IDAT") {+ idat.push(Buffer.from(data))+ }+ offset += 12 + length+ if (type === "IEND") break+ }++ const bytesPerPixel = 4+ const rowLength = width * bytesPerPixel+ const filtered = inflateSync(Buffer.concat(idat))+ expect(filtered).toHaveLength((rowLength + 1) * height)+ const rgba = new Uint8Array(rowLength * height)++ for (let y = 0; y < height; y += 1) {+ const sourceRow = y * (rowLength + 1)+ const targetRow = y * rowLength+ const filter = filtered[sourceRow]+ expect(filter).toBeGreaterThanOrEqual(0)+ expect(filter).toBeLessThanOrEqual(4)+ for (let x = 0; x < rowLength; x += 1) {+ const raw = filtered[sourceRow + 1 + x]+ const left = x >= bytesPerPixel ? rgba[targetRow + x - bytesPerPixel] : 0+ const above = y > 0 ? rgba[targetRow - rowLength + x] : 0+ const upperLeft = y > 0 && x >= bytesPerPixel+ ? rgba[targetRow - rowLength + x - bytesPerPixel]+ : 0+ const predictor = filter === 0+ ? 0+ : filter === 1+ ? left+ : filter === 2+ ? above+ : filter === 3+ ? Math.floor((left + above) / 2)+ : paeth(left, above, upperLeft)+ rgba[targetRow + x] = (raw + predictor) & 0xff+ }+ }++ return { width, height, rgba }+}++function colorBounds(+ decoded: DecodedPng,+ color: readonly [number, number, number],+ region: { minX: number; maxX: number; minY: number; maxY: number },+ tolerance = 12,+): PixelBounds | null {+ let minX = decoded.width+ let maxX = -1+ let minY = decoded.height+ let maxY = -1+ let count = 0++ for (let y = region.minY; y <= region.maxY; y += 1) {+ for (let x = region.minX; x <= region.maxX; x += 1) {+ const index = (y * decoded.width + x) * 4+ const distance = Math.hypot(+ decoded.rgba[index] - color[0],+ decoded.rgba[index + 1] - color[1],+ decoded.rgba[index + 2] - color[2],+ )+ if (distance <= tolerance) {+ minX = Math.min(minX, x)+ maxX = Math.max(maxX, x)+ minY = Math.min(minY, y)+ maxY = Math.max(maxY, y)+ count += 1+ }+ }+ }++ return count > 0 ? { minX, maxX, minY, maxY, count } : null+}++function countSmallColorComponents(+ decoded: DecodedPng,+ color: readonly [number, number, number],+ region: { minX: number; maxX: number; minY: number; maxY: number },+ tolerance = 12,+): number {+ const width = region.maxX - region.minX + 1+ const height = region.maxY - region.minY + 1+ const mask = new Uint8Array(width * height)+ for (let y = region.minY; y <= region.maxY; y += 1) {+ for (let x = region.minX; x <= region.maxX; x += 1) {+ const sourceIndex = (y * decoded.width + x) * 4+ const distance = Math.hypot(+ decoded.rgba[sourceIndex] - color[0],+ decoded.rgba[sourceIndex + 1] - color[1],+ decoded.rgba[sourceIndex + 2] - color[2],+ )+ if (distance <= tolerance) {+ mask[(y - region.minY) * width + x - region.minX] = 1+ }+ }+ }++ let smallComponents = 0+ for (let start = 0; start < mask.length; start += 1) {+ if (mask[start] !== 1) continue+ const queue = [start]+ mask[start] = 2+ let minX = width+ let maxX = -1+ let minY = height+ let maxY = -1+ let pixels = 0+ while (queue.length > 0) {+ const current = queue.pop()+ if (current === undefined) break+ const x = current % width+ const y = Math.floor(current / width)+ minX = Math.min(minX, x)+ maxX = Math.max(maxX, x)+ minY = Math.min(minY, y)+ maxY = Math.max(maxY, y)+ pixels += 1++ for (let dy = -1; dy <= 1; dy += 1) {+ for (let dx = -1; dx <= 1; dx += 1) {+ if (dx === 0 && dy === 0) continue+ const nextX = x + dx+ const nextY = y + dy+ if (nextX < 0 || nextX >= width || nextY < 0 || nextY >= height) continue+ const next = nextY * width + nextX+ if (mask[next] !== 1) continue+ mask[next] = 2+ queue.push(next)+ }+ }+ }++ const componentWidth = maxX - minX + 1+ const componentHeight = maxY - minY + 1+ if (pixels >= 4 && componentWidth <= 6 && componentHeight <= 8) smallComponents += 1+ }++ return smallComponents+}++describe("OG image", () => {+ it("loads the generated raster logo instead of embedding manual base64 or requesting SVG", () => {+ const officialLogo = readFileSync(new URL("../../../public/icon-192.png", import.meta.url))+ const rendererSource = readFileSync(new URL("./render-og-image.tsx", import.meta.url), "utf8")++ expect(officialLogo.byteLength).toBeGreaterThan(1_000)+ expect(rendererSource).toContain('processRoot.endsWith(join("src", "web"))')+ expect(rendererSource).toContain('join(webRoot, "public/icon-192.png")')+ expect(rendererSource).not.toContain("iVBORw0KGgo")+ expect(rendererSource).not.toContain("alook.svg")+ })++ it("renders the official brand colors into the logo crop", async () => {+ const response = await renderOgImage("OG logo regression")+ expect(response.status).toBe(200)+ expect(response.headers.get("content-type")).toBe("image/png")++ const decoded = decodeRgbaPng(new Uint8Array(await response.arrayBuffer()))+ expect([decoded.width, decoded.height]).toEqual([1200, 630])++ const brandColors = [+ [254, 67, 101],+ [138, 90, 158],+ [69, 173, 168],+ [106, 140, 175],+ [255, 153, 21],+ ]+ const hits = brandColors.map(() => 0)+ for (let y = 70; y < 330; y += 1) {+ for (let x = 75; x < 205; x += 1) {+ const index = (y * decoded.width + x) * 4+ const pixel = decoded.rgba.subarray(index, index + 3)+ brandColors.forEach((color, colorIndex) => {+ const distance = Math.hypot(+ pixel[0] - color[0],+ pixel[1] - color[1],+ pixel[2] - color[2],+ )+ if (distance < 18) hits[colorIndex] += 1+ })+ }+ }++ for (const count of hits) expect(count).toBeGreaterThan(20)+ expect(hits.reduce((sum, count) => sum + count, 0)).toBeGreaterThan(4_000)+ })++ it("keeps bounded short, medium, long, CJK, and unbroken titles within two non-overlapping lines", async () => {+ const cases = [+ {+ name: "short",+ title: "Bring your agents",+ expectedFontSize: 52,+ maxTitleHeight: 65,+ },+ {+ name: "medium",+ title: "How to Coordinate Multiple AI Agents Across Teams Without Losing Context, Duplicating Work, or Missing Approvals",+ expectedFontSize: 44,+ maxTitleHeight: 103,+ expectsEllipsis: true,+ },+ {+ name: "long",+ title: "How to Coordinate Multiple AI Agents Across Teams Without Losing Context, Duplicating Work, Missing Approvals, or Breaking Shared Workflows in a Fast-Moving Organization While Keeping Every Decision Visible and Reviewable",+ expectedFontSize: 38,+ maxTitleHeight: 90,+ expectsEllipsis: true,+ },+ {+ name: "unbroken",+ title: "X".repeat(5_600),+ expectedFontSize: 38,+ maxTitleHeight: 90,+ expectsEllipsis: true,+ },+ {+ name: "cjk-long",+ title: "如何在快速变化的团队里协调多个人工智能代理同时保留上下文避免重复工作遗漏审批并确保每一个共享流程都清晰可靠可追溯并能长期安全展示",+ expectedFontSize: 38,+ maxTitleHeight: 90,+ expectsEllipsis: true,+ },+ ]++ expect(OG_TITLE_MAX_LINES).toBe(2)+ expect(OG_TITLE_LINE_CLAMP).toBe('2 "…"')+ expect(OG_TITLE_MAX_INPUT_GRAPHEMES).toBe(240)++ const familyEmoji = "👨👩👧👦"+ const oversized = ` ${familyEmoji.repeat(260)} `+ const normalized = normalizeOgTitle(oversized)+ expect(Array.from(new Intl.Segmenter("en", { granularity: "grapheme" }).segment(normalized)))+ .toHaveLength(OG_TITLE_MAX_INPUT_GRAPHEMES)+ expect(normalized.endsWith("…")).toBe(true)+ expect(normalizeOgTitle(" spaced\n\t title ")).toBe("spaced title")++ for (const emojiTitle of ["😀".repeat(100), familyEmoji.repeat(100)]) {+ const presentation = getOgTitlePresentation(emojiTitle)+ expect(presentation.fontSize).toBe(38)+ expect(presentation.displayTitle.endsWith("…")).toBe(true)+ expect(getOgTitleVisualUnits(presentation.displayTitle)).toBeLessThanOrEqual(+ OG_TITLE_MAX_DISPLAY_UNITS[38],+ )+ }++ for (const testCase of cases) {+ const presentation = getOgTitlePresentation(testCase.title)+ expect(presentation.fontSize).toBe(testCase.expectedFontSize)+ expect(presentation.lineClamp).toBe('2 "…"')+ expect(presentation.maxHeight).toBe(+ Math.ceil(testCase.expectedFontSize * 1.15 * OG_TITLE_MAX_LINES),+ )+ expect(getOgTitleVisualUnits(presentation.displayTitle))+ .toBeLessThanOrEqual(OG_TITLE_MAX_DISPLAY_UNITS[testCase.expectedFontSize as 38 | 44 | 52])+ if (testCase.expectsEllipsis) expect(presentation.displayTitle.endsWith("…")).toBe(true)++ const response = await renderOgImage(testCase.title)+ expect(response.status, testCase.name).toBe(200)+ const decoded = decodeRgbaPng(new Uint8Array(await response.arrayBuffer()))+ expect([decoded.width, decoded.height], testCase.name).toEqual([1200, 630])++ const titleBounds = colorBounds(decoded, [42, 35, 26], {+ minX: 70,+ maxX: 740,+ minY: 280,+ maxY: 430,+ })+ const subtitleBounds = colorBounds(decoded, [138, 126, 110], {+ minX: 70,+ maxX: 740,+ minY: 440,+ maxY: 560,+ })+ const logoBounds = colorBounds(decoded, [255, 153, 21], {+ minX: 70,+ maxX: 210,+ minY: 80,+ maxY: 360,+ })+ const typewriterBounds = colorBounds(decoded, [184, 169, 142], {+ minX: 740,+ maxX: 1120,+ minY: 220,+ maxY: 520,+ })++ expect(titleBounds, testCase.name).not.toBeNull()+ expect(subtitleBounds, testCase.name).not.toBeNull()+ expect(logoBounds, testCase.name).not.toBeNull()+ expect(typewriterBounds, testCase.name).not.toBeNull()+ if (!titleBounds || !subtitleBounds || !logoBounds || !typewriterBounds) continue++ expect(titleBounds.maxY - titleBounds.minY + 1, testCase.name)+ .toBeLessThanOrEqual(testCase.maxTitleHeight)+ expect(titleBounds.maxX, testCase.name).toBeLessThan(710)+ expect(titleBounds.minY - logoBounds.maxY, testCase.name).toBeGreaterThanOrEqual(24)+ expect(subtitleBounds.minY - titleBounds.maxY, testCase.name).toBeGreaterThanOrEqual(16)+ expect(typewriterBounds.minX - titleBounds.maxX, testCase.name).toBeGreaterThanOrEqual(40)+ if (testCase.expectsEllipsis) {+ const ellipsisComponents = countSmallColorComponents(decoded, [42, 35, 26], {+ minX: titleBounds.minX,+ maxX: titleBounds.maxX,+ minY: titleBounds.maxY - 24,+ maxY: titleBounds.maxY,+ })+ expect(ellipsisComponents, testCase.name).toBeGreaterThanOrEqual(3)+ }+ }+ }, 20_000)+})diff --git a/src/web/src/app/_og/render-og-image.tsx b/src/web/src/app/_og/render-og-image.tsxnew file mode 100644index 000000000..429049870--- /dev/null+++ b/src/web/src/app/_og/render-og-image.tsx@@ -0,0 +1,217 @@+import { readFile } from "node:fs/promises";+import { join } from "node:path";+import { ImageResponse } from "next/og";+import { BRAND_SLOGAN } from "@/lib/brand-copy";+import { getOgTitlePresentation, normalizeOgTitle } from "./og-title";++export const OG_IMAGE_SIZE = { width: 1200, height: 630 } as const;+export const OG_IMAGE_CONTENT_TYPE = "image/png";++const processRoot = process.cwd();+const webRoot = processRoot.endsWith(join("src", "web"))+ ? processRoot+ : join(processRoot, "src", "web");++const assetsPromise = Promise.all([+ readFile(join(webRoot, "public/icon-192.png")),+ readFile(join(webRoot, "src/app/fonts/dm-sans-600.ttf")),+]);++function TypewriterIllustration() {+ const keyRows = [9, 7, 9];++ return (+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center" }}>+ <div+ style={{+ display: "flex",+ flexDirection: "column",+ width: 260,+ padding: "20px 24px",+ background: "#f5f0e8",+ borderRadius: "4px 4px 0 0",+ border: "1px solid #e0d9cc",+ marginBottom: -2,+ }}+ >+ <div+ style={{+ display: "flex",+ flexDirection: "column",+ borderBottom: "1px solid #d5cec0",+ paddingBottom: 10,+ marginBottom: 10,+ }}+ >+ <div style={{ display: "flex", fontSize: 11, color: "#8a7e6e", marginBottom: 4 }}>+ HOME / FAMILY-PLANS+ </div>+ <div style={{ display: "flex", fontSize: 11, color: "#8a7e6e", marginBottom: 4 }}>+ Maya joined the room.+ </div>+ <div style={{ display: "flex", fontSize: 11, color: "#8a7e6e" }}>+ A note for Alli#8145+ </div>+ </div>+ <div style={{ display: "flex", fontSize: 12, color: "#8a7e6e", lineHeight: 1.5 }}>+ Maya and Alli now share this channel. Gus can catch up when he returns.+ </div>+ </div>++ <div+ style={{+ display: "flex",+ width: 280,+ height: 14,+ background: "#2a231a",+ borderRadius: 7,+ }}+ />++ <div+ style={{+ display: "flex",+ flexDirection: "column",+ alignItems: "center",+ width: 320,+ padding: "16px 20px 24px",+ background: "#3d3428",+ borderRadius: 8,+ marginTop: -4,+ }}+ >+ <div style={{ display: "flex", flexDirection: "column", marginTop: 8 }}>+ {keyRows.map((count, rowIndex) => (+ <div+ key={rowIndex}+ style={{ display: "flex", justifyContent: "center", marginBottom: 8 }}+ >+ {Array.from({ length: count }).map((_, keyIndex) => (+ <div+ key={keyIndex}+ style={{+ width: 22,+ height: 22,+ borderRadius: 11,+ background: "#b8a98e",+ border: "1px solid #8a7e6e",+ marginRight: keyIndex < count - 1 ? 6 : 0,+ }}+ />+ ))}+ </div>+ ))}+ </div>+ </div>+ </div>+ );+}++export async function renderOgImage(rawTitle: string): Promise<ImageResponse> {+ const title = normalizeOgTitle(rawTitle) || BRAND_SLOGAN;+ const titlePresentation = getOgTitlePresentation(title);+ const [logoData, fontData] = await assetsPromise;+ const logoDataUri = `data:image/png;base64,${logoData.toString("base64")}`;++ return new ImageResponse(+ (+ <div+ style={{+ width: "100%",+ height: "100%",+ display: "flex",+ position: "relative",+ background: "linear-gradient(135deg, #f5f0e8 0%, #ddd5c8 100%)",+ fontFamily: '"DM Sans"',+ }}+ >+ <div+ style={{+ display: "flex",+ alignItems: "center",+ position: "absolute",+ left: 80,+ top: 150,+ }}+ >+ <img+ src={logoDataUri}+ width={120}+ height={120}+ alt=""+ style={{ borderRadius: 28, marginRight: 24 }}+ />+ <span style={{ fontSize: 32, fontWeight: 600, color: "#3d3428" }}>alook.ai</span>+ </div>++ <div+ style={{+ display: "flex",+ position: "absolute",+ left: 80,+ top: 310,+ height: titlePresentation.maxHeight,+ width: 600,+ overflow: "hidden",+ }}+ >+ <div+ style={{+ display: "block",+ fontSize: titlePresentation.fontSize,+ fontWeight: 600,+ color: "#2a231a",+ lineHeight: 1.15,+ lineClamp: titlePresentation.lineClamp,+ width: "100%",+ overflow: "hidden",+ wordBreak: "break-word",+ }}+ >+ {titlePresentation.displayTitle}+ </div>+ </div>++ <div+ style={{+ display: "flex",+ position: "absolute",+ left: 80,+ top: 450,+ width: 600,+ fontSize: 22,+ color: "#8a7e6e",+ }}+ >+ Bring the agents you already use into a room with people you trust.+ </div>++ <div+ style={{+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ position: "absolute",+ left: 760,+ top: 168,+ width: 380,+ height: 296,+ }}+ >+ <TypewriterIllustration />+ </div>+ </div>+ ),+ {+ ...OG_IMAGE_SIZE,+ fonts: [+ {+ name: "DM Sans",+ data: Uint8Array.from(fontData).buffer,+ weight: 600,+ style: "normal",+ },+ ],+ },+ );+}diff --git a/src/web/src/app/blog/(index)/opengraph-image.tsx b/src/web/src/app/blog/(index)/opengraph-image.tsxnew file mode 100644index 000000000..9299f6c95--- /dev/null+++ b/src/web/src/app/blog/(index)/opengraph-image.tsx@@ -0,0 +1,13 @@+import {+ OG_IMAGE_CONTENT_TYPE,+ OG_IMAGE_SIZE,+ renderOgImage,+} from "@/app/_og/render-og-image";++export const alt = "Multi-Agent Collaboration & AI Team — Alook";+export const size = OG_IMAGE_SIZE;+export const contentType = OG_IMAGE_CONTENT_TYPE;++export default function OpenGraphImage() {+ return renderOgImage("Multi-Agent Collaboration & AI Team");+}diff --git a/src/web/src/app/blog/page.tsx b/src/web/src/app/blog/(index)/page.tsxsimilarity index 97%rename from src/web/src/app/blog/page.tsxrename to src/web/src/app/blog/(index)/page.tsxindex 706526610..15aa05fb7 100644--- a/src/web/src/app/blog/page.tsx+++ b/src/web/src/app/blog/(index)/page.tsx@@ -26,19 +26,11 @@ export const metadata: Metadata = {title: pageTitle,description,url: "https://alook.ai/blog",- images: [- {- url: `/og?title=${encodeURIComponent(pageTitle)}`,- width: 1200,- height: 630,- },- ],},twitter: {card: "summary_large_image",title: pageTitle,description,- images: [`/og?title=${encodeURIComponent(pageTitle)}`],},};diff --git a/src/web/src/app/blog/(index)/twitter-image.tsx b/src/web/src/app/blog/(index)/twitter-image.tsxnew file mode 100644index 000000000..8f726ce33--- /dev/null+++ b/src/web/src/app/blog/(index)/twitter-image.tsx@@ -0,0 +1 @@+export { alt, contentType, default, size } from "./opengraph-image";diff --git a/src/web/src/app/blog/[slug]/og-image.test.ts b/src/web/src/app/blog/[slug]/og-image.test.tsnew file mode 100644index 000000000..e76bc65d0--- /dev/null+++ b/src/web/src/app/blog/[slug]/og-image.test.ts@@ -0,0 +1,19 @@+import { describe, expect, it } from "vitest";+import { getBlogOgImage } from "./og-image";++describe("getBlogOgImage", () => {+ it("preserves the existing article hero URL", () => {+ expect(+ getBlogOgImage({+ slug: "existing-hero",+ image: "/blog/existing-hero/hero.webp",+ }),+ ).toBe("/blog/existing-hero/hero.webp");+ });++ it("uses a route-owned fallback instead of accepting title input", () => {+ expect(getBlogOgImage({ slug: "missing hero", image: undefined })).toBe(+ "/og/blog/missing%20hero",+ );+ });+});diff --git a/src/web/src/app/blog/[slug]/og-image.ts b/src/web/src/app/blog/[slug]/og-image.tsnew file mode 100644index 000000000..781f8fdef--- /dev/null+++ b/src/web/src/app/blog/[slug]/og-image.ts@@ -0,0 +1,5 @@+import type { BlogPost } from "@/lib/blog/posts";++export function getBlogOgImage(post: Pick<BlogPost, "image" | "slug">): string {+ return post.image ?? `/og/blog/${encodeURIComponent(post.slug)}`;+}diff --git a/src/web/src/app/blog/[slug]/page.tsx b/src/web/src/app/blog/[slug]/page.tsxindex 6ba475a5c..4e73d53d6 100644--- a/src/web/src/app/blog/[slug]/page.tsx+++ b/src/web/src/app/blog/[slug]/page.tsx@@ -10,6 +10,7 @@ import {getNextTopicBridge,getRelatedPosts,} from "@/lib/blog/topics";+import { getBlogOgImage } from "./og-image";export const dynamicParams = false;@@ -27,7 +28,10 @@ export async function generateMetadata({const post = await getPostBySlug(slug);if (!post) return {};- const ogImage = post.image ?? `/og?title=${encodeURIComponent(post.title)}`;+ // Preserve existing hero images. Only posts without one use the bounded,+ // route-owned fallback; unlike the retired query route, the slug is resolved+ // against canonical post metadata on the server.+ const ogImage = getBlogOgImage(post);return {title: post.title,diff --git a/src/web/src/app/layout.tsx b/src/web/src/app/layout.tsxindex 96dc0d3da..ddbf9cd01 100644--- a/src/web/src/app/layout.tsx+++ b/src/web/src/app/layout.tsx@@ -12,7 +12,7 @@ import { caveat, dmMono, dmSans, instrumentSerif, literata, vt323 } from "./fontimport "./globals.css";const SITE_URL = "https://alook.ai";-const OG_IMAGE_URL = "/og?title=Share%20your%20agents%20with%20people%20you%20trust";+const OG_IMAGE_URL = "/og";export const viewport: Viewport = {width: "device-width",diff --git a/src/web/src/app/og/blog/[slug]/route.tsx b/src/web/src/app/og/blog/[slug]/route.tsxnew file mode 100644index 000000000..79ad3921e--- /dev/null+++ b/src/web/src/app/og/blog/[slug]/route.tsx@@ -0,0 +1,13 @@+import { renderOgImage } from "@/app/_og/render-og-image";+import { getPostBySlug } from "@/lib/blog/posts";++export async function GET(+ _request: Request,+ { params }: { params: Promise<{ slug: string }> },+) {+ const { slug } = await params;+ const post = await getPostBySlug(slug);+ if (!post) return new Response("Not Found", { status: 404 });++ return renderOgImage(post.title);+}diff --git a/src/web/src/app/og/route.tsx b/src/web/src/app/og/route.tsxindex 64ff70cd4..79c947dc3 100644--- a/src/web/src/app/og/route.tsx+++ b/src/web/src/app/og/route.tsx@@ -1,207 +1,16 @@-import { ImageResponse } from "next/og";-import type { NextRequest } from "next/server";import { BRAND_SLOGAN } from "@/lib/brand-copy";--async function loadFont(): Promise<ArrayBuffer | null> {- try {- const res = await fetch(new URL("../fonts/dm-sans-600.ttf", import.meta.url));- if (!res.ok) return null;- return await res.arrayBuffer();- } catch {- return null;- }-}--function TypewriterIllustration() {- const keyRows = [9, 7, 9];- return (- <div- style={{- display: "flex",- flexDirection: "column",- alignItems: "center",- }}- >- {/* Paper */}- <div- style={{- display: "flex",- flexDirection: "column",- width: 260,- padding: "20px 24px",- background: "#f5f0e8",- borderRadius: "4px 4px 0 0",- border: "1px solid #e0d9cc",- marginBottom: -2,- }}- >- <div- style={{- display: "flex",- flexDirection: "column",- borderBottom: "1px solid #d5cec0",- paddingBottom: 10,- marginBottom: 10,- }}- >- <div style={{ display: "flex", fontSize: 11, color: "#8a7e6e", marginBottom: 4 }}>- HOME / FAMILY-PLANS- </div>- <div style={{ display: "flex", fontSize: 11, color: "#8a7e6e", marginBottom: 4 }}>- Maya joined the room.- </div>- <div style={{ display: "flex", fontSize: 11, color: "#8a7e6e" }}>- A note for Alli#8145- </div>- </div>- <div style={{ display: "flex", fontSize: 12, color: "#8a7e6e", lineHeight: 1.5 }}>- Maya and Alli now share this channel. Gus can catch up when he returns.- </div>- </div>-- {/* Roller */}- <div- style={{- display: "flex",- width: 280,- height: 14,- background: "#2a231a",- borderRadius: 7,- }}- />-- {/* Body */}- <div- style={{- display: "flex",- flexDirection: "column",- alignItems: "center",- width: 320,- padding: "16px 20px 24px",- background: "#3d3428",- borderRadius: 8,- marginTop: -4,- }}- >- <div- style={{- display: "flex",- flexDirection: "column",- marginTop: 8,- }}- >- {keyRows.map((count, ri) => (- <div- key={ri}- style={{- display: "flex",- justifyContent: "center",- marginBottom: 8,- }}- >- {Array.from({ length: count }).map((_, ki) => (- <div- key={ki}- style={{- width: 22,- height: 22,- borderRadius: 11,- background: "#b8a98e",- border: "1px solid #8a7e6e",- marginRight: ki < count - 1 ? 6 : 0,- }}- />- ))}- </div>- ))}- </div>- </div>- </div>- );-}--export async function GET(request: NextRequest) {+import { renderOgImage } from "@/app/_og/render-og-image";++/**+ * Fixed compatibility image for metadata inherited from the root layout.+ * Query parameters are intentionally ignored; route-owned image files provide+ * every page-specific title.+ */+export async function GET() {try {- const { searchParams } = request.nextUrl;- const title = searchParams.get("title") || BRAND_SLOGAN;- const logoUrl = new URL("/alook.svg", request.url).toString();-- const fontData = await loadFont();-- return new ImageResponse(- (- <div- style={{- width: "100%",- height: "100%",- display: "flex",- background: "linear-gradient(135deg, #f5f0e8 0%, #ddd5c8 100%)",- padding: "60px 80px",- fontFamily: '"DM Sans"',- }}- >- {/* Left side */}- <div- style={{- display: "flex",- flexDirection: "column",- justifyContent: "center",- flex: 1,- paddingRight: 60,- }}- >- <div style={{ display: "flex", alignItems: "center", marginBottom: 32 }}>- <img- src={logoUrl}- width={120}- height={120}- alt=""- style={{ borderRadius: 28, marginRight: 24 }}- />- <span style={{ fontSize: 32, fontWeight: 600, color: "#3d3428" }}>- alook.ai- </span>- </div>- <div style={{ display: "flex", fontSize: 52, fontWeight: 600, color: "#2a231a", lineHeight: 1.15 }}>- {title}- </div>- <div style={{ display: "flex", fontSize: 22, color: "#8a7e6e", marginTop: 20 }}>- Bring the agents you already use into a room with people you trust.- </div>- </div>-- {/* Right side — typewriter */}- <div- style={{- display: "flex",- alignItems: "center",- justifyContent: "center",- width: 380,- }}- >- <TypewriterIllustration />- </div>- </div>- ),- {- width: 1200,- height: 630,- ...(fontData- ? {- fonts: [- {- name: "DM Sans",- data: fontData,- weight: 600,- style: "normal" as const,- },- ],- }- : {}),- },- );- } catch (e) {- const msg = e instanceof Error ? e.message : String(e);- return new Response(`OG generation failed: ${msg}`, { status: 500 });+ return await renderOgImage(BRAND_SLOGAN);+ } catch (error) {+ const message = error instanceof Error ? error.message : String(error);+ return new Response(`OG generation failed: ${message}`, { status: 500 });}}diff --git a/src/web/src/app/templates/[id]/opengraph-image.tsx b/src/web/src/app/templates/[id]/opengraph-image.tsxnew file mode 100644index 000000000..b7b3fe6ba--- /dev/null+++ b/src/web/src/app/templates/[id]/opengraph-image.tsx@@ -0,0 +1,20 @@+import {+ OG_IMAGE_CONTENT_TYPE,+ OG_IMAGE_SIZE,+ renderOgImage,+} from "@/app/_og/render-og-image";+import { getTemplateById } from "@/lib/templates";++export const alt = "Alook AI company template";+export const size = OG_IMAGE_SIZE;+export const contentType = OG_IMAGE_CONTENT_TYPE;++export default async function OpenGraphImage({+ params,+}: {+ params: Promise<{ id: string }>;+}) {+ const { id } = await params;+ const template = getTemplateById(id);+ return renderOgImage(template?.name ?? "AI Company Templates");+}diff --git a/src/web/src/app/templates/[id]/page.tsx b/src/web/src/app/templates/[id]/page.tsxindex c25c20c44..573d4194c 100644--- a/src/web/src/app/templates/[id]/page.tsx+++ b/src/web/src/app/templates/[id]/page.tsx@@ -23,8 +23,6 @@ export async function generateMetadata({const title = `${template.name} — AI Company Templates`;const url = `${SITE_URL}/templates/${id}`;- const ogImage = `/og?title=${encodeURIComponent(template.name)}`;-return {title,description: template.description,@@ -34,13 +32,11 @@ export async function generateMetadata({title,description: template.description,url,- images: [{ url: ogImage, width: 1200, height: 630 }],},twitter: {card: "summary_large_image",title,description: template.description,- images: [ogImage],},};}diff --git a/src/web/src/app/templates/[id]/twitter-image.tsx b/src/web/src/app/templates/[id]/twitter-image.tsxnew file mode 100644index 000000000..8f726ce33--- /dev/null+++ b/src/web/src/app/templates/[id]/twitter-image.tsx@@ -0,0 +1 @@+export { alt, contentType, default, size } from "./opengraph-image";diff --git a/src/web/src/app/templates/opengraph-image.tsx b/src/web/src/app/templates/opengraph-image.tsxnew file mode 100644index 000000000..5678fff5b--- /dev/null+++ b/src/web/src/app/templates/opengraph-image.tsx@@ -0,0 +1,13 @@+import {+ OG_IMAGE_CONTENT_TYPE,+ OG_IMAGE_SIZE,+ renderOgImage,+} from "@/app/_og/render-og-image";++export const alt = "AI Company Templates — Alook";+export const size = OG_IMAGE_SIZE;+export const contentType = OG_IMAGE_CONTENT_TYPE;++export default function OpenGraphImage() {+ return renderOgImage("AI Company Templates");+}diff --git a/src/web/src/app/templates/page.tsx b/src/web/src/app/templates/page.tsxindex a5b628a19..c8276619e 100644--- a/src/web/src/app/templates/page.tsx+++ b/src/web/src/app/templates/page.tsx@@ -14,13 +14,11 @@ export const metadata: Metadata = {title: "AI Company Templates — Alook",description,url: "https://alook.ai/templates",- images: [{ url: "/og?title=AI Company Templates", width: 1200, height: 630 }],},twitter: {card: "summary_large_image",title: "AI Company Templates — Alook",description,- images: ["/og?title=AI Company Templates"],},};diff --git a/src/web/src/app/templates/twitter-image.tsx b/src/web/src/app/templates/twitter-image.tsxnew file mode 100644index 000000000..8f726ce33--- /dev/null+++ b/src/web/src/app/templates/twitter-image.tsx@@ -0,0 +1 @@+export { alt, contentType, default, size } from "./opengraph-image";diff --git a/src/web/src/components/home/landing-content.test.ts b/src/web/src/components/home/landing-content.test.tsindex db1c31bba..c820e796c 100644--- a/src/web/src/components/home/landing-content.test.ts+++ b/src/web/src/components/home/landing-content.test.ts@@ -167,13 +167,14 @@ describe("landing content contract", () => {it("promotes the approved landing while preserving the legacy route", () => {const root = webRoot()const repoRoot = path.resolve(root, "../..")- const rootRoute = readFileSync(path.join(root, "src/app/page.tsx"), "utf8")+ const rootRoute = readFileSync(path.join(root, "src/app/(home)/page.tsx"), "utf8")const legacyRoute = readFileSync(path.join(root, "src/app/landing-legacy/page.tsx"), "utf8")const rootLayout = readFileSync(path.join(root, "src/app/layout.tsx"), "utf8")const authLayout = readFileSync(path.join(root, "src/app/(auth)/layout.tsx"), "utf8")const signInClient = readFileSync(path.join(root, "src/app/(auth)/sign-in/sign-in-client.tsx"), "utf8")const communityLayout = readFileSync(path.join(root, "src/app/c/layout.tsx"), "utf8")const ogRoute = readFileSync(path.join(root, "src/app/og/route.tsx"), "utf8")+ const ogRenderer = readFileSync(path.join(root, "src/app/_og/render-og-image.tsx"), "utf8")const publicLayout = readFileSync(path.join(root, "src/components/public-layout.tsx"), "utf8")const landingPageSource = readFileSync(path.join(root, "src/components/home/landing-page.tsx"), "utf8")const landingContentSource = readFileSync(path.join(root, "src/components/home/landing-content.ts"), "utf8")@@ -236,18 +237,22 @@ describe("landing content contract", () => {expect(signInClient).toContain('description: "Use your own computer and existing agent subscriptions."')expect(signInClient).not.toContain("Bring your own workspaces")expect(communityLayout).toContain('<SignupTracker redirectTo="/c/me/machines" />')- expect(ogRoute).toContain('searchParams.get("title") || BRAND_SLOGAN')- expect(ogRoute).toContain('new URL("/alook.svg", request.url)')- expect(ogRoute).toContain("width={120}")- expect(ogRoute).toContain("height={120}")- expect(ogRoute).toContain("borderRadius: 28")- expect(ogRoute).toContain("HOME / FAMILY-PLANS")- expect(ogRoute).toContain("Maya joined the room.")- expect(ogRoute).toContain("Bring the agents you already use into a room with people you trust.")- expect(ogRoute).not.toContain("[email protected]")- expect(ogRoute).not.toContain("[email protected]")- expect(ogRoute).not.toContain("stay always on")- expect(ogRoute).not.toContain("Personal Company")+ expect(ogRoute).toContain("renderOgImage(BRAND_SLOGAN)")+ expect(ogRoute).not.toContain("searchParams")+ expect(ogRenderer).toContain('processRoot.endsWith(join("src", "web"))')+ expect(ogRenderer).toContain('join(webRoot, "public/icon-192.png")')+ expect(ogRenderer).not.toContain("OG_LOGO_DATA_URI")+ expect(ogRenderer).not.toContain("alook.svg")+ expect(ogRenderer).toContain("width={120}")+ expect(ogRenderer).toContain("height={120}")+ expect(ogRenderer).toContain("borderRadius: 28")+ expect(ogRenderer).toContain("HOME / FAMILY-PLANS")+ expect(ogRenderer).toContain("Maya joined the room.")+ expect(ogRenderer).toContain("Bring the agents you already use into a room with people you trust.")+ expect(ogRenderer).not.toContain("[email protected]")+ expect(ogRenderer).not.toContain("[email protected]")+ expect(ogRenderer).not.toContain("stay always on")+ expect(ogRenderer).not.toContain("Personal Company")expect(publicLayout).toContain("BRAND_SLOGAN")expect(publicLayout).not.toContain("Personal Company")expect(manifest.name).toBe("Alook — Share your agents with people you trust")