LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-grace
createdAtNov 17, 2026, 1:02 AM
updatedAtNov 18, 2026, 1:15 PM
githubUrlhttps://github.com/neomjs/neo/issues/21199
authorneo-opus-grace
commentsCount0
parentIssue21198
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[ ] 21201 The desktop container, taskbar and app window move into src
closedAtNov 18, 2026, 1:15 PM

A desktop window manager in src owns app windows and their tasks

Closed v14.0.0/archive-v14-0-0-chunk-3 enhancementairefactoring
neo-opus-grace
neo-opus-grace commented on Nov 17, 2026, 1:02 AM

Context

First leaf of #21198, and the one that creates src/desktop/. The demo's apps/webdesktop/view/ViewportController.mjs holds a window manager next to its sign-in and permission code: windows and createdWindows, createWindow(), openApp(), onTaskItemClick(), onWindowHeaderAction(), onWindowHide(), onAppsFilter(), hideAllWindows(), releaseWindows(), and the signOuts counter that cancels a window load a sign-out overtook (#21100). The order of the windows lives elsewhere, as module state in view/AppWindow.mjs.

The Problem

That logic is what every web desktop needs. Today a consumer can only copy it, and a copy never receives a fix like #21100's. The order cannot be copied safely at all: as module state it is one stack for every desktop on an App worker.

The Architectural Reality

  • Design authority: n/a — moves and generalizes existing behavior; calls none of it wrong.
  • TreeStore#isKept(nodeOrKey) (src/data/TreeStore.mjs:792) says whether the apps store's filter keeps an app.
  • A window is a dialog.Base (src/dialog/Base.mjs: hide(), show(), hidden, animateTargetId, boundaryContainerId). It floats outside the component tree, so whoever creates it destroys it. It has one fixed z-index: 1000 (resources/scss/src/dialog/Base.scss:8) and no order among dialogs; toFront exists nowhere in src/.
  • The demo's order is module state in view/AppWindow.mjs (lines 9-30 and 116-128): a stack, baseZIndex = 10, restack(), and toFront() on mousedown.
  • The demo loads AppWindow through import() on first open and parents the window's state provider to the desktop's.
  • Today's coverage: test/playwright/unit/apps/webdesktop/view/ViewportController.spec.mjs.

The Fix

  • src/desktop/WindowManager.mjs, Neo.desktop.WindowManager (core.Base):
    • configs appStore, taskStore, windowClass (a class or an async module loader) and windowConfig (record => config, merged into each window);
    • openApp(record): create on first open and keep, or show; add or un-minimize its task; bring it to the front;
    • restore(appId): show a minimized window, or bring a visible one to the front;
    • minimize(appId) and close(appId);
    • bringToFront(appId): the manager's own stack sets the z-index of the windows it created; a mousedown on one of them brings it to the front;
    • reset(): cancel opens in flight, clear the tasks, hide every window without animation;
    • destroy(): destroy what it created, including loads in flight;
    • it listens to the app store's filter event and closes the windows of apps the filter no longer keeps.
  • Its @summary says that a window here is an app window addressed by appId, that windowId keeps its engine meaning (a browser window), and points at Neo.manager.Window.
  • src/desktop/model/Task.mjs and src/desktop/store/Tasks.mjs, moved from the demo.
  • The demo's controller creates the manager and delegates to it until the desktop container owns it (a later leaf of #21198); its sign-out calls reset(). Its window code and AppWindow.mjs's module-level stack go.
  • The window tests move from the controller's spec to a spec beside the manager.
  • The Architecture Overview's Structural Inventory gains a src/desktop/ row.

Contract Ledger

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
Neo.desktop.WindowManager configs appStore, taskStore, windowClass, windowConfig #21198 One window per app id, created on first open and kept A failed or cancelled load caches nothing; the next open loads again JSDoc unit
What the manager uses of a window src/dialog/Base.mjs show(), hide(), hidden, its hide and headerAction events, and the z-index the manager sets; any dialog.Base qualifies — JSDoc unit
openApp, restore, minimize, close, bringToFront, reset, destroy the demo's controller and AppWindow.mjs on dev The demo's behavior, with the order per manager instead of per module An unknown app id is a no-op JSDoc unit
App-store filter → close the demo's onAppsFilter() Closes the windows, minimized ones too, of apps the filter drops — JSDoc unit
Neo.desktop.model.Task, Neo.desktop.store.Tasks the demo's files Fields id, text, iconCls, color, minimized — JSDoc unit

Acceptance Criteria

  • AC-1: WindowManager.mjs, model/Task.mjs and store/Tasks.mjs exist under src/desktop/ with @summary JSDoc, the manager's carrying the naming rule. The demo uses them; its controller holds no window state (windows, createdWindows, signOuts), and AppWindow.mjs no module-level stack.
  • AC-2: Unit specs pin: two opens during one slow load create one window; a minimize keeps the task and a close removes it; a filter that drops an app closes its window, minimized or not; reset() during a load creates no window and clears the tasks; destroy() destroys created windows and loads in flight; a window brought to the front is above the others of its manager, and two managers keep separate stacks.
  • AC-3: The demo is unchanged for its user: test/playwright/e2e/webdesktop/PhoneAndTouch.spec.mjs and the remaining demo unit specs pass.
  • AC-4: The Architecture Overview's Structural Inventory has a src/desktop/ row.

Out of Scope

The launcher, the taskbar, the app window and the desktop container (later leaves of #21198); order among floating dialogs the manager did not create; the tear-out of D#21204; everything #21198 excludes.

Related

Parent #21198 · blocked by #21033, so it lands after the Engine 14 cut · #21100 (the sign-out race this carries into src/) · #21064 (the demo's windows) · D#21204 (where a popup embodiment would plug into the window-class seam).

Sweeps: as #21198 at 2026-11-16T23:59Z (latest 20 open, open and closed window manager, A2A, MC, own assignments); no equivalent. Revised 2026-11-17 after Mnemosyne's epic review on #21198.

Origin Session ID: 99757ce4-c1d9-4801-83f2-e2f545246917 Retrieval Hint: "desktop WindowManager src one window per app id minimize restore close reset filter drop z-index stack per manager"