Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,7 @@ The standalone viewer:
- **Canvas detail** (`/canvas/:id`) — full rendered design with responsive viewport buttons (Mobile / Tablet / Desktop), Compare mode, Fit toggle, and JSON inspector; a canvas declared `mobile` opens 1:1 in a device frame with a Safe area toggle instead of the viewport, Compare and Fit buttons
- **Raw HTML** (`/canvas/:id/html`) — the rendered HTML for embedding or inspection
- **JSON API** (`/api/canvases`, `/api/canvas/:id/meta`) — programmatic access
- **Fonts** (`/assets/fonts/<file>`) — the viewer's own faces (Inter, Space Grotesk), served from the font cache (`~/.framesmith/fonts/`)
- **Live auto-refresh** — the viewer polls for changes every 2 seconds, so the browser updates automatically as your agent runs `batch_design`

Unbound canvases persist to `~/.framesmith/canvases/` as JSON files, and canvases in a bound repo persist to that repo's `.framesmith/` (see [`canvas_bind`](#canvas_bind)). Both survive process restarts, and the viewer shows both: the global store plus every repo registered in `~/.framesmith/registry.json`. Set `FRAMESMITH_VIEWER_URL` in the MCP server env to point at a viewer running on a non-default port.
Expand Down
3 changes: 2 additions & 1 deletion VISION.md
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,12 @@ _Full spec-driven breakdown in [`docs/specs/PHASE-32-SPEC.md`](docs/specs/PHASE-

Phase 31 rebuilt the viewer as canvases and left the code alone. A design pass on 2026-11-24 redrew those seven screens (gallery, detail with its menu, comment and delete states, archive and its empty state), each clean in both themes, and they are committed under `.framesmith/viewer-redesign/`. This phase ports them into the viewer: neutral chrome that follows the system's light or dark setting, real thumbnails scored against the evaluator's bar, an inspector that leads with what holds a design back, and live updates that cover thumbnails, scores and comments, not only the preview.

- [ ] Slice A — foundation: `src/viewer/` modules, tokens copied from the design system and pinned by a test, fonts served from the cache, one sidebar, tabs, menu and dialog used everywhere
- [x] Slice A — foundation: `src/viewer/` modules, tokens copied from the design system and pinned by a test, chrome that follows the system's light or dark setting, fonts served from the cache, one sidebar, tabs, menu and dialog used everywhere
- [ ] Slice B — gallery: thumbnail cards with a score chip against the bar, search and type filter kept in the URL, a live status, and refresh on every edit
- [ ] Slice C — detail shell: toolbar with state tabs, a More menu (JSON, copy ID, archive, delete), a delete dialog, and preview tools (zoom, fit, preview theme, safe area)
- [ ] Slice D — inspector and comments: the Quality tab sorted lowest first with a reason line, Design system and Feedback restyled, the Import placeholder removed, the comment popover, and panels that refresh live
- [ ] Slice E — archive, docs and acceptance: the archive tree with a preview panel, README and screenshots, and each screen beside its design
- [ ] Follow-up — the viewer sends `Access-Control-Allow-Origin: *` on every response, the routes that archive, delete and post comments included. It listens on 127.0.0.1 only, but a page open in the same browser can still send it a simple cross-origin POST (archive, unarchive, add or resolve a comment) without a preflight. Drop the header from mutating routes, reject requests whose `Origin` is not the viewer's own, and test both; a separate change from the visual port

_Full spec-driven breakdown in [`docs/specs/PHASE-33-SPEC.md`](docs/specs/PHASE-33-SPEC.md). Deliberately out of scope: a bundler or framework, a theme toggle, static thumbnails, a mirror marker, the Import tab's content, and the CORS policy on mutating routes (its own change)._

Expand Down
18 changes: 18 additions & 0 deletions src/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,24 @@ function mimeOf(ext: string): string {
return ext === 'woff2' ? 'font/woff2' : ext === 'woff' ? 'font/woff' : ext === 'otf' ? 'font/otf' : 'font/ttf';
}

/** Phase 33 — the cached faces of a family whose files are on disk, with no
* network: what the viewer declares in @font-face and serves by file name. */
export function cachedFontFaces(family: string): Array<{ family: string; file: string; weight?: string; style?: 'normal' | 'italic' }> {
const entry = readRegistry().families[family.toLowerCase()];
return (entry?.faces ?? [])
.filter((face) => existsSync(join(fontsDir(), face.file)))
.map(({ family: name, file, weight, style }) => ({ family: name, file, ...(weight !== undefined ? { weight } : {}), ...(style ? { style } : {}) }));
}

/** A cached font file by bare name, with its media type; null for anything
* that is not a file directly in the fonts dir (no separators, no dot-files). */
export function cachedFontFile(file: string): { path: string; mime: string } | null {
if (!/^[A-Za-z0-9_-]+\.(woff2|woff|ttf|otf)$/.test(file)) return null;
const path = join(fontsDir(), file);
if (!existsSync(path)) return null;
return { path, mime: mimeOf(file.split('.').pop() ?? 'woff2') };
}

function faceToDataUri(face: RegistryFace): FontFace | null {
const path = join(fontsDir(), face.file);
if (!existsSync(path)) return null;
Expand Down
Loading
Loading