Skip to content

dogfooding fixes: astryx theme build --watch - #3478

Merged
cixzhang merged 1 commit into
mainfrom
navi/feat/theme-build-watch
Jul 4, 2026
Merged

cixzhang merged 1 commit into
mainfrom
navi/feat/theme-build-watch

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

What this adds

astryx theme build --watch — rebuild a theme automatically whenever its source file changes, until interrupted with Ctrl-C. Closes #3375 (item 1, the highest-impact request in that DX report).

Why

Today every tweak to a defineTheme file requires manually re-running astryx theme build theme.ts --out theme.css. Forget it once and you're debugging stale CSS that has nothing to do with your change. --watch turns theme authoring into a real tight loop: edit → save → rebuilt.

How it works

  • Runs an initial build, then watches the theme file and rebuilds on change (debounced, since editors emit several events per save).
  • Watches the containing directory and filters to the theme file, so atomic-save/rename (used by many editors) doesn't drop the watch.
  • Each rebuild runs in a child process that reuses the exact single-build code path. This has two benefits: the existing single-build behavior is untouched (zero regression risk), and a build error — which the single-build path reports via a hard exit — is contained in the child so the watcher keeps running instead of dying.
  • Coalesces changes that land mid-build into a single follow-up rebuild.
  • Stops cleanly on SIGINT/SIGTERM (closes the watcher, no orphaned process).
  • --watch is a human-interactive mode and is rejected with --json (which expects a single machine-readable envelope).

Per-rebuild latency is ~235ms (Node startup + core import), which is imperceptible next to the browser refresh that follows a theme edit.

Verification

New build-theme.watch.test.mjs (3 tests):

  1. --watch is advertised in theme build --help.
  2. --watch with --json is rejected.
  3. End-to-end: an initial build produces the CSS, editing the theme triggers a rebuild whose CSS reflects the new token value, and SIGINT stops the watcher cleanly (asserts the "Stopped watching" output and process exit).

Existing build-theme tests (prose, import-path, path-safety, variants) are unaffected — the single-build path is unchanged. ESLint clean.

@vercel

vercel Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 4, 2026 12:03am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 2, 2026
@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Jul 3, 2026
Add a --watch flag to theme build that rebuilds automatically whenever
the theme source file changes, until interrupted with Ctrl-C. This
removes the manual re-run step (and the stale-CSS confusion from
forgetting it) from the theme-authoring loop. Each rebuild runs in a
child process reusing the exact single-build code path, so a build error
is contained and the watcher keeps running. Watch is a human-interactive
mode and is not supported with --json.

Closes #3375
@cixzhang
cixzhang force-pushed the navi/feat/theme-build-watch branch from 0338db8 to 1e20d0a Compare July 3, 2026 23:58
github-actions Bot added a commit that referenced this pull request Jul 4, 2026
@cixzhang
cixzhang merged commit a1dd3f9 into main Jul 4, 2026
16 of 17 checks passed
@github-actions
github-actions Bot deleted the navi/feat/theme-build-watch branch July 12, 2026 06:58

This branch was successfully deployed

1 active deployment
Preview — 1e20d0a5 Deployed Jul 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Theme-authoring DX: tighten the edit loop (theme build --watch, a theme preview/gallery, earlier discoverability of astryx component/docs)

2 participants