Files
Vito 9d398f9862 feat(workspace): concept shell — sidebar, topbar, heading and footer on the approved mock's CSS (#256)
* build(workspace): vendor the approved concept stylesheet with a drift check

* refactor(workspace): adopt the concept stylesheet as the workspace base

* feat(workspace): concept sidebar with real navigation counts

* feat(workspace): concept topbar with Theme and ComfyUI link

* refactor(workspace): one concept heading and footer for every route

* fix(workspace): keep the canvas link on the proxy mount

A resolver failure no longer stops the shell from mounting: the ComfyUI link falls back to the root read from the page's own mount path (never another origin). Tests cover a non-standard /ComfyBackendDirect mount, including that no request escapes it.

* test(workspace): concept fixture and shell comparison

* test(workspace): concept fixture carries the concept inspector facts

* fix(workspace): match the concept brand name and compare shell hover states

* test(workspace): shell comparison mutation check and docs

Add mutate() to the shared concept inventory and a shell mutation check: a
nav-row min-height rule and a removed .breadcrumbs each make the comparison
fail with the changed path. Harden the resolver-failure guard test with an
injection count, make the overlay lint fail when workspace.css is missing,
mark the library.css .row-actions leftovers for PR E, and document the
concept CSS base, the overlay lint, the comparison method and the recorded
shell deviations in TESTING.md.

* fix(workspace): focus the page title on a route change

A sidebar or history navigation now focuses #page-title, as the concept
does on every hashchange (app.js 1168), so a screen reader announces the
page heading instead of the main region. The first render leaves focus
alone and the skip link still focuses main. The heading module's comment
now describes what the shell does.

* fix(workspace): give the Overview nav entry its own home glyph

Overview reused the concept's Activity pulse byte for byte, so once the
Activity row lands two entries would share one icon. Overview now has an
outline home glyph. The shell comparison takes it from the D28 ruling
instead of the concept's activity path, and the icon test checks that
every approved glyph is distinct.

* test(workspace): accept only #249 decision markers and state the lint scope

The overlay lint accepted any D-number, so another issue's ruling such
as "D5 (#245)" could mark a concept override. A marker now has to be a
D-number with no other issue cited; the vocabulary rule that cited #245
reads "#245 decision 5". TESTING.md now states that the lint covers
workspace.css only, lists the unmarked overrides still in images.css,
and says PRs C and D run the lint over each page sheet they keep.

* perf(workspace): re-read only Library and Tags counts after a Library write

A confirmed Library or vocabulary write cannot change the Images count,
but it re-read all three, including the Images output listing. It now
re-reads only the Library and Tags counts. Each count has its own read,
so a write never cancels an Images read that is still in flight.
2026-10-19 23:04:40 -07:00

51 lines
2.2 KiB
JavaScript

// The concept topbar's "ComfyUI ↗" link (D6 of #249).
const PROMPT_MANAGER = /prompt_manager\/$/;
/** The ComfyUI canvas root under the page's mount: the shared resolver's Prompt Manager root minus its own segment. */
export function canvasRoot(resolve) {
const root = resolve('/prompt_manager/');
if (typeof root !== 'string' || !root.startsWith('/') || root.startsWith('//') || !PROMPT_MANAGER.test(root)) {
throw new TypeError('Cannot resolve the ComfyUI canvas root');
}
return root.replace(PROMPT_MANAGER, '');
}
const PAGE_MOUNT = /^(.*\/)prompt_manager(?:\/|$)/;
/**
* The canvas link's href. A resolver failure must never stop the shell from mounting, so it falls back to the
* ComfyUI root read from the page's own path (the #164 proxy mount), and to the origin root when even that is not a
* same-origin root-relative path.
*/
export function canvasHref(resolve, pathname) {
try {
return canvasRoot(resolve);
} catch (error) {
console.warn('Prompt Manager: the ComfyUI link falls back to the page mount.', error);
const mount = typeof pathname === 'string' ? pathname.match(PAGE_MOUNT)?.[1] : undefined;
return mount && !mount.startsWith('//') ? mount : '/';
}
}
const plainClick = event => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
const isPair = roles => roles !== null && typeof roles === 'object' &&
typeof roles.positive === 'string' && typeof roles.negative === 'string';
/**
* Point the link at the canvas. A plain click while `getSelectedPair()` returns both resolved roles opens the
* acknowledged pair send instead, as the concept does; otherwise the browser follows the link. Returns an unbind.
*/
export function bindCanvasLink(link, { getSelectedPair = () => null, sender, href }) {
link.href = href;
const onClick = event => {
if (event.defaultPrevented || !plainClick(event) || !sender) return;
const roles = getSelectedPair();
if (!isPair(roles)) return;
event.preventDefault();
sender.open({ positive: roles.positive, negative: roles.negative }, link);
};
link.addEventListener('click', onClick);
return () => link.removeEventListener('click', onClick);
}