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
@@ -21,11 +21,13 @@ const RENDER = {
const VIEW = { spreadId: 'sp-1', bookVersion: 7, width: 1280, height: 640, bytes: 182_000, description: 'Page 2' };
describe('the Studio page image', () => {
it('ASTVIS-001: a render request names the page, the version and the photos left out; ops are a proposal', () => {
it('ASTVIS-001: a render request names the page, the version and the photos left out; a proposal its page', () => {
expect(assistantPageRenderSchema.safeParse(RENDER).success).toBe(true);
const ops = [{ op: 'background', color: '#ffffff' }];
expect(assistantPageRenderSchema.safeParse({ ...RENDER, ops }).success).toBe(true);
expect(assistantPageRenderSchema.safeParse({ ...RENDER, ops: [] }).success).toBe(false);
// A proposal comes as the page the server applied it to, for the Studio to draw as it is.
const spread = { id: 'sp-1', role: 'inner', background: '#ffffff', elements: [], parked: [], entryId: null };
expect(assistantPageRenderSchema.parse({ ...RENDER, spread }).spread).toEqual(spread);
const notAPage = { ...spread, background: 'white' };
expect(assistantPageRenderSchema.safeParse({ ...RENDER, spread: notAPage }).success).toBe(false);
expect(assistantPageRenderSchema.safeParse({ ...RENDER, requestId: 'r1' }).success).toBe(false);
expect(assistantPageRenderSchema.safeParse({ ...RENDER, spreadId: '../x' }).success).toBe(false);
});
@@ -1,5 +1,6 @@
import { bookSpreadIdSchema } from '../book/book-op-ids';
import { bookDesignIdSchema, editBookPageArgs } from '../book/book-ops.schema';
import { bookSpreadSchema } from '../book/book.schema';
import { idSchema } from '../common/primitives.schema';
import { z } from 'zod';
@@ -35,17 +36,23 @@ export const ASSISTANT_PAGE_IMAGE = {
/**
* A page the server asks the Studio to draw, streamed while the turn waits.
* `ops` are a proposal to draw on an unsaved copy (a preview); without them
* the page is drawn as the book stands at `bookVersion`. The photos in
* `hiddenPhotoIds` are drawn as empty frames, and a map stop showing one as
* a plain dot: only the asking user's own photos leave the browser.
* `spread` is a proposal's page as the server applied it (a preview): the
* Studio draws that one in place of the stored page; without it the page is
* drawn as the book stands at `bookVersion`. The photos in `hiddenPhotoIds`
* are drawn as empty frames, and a map stop showing one as a plain dot: only
* the asking user's own photos leave the browser.
*/
export const assistantPageRenderSchema = z.object({
requestId: z.uuid(),
threadId: idSchema,
spreadId: bookSpreadIdSchema,
bookVersion: z.number().int().nonnegative(),
ops: editBookPageArgs.ops.optional(),
/**
* A proposal's page as the server applied it, with the journey's photos,
* words and figures: the Studio draws this one in place of the stored page,
* nothing saved.
*/
spread: bookSpreadSchema.optional(),
/** A page of a design draft (design_book) rather than of the book: the Studio draws it from the draft. */
designId: bookDesignIdSchema.optional(),
hiddenPhotoIds: z.array(idSchema).max(ASSISTANT_PAGE_IMAGE.maxPagePhotos),