diff --git a/app/ui/shell/modal-layer.ts b/app/ui/shell/modal-layer.ts index 115565fc..6bfc6c2e 100644 --- a/app/ui/shell/modal-layer.ts +++ b/app/ui/shell/modal-layer.ts @@ -6,7 +6,7 @@ import { Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../la import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry"; // The modal box covers most of the min-height app viewport. Retained vector -// clears hide the app outside its opaque rect. Size and position are +// clears optionally hide the app outside its opaque rect. Size and position are // computed per paint: the display-mode setting changes the viewport size at // runtime, and the vertical position setting moves the band. const MODAL_MARGIN = 14; @@ -34,10 +34,10 @@ export function modalRect(): { x: number; y: number; width: number; height: numb /** * A shell overlay hosting an inner layer stack in a bordered box over the - * app viewport (used for new-notification popups). It replaces the shell's - * lower layers. Only the box is opaque, so its cropped image fits the 64 KiB - * resource limit; a resource-free retained list clears the outside margins - * over separate app surfaces. The inner stack paints at the modal's interior + * app viewport (used for new-notification popups). Normally the shell's lower + * layers stay visible. For a wake popup, only the box is opaque (keeping its + * image within 64 KiB), and a resource-free retained list clears the outside + * margins over separate app surfaces. The inner stack paints at the modal's interior * size; inner value-0 pixels read as black, not transparent. */ export class ShellModalLayer implements Layer { @@ -47,6 +47,8 @@ export class ShellModalLayer implements Layer { baseLayer: Layer, actions: LayerActions, private readonly hooks: { + /** Arrival-time screen state: mask the background only for a wake popup. */ + hideBackground?: boolean; /** The modal left the shell stack, however it went. */ removed?: () => void; /** Input reached the modal (before its inner stack handles it). */ @@ -60,9 +62,10 @@ export class ShellModalLayer implements Layer { this.hooks.removed?.(); } - paint(ctx: LayerContext, _paintBelow: PaintBelow): GrayImage { - // Do not call paintBelow: retained chrome/menu animations must not remain - // beneath the notification. Leave the outer margins transparent so the + paint(ctx: LayerContext, paintBelow: PaintBelow): GrayImage { + // Wake popups omit lower chrome, but ordinary popups keep the usual overlay. + if (!this.hooks.hideBackground) paintBelow(); + // Leave the outer margins transparent so the // scene encoder crops to the resource-sized modal, not the whole display. // Native dim=0 still preserves a 1/0 halftone; clipped CLEAR calls below // instead produce literal black without changing shared dimming semantics. @@ -87,6 +90,7 @@ export class ShellModalLayer implements Layer { image.drawRect(rect.x, rect.y, rect.width, rect.height, 110); image.bitBlt(inner, innerX, innerY, { transparentZero: true }); top.image.copyPresentationsInto(image, innerX + top.x, innerY + top.y); + if (!this.hooks.hideBackground) return image; // ShellScene replays retained calls after the opaque box. Clear only the // complement of that box, keeping the inner menu's presentation order. // These are vector clips, not tiled image resources; no full-screen image diff --git a/app/ui/shell/notification-modal-queue.ts b/app/ui/shell/notification-modal-queue.ts index 6a9081e9..9d1caee5 100644 --- a/app/ui/shell/notification-modal-queue.ts +++ b/app/ui/shell/notification-modal-queue.ts @@ -9,7 +9,7 @@ */ export interface NotificationModalHost { /** Create and stack a modal showing this notification. */ - open(notificationKey: string): M; + open(notificationKey: string, hideBackground: boolean): M; /** Whether a queued notification is still worth opening (not dismissed, popups still on). */ isAvailable(notificationKey: string): boolean; /** Put the screen back to sleep. */ @@ -20,6 +20,8 @@ interface Entry { readonly notificationKey: string; /** Whether this notification woke the screen, so closing the last modal sleeps again. */ readonly wokeScreen: boolean; + /** Arrival-time state, independent of the inherited return-to-sleep flag. */ + readonly hideBackground: boolean; } export class NotificationModalQueue { @@ -37,11 +39,14 @@ export class NotificationModalQueue { if (this.current) { if (this.current.notificationKey !== notificationKey && !this.queued.some((entry) => entry.notificationKey === notificationKey)) { - this.queued.push({ notificationKey, wokeScreen }); + this.queued.push({ notificationKey, wokeScreen, hideBackground: wokeScreen }); } return; } - this.current = { modal: this.host.open(notificationKey), notificationKey, wokeScreen }; + this.current = { + modal: this.host.open(notificationKey, wokeScreen), + notificationKey, wokeScreen, hideBackground: wokeScreen, + }; } /** @@ -94,7 +99,11 @@ export class NotificationModalQueue { while (this.queued.length > 0) { const next = this.queued.shift()!; if (!this.host.isAvailable(next.notificationKey)) continue; - this.post(next.notificationKey, wokeScreen || next.wokeScreen); + this.current = { + ...next, + wokeScreen: wokeScreen || next.wokeScreen, + modal: this.host.open(next.notificationKey, next.hideBackground), + }; return true; } return false; diff --git a/app/ui/shell/shell.ts b/app/ui/shell/shell.ts index fd6ba8fc..ea3103de 100644 --- a/app/ui/shell/shell.ts +++ b/app/ui/shell/shell.ts @@ -482,7 +482,7 @@ class Shell { // App-posted notifications that are open or queued, by key. private readonly appNotifications = new Map(); private readonly notificationModals = new NotificationModalQueue({ - open: (notificationKey) => this.pushNotificationModal(notificationKey), + open: (notificationKey, hideBackground) => this.pushNotificationModal(notificationKey, hideBackground), isAvailable: (notificationKey) => { if (this.appNotifications.has(notificationKey)) return true; const notification = readActiveNotifications(ALL_NOTIFICATIONS).find((item) => item.key === notificationKey); @@ -926,7 +926,7 @@ class Shell { this.openNotificationModal(notification.key, wokeScreen); } - private pushNotificationModal(notificationKey: string): NotificationPopup { + private pushNotificationModal(notificationKey: string, hideBackground: boolean): NotificationPopup { const appNotification = this.appNotifications.get(notificationKey); const close = () => this.closeNotificationModal(popup, notificationKey); const content = appNotification @@ -951,6 +951,7 @@ class Shell { appNotification ? appNotification.createLayer(close) : content!, this.config.actions, { + hideBackground, removed: () => { timeout.stop(); this.appNotifications.delete(notificationKey); diff --git a/docs/validation-notification-focus-marquee.md b/docs/validation-notification-focus-marquee.md index c8ee7433..8642610c 100644 --- a/docs/validation-notification-focus-marquee.md +++ b/docs/validation-notification-focus-marquee.md @@ -4,8 +4,11 @@ Feature branch: `feat/notification-focus-marquee`. ## Notification backdrop -Notification popups hide the whole glasses interface, not only the small box. -The shell does not repaint lower chrome layers while the popup is visible. The +Notification popups hide the whole glasses interface only when the notification +arrived with the screen off and woke it. If the screen was already on, the usual +overlay keeps the app and chrome visible behind the box. This arrival-time choice +is preserved per queued notification, separately from the existing inherited +return-to-sleep state. For wake popups the shell omits lower chrome layers. The box is an opaque cropped image below the firmware's 64 KiB resource limit; resource-free retained CLEAR calls black out its outside margins over separate app surfaces. No oversized full-screen image is uploaded. The notification's @@ -48,6 +51,18 @@ assertions to the actual upstream UI. - Existing menu display-list regression suite: 11 passed. - TypeScript (`tsc --noEmit`) and lint passed; existing lint warnings remain. +## Wake-only backdrop correction + +- A screen-off arrival masks app/chrome; an already-on arrival preserves them. +- Queued arrivals preserve their own mask flag, while the original wake still + restores sleep after the last popup. Closing a popup does not close its app. +- RED: the new overlay and queue assertions failed before implementation. +- GREEN: all 24 focused queue/backdrop/menu display-list tests passed. +- Full standalone suite: 1,235 tests, 1,230 passed, 2 known onboarding failures, + 3 skipped. No new failures. TypeScript and lint passed. +- Combined build: 1,332 tests, 1,329 passed, 0 failed, 3 skipped; TypeScript and + lint passed. Independent review found no blocking issues. + ## Hardware limitation No phone, glasses or ring is attached to this development environment. No firmware diff --git a/tests/notification-backdrop.test.cjs b/tests/notification-backdrop.test.cjs index 23883ff5..2fac15da 100644 --- a/tests/notification-backdrop.test.cjs +++ b/tests/notification-backdrop.test.cjs @@ -7,7 +7,7 @@ const { encodeShellScene } = require('../.test-build/app/graphics/shell-scene.js const { readPresentation, paintPresentation } = require('../.test-build/app/graphics/presentation-wire.js'); const { DrawOp } = require('../.test-build/app/graphics/display-list.js'); -function fixture(width = 640, height = 480, retained = false) { +function fixture(width = 640, height = 480, retained = false, hideBackground = true) { const screen = { width, height, top: 0 }; const load = loader({}, { '../graphics/image': graphics, '../graphics/plane': planes, @@ -41,7 +41,7 @@ function fixture(width = 640, height = 480, retained = false) { }, handleInput() {}, }; - const modal = new ShellModalLayer(inner, noopLayerActions, { removed() { removed++; } }); + const modal = new ShellModalLayer(inner, noopLayerActions, { hideBackground, removed() { removed++; } }); return { screen, stack, modal, modalRect, innerSize: () => innerSize, lowerPaints: () => lowerPaints, removed: () => removed }; } @@ -88,6 +88,18 @@ test('G2 notification serializes through the production shell scene within one 6 assert.ok(mask.calls.every(call => call.op === DrawOp.CLEAR && call.color === 0 && call.clip)); }); +test('an already-awake notification keeps app and chrome visible with no blackout presentation', () => { + const f = fixture(640, 480, false, false); + f.stack.push(f.modal); + const { frame, layers } = sceneFrame(f); + assert.equal(f.lowerPaints(), 1, 'chrome is painted underneath the popup'); + assert.equal(layers.length, 2); + assert.equal(frame.getPixel(639, 479), 200, 'app is visible outside the popup'); + assert.equal(frame.getPixel(0, 0), 170, 'chrome remains visible'); + assert.ok(frame.pixels.includes(240), 'popup still appears above the app'); + assert.ok(layers.every(layer => layer.selections.length === 0), 'no margin mask for an already-on screen'); +}); + test('notification omits chrome and blacks out a separate app until dismissed', () => { const f = fixture(), before = sceneFrame(f).frame; assert.equal(f.lowerPaints(), 1); diff --git a/tests/notification-modal-queue.test.cjs b/tests/notification-modal-queue.test.cjs index d639dfe2..5eb6d49b 100644 --- a/tests/notification-modal-queue.test.cjs +++ b/tests/notification-modal-queue.test.cjs @@ -3,13 +3,27 @@ const assert = require("node:assert/strict"); const { NotificationModalQueue } = require("../.test-build/app/ui/shell/notification-modal-queue.js"); +test('background visibility follows each arrival, independently of inherited return-to-sleep state', () => { + const host = makeHost(); + const queue = new NotificationModalQueue(host); + queue.post('wake', true); + queue.post('already-on', false); + assert.equal(host.opened[0].hideBackground, true); + queue.closed(host.opened[0]); + assert.equal(host.opened[1].hideBackground, false, 'queued arrivals must not inherit the first popup mask'); + queue.closed(host.opened[1]); + assert.equal(host.sleeps, 1, 'sleep restoration is still inherited across the queue'); + queue.post('normal', false); + assert.equal(host.opened[2].hideBackground, false); +}); + /** A host that records opened modals (one handle object each) and sleeps. */ function makeHost(unavailable = new Set()) { const host = { opened: [], sleeps: 0, - open(notificationKey) { - const modal = { notificationKey }; + open(notificationKey, hideBackground) { + const modal = { notificationKey, hideBackground }; host.opened.push(modal); return modal; },