Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
docs: keep code frames in the content column and dev-server styling current (#4076)
Maximilian Roos4f26e9a1c160
diff --git a/.config/wt.toml b/.config/wt.tomlindex e583e4129..f344d4714 100644--- a/.config/wt.toml+++ b/.config/wt.toml@@ -12,8 +12,12 @@ docs-install = "npm --prefix docs install --prefer-offline --no-audit --no-fund"# worktree is removed (any path — `wt remove`, `git worktree remove`, `rm -rf`),# so no `pre-remove`/`post-remove` cleanup is needed. The worktree root is still# what teardown watches even though the server runs from `docs/`.+# When `astro dev` detects an AI agent (`CLAUDECODE`, `CODEX_THREAD_ID`, …), it+# respawns itself as a detached process, which tether can't reach and which+# drops `--force`. `ASTRO_DEV_BACKGROUND=1`, the variable Astro sets on that+# respawned child, keeps the server in the foreground.[[post-start]]-docs = "wt step tether -C docs -- npm run dev -- --host 127.0.0.1 --port {{ branch | hash_port }}"+docs = "ASTRO_DEV_BACKGROUND=1 wt step tether -C docs -- npm run dev -- --host 127.0.0.1 --port {{ branch | hash_port }}"[post-merge]clippy = "pre-commit run clippy --all-files || true"diff --git a/docs/CLAUDE.md b/docs/CLAUDE.mdindex 0088a062d..618c179bd 100644--- a/docs/CLAUDE.md+++ b/docs/CLAUDE.md@@ -25,10 +25,18 @@ npm --prefix docs run buildnpm --prefix docs run test:site```-`npm run build` clears Astro's content cache, writes `docs/dist/`, and builds-the Pagefind search index. The forced content rebuild is intentional: renderer-plugin changes affect generated asset hashes but are not part of Astro's-content-cache key.+`npm run build` writes `docs/dist/` and builds the Pagefind search index. Both+`build` and `dev` pass `--force`, which clears Astro's content cache before+rendering. Cached pages carry the URL of the Expressive Code stylesheet, whose+hash comes from the code-rendering configuration and plugins, and Astro's cache+key covers neither: a stale page links a stylesheet the server no longer serves,+and every code block renders unstyled.++The cache is cleared only when the server starts. When `astro.config.mjs`+changes under a running dev server, through an edit or a merge, Astro restarts+the server in place but keeps rendering content with the renderer it started+with, and pages break the same way. Restart it with `wt hook post-start docs`;+the new `astro dev --force` replaces the running server.### Verifying changesdiff --git a/docs/package.json b/docs/package.jsonindex ffaba2773..b0a2b79a1 100644--- a/docs/package.json+++ b/docs/package.json@@ -5,7 +5,7 @@"scripts": {"build": "astro build --force","check": "astro check",- "dev": "astro dev",+ "dev": "astro dev --force","parity": "node scripts/parity.mjs","preview": "astro preview","test": "node --test tests/plugins.test.mjs",diff --git a/docs/src/styles/custom.css b/docs/src/styles/custom.cssindex 0778da5d7..a89d75b6c 100644--- a/docs/src/styles/custom.css+++ b/docs/src/styles/custom.css@@ -754,22 +754,3 @@ figure.demo img {font-size: 1.8rem;}}--/* Terminal output is the site's widest material — `wt list --full` renders far- past the prose column and disappears behind a horizontal scrollbar while the- pane beside the column sits empty. On viewports with that slack, let a- terminal frame take the whole pane. `.content-panel` becomes the query- container so the room available is measured rather than recomputed from- Starlight's main-pane formula: `100cqi` is the pane's content box, and the- frame's own `100%` is the content column it would otherwise be trapped in. */-@media (min-width: 72rem) {- .content-panel {- container-type: inline-size;- }-- .sl-markdown-content .expressive-code:has(.frame.is-terminal),- .sl-markdown-content .expressive-code:has(.frame.wt-command-reference) {- width: 100cqi;- margin-inline-start: min(0px, calc(100% - 100cqi));- }-}diff --git a/docs/tests/browser-site.test.mjs b/docs/tests/browser-site.test.mjsindex f93736d22..25a79b642 100644--- a/docs/tests/browser-site.test.mjs+++ b/docs/tests/browser-site.test.mjs@@ -196,25 +196,41 @@ test('mobile pages stay viewport-bound while code remains readable', { timeout:}});-test('desktop terminal examples fit without horizontal scrolling', { timeout: 60_000 }, async () => {+// 1920px leaves the content panel wider than the capped content column, so a+// code frame sized off the panel instead of the column shows up there.+test('desktop code examples fit the content column', { timeout: 60_000 }, async () => {const browser = await webkit.launch();try {- for (const width of [1152, 1376]) {+ for (const width of [1152, 1376, 1920]) {const page = await browser.newPage({ viewport: { width, height: 900 } });for (const route of await sitemapRoutes()) {await page.goto(`${baseUrl}${route}`, { waitUntil: 'domcontentloaded' });- const terminals = await page.evaluate(() => (- [...document.querySelectorAll('.frame.is-terminal')]- .filter((frame) => frame.querySelector('.wt-output'))- .map((frame) => {- const pre = frame.querySelector('pre');- return {- command: frame.querySelector('.wt-command')?.textContent.trim(),- clientWidth: pre.clientWidth,- scrollWidth: pre.scrollWidth,- };- })- ));+ const { column, blocks, terminals } = await page.evaluate(() => {+ const { left, right } = document.querySelector('.sl-markdown-content').getBoundingClientRect();+ return {+ column: { left, right },+ blocks: [...document.querySelectorAll('.sl-markdown-content .expressive-code')].map((block) => {+ const rect = block.getBoundingClientRect();+ return { left: rect.left, right: rect.right, text: block.textContent.trim().slice(0, 60) };+ }),+ terminals: [...document.querySelectorAll('.frame.is-terminal')]+ .filter((frame) => frame.querySelector('.wt-output'))+ .map((frame) => {+ const pre = frame.querySelector('pre');+ return {+ command: frame.querySelector('.wt-command')?.textContent.trim(),+ clientWidth: pre.clientWidth,+ scrollWidth: pre.scrollWidth,+ };+ }),+ };+ });+ for (const block of blocks) {+ assert.ok(+ block.left >= column.left - 1 && block.right <= column.right + 1,+ `${route} "${block.text}" leaves the content column at ${width}px`,+ );+ }for (const terminal of terminals) {assert.ok(terminal.scrollWidth <= terminal.clientWidth + 1,