Skip to content

feat(doop): add frame lock UI with unlock confirm (CHE-9395) [squash] - #169

Draft
congvc-bot-x99[bot] wants to merge 4 commits into
cheese/mainfrom
agent/x99-claude-sonnet-200k/che-9395-088893b09ba6
Draft

congvc-bot-x99[bot] wants to merge 4 commits into
cheese/mainfrom
agent/x99-claude-sonnet-200k/che-9395-088893b09ba6

Conversation

@congvc-bot-x99

@congvc-bot-x99 congvc-bot-x99 Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Part of CHE-9308 (step 7). Closes CHE-9395.

What

U1 frame lock UI. Marker Locked · <actor> · <time> ICT on the frame title, the Layers row and the Inspector. One "Unlock ?" confirm, raised inside setFramesLocked(frames, false), so all five entry points get it: Layers frame row, Layers element row, Inspector Unlock button, frame context menu, Cmd+Shift+L. The 423 toast names who, when and why. A refused unlock (403, or 423 policy_refused) keeps the frame locked and shows the A1 error state. After a lost reply the UI re-reads the frame before it draws the marker. Lock empty state. Disconnected pauses lock and unlock. Element locks unchanged.

Test command

npx vitest run tests/frameLockUi.test.tsx tests/layerLock.test.ts tests/layersKeys.test.tsx tests/layersEye.test.tsx

RED (base 85397ab1, same test file, no source change)

     × the Layers frame row opens the confirm; Keep locked sends nothing and Unlock sends one write
     × the Layers element row of a standalone element opens the confirm; Keep locked sends nothing and Unlock sends one write
     × the Inspector Unlock button opens the confirm; Keep locked sends nothing and Unlock sends one write
     × the frame context menu opens the confirm; Keep locked sends nothing and Unlock sends one write
     × Cmd+Shift+L opens the confirm; Keep locked sends nothing and Unlock sends one write
     × names who locked it and when, in ICT, in the confirm
     × shows Locked, the actor and the ICT time on the Layers row, the Inspector and the frame title source
     × hides the reason line when the reason is null, and still shows the marker
     × shows a bare Locked for a lock made before S1 recorded who and when
     × toasts who locked it, when and why from the 423 body
     × 403 keeps the frame locked and shows the A1 error state
     × 423 policy_refused keeps the frame locked and shows the A1 error state
     × re-reads the frame before it shows the marker, then shows the server state
     × shows the unlocked server state after a lost unlock reply that did land
     × shows No locked frames and the one Lock frame action when nothing is locked
     × pauses lock and unlock while disconnected, with the banner
⎯⎯⎯⎯⎯⎯ Failed Tests 16 ⎯⎯⎯⎯⎯⎯⎯
 Test Files  1 failed (1)
      Tests  16 failed | 2 passed (18)

GREEN (this head)

 ✓ tests/frameLockUi.test.tsx > the unlock confirm, from every entry point > the Layers frame row opens the confirm; Keep locked sends nothing and Unlock sends one write
 ✓ tests/frameLockUi.test.tsx > the unlock confirm, from every entry point > the Layers element row of a standalone element opens the confirm; Keep locked sends nothing and Unlock sends one write
 ✓ tests/frameLockUi.test.tsx > the unlock confirm, from every entry point > the Inspector Unlock button opens the confirm; Keep locked sends nothing and Unlock sends one write
 ✓ tests/frameLockUi.test.tsx > the unlock confirm, from every entry point > the frame context menu opens the confirm; Keep locked sends nothing and Unlock sends one write
 ✓ tests/frameLockUi.test.tsx > the unlock confirm, from every entry point > Cmd+Shift+L opens the confirm; Keep locked sends nothing and Unlock sends one write
 ✓ tests/frameLockUi.test.tsx > the unlock confirm, from every entry point > names who locked it and when, in ICT, in the confirm
 ✓ tests/frameLockUi.test.tsx > the unlock confirm, from every entry point > does not confirm a lock
 ✓ tests/frameLockUi.test.tsx > the unlock confirm, from every entry point > does not confirm an element lock toggle, and leaves the frame alone
 ✓ tests/frameLockUi.test.tsx > the lock marker > shows Locked, the actor and the ICT time on the Layers row, the Inspector and the frame title source
 ✓ tests/frameLockUi.test.tsx > the lock marker > hides the reason line when the reason is null, and still shows the marker
 ✓ tests/frameLockUi.test.tsx > the lock marker > shows a bare Locked for a lock made before S1 recorded who and when
 ✓ tests/frameLockUi.test.tsx > a refused edit > toasts who locked it, when and why from the 423 body
 ✓ tests/frameLockUi.test.tsx > an unlock the server refuses > 403 keeps the frame locked and shows the A1 error state
 ✓ tests/frameLockUi.test.tsx > an unlock the server refuses > 423 policy_refused keeps the frame locked and shows the A1 error state
 ✓ tests/frameLockUi.test.tsx > a lost reply > re-reads the frame before it shows the marker, then shows the server state
 ✓ tests/frameLockUi.test.tsx > a lost reply > shows the unlocked server state after a lost unlock reply that did land
 ✓ tests/frameLockUi.test.tsx > the lock states > shows No locked frames and the one Lock frame action when nothing is locked
 ✓ tests/frameLockUi.test.tsx > the lock states > pauses lock and unlock while disconnected, with the banner
 Test Files  1 passed (1)
      Tests  18 passed (18)

Also green: tests/layerLock.test.ts, tests/layersKeys.test.tsx, tests/layersEye.test.tsx (37 of 37 across the four files). bun run typecheck, bun run lint, bun run format:check clean.

Review fixes (head 88c9189e)

Two findings from the first review. Each has a test that was red on 66c4e344 (tests added first, no source change) and is green now.

  1. Failed re-read after a lost lock or unlock reply: the UI keeps the state from before the click and shows the A1 error state "Could not confirm the lock state of . Showing the last known state." with Try again, which reads the locks again. No guessed marker. (src/lib/layerEdits.ts, FrameLockPanel.tsx)
  2. A 423 on a stage edit (FrameView saveEdited): the undo step is dropped, the optimistic html is rolled back, the runtime document resyncs, and the 423 toast names who, when and why. It shares one helper with the Layers edit path. (rollBackRefusedHtml)

RED (tests/frameLockUi.test.tsx, 3 new tests, source as in 66c4e344):

× rolls the edit back and toasts who locked it, when and why 103ms
     × keeps the last known state and shows the A1 error state when the re-read after a lost lock reply fails 83ms
     × keeps the last known state and shows the A1 error state when the re-read after a lost unlock reply fails 114ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯
AssertionError: expected '<!doctype html><html><head></head><bo…' to be '<!doctype html><html><head></head><bo…' // Object.is equality
Expected: "<!doctype html><html><head></head><body><div><p>A</p></div></body></html>"
Received: "<!doctype html><html><head></head><body><p>typed</p></body></html>"
AssertionError: the given combination of arguments (undefined and string) is invalid for this assertion. You can use an array, a map, an object, a set, a string, or a weakset instead of a string
 Test Files  1 failed (1)
      Tests  3 failed | 18 passed (21)

GREEN (tests/frameLockUi.test.tsx tests/layerLock.test.ts tests/layersKeys.test.tsx tests/layersEye.test.tsx, head 88c9189e):

 Test Files  4 passed (4)
      Tests  40 passed (40)

Also green: bun run typecheck, bun run lint, bun run format:check.

Review fixes round 2 (head c96cd8dc)

Two findings from the exact-head review of 88c9189e. Tests were added first and were red with no source change; they are green now.

  1. P1, uncertain lock state must not allow edits that may be lost. After a lost lock or unlock reply and a failed re-read, the frame now stays locked locally (every edit guard reads frame.locked), shows the A1 error "Could not confirm the lock state of . Edits stay off until it is read again." and Try again reads the server. A lock that was only guessed has no actor or time; a lost unlock reply rolls back to locked with its original actor. (src/lib/layerEdits.ts, panels.ts en + pt-BR)
  2. P2, unlock refusal on phone. The 390 Inspector sheet has no Layers panel, so the sheet now shows the refusal or unreadable-state error with a Try again (LockErrorNote, data-testid="inspector-lock-error", role alert). Try again sends the unlock again (refusal) or reads the locks again (unreadable). Desktop keeps one error, in the Layers panel. (FrameLockPanel.tsx, Inspector.tsx)

RED (tests/frameLockUi.test.tsx, source as in 88c9189e):

 × keeps the frame locked and shows the A1 error state when the re-read after a lost lock reply fails
 × keeps the frame locked and shows the A1 error state when the re-read after a lost unlock reply fails
 × blocks an edit while a landed lock cannot be read, and edits again once the read says it is unlocked
 × shows a refused unlock and a Try again that sends the unlock again
 × shows an unreadable lock state and a Try again that reads it again
      Tests  5 failed | 19 passed (24)

GREEN (same file, head c96cd8dc): Tests 24 passed (24). Neighbouring suites tests/i18n.test.ts tests/frameLock*: 10 files, 178 tests passed. bun run typecheck, bun run lint, bun run format:check clean.

Test cases covered: landed lock + failed read + attempted edit (roundFramesToPixel() refused, no write) + recovery (Try again reads unlocked, edit goes through); refused unlock on the phone Inspector with retry; unreadable state on the phone Inspector with retry.

Review fixes round 3 (head 8f5ab7a0)

One finding from the UX verdict on c96cd8dc (x99-codex-terra-ux, CHANGES, P1): at 390 the open Inspector sheet covers the toast, so a refused edit (423) showed the person no reason.

  • Fix: a refused edit now also writes useLockUi.refusal (noteRefusal in src/lib/frameLock.ts, called from rollBackRefusedHtml and failedLock in src/lib/layerEdits.ts). LockErrorNote (phone Inspector, surface="inline" only) shows it as a red alert: frame name, who, when (ICT), reason, what to do, plus Dismiss (data-testid="inspector-lock-refusal", src/components/FrameLockPanel.tsx). It clears on the next write, on Dismiss, and when the frame is unlocked; another frame's refusal is never shown. Desktop is unchanged (toast still raised, no inline note).
  • Not changed: the desktop density notes (Layers row name truncation, size badge beside the Footer lock chip). They are P2, non-blocking, and need a Layers layout change outside this slice. See Residuals.

RED (tests/frameLockUi.test.tsx, new tests, no source change):

 × shows a refused edit inside the sheet: frame, who, when, why and what to do
 × takes the refusal away once the frame is unlocked, and for another frame never shows it
      Tests  2 failed | 24 passed (26)

GREEN (head 8f5ab7a0, tests/frameLockUi.test.tsx + tests/i18n.test.ts): Test Files 2 passed (2), Tests 32 passed (32). All 11 required checks are green on this head. Recaptured at 1440 and 390 on this head; new-390-2-edit-refused.png shows the alert inside the open sheet. Captures: CHE-10384.

Existing tests changed (2)

tests/layerLock.test.ts and tests/layersKeys.test.tsx now set connected: true (lock is paused offline); layerLock calls unlockConfirmed after the unlock toggle because unlock now waits for the confirm.

UI review pack (CHE-1485 Layer A)

  • Design: design/lifecycle-ui/approved/A1-frame-lock.html @ 572cc77
  • Admit sheet: docs/ux/CHE-9395.yml
  • Pattern ledger: the repo has no design/patterns.yml yet, so the ledger rules are skipped. Built from existing parts: U0 PanelState for the states, ConfirmDialog for the confirm.
  • Preview: not available.
  • Visual diff: NOT-RUN (CHE-1485 Layer B pending)
Page 1440 before 1440 after (round 3, 8f5ab7a0) 390 before 390 after (round 3, 8f5ab7a0)
canvas-editor-locked-frame before frame Jdgg3xGqZl, cell before-1440-1-locked after frame f_mI0G4gHf, cell r3-1440-1-locked before frame Jdgg3xGqZl, cell before-390-1-locked after frame f_mI0G4gHf, cell r3-390-1-locked
canvas-editor-edit-refused before frame Jdgg3xGqZl, cell before-1440-2-edit-refused after frame f_mI0G4gHf, cell r3-1440-2-edit-refused before frame Jdgg3xGqZl, cell before-390-1-locked (no message before; same as the locked capture) after frame f_mI0G4gHf, cell r3-390-2-edit-refused (alert inside the open sheet)

Review pack: CHE-10384. Reference frames on doop page che-5478: before frame Jdgg3xGqZl (updatedAt 2026-11-27T04:03:48.711Z, origin/cheese/main) and after frame f_mI0G4gHf (updatedAt 2026-11-26T22:50:05.790Z, head 8f5ab7a0). Extra states in the after frame: Unlock confirm and Unlock refused (A1 error) at 1440 and 390. Earlier packs (88c9189e, c96cd8dc) stay on CHE-10384 as history.

UX verdict on head 8f5ab7a0 (x99-codex-terra-ux, different lab): see CHE-10384. The frame screenshot tool renders the images blank; the designer rendered them in headless Chrome and saw pixels, and the asset sha256 match the CHE-10384 attachments. This PR stays DRAFT for the agent review.

Manual Keep / Change / Remove check (written out)

  • canvas-editor-locked-frame. Keep: lock toggle labels ("Lock"/"Unlock"), eye toggle, frame title, data-frame-locked. Checked in the tests: the toggles and the row still render and still send one locked write. Change: marker, Inspector lock banner (now with By/When/Reason), unlock confirm, lock panel. Remove: nothing.
  • canvas-editor-edit-refused. Keep: the notice toast. Change: its text (who, when, why from the 423 body). Remove: nothing.

Residuals

  • UX P2 (non-blocking), desktop density: Layers row truncates long frame names and lock details; the size badge sits beside the Footer lock chip. Needs a Layers row layout change; left for a follow-up.
  • A refused unlock leaves its undo entry (recordUpdates returns nothing to drop); undo then writes locked: true on an already locked frame, which the server treats as a no-op.
  • Full vitest run on this machine shows failures in browser layout-alignment and compose/deploy tests and a timeout. Not compared against base; CI is the check.
  • Out of scope, untouched: A3 page versions (CHE-9351), lock-port gate (CHE-9385), Trash purge, deploy.

congvc-bot[bot] added 4 commits November 27, 2026 03:15
…rors on phone (CHE-9395)

A lost lock reply with a failed re-read left the frame editable while the
server may hold the lock. It now stays locked here until a read succeeds.
The refused-unlock and unknown-state error, with Try again, also shows in
the phone Inspector sheet, which has no Layers panel.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants