fix(studio): the assistant column draws the page the server applied, and reads the user's role

A page preview draws the spread the server applied with the journey's photos,
texts and figures instead of applying the operations again without them. The
Studio's welcome, privacy banner and header fit a journey chat: a viewer is
told they can only look, the banner speaks of the book, and the trip notes
button stays in the trip chat. Escape closes the header menu before it stops a
reply, a single page renders at the full long edge, the status says a model
reads pages only while its provider has not refused an image, and pointing at
a page in a design card outlines it in the Studio.
This commit is contained in:
Maurice
2026-10-23 01:45:16 +00:00
parent 72c61f242e
commit 9e40092507
85 changed files with 857 additions and 144 deletions
@@ -1,6 +1,5 @@
import {
ASSISTANT_PAGE_IMAGE,
applyBookOps,
bookElementIdSchema,
bookSpreadIdSchema,
type AssistantPageRender,
@@ -27,7 +26,8 @@ import { sheetSizePx, snapshotSpread } from './pageSnapshot';
* - Each question carries the page on screen and the elements selected on it.
* - A page a turn asks to look at is drawn here, by the editor's own
* SpreadView off screen, and uploaded as an image (3.1): a page of the
* book, or of a design draft the assistant has not applied yet.
* book, of a design draft the assistant has not applied yet, or a
* proposal's page as the server applied it.
* - `?page=<spread id>`, which a page card opens, shows that page.
*/
@@ -83,29 +83,27 @@ function withDeadline(signal: AbortSignal): { signal: AbortSignal; release: () =
}
/**
* The page a request asks for, from the book at the version it names: with
* the request's ops applied to an unsaved copy (a preview). Null when the
* page is gone or the ops do not apply, so nothing is drawn.
* The page a request asks for, from the book at the version it names. A
* preview carries the proposal's page as the server applied it, with the
* journey's photos, words and figures this tab does not hold: that page is
* drawn in place of the stored one, nothing saved. A proposal changes only
* its own page, so the page setup and the folios stay the book's. Null when
* the page is gone, so nothing is drawn.
*/
export function renderJobOf(
doc: BookDocument,
request: AssistantPageRender,
deadline: { signal: AbortSignal; release: () => void }
): StudioRenderJob | null {
let next = doc;
if (request.ops) {
const made = applyBookOps(doc, { spreadId: request.spreadId, ops: request.ops });
if (made.ok === false) return null;
next = made.doc;
}
const index = next.spreads.findIndex((s) => s.id === request.spreadId);
const spread = next.spreads[index];
if (!spread) return null;
const index = doc.spreads.findIndex((s) => s.id === request.spreadId);
const stored = doc.spreads[index];
if (!stored) return null;
const spread = request.spread?.id === stored.id ? request.spread : stored;
return {
request,
spread,
page: next.page,
folios: foliosOf(next.spreads, index, next.page.pageNumbers.startAt),
page: doc.page,
folios: foliosOf(doc.spreads, index, doc.page.pageNumbers.startAt),
hidden: new Set(request.hiddenPhotoIds),
...deadline,
};