Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Hub: link previews can fetch a harness's cover again; no Open Harness in the signed-in bar (#1413)

Jacob Phamfea9debabba0
diff --git a/website/public/robots.txt b/website/public/robots.txt
index 9190d1078..9296f16fe 100644
--- a/website/public/robots.txt
+++ b/website/public/robots.txt
@@ -1,6 +1,8 @@
User-agent: *
Allow: /
-# Built for one reader on request, not pages to keep: a project's ZIP, its fork snapshot, and the API.
+# Built for one reader on request, not pages to keep: a project's ZIP, its fork snapshot, and the API —
+# except a harness's cover, the image its link preview shows (X and LinkedIn will not fetch a disallowed one).
+Allow: /api/community/harnesses/*/cover
Disallow: /api/
Disallow: /hub/*/download
Disallow: /hub/*/snapshot
diff --git a/website/src/app/api/community/[...path]/route.spec.ts b/website/src/app/api/community/[...path]/route.spec.ts
index afa90e712..8a176da2a 100644
--- a/website/src/app/api/community/[...path]/route.spec.ts
+++ b/website/src/app/api/community/[...path]/route.spec.ts
@@ -1,7 +1,7 @@
// @vitest-environment node
import { gzipSync } from 'node:zlib';
import { afterEach, describe, expect, it, vi } from 'vitest';
-import { DELETE, GET, POST } from './route';
+import { DELETE, GET, HEAD, POST } from './route';
afterEach(() => { vi.unstubAllGlobals(); vi.unstubAllEnvs(); });
describe('community API boundary', () => {
@@ -64,6 +64,13 @@ describe('community API boundary', () => {
expect(fetcher.mock.calls[0][1].headers.has('content-type')).toBe(false);
expect(fetcher.mock.calls[0][1].body).toBeUndefined();
});
+ it('answers a link preview’s HEAD for a cover as the image it is', async () => {
+ const id = '0f8fad5b-d9cb-469f-a165-70867728950e';
+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response(new Uint8Array([137, 80]), { headers: { 'Content-Type': 'image/png' } })));
+ const response = await HEAD(new Request(`https://harness.example/api/community/harnesses/${id}/cover`, { method: 'HEAD' }), { params: Promise.resolve({ path: ['harnesses', id, 'cover'] }) });
+ expect(response.status).toBe(200);
+ expect(response.headers.get('content-type')).toBe('image/png');
+ });
it('serves a cover as a cacheable image, and only an image', async () => {
const id = '0f8fad5b-d9cb-469f-a165-70867728950e', context = { params: Promise.resolve({ path: ['harnesses', id, 'cover'] }) };
const request = new Request(`https://harness.example/api/community/harnesses/${id}/cover`, { headers: { authorization: 'Bearer fixture' } });
diff --git a/website/src/app/api/community/[...path]/route.ts b/website/src/app/api/community/[...path]/route.ts
index aea0ac81a..1492ee969 100644
--- a/website/src/app/api/community/[...path]/route.ts
+++ b/website/src/app/api/community/[...path]/route.ts
@@ -34,7 +34,7 @@ async function cover(path: string): Promise<Response> {
async function forward(request: Request, context: Context): Promise<Response> {
const path = (await context.params).path.join('/');
- if (request.method === 'GET' && coverPath.test(path)) return cover(path);
+ if ((request.method === 'GET' || request.method === 'HEAD') && coverPath.test(path)) return cover(path);
const sessionPath = path === 'session' && request.method === 'GET' ? 'me'
: path === 'session/refresh' && request.method === 'POST' ? 'refresh' : null;
if (!sessionPath && !allowed.test(path)) return Response.json({ success: false, error: { message: 'Not found.' } }, { status: 404 });
@@ -58,6 +58,8 @@ async function forward(request: Request, context: Context): Promise<Response> {
}
}
export const GET = forward;
+/** A link preview's crawler may ask for a cover's headers before its bytes. */
+export const HEAD = forward;
export const POST = forward;
export const PUT = forward;
export const DELETE = forward;
diff --git a/website/src/app/hub/community.module.css b/website/src/app/hub/community.module.css
index be1c3db41..1004819aa 100644
--- a/website/src/app/hub/community.module.css
+++ b/website/src/app/hub/community.module.css
@@ -137,7 +137,7 @@
.handoff{position:relative;display:inline-flex}
.filesReview{margin:30px 0}.filesReview summary{cursor:pointer;font-size:14px}.fileRow{display:flex;align-items:center;gap:12px;margin:10px 0;font-size:12px}.fileRow code{flex:1;overflow-wrap:anywhere}.fileRow button{text-decoration:underline;color:#666}.importActions{margin:24px 0;background:#f7f7f5;padding:22px}.importActions p{color:#666;font-size:13px;margin-top:8px}
/* Phones: one sticky glass bar. Brand and actions on the first row, the tabs under them, and an open search across its own row. */
-@media(max-width:760px){.topbar{position:sticky;top:0;z-index:20;background:rgba(255,255,255,.82);-webkit-backdrop-filter:saturate(180%) blur(18px);backdrop-filter:saturate(180%) blur(18px);box-shadow:0 1px 0 rgba(36,36,36,.07)}.bar{flex-wrap:wrap;gap:0 16px;min-height:0;padding:4px 0 0}.bar .brand{font-size:21px;margin-right:auto}.barActions{display:contents;font-size:14px}.barActions>a,.barActions>button{order:1}.page .barActions .primary{min-height:34px;padding:6px 14px}.barActions .openApp{display:none}.nav{order:2;width:100%;gap:24px;font-size:14px}.nav a{position:relative;min-height:42px}.nav [aria-current=page]:after{content:'';position:absolute;left:0;right:0;bottom:0;height:2px;background:#242424}.barActions>.searchField{order:3;width:100%;margin:4px 0 10px;animation:none}}
+@media(max-width:760px){.topbar{position:sticky;top:0;z-index:20;background:rgba(255,255,255,.82);-webkit-backdrop-filter:saturate(180%) blur(18px);backdrop-filter:saturate(180%) blur(18px);box-shadow:0 1px 0 rgba(36,36,36,.07)}.bar{flex-wrap:wrap;gap:0 16px;min-height:0;padding:4px 0 0}.bar .brand{font-size:21px;margin-right:auto}.barActions{display:contents;font-size:14px}.barActions>a,.barActions>button{order:1}.page .barActions .primary{min-height:34px;padding:6px 14px}.nav{order:2;width:100%;gap:24px;font-size:14px}.nav a{position:relative;min-height:42px}.nav [aria-current=page]:after{content:'';position:absolute;left:0;right:0;bottom:0;height:2px;background:#242424}.barActions>.searchField{order:3;width:100%;margin:4px 0 10px;animation:none}}
/* The narrowest phones (320px): brand, search, Publish and Sign in still share the first row. */
@media(max-width:360px){.bar{gap:0 10px}.bar .brand{font-size:19px}.page .barActions .primary{padding:6px 12px}}
.handoffHelp{position:absolute;top:calc(100% + 8px);left:0;z-index:5;white-space:nowrap;font-size:12px;line-height:1.5;color:#666;padding:8px 12px;border-radius:10px;background:rgba(255,255,255,.78);-webkit-backdrop-filter:saturate(180%) blur(18px);backdrop-filter:saturate(180%) blur(18px);border:1px solid rgba(36,36,36,.08);box-shadow:0 8px 24px rgba(36,36,36,.1);animation:handoffIn .18s ease-out}
diff --git a/website/src/app/hub/components/Header.tsx b/website/src/app/hub/components/Header.tsx
index c8132a687..79755fd93 100644
--- a/website/src/app/hub/components/Header.tsx
+++ b/website/src/app/hub/components/Header.tsx
@@ -1,7 +1,7 @@
'use client';
import { useEffect } from 'react';
import Link from 'next/link';
-import { ArrowUpRight, Bell } from 'lucide-react';
+import { Bell } from 'lucide-react';
import { countHub } from '@/lib/community/hubMeasure';
import { rememberHubReturn } from '@/lib/community/session';
import { webAppPath } from '@/lib/webApp';
@@ -10,11 +10,10 @@ import { useSignedIn } from './useSignedIn';
import { useUnread } from './useUnread';
import styles from '../community.module.css';
-/** One way out to the app: sign in (and come back) while signed out, open it once signed in. */
+/** Sign in (and come back) while signed out; once signed in, the bar needs no way out of the Hub. */
function AccountLink({ signedIn }: { signedIn: boolean | null }) {
- if (signedIn === null) return null;
- if (!signedIn) return <a href={webAppPath} onClick={rememberHubReturn}>Sign in</a>;
- return <a href={webAppPath} className={styles.openApp}>Open Harness <ArrowUpRight /></a>;
+ if (signedIn !== false) return null;
+ return <a href={webAppPath} onClick={rememberHubReturn}>Sign in</a>;
}
/** The reader's notifications, with how many are unread. */