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,4 +1,4 @@
// FE-W4CTX-001 to FE-W4CTX-010
// FE-W4CTX-001 to FE-W4CTX-013
import { describe, it, expect, vi, afterEach } from 'vitest'
import { Trash2 } from 'lucide-react'
import { renderHook, act } from '@testing-library/react'
@@ -124,6 +124,26 @@ describe('ContextMenu', () => {
expect(onClose).toHaveBeenCalledTimes(3)
})
it('FE-W4CTX-013: Escape on an item closes the menu and goes no further, so nothing under it acts on it', () => {
const onClose = vi.fn()
const parentKeys = vi.fn()
const documentKeys = vi.fn()
document.addEventListener('keydown', documentKeys)
render(
<div onKeyDown={parentKeys}>
<ContextMenu menu={{ x: 0, y: 0, items: [{ label: 'Open' }] }} onClose={onClose} />
</div>,
)
fireEvent.keyDown(screen.getByRole('button', { name: 'Open' }), { key: 'Escape' })
expect(onClose).toHaveBeenCalledOnce()
expect(parentKeys).not.toHaveBeenCalled()
expect(documentKeys).not.toHaveBeenCalled()
// Any other key still reaches the page.
fireEvent.keyDown(screen.getByRole('button', { name: 'Open' }), { key: 'a' })
expect(parentKeys).toHaveBeenCalledOnce()
document.removeEventListener('keydown', documentKeys)
})
it('FE-W4CTX-012: focus starts on the first usable item and the arrow keys move it, wrapping', () => {
render(<ContextMenu menu={{ x: 0, y: 0, items: [{ label: 'Off', disabled: true }, { label: 'Open' }, { label: 'Rename' }] }} onClose={() => {}} />)
expect(screen.getByRole('button', { name: 'Open' })).toHaveFocus()
+10 -4
View File
@@ -56,17 +56,23 @@ export function ContextMenu({ menu, onClose }: ContextMenuProps) {
if (!menu) return
const handler = () => onClose()
// A fixed menu stays where it opened, so it closes when the page under it
// moves or the window changes size, and Escape closes it like any menu.
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() }
// moves or the window changes size. Escape closes it in the capture phase
// and goes no further, so a dialog, the assistant column or Studio under
// it does not act on the same key.
const onKey = (e: KeyboardEvent) => {
if (e.key !== 'Escape') return
e.stopPropagation()
onClose()
}
document.addEventListener('click', handler)
document.addEventListener('contextmenu', handler)
document.addEventListener('keydown', onKey)
document.addEventListener('keydown', onKey, true)
window.addEventListener('scroll', handler, true)
window.addEventListener('resize', handler)
return () => {
document.removeEventListener('click', handler)
document.removeEventListener('contextmenu', handler)
document.removeEventListener('keydown', onKey)
document.removeEventListener('keydown', onKey, true)
window.removeEventListener('scroll', handler, true)
window.removeEventListener('resize', handler)
}