From 459560cd723732d2c29950381a9c66ce0df2fc6b Mon Sep 17 00:00:00 2001 From: James Babcock Date: Fri, 25 Sep 2026 22:06:44 -0700 Subject: [PATCH] Fix a frozen menu in the notification modal --- app/ui/shell/modal-layer.ts | 12 ++++++++++-- tests/menu-display-list.test.cjs | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/ui/shell/modal-layer.ts b/app/ui/shell/modal-layer.ts index 0e200e7d..9001d0ae 100644 --- a/app/ui/shell/modal-layer.ts +++ b/app/ui/shell/modal-layer.ts @@ -52,11 +52,19 @@ export class ShellModalLayer implements Layer { this.stack.setBaseSize(interior); // Flattening bakes the inner stack's planes (glyphs included) so the blit // below transplants the finished modal content into this layer's plane. - const inner = flattenPlanes(this.stack.paint(), interior); + // The top plane's retained presentations (a menu's selection highlight + // and scroll strip) stay unbaked: they are display lists the glasses + // animate, and baking one freezes it on its first frame. Lower planes' + // are baked so the top plane's raster still covers them. + const planes = this.stack.paint(); + const top = planes[planes.length - 1]!; + const inner = flattenPlanes(planes.map((plane) => plane === top ? { ...plane, image: plane.image.withDrawsBaked(false) } : plane), interior); const rect = modalRect(); + const innerX = rect.x + MODAL_PADDING, innerY = rect.y + MODAL_PADDING; image.fillRect(rect.x, rect.y, rect.width, rect.height, SHELL_OPAQUE_BLACK); image.drawRect(rect.x, rect.y, rect.width, rect.height, 110); - image.bitBlt(inner, rect.x + MODAL_PADDING, rect.y + MODAL_PADDING, { transparentZero: true }); + image.bitBlt(inner, innerX, innerY, { transparentZero: true }); + top.image.copyPresentationsInto(image, innerX + top.x, innerY + top.y); return image; } diff --git a/tests/menu-display-list.test.cjs b/tests/menu-display-list.test.cjs index 2a176bea..fdfe12df 100644 --- a/tests/menu-display-list.test.cjs +++ b/tests/menu-display-list.test.cjs @@ -112,3 +112,21 @@ test('unselected sidebar icons retain -2 depth through shell cropping, including state.selectedIndex=1;const next=new graphics.GrayImage(640,480);chrome.drawSidebar(next,state); assert.equal(next.draws.filter(d=>d.presentation).length,2); }); +test('shell modal carries its inner menu highlight animation instead of baking its first frame',async()=>{ + const {ShellModalLayer}=load('app/ui/shell/modal-layer.ts',{ + '../../graphics/image':graphics,'../../graphics/plane':planes,'../gestures':{},'../layers':load('app/ui/layers.ts',{ + '../graphics/image':graphics,'../graphics/plane':planes,'../native/frame-timings':{spanCurrent:(_name,fn)=>fn()}, + './gestures':{isDirectionalInput:()=>false}, + }), + './geometry':{appViewportSize:()=>({width:120,height:110}),appViewportRect:()=>({x:10,y:20,width:120,height:110}),SHELL_OPAQUE_BLACK:1}, + }); + const modal=new ShellModalLayer(menu().layer,noopLayerActions),paint=()=>modal.paint({},()=>new graphics.GrayImage(200,200)); + const bare=menu().paint().draws.find(d=>d.presentation),before=paint().draws.find(d=>d.presentation); + assert.equal(before.x,bare.x+28);assert.equal(before.y,bare.y+38); // translated into the box interior + await modal.handleInput({type:'scroll-down'},{}); + const image=paint(),row=image.draws.find(d=>d.presentation); + assert.ok(row.y>before.y);assert.ok(row.presentation.displayList.timeline,'the slide stays a timed display list'); + assert.ok(!image.withDrawsBaked(false).pixels.some(v=>v===255),'selected text is not baked into the modal surface'); + const c=new SurfaceCompositor(200,200);c.setShellScene(encodeShellScene([{image,x:0,y:0,shellKey:9}])); + assert.ok(c.composite().some(v=>v===240)); +});