mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 15:36:33 +00:00
fix(assistant): a book page card draws the page after as the server's trial made it
The Studio drew the page after a held edit or cover change by running the card's operations on its own book, which knows nothing of the journey's photos, words and figures, so a caption from a photo, a text from an entry or a map from the route came out differently or not at all. The card now carries the page the server's trial made with the full context, read with the book's schema and within the card's size, and the Studio draws it while its book stands at the version the trial ran on. A book that moved on, a card from before and a page too heavy to carry still run the operations on the book on screen, the book the change will run on. The receipt leaves the page out, since an applied change is drawn from the book itself.
This commit is contained in:
@@ -4,7 +4,7 @@ import { storedTrekCardSchema, trekCardSchema } from './index';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
// BOOKCARD-001 to BOOKCARD-006
|
||||
// BOOKCARD-001 to BOOKCARD-007
|
||||
|
||||
function page(over: Partial<BookCardPage> = {}): BookCardPage {
|
||||
return { spreadId: 'sp-lisbon', index: 2, role: 'inner', number: 1, photos: 3, ...over };
|
||||
@@ -102,4 +102,18 @@ describe('the book page card', () => {
|
||||
});
|
||||
expect(applied.entity).toBe('book_page');
|
||||
});
|
||||
|
||||
it('BOOKCARD-007: carries the page after as the server made it; without one it reads, an unreadable one drops itself', () => {
|
||||
const after = { id: 'sp-lisbon', role: 'inner', background: '#ffffff', elements: [], parked: [], entryId: null };
|
||||
expect(bookPageCardSchema.parse(card({ after })).after).toEqual(after);
|
||||
// A card from before the page rode on it, as the thread keeps it, reads as it was.
|
||||
expect(bookPageCardSchema.parse(card()).after).toBeUndefined();
|
||||
expect(storedTrekCardSchema.parse(card())).toMatchObject({ kind: 'bookPage', journeyId: 4 });
|
||||
// A page a later build cannot read drops itself, never the card: the Studio then runs the operations.
|
||||
const unread = { ...after, background: 'white' };
|
||||
const kept = bookPageCardSchema.parse(card({ after: unread }));
|
||||
expect(kept.after).toBeUndefined();
|
||||
expect(kept.ops).toHaveLength(2);
|
||||
expect(storedTrekCardSchema.parse(card({ after: unread }))).toMatchObject({ kind: 'bookPage', journeyId: 4 });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,10 +14,13 @@ import { z } from 'zod';
|
||||
/**
|
||||
* A change to a journey's photo book as the Studio's chat shows it: the pages
|
||||
* a held book write works on, what it lays them out on and brings onto them,
|
||||
* and what the server's check of the result found. The card carries the
|
||||
* page operations themselves, so the Studio draws the page before and after
|
||||
* with the same engine and the same view the editor uses, never from an image.
|
||||
* Once applied it names the pages as the change left them.
|
||||
* and what the server's check of the result found. For an edit or the cover
|
||||
* it carries the page after as the server's trial of the change made it, so
|
||||
* the Studio draws the page before and after with the view the editor uses,
|
||||
* never from an image, and the page after as the server would write it. The
|
||||
* page operations ride along for a card without that page and for a book
|
||||
* that moved on since the trial: the Studio runs them on its own book with
|
||||
* the same engine. Once applied it names the pages as the change left them.
|
||||
*/
|
||||
|
||||
/** How much of a change a card carries; the server cuts to the same numbers. */
|
||||
@@ -83,9 +86,25 @@ export const bookPageCardSchema = z.object({
|
||||
count: cardCountSchema,
|
||||
/** Where a moved page lands among the double pages, from 1. */
|
||||
movedTo: z.number().int().min(1).max(MAX_SPREADS).nullable(),
|
||||
/** `edit_book_page`'s operations, to draw the page after; empty for another tool or when too long to carry. */
|
||||
/**
|
||||
* `edit_book_page`'s operations, to draw the page after where the card has
|
||||
* no `after` or the Studio's book moved on from `baseVersion`; empty for
|
||||
* another tool, when too long to carry, or when the page after needs their
|
||||
* room.
|
||||
*/
|
||||
ops: z.array(bookPageOpSchema).max(BOOK_OP_LIMITS.opsPerCall),
|
||||
cover: bookCardCoverSchema.nullable(),
|
||||
/**
|
||||
* The page an edit or the cover leaves, as the server's trial of the change
|
||||
* made it with the journey's photos, words and figures: a caption from its
|
||||
* photo's caption, a text from its entry, a map from the route. The Studio
|
||||
* draws the page after from it while its book is at `baseVersion`. Absent
|
||||
* on a card from before it, on a page too heavy to carry and on another
|
||||
* tool's card, where the Studio runs `ops` or `cover` on its own book, as
|
||||
* it does once its book moved on; absent once applied, where it draws the
|
||||
* page as it is. One a later build cannot read drops itself, never the card.
|
||||
*/
|
||||
after: bookSpreadSchema.optional().catch(undefined),
|
||||
layout: bookCardLayoutSchema.nullable(),
|
||||
/** Photos the change brings onto its pages that were not on them. */
|
||||
photosAdded: cardCountSchema,
|
||||
|
||||
Reference in New Issue
Block a user