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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Run `npx -p framesmith framesmith-viewer` to start the standalone browser viewer

> Above: a canvas in the detail view with the **Quality inspector** on the right — the same `canvas_evaluate` score the agent sees, with per-category bars and the issue list; the tabs along the top switch to the **Design-system** and **Feedback** panels. The toolbar exposes breakpoint previews, Compare, Fit, JSON, a **Comment** toggle for point-and-tell feedback, and lifecycle actions.

**Quality panel.** The canvas detail view shows a read-only **quality inspector** on the right: the heuristic `canvas_evaluate` score (0–100), per-category bars, and the issue list — each cliché tell with its `category · tell` badge, severity, and suggestion. Issues that `canvas_autofix` can resolve carry an **auto-fixable** tag, and clicking any issue **highlights its node** in the live preview. Every gallery card also shows a color-coded score badge so weak canvases stand out at a glance. The score matches what your agent sees over MCP (same fast-mode evaluation, relaxed by the canvas's stored genre and applied preset) — it's computed for display only and never written back.
**Quality panel.** The canvas detail view shows a read-only **quality inspector** on the right: the heuristic `canvas_evaluate` score (0–100), per-category bars, and the issue list — each cliché tell with its `category · tell` badge, severity, and suggestion. Issues that `canvas_autofix` can resolve carry an **auto-fixable** tag, and clicking any issue **highlights its node** in the live preview. Every gallery card also shows a score chip on its thumbnail: neutral at 96 and above, amber at 95 or below (the quality bar), so canvases under the bar stand out at a glance. The project header sums it up as "N canvases · M below the bar". The score matches what your agent sees over MCP (same fast-mode evaluation, relaxed by the canvas's stored genre and applied preset) — it's computed for display only and never written back.

![framesmith point-and-tell feedback — a newsletter signup card in the detail view with Comment mode active: a popover anchored to the clicked paragraph shows breadcrumb chips (Body · Signup Card · Document · whole page) and a typed note, while the Feedback inspector tab on the right lists one open comment on "Fine Print" and one resolved comment with the agent's reply beneath it.](https://raw.githubusercontent.com/vicmaster/framesmith/master/docs/framesmith-feedback.png?v=1.8)

Expand Down Expand Up @@ -214,7 +214,7 @@ Clone a screen into a linked **state variant** — the empty / loading / error v
| `canvasId` | string | The base canvas (a variant id also works — it resolves to the root base; variants never nest) |
| `state` | string | The state this variant designs — `empty` / `loading` / `error` for data states, `menu-open` / `comment-open` / `confirm-delete` / `toast` for overlay states; free string accepted |

Returns `{ canvasId, name, state, of, idMap }` — `idMap` maps every base node id to its clone, so follow-up edits target the right nodes immediately. One canvas per state per base (a duplicate state errors). The viewer shows a screen and its variants as one card with state chips; `canvas_list` rolls designed states onto the base row.
Returns `{ canvasId, name, state, of, idMap }` — `idMap` maps every base node id to its clone, so follow-up edits target the right nodes immediately. One canvas per state per base (a duplicate state errors). The viewer's project page shows a screen and its variants as one card, with the designed-state count in the card's meta line ("… · 3 states"); the detail page lists the states as chips; `canvas_list` rolls designed states onto the base row.

### `canvas_move` / `canvas_archive` / `canvas_unarchive` / `canvas_delete`

Expand Down Expand Up @@ -1375,13 +1375,13 @@ The standalone viewer:
### Routes & API

- **Gallery** (`/`) — browse all canvases as clickable cards with live thumbnails
- **Project** (`/project/:id`) — same gallery but scoped to one project
- **Project** (`/project/:id`) — one project's canvases as cards (score chip, type, size, edit date, state count), with a Live / Offline status, a search field (`?q=`) and Web / Mobile / Desktop app tabs (`?type=`) kept in the URL
- **Archive** (`/archive`) — soft-deleted canvases with restore / permadelete actions
- **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
- **JSON API** (`/api/canvases`, `/api/canvas/:id/meta`) — programmatic access; each `/api/canvases` row carries the canvas's resolved `type` and `genre`
- **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`
- **Live auto-refresh** — the canvas page polls every 2 seconds and the project page every 3, so the browser updates as your agent runs `batch_design`; the project page reloads on any edit, rename, genre, type or state change

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
2 changes: 1 addition & 1 deletion VISION.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ _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.

- [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
- [x] 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
Expand Down
7 changes: 7 additions & 0 deletions docs/specs/PHASE-33-SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ Its design system is the project's: seed `#B45309`, personality `technical`, 14p

**Slice B — gallery.** `pages/project.ts` and `client/project.ts` (FR-B1 to FR-B4), with the fixture store. Tests rewritten: `test-viewer-panels.ts` (its `card-score` assertion), `test-empty-thumbnail.ts`, `test-variants.ts` (state chips become the meta line), `test-viewer-surface.ts` (thumbnail sizing strings). New: `test/browser/test-viewer-gallery.ts`.

**Slice B — as built.**
- **B1: the fixture store is a builder, not JSON.** `test/fixtures/viewer-store.ts` seeds whatever store `FRAMESMITH_HOME` points at through the store's own functions, so it follows the canvas format as it changes; `test/unit/test-viewer-fixture.ts` pins what it holds. The 95 canvas is the pattern library's own dashboard; the 96 canvas is a marquee-hero copy (100) with a 13px low-contrast note and one off-scale gap. The fixture test asserts both scores, so a scoring change fails there, not in a page test.
- **B2: the sidebar counts cards.** A state variant folds into its base in the sidebar count too (`baseRows`, now in `shared.ts`), so the sidebar and the header agree (19 canvases were 17 cards on the fixture).
- **B3: the gallery header has no breadcrumb**, as the design shows; the workspace is the sidebar's label.
- **B4: one key, two places.** The live key is `galleryKey` in `pages/project.ts`, computed once per render from the same listing as the cards, and the same fold in `client/project.ts` over `/api/canvases`. The browser test checks that nothing reloads when nothing changed.
- **B5: `scoreColor` survives until slice D.** The gallery no longer uses the 80/60 scale; the detail page's inspector still does, and slice D's Quality tab replaces it (FR-D1), so it is deleted there.

**Slice C — detail shell.** `pages/detail.ts` toolbar, More menu, delete dialog, preview tools, caption and JSON panel (FR-C1 to FR-C4). Tests rewritten: `test-archive-view.ts` (its `btn-archive`, `btn-restore`, `btn-delete` and `lifecycleAction` assertions), `test-viewer-surface.ts` (device frame and breakpoint strings), `test-desktop-app.ts:260-266` (its `bp-w1024`, `bp-w1280`, `bp-desktop` ids and `bp-btn` count), `test-variants.ts:88-98` (the detail page's state chips become the States nav), `test/browser/test-viewer-compare.ts`, `test/browser/test-viewer-surface-browser.ts` (`.bp-btn` becomes the tab selector). New: `test/browser/test-viewer-detail.ts`. The `src/viewer.ts` re-export keeps every name tests import, `evalCacheKey` included (`test-dual-theme.ts`, `test-viewer-perf.ts`, `test/e2e/test-surface.ts`).

**Slice D — inspector and comments.** The Quality tab (FR-D1), the restyled Design system and Feedback tabs and the removed Import tab (FR-D2), the comment popover (FR-D3), and the live inspector with its route and `feedbackKey` (FR-D4). Tests rewritten: `test-viewer-panels.ts` (inspector selectors), `test-viewer-feedback.ts` (`data-tab="feedback"`, `btn-comment`, `FB_INIT`), `test-eval-cache-key.ts:104` (it reads the provenance chip from the toolbar; the chip moves into the Quality tab). New: `test/browser/test-viewer-inspector.ts`, with an MCP-driven check of FR-D4 in `test/e2e/`.
Expand Down
88 changes: 75 additions & 13 deletions src/viewer/client/project.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,85 @@
// Phase 33 slice A — the project page's browser script, moved from viewer.ts.
// Phase 33 slice B — the gallery's browser script: search and type filter
// kept in the URL (FR-B3), and the live poll with its Live / Offline status
// (FR-B4).
import { COMPONENTS_JS, MOBILE_TOGGLE_JS } from '../components.js';
import { scriptJson, THUMB_FIT_JS } from '../shared.js';

export function projectScript(projectId: string, count: number): string {
export function projectScript(projectId: string, initialKey: string): string {
return `
${MOBILE_TOGGLE_JS}
${COMPONENTS_JS}
${THUMB_FIT_JS}

// Auto-refresh: poll the canvas count for this project, reload if it changes.
let lastCount = ${scriptJson(count)};
const projectId = ${scriptJson(projectId)};
setInterval(async () => {
try {
const res = await fetch('/api/canvases');
const data = await res.json();
const inProject = data.filter((c) => c.projectId === projectId && !c.archived).length;
if (inProject !== lastCount) location.reload();
} catch {}
}, 3000);
(() => {
const projectId = ${scriptJson(projectId)};
const cards = Array.from(document.querySelectorAll('.card'));
const search = document.getElementById('search');
const tablist = document.querySelector('.filter-bar [role="tablist"]');
const noMatch = document.getElementById('no-match');
const params = new URLSearchParams(location.search);
let query = params.get('q') || '';
let type = params.get('type') || 'all';

const apply = () => {
const q = query.trim().toLowerCase();
let shown = 0;
for (const card of cards) {
const on = (!q || card.dataset.name.includes(q)) && (type === 'all' || card.dataset.type === type);
card.hidden = !on;
if (on) shown++;
}
if (noMatch) {
noMatch.hidden = shown > 0 || cards.length === 0;
document.getElementById('no-match-text').textContent = q ? 'No canvases match \\u201c' + query.trim() + '\\u201d' : 'No canvases of this type';
}
const next = new URLSearchParams();
if (q) next.set('q', query.trim());
if (type !== 'all') next.set('type', type);
const url = location.pathname + (next.toString() ? '?' + next : '');
if (url !== location.pathname + location.search) history.replaceState(null, '', url);
};
const selectTab = (id) => {
const tab = tablist && tablist.querySelector('[data-tab="' + id + '"]');
if (!tab) { type = 'all'; return; }
tablist.querySelectorAll('[role="tab"]').forEach((t) => { const on = t === tab; t.setAttribute('aria-selected', on ? 'true' : 'false'); t.tabIndex = on ? 0 : -1; });
};

if (search) {
search.value = query;
search.addEventListener('input', () => { query = search.value; apply(); });
}
if (tablist) tablist.addEventListener('tabchange', (e) => { type = e.detail.tab; apply(); });
const clear = document.getElementById('clear-filters');
if (clear) clear.addEventListener('click', () => { query = ''; if (search) search.value = ''; selectTab('all'); type = 'all'; apply(); if (search) search.focus(); });
selectTab(type);
apply();

// Live: reload when a base canvas of this project is added, removed,
// edited, renamed, retyped, re-genred or gains or loses a state.
const galleryKey = (rows) => {
const live = rows.filter((r) => r.projectId === projectId && !r.archived);
const present = new Set(live.map((r) => r.id));
return live
.filter((r) => !(r.variant && present.has(r.variant.of)))
.map((r) => [r.id, r.versionHash, r.name, r.type || '', r.genre || '', (r.variants || []).map((v) => v.state).sort().join(',')].join('|'))
.sort()
.join('\\n');
};
const initialKey = ${scriptJson(initialKey)};
const live = document.getElementById('live');
const setLive = (ok) => {
live.classList.toggle('offline', !ok);
live.querySelector('.live-label').textContent = ok ? 'Live' : 'Offline';
};
setInterval(async () => {
try {
const res = await fetch('/api/canvases', { cache: 'no-store' });
if (!res.ok) throw new Error(String(res.status));
const rows = await res.json();
setLive(true);
if (galleryKey(rows) !== initialKey) location.reload();
} catch { setLive(false); }
}, 3000);
})();
`;
}
7 changes: 4 additions & 3 deletions src/viewer/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { listCanvases } from '../scene-graph.js';
import { listProjects, listWorkspaces } from '../workspaces.js';
import { getIconSvg } from '../icons.js';
import { esc } from './shared.js';
import { baseRows, esc } from './shared.js';
import { LIGHT } from './tokens.js';

/** A bundled Lucide icon, stroked in the current text colour. */
Expand Down Expand Up @@ -39,11 +39,12 @@ export function projectDotToken(projectId: string): string {
}

/** The sidebar: wordmark; per workspace its label and one link per project
* (identity dot, name, non-archived count), or "No projects yet"; Archive
* (identity dot, name, card count), or "No projects yet"; Archive
* pinned to the bottom with its count. `active` is a project id or 'archive'. */
export function renderSidebar(active: string): string {
const all = listCanvases();
const projectCount = (projectId: string) => all.filter((c) => c.projectId === projectId && !c.archived).length;
// Cards, not canvases: a state variant folds into its base, as on the page.
const projectCount = (projectId: string) => baseRows(all, projectId).length;
const archivedCount = all.filter((c) => c.archived).length;
const current = (on: boolean) => (on ? ' aria-current="page"' : '');

Expand Down
Loading
Loading