Skip to content

Self-hosted AI workspace.

Python

fix(css): repoint the two stylesheet links the split left behind

Léo51e09a1e326f
diff --git a/scripts/verify_background_research_cards.mjs b/scripts/verify_background_research_cards.mjs
index 16d580fba..158bc9b2e 100644
--- a/scripts/verify_background_research_cards.mjs
+++ b/scripts/verify_background_research_cards.mjs
@@ -1,10 +1,26 @@
/** Card layout and reconciliation against the served assets; no user mutations. */
import { chromium } from 'playwright';
+
+const ORIGIN = 'http://127.0.0.1:7011';
+
+/** The `<link rel="stylesheet">` tags the app shell ships, in shell order. */
+async function shellStylesheets() {
+ const response = await fetch(`${ORIGIN}/static/index.html`);
+ if (!response.ok) throw new Error(`static/index.html returned ${response.status}`);
+ const links = (await response.text()).match(/<link\b[^>]*rel=["']stylesheet["'][^>]*>/gi) || [];
+ if (!links.length) throw new Error('no stylesheet links found in static/index.html');
+ return links.join('');
+}
+
const browser = await chromium.launch({ headless: true });
try {
const page = await browser.newPage({ viewport: { width: 390, height: 844 } });
- await page.goto('http://127.0.0.1:7011/static/test-fixtures/browser-catalog.html');
- await page.setContent('<link rel="stylesheet" href="/static/style.css"><main style="padding:16px"><div id="chat-history"><p>Existing conversation</p></div></main>');
+ await page.goto(`${ORIGIN}/static/test-fixtures/browser-catalog.html`);
+ // Read the shell's stylesheets out of index.html rather than naming one
+ // here. style.css is now a set of ordered fragments, and a hardcoded link
+ // to a file that has moved does not fail - it renders unstyled and the
+ // layout checks below pass against nothing.
+ await page.setContent(`${await shellStylesheets()}<main style="padding:16px"><div id="chat-history"><p>Existing conversation</p></div></main>`);
const checks = await page.evaluate(async () => {
const { renderResearchCards } = await import('/static/js/backgroundToolJobs.js');
const box = document.querySelector('#chat-history');
diff --git a/tests/css_snapshot/bench.html b/tests/css_snapshot/bench.html
index a992f20ff..50e11d4cc 100644
--- a/tests/css_snapshot/bench.html
+++ b/tests/css_snapshot/bench.html
@@ -9,7 +9,27 @@
for opening the page by hand; it is deliberately unversioned so the
cache-bust string has one home (tests/test_static_stylesheet_manifest.py
pins the shipped ones). -->
- <link rel="stylesheet" href="/static/style.css">
+ <link rel="stylesheet" href="/static/css/00-tokens.css">
+ <link rel="stylesheet" href="/static/css/01-agent-chat.css">
+ <link rel="stylesheet" href="/static/css/02-compare.css">
+ <link rel="stylesheet" href="/static/css/03-agent-chat.css">
+ <link rel="stylesheet" href="/static/css/04-memory.css">
+ <link rel="stylesheet" href="/static/css/05-documents.css">
+ <link rel="stylesheet" href="/static/css/06-admin-settings.css">
+ <link rel="stylesheet" href="/static/css/07-documents.css">
+ <link rel="stylesheet" href="/static/css/08-skills.css">
+ <link rel="stylesheet" href="/static/css/09-gallery.css">
+ <link rel="stylesheet" href="/static/css/10-cookbook.css">
+ <link rel="stylesheet" href="/static/css/11-tasks.css">
+ <link rel="stylesheet" href="/static/css/12-gallery.css">
+ <link rel="stylesheet" href="/static/css/13-image-editor.css">
+ <link rel="stylesheet" href="/static/css/14-email.css">
+ <link rel="stylesheet" href="/static/css/15-notes.css">
+ <link rel="stylesheet" href="/static/css/16-calendar.css">
+ <link rel="stylesheet" href="/static/css/17-research.css">
+ <link rel="stylesheet" href="/static/css/documents-gallery-editor.css">
+ <link rel="stylesheet" href="/static/css/email-calendar-notes-tasks.css">
+ <link rel="stylesheet" href="/static/css/cookbook-research-memory-settings.css">
</head>
<body>
<!-- Intentionally empty. tests/css_snapshot/capture.mjs mounts one subtree
diff --git a/tests/test_static_stylesheet_manifest.py b/tests/test_static_stylesheet_manifest.py
index fd1082660..a6d6f167e 100644
--- a/tests/test_static_stylesheet_manifest.py
+++ b/tests/test_static_stylesheet_manifest.py
@@ -55,14 +55,23 @@ def _local_path(url):
return ROOT / url.split("?", 1)[0].lstrip("/")
+# HTML outside static/ that still links app stylesheets by URL. The snapshot
+# bench is one: it is not shipped, but a dead link there renders the bench
+# unstyled and every computed-style measurement taken from it is worthless.
+_UNSHIPPED_HTML = ("tests/css_snapshot/bench.html",)
+
+
def test_every_stylesheet_referenced_by_shipped_html_exists():
checked = 0
- for html_path in sorted((ROOT / "static").glob("*.html")):
+ html_files = sorted((ROOT / "static").glob("*.html"))
+ html_files += [ROOT / rel for rel in _UNSHIPPED_HTML]
+ for html_path in html_files:
for href in _stylesheet_hrefs(html_path):
if not href.startswith("/"):
continue # external or relative-to-page; not ours to resolve
assert _local_path(href).is_file(), (
- f"{html_path.name} links {href}, which does not exist on disk"
+ f"{html_path.relative_to(ROOT)} links {href}, "
+ "which does not exist on disk"
)
checked += 1
assert checked, "no app stylesheet links found - the parser or the markup moved"