Skip to content

An open-source, self-hosted system for apps built with web technologies.

Release System 0.1.86

zohayrslileh7b7f8925eec6
diff --git a/bun.lock b/bun.lock
index 54695b3..de5e9bf 100644
--- a/bun.lock
+++ b/bun.lock
@@ -8,7 +8,7 @@
"@fontsource/roboto": "^5.3.0",
"@hono/node-server": "^2.1.1",
"@jitl/quickjs-ng-wasmfile-release-sync": "^0.32.0",
- "@phreshos/core": "^0.1.57",
+ "@phreshos/core": "^0.1.58",
"@phreshos/react-ui": "^0.1.32",
"@the-link/core": "^0.3.1",
"@the-link/http": "^0.1.1",
@@ -199,7 +199,7 @@
"@oxc-project/types": ["@oxc-project/[email protected]", "", {}, "sha512-rDS5/31E9HfPl/CIzGrn0DOlvBbXFseQ5URJ9sYMfstbKLD/c6Gm9vmRzRGDdAXyOIL4zmO37lc9RIwYqVruZw=="],
- "@phreshos/core": ["@phreshos/[email protected]", "", { "dependencies": { "zod": "^4.6.5" } }, "sha512-q7oJQAu9FE7CJmtM9J6xOYOK5ZjCYbJMq0FY4u1TlW+u8eHN4lwLhAXq1njotph0Fcp7VLKoxFyVzhitCk6KCQ=="],
+ "@phreshos/core": ["@phreshos/[email protected]", "", { "dependencies": { "zod": "^4.6.5" } }, "sha512-qj7tKMloJpYI117ICNRKvaywan15KOaasCH+uLSU9nDf8RXjZJ3lGE+QlGJWNBpBLfzRft3GZt3U1zK83uRbrA=="],
"@phreshos/react-ui": ["@phreshos/[email protected]", "", { "dependencies": { "@base-ui/react": "^1.7.0", "@internationalized/date": "^3.12.3", "@phreshos/core": "^0.1.56", "colorjs.io": "^0.7.1", "motion": "^13.2.0", "react-aria": "^3.51.0", "react-aria-components": "^1.20.0" }, "peerDependencies": { "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-QmmpNTrM4lRaQPcAhmIwfMnf+g0lG83Z/jW3CG2HSEN5TQmlN86gzNFKED52xLY/XRfQ7VU+Ptj6MHgL0hX8zg=="],
diff --git a/package.json b/package.json
index 6c9506d..47f926c 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "phreshos",
"displayName": "PhreshOS",
- "version": "0.1.85",
+ "version": "0.1.86",
"description": "The PhreshOS server, desktop, and authoritative system runtime.",
"type": "module",
"private": true,
@@ -37,7 +37,7 @@
"@fontsource/roboto": "^5.3.0",
"@hono/node-server": "^2.1.1",
"@jitl/quickjs-ng-wasmfile-release-sync": "^0.32.0",
- "@phreshos/core": "^0.1.57",
+ "@phreshos/core": "^0.1.58",
"@phreshos/react-ui": "^0.1.32",
"@the-link/core": "^0.3.1",
"@the-link/http": "^0.1.1",
diff --git a/source/client/core/link-manager/auth-manager/auth-manager.ts b/source/client/core/link-manager/auth-manager/auth-manager.ts
index 8ee3ac1..cf01f74 100644
--- a/source/client/core/link-manager/auth-manager/auth-manager.ts
+++ b/source/client/core/link-manager/auth-manager/auth-manager.ts
@@ -65,12 +65,17 @@ export default class AuthManager extends TheLink {
await this.$outbound.publishFirst("/session/sign-out-current")
}
- public connection(operation: "current" | "list" | "find" | "state" | "session" | "sign-in", identity?: string) {
+ public authentication(operation: "state" | "requirements" | "set-credentials" | "sign-out-all-sessions" | "connections" | "connection" | "sessions" | "session", value?: unknown) {
+
+ return this.$outbound.publishFirst(`/authentication/${operation}`, ...(value === undefined ? [] : [value]))
+ }
+
+ public connection(operation: "current" | "state" | "session" | "sign-in", identity?: string) {
return this.$outbound.publishFirst(`/connection/${operation}`, ...(identity === undefined ? [] : [identity]))
}
- public session(operation: "list" | "find" | "state" | "connections" | "sign-out", identity?: string) {
+ public session(operation: "state" | "connections" | "sign-out", identity?: string) {
return this.$outbound.publishFirst(`/session/${operation}`, ...(identity === undefined ? [] : [identity]))
}
diff --git a/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts b/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts
index daf100f..f0dc0b9 100644
--- a/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts
+++ b/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts
@@ -355,9 +355,9 @@ export default class ProcessManager extends TheLink {
return this.followed(payload)
}
- @Subscribe("/change-frame")
+ @Subscribe("/change-surface")
@Publish("/processes", "inbound")
- protected async changeFrameHandle(payload: { identity: string, window: WindowSnapshot } | null) {
+ protected async changeSurfaceHandle(payload: { identity: string, window: WindowSnapshot } | null) {
return this.followed(payload)
}
diff --git a/source/client/core/link-manager/auth-manager/process-manager/window.ts b/source/client/core/link-manager/auth-manager/process-manager/window.ts
index fa1509d..687c3fd 100644
--- a/source/client/core/link-manager/auth-manager/process-manager/window.ts
+++ b/source/client/core/link-manager/auth-manager/process-manager/window.ts
@@ -1,5 +1,5 @@
import { type WindowSnapshot, type Position, type Size } from "@server/core/link-manager/auth-manager/process-manager/window"
-import { type WindowFrame, type WindowGeometry, type WindowLayer, type WindowState, type WindowTransaction } from "@phreshos/core"
+import { type WindowSurface, type WindowGeometry, type WindowLayer, type WindowState, type WindowTransaction } from "@phreshos/core"
import ProcessManager from "./process-manager"
/**
@@ -35,7 +35,7 @@ export default class Window implements Omit<WindowState, "front"> {
public header: boolean
- public frame: WindowFrame
+ public surface: WindowSurface
public transaction: WindowTransaction
@@ -48,7 +48,7 @@ export default class Window implements Omit<WindowState, "front"> {
this.header = payload.header
- this.frame = payload.frame
+ this.surface = payload.surface
this.transaction = payload.transaction
@@ -77,7 +77,7 @@ export default class Window implements Omit<WindowState, "front"> {
this.header = payload.header
- this.frame = payload.frame
+ this.surface = payload.surface
this.transaction = payload.transaction
@@ -120,9 +120,9 @@ export default class Window implements Omit<WindowState, "front"> {
await this.processManager.$outbound.publish("/set-header", this.process, header)
}
- public async setFrame(frame: WindowFrame) {
+ public async setSurface(surface: WindowSurface) {
- await this.processManager.$outbound.publish("/set-frame", this.process, frame)
+ await this.processManager.$outbound.publish("/set-surface", this.process, surface)
}
public async setTransaction(transaction: WindowTransaction) {
diff --git a/source/client/view/appearance/appearance.css b/source/client/view/appearance/appearance.css
index cd23acb..5c00d3c 100644
--- a/source/client/view/appearance/appearance.css
+++ b/source/client/view/appearance/appearance.css
@@ -84,7 +84,6 @@ html[data-phreshos-theme-transition]::view-transition-new(root) {
--text-taskbar-status: 0.625rem;
- --spacing-taskbar: 2.75rem;
--shadow-taskbar-control: inset 0 1px 0 rgba(255, 255, 255, 0.8);
diff --git a/source/client/view/components/desktop-host/host.ts b/source/client/view/components/desktop-host/host.ts
index 69a7cfc..71b4a3e 100644
--- a/source/client/view/components/desktop-host/host.ts
+++ b/source/client/view/components/desktop-host/host.ts
@@ -21,7 +21,7 @@ import {
type ProgramIconSize
} from "@phreshos/core"
import {
- presentationFrame,
+ presentationSurface,
presentationGeometry,
presentationPosition,
presentationSize,
@@ -189,50 +189,61 @@ export default function host(authManager: AuthManager, pane: string, viewport: (
return [visible.map(sdkProgram)]
}
- if (typeof word === "string" && word.startsWith("host-connection-")) {
+ if (typeof word === "string" && word.startsWith("host-authentication-")) {
+
+ const operation = word.slice("host-authentication-".length) as "state" | "requirements" | "set-credentials" | "sign-out-all-sessions" | "connections" | "connection" | "sessions" | "session"
- const operation = word.slice("host-connection-".length) as "list" | "find" | "state" | "session" | "sign-in"
+ if (operation === "state" || operation === "requirements" || operation === "set-credentials" || operation === "sign-out-all-sessions") {
- if (operation === "list") {
+ await access.require("authentication", [])
- const connections = await authManager.connection("list") as { identity: string }[]
+ return [await authManager.authentication(operation, args[0])]
+ }
+
+ if (operation === "connections") {
+
+ const connections = await authManager.authentication("connections") as { identity: string }[]
return [await access.connections(connections)]
}
+ if (operation === "sessions") {
+
+ const sessions = await authManager.authentication("sessions") as { identity: string }[]
+
+ return [await access.sessions(sessions)]
+ }
+
const identity = String(args[0])
- if (operation === "find") {
+ if (operation === "connection") {
- const connection = await authManager.connection("find", identity) as { identity: string } | null
+ const connection = await authManager.authentication("connection", identity) as { identity: string } | null
return [connection && await access.canConnection(connection.identity) ? connection : null]
}
- if (!await access.canConnection(identity)) throw new Error("Connection not found")
+ const session = await authManager.authentication("session", identity) as { identity: string } | null
- return [await authManager.connection(operation, identity)]
+ return [session && await access.canSession(session.identity) ? session : null]
}
- if (typeof word === "string" && word.startsWith("host-session-")) {
-
- const operation = word.slice("host-session-".length) as "list" | "find" | "state" | "connections" | "sign-out"
+ if (typeof word === "string" && word.startsWith("host-connection-")) {
- if (operation === "list") {
+ const operation = word.slice("host-connection-".length) as "state" | "session" | "sign-in"
- const sessions = await authManager.session("list") as { identity: string }[]
+ const identity = String(args[0])
- return [await access.sessions(sessions)]
- }
+ if (!await access.canConnection(identity)) throw new Error("Connection not found")
- const identity = String(args[0])
+ return [await authManager.connection(operation, identity)]
+ }
- if (operation === "find") {
+ if (typeof word === "string" && word.startsWith("host-session-")) {
- const session = await authManager.session("find", identity) as { identity: string } | null
+ const operation = word.slice("host-session-".length) as "state" | "connections" | "sign-out"
- return [session && await access.canSession(session.identity) ? session : null]
- }
+ const identity = String(args[0])
if (!await access.canSession(identity)) throw new Error("Session not found")
@@ -815,7 +826,7 @@ export default function host(authManager: AuthManager, pane: string, viewport: (
header: shown.header,
- frame: shown.frame,
+ surface: shown.surface,
transaction: shown.transaction,
@@ -905,9 +916,9 @@ export default function host(authManager: AuthManager, pane: string, viewport: (
return []
}
- if (word === "windowPresentationFrame") {
+ if (word === "windowPresentationSurface") {
const target = presentationProcess(args[0])
- await presentation.setFrame(target.identity, presentationFrame(args[1]), selectedTransaction(target))
+ await presentation.setSurface(target.identity, presentationSurface(args[1]), selectedTransaction(target))
return []
}
@@ -969,9 +980,9 @@ export default function host(authManager: AuthManager, pane: string, viewport: (
return [pane]
}
- if (word === "setFrame") {
+ if (word === "setSurface") {
- await windowOf(await permittedProcess(args[0])).setFrame(args[1] as never)
+ await windowOf(await permittedProcess(args[0])).setSurface(args[1] as never)
return [pane]
}
diff --git a/source/client/view/components/desktop-host/system-access.ts b/source/client/view/components/desktop-host/system-access.ts
index abd52e3..619c6a6 100644
--- a/source/client/view/components/desktop-host/system-access.ts
+++ b/source/client/view/components/desktop-host/system-access.ts
@@ -156,7 +156,7 @@ export default class SystemAccess {
private async connectionScope(): Promise<"all" | ConnectionSnapshot | null> {
- if (allowsSynchronizedPermission(this.permissions(), "connections", [])) return "all"
+ if (allowsSynchronizedPermission(this.permissions(), "authentication", [])) return "all"
if (!allowsSynchronizedPermission(this.permissions(), "desktopConnection", [])) return null
return await this.currentConnection()
diff --git a/source/client/view/components/desktop-host/window-presentation.ts b/source/client/view/components/desktop-host/window-presentation.ts
index cbba678..9967ad1 100644
--- a/source/client/view/components/desktop-host/window-presentation.ts
+++ b/source/client/view/components/desktop-host/window-presentation.ts
@@ -1,10 +1,10 @@
import {
isRelativeValue,
- parseWindowFrame,
+ parseWindowSurface,
parseWindowTransaction,
type Position,
type Size,
- type WindowFrame,
+ type WindowSurface,
type WindowGeometry,
type WindowState,
type WindowTransaction
@@ -16,10 +16,10 @@ export type PresentationAnimation = Readonly<{
transaction: WindowTransaction
}>
-/** Everything physically represented by one exact live Client iframe. */
+/** Values this Desktop relies on for one Client Window, not measured rendered output. */
export type WindowPresentationState = WindowState & Readonly<{
depth: number
- frameAnimation: PresentationAnimation | null
+ surfaceAnimation: PresentationAnimation | null
geometryAnimation: PresentationAnimation | null
minimizeAnimation: PresentationAnimation | null
}>
@@ -43,10 +43,10 @@ export interface WindowPresentationHost {
unfollow(identity: string): Promise<void>
setTitle(identity: string, title: string): void
setHeader(identity: string, header: boolean): void
- setFrame(identity: string, frame: WindowFrame, transaction?: PresentationTransactionRequest): Promise<void>
+ setSurface(identity: string, surface: WindowSurface, transaction?: PresentationTransactionRequest): Promise<void>
raise(identity: string): void
observe(identity: string, event: string | null, listener: (event: string, value: unknown) => void): () => void
- complete(identity: string, kind: "geometry" | "minimize" | "frame", revision: number): void
+ complete(identity: string, kind: "geometry" | "minimize" | "surface", revision: number): void
}
export function presentationPosition(value: unknown): Position {
@@ -72,8 +72,8 @@ export function presentationGeometry(value: unknown): WindowGeometry {
return Object.freeze({ x: record.x, y: record.y, width: record.width, height: record.height }) as WindowGeometry
}
-export function presentationFrame(value: unknown) {
- return parseWindowFrame(value)
+export function presentationSurface(value: unknown) {
+ return parseWindowSurface(value)
}
export function presentationTransaction(value: unknown, wait: unknown): PresentationTransactionRequest | undefined {
diff --git a/source/client/view/components/window-manager/layer-policy.ts b/source/client/view/components/window-manager/layer-policy.ts
index ff31462..7ad802d 100644
--- a/source/client/view/components/window-manager/layer-policy.ts
+++ b/source/client/view/components/window-manager/layer-policy.ts
@@ -15,4 +15,4 @@ export function followedState(current: WindowPresentationState, target: WindowPr
return changes
}
-const followedProperties = ["title", "header", "frame", "position", "size", "minimized", "maximized"] as const satisfies readonly WindowPresentationProperty[]
+const followedProperties = ["title", "header", "surface", "position", "size", "minimized", "maximized"] as const satisfies readonly WindowPresentationProperty[]
diff --git a/source/client/view/components/window-manager/window-geometry.ts b/source/client/view/components/window-manager/window-geometry.ts
index 1146fe7..c444078 100644
--- a/source/client/view/components/window-manager/window-geometry.ts
+++ b/source/client/view/components/window-manager/window-geometry.ts
@@ -70,7 +70,7 @@ export function constrainWindowGeometry(region: WindowRegion, surface: WindowSur
}
/**
- * The window's box is its geometry; an ordinary painted frame is inset only
+ * The window's box is its geometry; an ordinary painted surface is inset only
* on edges that do not touch that box's containing surface. Snap previews use
* this same function, so preview and final paint cannot disagree.
*/
diff --git a/source/client/view/components/window-manager/window-manager.ts b/source/client/view/components/window-manager/window-manager.ts
index 974732e..8c4050d 100644
--- a/source/client/view/components/window-manager/window-manager.ts
+++ b/source/client/view/components/window-manager/window-manager.ts
@@ -159,7 +159,7 @@ export default function useWindows(authManager: AuthManager) {
const summit = useCallback((layer: Layer) => [...peer.processes.values()].reduce((highest, process) => process.client?.window.layer === layer ? Math.max(highest, process.client.window.depth) : highest, 0), [peer])
// Resolve the front window of every layer in one pass.
- const fronts: Record<Layer, Process | null> = { wallpaper: null, under: null, window: null, over: null, "start-menu": null }
+ const fronts: Record<Layer, Process | null> = { wallpaper: null, under: null, window: null, over: null, shell: null }
for (const process of records) {
@@ -316,7 +316,7 @@ export default function useWindows(authManager: AuthManager) {
.sort((one, other) => (rank.get(one.identity) ?? Number.MAX_SAFE_INTEGER) - (rank.get(other.identity) ?? Number.MAX_SAFE_INTEGER))
- const panesByLayer: Record<Layer, typeof panes> = { wallpaper: [], under: [], window: [], over: [], "start-menu": [] }
+ const panesByLayer: Record<Layer, typeof panes> = { wallpaper: [], under: [], window: [], over: [], shell: [] }
for (const pane of panes) {
diff --git a/source/client/view/components/window-manager/window-presentations.ts b/source/client/view/components/window-manager/window-presentations.ts
index 06d8a92..e8d6c36 100644
--- a/source/client/view/components/window-manager/window-presentations.ts
+++ b/source/client/view/components/window-manager/window-presentations.ts
@@ -1,13 +1,13 @@
import { followedState, requirePresentationMutation } from "./layer-policy"
import ClientState from "@client/core/link-manager/auth-manager/process-manager/client-state"
import {
- type WindowFrame,
+ type WindowSurface,
type WindowGeometry,
type WindowState
} from "@phreshos/core"
import { type PresentationTransactionRequest, type WindowPresentationHost, type WindowPresentationState } from "../desktop-host/window-presentation"
import { type WindowRegion } from "./window-geometry"
-import { isFixedWindowPresentationLayer, requireWindowPresentationRead, supportsWindowPresentationApplication, windowPresentationFollowing } from "@shared/window-layers"
+import { isFixedWindowPresentationLayer, requireWindowPresentationRead, supportsWindowPresentationApplication } from "@shared/window-layers"
export interface WindowPresentationEntry {
identity: string
@@ -23,7 +23,6 @@ export default class WindowPresentations implements WindowPresentationHost {
private readonly authoritative = new Map<string, WindowPresentationState>()
private readonly waiting = new Map<string, WaitingAnimation>()
private readonly representations = new Map<string, PresentationGeometryRepresentation>()
- private readonly representationListeners = new Map<string, () => void>()
private readonly following = new Map<string, FollowingWindow>()
private readonly observers = new Map<string, Set<(event: string, value: unknown) => void>>()
private readonly emitted = new Map<string, WindowState>()
@@ -48,7 +47,7 @@ export default class WindowPresentations implements WindowPresentationHost {
if (current.get(process)?.identity === identity) continue
this.cancel(identity, "geometry", "The Window presentation was removed")
this.cancel(identity, "minimize", "The Window presentation was removed")
- this.cancel(identity, "frame", "The Window presentation was removed")
+ this.cancel(identity, "surface", "The Window presentation was removed")
this.following.delete(identity)
this.authoritative.delete(identity)
}
@@ -115,11 +114,7 @@ export default class WindowPresentations implements WindowPresentationHost {
public state(process: string) {
const { identity, state } = this.existing(process)
- const geometry = this.representations.get(identity)?.read()
- return windowState(state, frontmost(this.windows, state.layer) === identity, geometry && {
- position: { x: geometry.x, y: geometry.y },
- size: { width: geometry.width, height: geometry.height }
- })
+ return windowState(state, frontmost(this.windows, state.layer) === identity)
}
public read(process: string, property: import("@shared/window-layers").WindowPresentationProperty) {
@@ -145,13 +140,6 @@ export default class WindowPresentations implements WindowPresentationHost {
if (representation) {
this.representations.set(identity, representation)
-
- this.representationListeners.set(identity, representation.listen(() => {
-
- if (this.representations.get(identity) !== representation) return
-
- this.emitPresentationEvents()
- }))
}
this.publish(new Map(this.windows))
@@ -239,10 +227,9 @@ export default class WindowPresentations implements WindowPresentationHost {
}
public follow(process: string, transaction?: PresentationTransactionRequest) {
- const { identity, state } = this.existing(process)
- const relationship = windowPresentationFollowing(state.layer)
- if (relationship === "required") return Promise.resolve()
- if (relationship === "forbidden") throw new Error(`The ${state.layer} layer cannot follow an authoritative Window`)
+ // Following is an intersection with the current layer's capabilities;
+ // an empty intersection is a successful no-op, never a layer error.
+ const { identity } = this.existing(process)
const snapshot = this.authoritative.get(identity)!
this.following.set(identity, { snapshot })
const current = this.windows.get(identity)!
@@ -266,10 +253,7 @@ export default class WindowPresentations implements WindowPresentationHost {
}
public unfollow(process: string) {
- const { identity, state } = this.existing(process)
- const relationship = windowPresentationFollowing(state.layer)
- if (relationship === "required") throw new Error(`The ${state.layer} layer cannot unfollow its authoritative Window`)
- if (relationship === "forbidden") return Promise.resolve()
+ const { identity } = this.existing(process)
this.following.delete(identity)
return Promise.resolve()
}
@@ -314,16 +298,16 @@ export default class WindowPresentations implements WindowPresentationHost {
}
}
- public setFrame(process: string, frame: WindowFrame, transaction?: PresentationTransactionRequest) {
+ public setSurface(process: string, surface: WindowSurface, transaction?: PresentationTransactionRequest) {
const { identity, state } = this.existing(process)
- requirePresentationMutation(state.layer, "frame")
- if (JSON.stringify(state.frame) === JSON.stringify(frame)) return Promise.resolve()
+ requirePresentationMutation(state.layer, "surface")
+ if (JSON.stringify(state.surface) === JSON.stringify(surface)) return Promise.resolve()
- this.cancel(identity, "frame")
+ this.cancel(identity, "surface")
const animation = presentationAnimation(++this.revision, defaultPresentationTransaction(state), transaction)
- this.replace(identity, { ...state, frame, frameAnimation: animation })
- return this.waitFor(identity, "frame", animation, transaction)
+ this.replace(identity, { ...state, surface, surfaceAnimation: animation })
+ return this.waitFor(identity, "surface", animation, transaction)
}
public complete(process: string, kind: AnimationKind, revision: number) {
@@ -335,14 +319,14 @@ export default class WindowPresentations implements WindowPresentationHost {
? state?.geometryAnimation
: kind === "minimize"
? state?.minimizeAnimation
- : state?.frameAnimation
+ : state?.surfaceAnimation
if (!state || animation?.revision !== revision) return
this.replace(identity, kind === "geometry"
? { ...state, geometryAnimation: null }
: kind === "minimize"
? { ...state, minimizeAnimation: null }
- : { ...state, frameAnimation: null })
+ : { ...state, surfaceAnimation: null })
const key = animationKey(identity, kind)
const waiting = this.waiting.get(key)
@@ -358,7 +342,7 @@ export default class WindowPresentations implements WindowPresentationHost {
if (!identity) return
this.cancel(identity, "geometry", "The Window presentation was removed")
this.cancel(identity, "minimize", "The Window presentation was removed")
- this.cancel(identity, "frame", "The Window presentation was removed")
+ this.cancel(identity, "surface", "The Window presentation was removed")
const client = this.client(process)
if (!client) return
@@ -386,10 +370,6 @@ export default class WindowPresentations implements WindowPresentationHost {
private removeRepresentation(identity: string) {
- this.representationListeners.get(identity)?.()
-
- this.representationListeners.delete(identity)
-
this.representations.delete(identity)
}
@@ -434,11 +414,10 @@ export default class WindowPresentations implements WindowPresentationHost {
private emitPresentationEvents() {
for (const [identity, presentation] of this.windows) {
- const represented = this.representations.get(identity)?.read()
- const current = windowState(presentation, frontmost(this.windows, presentation.layer) === identity, represented && {
- position: { x: represented.x, y: represented.y },
- size: { width: represented.width, height: represented.height }
- })
+ // Renderer measurements are private output. Presentation events expose
+ // the values the Desktop relies on, so maximize and animation cannot
+ // rewrite or continuously reinterpret the retained geometry.
+ const current = windowState(presentation, frontmost(this.windows, presentation.layer) === identity)
const previous = this.emitted.get(identity)
this.emitted.set(identity, current)
if (!previous) continue
@@ -456,7 +435,7 @@ export default class WindowPresentations implements WindowPresentationHost {
if (previous.maximized !== current.maximized) emit("maximized", "maximize", current.maximized)
if (previous.title !== current.title) emit("title", "changeTitle", current.title)
if (previous.header !== current.header) emit("header", "changeHeader", current.header)
- if (JSON.stringify(previous.frame) !== JSON.stringify(current.frame)) emit("frame", "changeFrame", current.frame)
+ if (JSON.stringify(previous.surface) !== JSON.stringify(current.surface)) emit("surface", "changeSurface", current.surface)
if (previous.front !== current.front) emit("front", "front", current.front)
}
}
@@ -480,7 +459,7 @@ export default class WindowPresentations implements WindowPresentationHost {
}
}
-type AnimationKind = "geometry" | "minimize" | "frame"
+type AnimationKind = "geometry" | "minimize" | "surface"
interface WaitingAnimation {
revision: number
@@ -505,10 +484,8 @@ function presentationAnimation(revision: number, fallback: WindowState["transact
return transaction === false ? null : Object.freeze({ revision, transaction })
}
-/** Standard Window motion belongs to the Desktop; other layers use their Window value. */
function defaultPresentationTransaction(state: Pick<WindowPresentationState, "layer" | "transaction">) {
-
- return state.layer === "window" ? true : state.transaction
+ return state.transaction
}
function initialPresentationState(client: ClientState): WindowPresentationState {
@@ -519,13 +496,13 @@ function initialPresentationState(client: ClientState): WindowPresentationState
...authoritativeState(client),
title: window.title,
header: window.layer === "window" ? window.header : false,
- frame: window.layer === "window" ? true : fixed ? false : window.frame,
+ surface: fixed ? false : window.surface,
position: fixed ? { x: 0, y: 0 } : window.position,
size: fixed ? { width: "100%", height: "100%" } : window.size,
minimized: fixed ? false : window.minimized,
maximized: fixed ? true : window.maximized,
depth: fixed ? 0 : window.depth,
- frameAnimation: null,
+ surfaceAnimation: null,
}
}
@@ -534,7 +511,7 @@ function authoritativeState(client: ClientState): WindowPresentationState {
return {
title: window.title,
header: window.header,
- frame: window.frame,
+ surface: window.surface,
transaction: window.transaction,
position: window.position,
size: window.size,
@@ -543,21 +520,21 @@ function authoritativeState(client: ClientState): WindowPresentationState {
front: false,
layer: window.layer,
depth: window.depth,
- frameAnimation: null,
+ surfaceAnimation: null,
geometryAnimation: null,
minimizeAnimation: null
}
}
-function windowState(local: WindowPresentationState, front: boolean, geometry?: Readonly<{ position: WindowState["position"], size: WindowState["size"] }>): WindowState {
+function windowState(local: WindowPresentationState, front: boolean): WindowState {
return {
title: local.title,
header: local.header,
- frame: local.frame,
+ surface: local.surface,
transaction: local.transaction,
- position: geometry?.position ?? local.position,
- size: geometry?.size ?? local.size,
+ position: local.position,
+ size: local.size,
minimized: local.minimized,
maximized: local.maximized,
front,
@@ -576,8 +553,6 @@ export interface PresentationGeometryRepresentation {
finish: () => void
cancel: () => void
-
- listen: (settled: () => void) => () => void
}
function frontmost(windows: ReadonlyMap<string, WindowPresentationState>, layer: WindowPresentationState["layer"]) {
diff --git a/source/client/view/structure/authentication/authentication.tsx b/source/client/view/structure/authentication/authentication.tsx
index 3580413..549d889 100644
--- a/source/client/view/structure/authentication/authentication.tsx
+++ b/source/client/view/structure/authentication/authentication.tsx
@@ -9,7 +9,7 @@ import SignIn from "./sign-in"
import SignUp from "./sign-up"
import { useEffect, useState, type ReactNode } from "react"
import { type AuthenticationState } from "@server/core/authentication/authentication"
-import { WallpaperStage } from "../desktop/wallpaper/wallpaper"
+import { WallpaperStage } from "../desktop/layers/wallpaper/wallpaper"
import { useReady } from "@libs/readiness"
import { useThemedValue } from "@phreshos/react-ui"
import { useProperty } from "@the-link/react"
diff --git a/source/client/view/structure/authentication/credentials-form.tsx b/source/client/view/structure/authentication/credentials-form.tsx
index 94eef66..4117708 100644
--- a/source/client/view/structure/authentication/credentials-form.tsx
+++ b/source/client/view/structure/authentication/credentials-form.tsx
@@ -1,5 +1,5 @@
import { type AuthenticationState } from "@server/core/authentication/authentication"
-import { surfacePresencePose, surfacePresenceTransition } from "../../appearance/surface-presence"
+import { surfaceLifecyclePose, surfacePresenceTransition } from "../../appearance/surface-presence"
import { useReducedMotion } from "@libs/react-motion"
import { motion } from "motion/react"
import { Button, Input, Panel, useAppearance } from "@phreshos/react-ui"
@@ -32,9 +32,9 @@ export default function CredentialsForm({ title, description, submitLabel, passw
<motion.form
- initial={reducedMotion ? surfacePresencePose.entered : surfacePresencePose.entering}
+ initial={reducedMotion ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden}
- animate={surfacePresencePose.entered}
+ animate={surfaceLifecyclePose.visible}
transition={surfacePresenceTransition(reducedMotion, transaction)}
diff --git a/source/client/view/structure/desktop/desktop-display.tsx b/source/client/view/structure/desktop/desktop-display.tsx
deleted file mode 100644
index 3c9c77b..0000000
--- a/source/client/view/structure/desktop/desktop-display.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import { type ReactNode, type Ref } from "react"
-import { desktopDisplayStyle } from "./geometry"
-
-/**
- * The desktop's visible stacking structure. Each program layer owns a
- * containing block; window geometry remains identical inside every layer.
- */
-export default function DesktopDisplay({ wallpaper, underWindows, windows, sharedResizeBoundaries, overWindows, windowSurfaceRef, taskbar }: DesktopDisplayProps) {
-
- return <div className="m-(--desktop-gutter) grid min-h-0 grid-cols-1 grid-rows-[1fr_auto] gap-(--desktop-gutter)" style={desktopDisplayStyle}>
-
- <div className="absolute inset-0 z-0 overflow-hidden">
-
- {wallpaper}
-
- </div>
-
- <div className="pointer-events-none absolute inset-0 z-1 overflow-hidden">
-
- {underWindows}
-
- </div>
-
- <div ref={windowSurfaceRef} className="pointer-events-none relative z-2">
-
- {windows}
-
- {sharedResizeBoundaries}
-
- </div>
-
- <div className="pointer-events-none absolute inset-0 z-3 overflow-hidden">
-
- {overWindows}
-
- </div>
-
- {taskbar}
-
- </div>
-}
-
-interface DesktopDisplayProps {
-
- wallpaper: ReactNode
-
- underWindows: ReactNode
-
- windows: ReactNode
-
- sharedResizeBoundaries: ReactNode
-
- overWindows: ReactNode
-
- windowSurfaceRef: Ref<HTMLDivElement>
-
- taskbar: ReactNode
-}
diff --git a/source/client/view/structure/desktop/desktop.tsx b/source/client/view/structure/desktop/desktop.tsx
index 9c9c2c7..7db99eb 100644
--- a/source/client/view/structure/desktop/desktop.tsx
+++ b/source/client/view/structure/desktop/desktop.tsx
@@ -2,19 +2,16 @@ import { type Layer } from "@phreshos/core"
import { useCallback, useEffect, useRef, useState } from "react"
import { ApplicationContext, AuthManagerContext, LinkManagerContext } from "../../contexts"
import useClientHost from "../../components/desktop-host/client-host"
-import DesktopDisplay from "./desktop-display"
+import DesktopLayers from "./layers/desktop-layers"
import useDesktopFocus from "./desktop-focus"
import programIcon from "./programs/program-icon"
import ProgramAccessProbe, { type ProgramAccess } from "../../components/program-access"
-import StartMenu from "./taskbar/launcher/start-menu"
-import OverflowRow from "./taskbar/programs/overflow-row"
-import SignOut from "./taskbar/system/sign-out"
-import SystemDialogs from "./taskbar/system/system-dialogs"
-import Taskbar from "./taskbar/taskbar"
-import WindowTaskbarItem from "./taskbar/programs/window-taskbar-item"
+import DefaultShell from "./layers/shell/default-shell"
+import OverflowRow from "./layers/shell/taskbar/programs/overflow-row"
+import WindowTaskbarItem from "./layers/shell/taskbar/programs/window-taskbar-item"
import ProcessWindow from "./windows/process-window"
import useWindows from "../../components/window-manager/window-manager"
-import { ReadyWallpaper, WallpaperBackground } from "./wallpaper/wallpaper"
+import { ReadyWallpaper, WallpaperBackground } from "./layers/wallpaper/wallpaper"
import Loading from "../../components/loading"
import { useRequirement } from "@libs/readiness"
import { usePreferences, useThemedValue } from "@phreshos/react-ui"
@@ -48,7 +45,7 @@ export default function Workspace() {
const [fileWallpaperReady, setFileWallpaperReady] = useState(false)
const hasWallpaperClient = windows.records.some(record => record.client?.window.layer === "wallpaper")
- const hasStartMenuClient = windows.records.some(record => record.client?.window.layer === "start-menu")
+ const hasShellClient = windows.records.some(record => record.client?.window.layer === "shell")
const wallpaperReady = hasWallpaperClient || fileWallpaperReady
const desktop = useRef<HTMLDivElement>(null)
@@ -127,7 +124,7 @@ export default function Workspace() {
header={presentation.header}
- frame={presentation.frame}
+ surface={presentation.surface}
layer={presentation.layer}
@@ -139,7 +136,7 @@ export default function Workspace() {
size={presentation.size}
- frameAnimation={presentation.frameAnimation}
+ surfaceAnimation={presentation.surfaceAnimation}
geometryAnimation={presentation.geometryAnimation}
@@ -153,6 +150,8 @@ export default function Workspace() {
// touch their surface. Positioning is identical in every layer.
paintSurfaceSize={layer === "window" ? windowSurfaceSize : undefined}
+ spacing={appearance.spacing}
+
depth={presentation.depth}
active={fronts[layer]?.identity === record.identity}
@@ -200,69 +199,69 @@ export default function Workspace() {
/>)
}
- const taskbar = <Taskbar
-
- leading={<StartMenu replacement={hasStartMenuClient ? renderWindows("start-menu") : undefined} />}
-
- trailing={<SignOut />}
-
- dialogs={<SystemDialogs />}
-
- className="z-4"
+ const taskbarOrientation = appearance.taskbar.position === "top" || appearance.taskbar.position === "bottom" ? "horizontal" : "vertical"
+ const taskbarItems = <OverflowRow
+ orientation={taskbarOrientation}
+ className="h-full w-full"
+ aria-label="Open windows"
+ backwardLabel="Earlier windows"
+ forwardLabel="Later windows"
>
{/* What a press means is composed here because it is a person's
expectation, not a system operation: the front window hides;
another window is shown and brought forward. */}
- <OverflowRow aria-label="Open windows" backwardLabel="Earlier windows" forwardLabel="Later windows">
+ {windows.listed.map(record => {
- {windows.listed.map(record => {
+ const window = windows.presentation.projection(record.identity)
- const window = windows.presentation.projection(record.identity)
+ return <WindowTaskbarItem
- return <WindowTaskbarItem
+ key={record.identity}
- key={record.identity}
+ record={record}
- record={record}
+ title={window.title}
- title={window.title}
+ icon={icon(record)}
- icon={icon(record)}
+ position={appearance.taskbar.position}
- active={fronts.window?.identity === record.identity}
+ active={fronts.window?.identity === record.identity}
- minimized={window.minimized}
+ minimized={window.minimized}
- maximized={window.maximized}
+ maximized={window.maximized}
- onElement={focus.taskbarItem}
+ onElement={focus.taskbarItem}
- onMinimize={focus.minimize}
+ onMinimize={focus.minimize}
- onShow={windows.show}
+ onShow={windows.show}
- onFill={windows.fill}
+ onFill={windows.fill}
- onClose={focus.close}
+ onClose={focus.close}
- />
- })}
+ />
+ })}
- </OverflowRow>
-
- </Taskbar>
+ </OverflowRow>
const wallpaper = hasWallpaperClient
? renderWindows("wallpaper")
: <WallpaperBackground file={desktopWallpaper} onReady={fileWallpaperLoaded} />
- return <div ref={desktop} tabIndex={-1} aria-label="Desktop" onFocusCapture={focus.remember} className="relative isolate grid min-h-0 grid-cols-1 grid-rows-1 outline-none" style={{ color: foreground }}>
+ const shell = hasShellClient
+ ? renderWindows("shell")
+ : <DefaultShell spacing={appearance.spacing} taskbar={appearance.taskbar}>{taskbarItems}</DefaultShell>
+
+ return <div ref={desktop} tabIndex={-1} aria-label="Desktop" onFocusCapture={focus.remember} className="relative isolate h-full min-h-0 w-full overflow-hidden outline-none" style={{ color: foreground }}>
<ProgramAccessProbe door={application.doors.program} setAccess={setProgramAccess} />
- <DesktopDisplay
+ <DesktopLayers
wallpaper={wallpaper}
@@ -276,11 +275,16 @@ export default function Workspace() {
windowSurfaceRef={windowSurfaceRef}
- taskbar={taskbar}
+ spacing={appearance.spacing}
- />
+ taskbar={appearance.taskbar}
- {!wallpaperReady && <Loading />}
+ shell={<>
+ {shell}
+ {!wallpaperReady && <Loading />}
+ </>}
+
+ />
{wallpaperReady && <ReadyWallpaper />}
diff --git a/source/client/view/structure/desktop/geometry.ts b/source/client/view/structure/desktop/geometry.ts
deleted file mode 100644
index 199735d..0000000
--- a/source/client/view/structure/desktop/geometry.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { type CSSProperties } from "react"
-
-/**
- * The gap between adjacent painted windows, in pixels. Each window uses
- * half inside its own box; the ordinary workspace uses the other half
- * at its boundary. The gutter remains private desktop layout state and never
- * enters the layer-independent Desktop viewport snapshot.
- *
- * The visible window edge, taskbar edge and Start Menu geometry derive from
- * this value rather than restating its pixel or rem equivalent.
- */
-export const desktopGutter = 10
-
-/** Paint inset for an ordinary window edge that touches no workspace boundary. */
-export const windowPaintInset = desktopGutter / 2
-
-/** The display core uses the same spacing between itself and its tracks. */
-export const desktopDisplayStyle = {
-
- "--desktop-gutter": `${desktopGutter}px`
-
-} as CSSProperties
diff --git a/source/client/view/structure/desktop/layers/desktop-layers.tsx b/source/client/view/structure/desktop/layers/desktop-layers.tsx
new file mode 100644
index 0000000..8f91606
--- /dev/null
+++ b/source/client/view/structure/desktop/layers/desktop-layers.tsx
@@ -0,0 +1,91 @@
+import { type CSSProperties, type ReactNode, type Ref } from "react"
+import { type AppearanceTaskbar } from "@phreshos/core"
+
+/**
+ * Five coextensive Desktop layers ordered from back to front. No layer owns
+ * layout space for another; each receives the complete Desktop bounds.
+ */
+export default function DesktopLayers({ wallpaper, underWindows, windows, sharedResizeBoundaries, overWindows, shell, windowSurfaceRef, spacing, taskbar }: DesktopLayersProps) {
+
+ return <div
+ data-desktop-layers=""
+ className="absolute inset-0 isolate overflow-hidden"
+ style={{ "--desktop-gutter": `${spacing}px` } as CSSProperties}
+ >
+
+ <div data-desktop-layer="wallpaper" className="absolute inset-0 z-0 overflow-hidden">
+
+ {wallpaper}
+
+ </div>
+
+ <div data-desktop-layer="under" className="pointer-events-none absolute inset-0 z-1 overflow-hidden">
+
+ {underWindows}
+
+ </div>
+
+ <div data-desktop-layer="window" className="pointer-events-none absolute inset-0 z-2 overflow-hidden">
+
+ {/* This surface defines standard-window geometry, not a paint
+ boundary. Windows may leave it and are clipped only by the
+ complete Desktop layer. */}
+ <div ref={windowSurfaceRef} data-window-surface="" className="absolute" style={windowSurfaceInsets(spacing, taskbar)}>
+
+ {windows}
+
+ {sharedResizeBoundaries}
+
+ </div>
+
+ </div>
+
+ <div data-desktop-layer="over" className="pointer-events-none absolute inset-0 z-3 overflow-hidden">
+
+ {overWindows}
+
+ </div>
+
+ <div data-desktop-layer="shell" className="pointer-events-none absolute inset-0 z-4 overflow-hidden">
+
+ {shell}
+
+ </div>
+
+ </div>
+}
+
+interface DesktopLayersProps {
+
+ wallpaper: ReactNode
+
+ underWindows: ReactNode
+
+ windows: ReactNode
+
+ sharedResizeBoundaries: ReactNode
+
+ overWindows: ReactNode
+
+ windowSurfaceRef: Ref<HTMLDivElement>
+
+ spacing: number
+
+ taskbar: AppearanceTaskbar
+
+ shell: ReactNode
+}
+
+/** Keeps one Appearance gap outside the Taskbar and another before windows. */
+export function windowSurfaceInsets(spacing: number, taskbar: AppearanceTaskbar): CSSProperties {
+ const inset = {
+ top: spacing,
+ right: spacing,
+ bottom: spacing,
+ left: spacing
+ }
+
+ inset[taskbar.position] += taskbar.size + spacing
+
+ return inset
+}
diff --git a/source/client/view/structure/desktop/layers/shell/default-shell.tsx b/source/client/view/structure/desktop/layers/shell/default-shell.tsx
new file mode 100644
index 0000000..a2ec024
--- /dev/null
+++ b/source/client/view/structure/desktop/layers/shell/default-shell.tsx
@@ -0,0 +1,39 @@
+import { type AppearanceTaskbar } from "@phreshos/core"
+import { type ReactNode } from "react"
+import SystemDialogs from "./dialogs/system-dialogs"
+import StartMenu, { StartMenuButton, StartMenuProvider } from "./start-menu/start-menu"
+import SignOut from "./taskbar/sign-out"
+import Taskbar from "./taskbar/taskbar"
+
+/** Built-in Shell entities composed as siblings in the complete Shell layer. */
+export default function DefaultShell({ spacing, taskbar, children }: Readonly<{
+ spacing: number
+ taskbar: AppearanceTaskbar
+ children: ReactNode
+}>) {
+
+ const horizontal = taskbar.position === "top" || taskbar.position === "bottom"
+
+ return <>
+
+ <StartMenuProvider spacing={spacing} taskbar={taskbar}>
+
+ <Taskbar
+ leading={<StartMenuButton showLabel={horizontal} />}
+ trailing={<SignOut showLabel={horizontal} />}
+ spacing={spacing}
+ taskbar={taskbar}
+ >
+
+ {children}
+
+ </Taskbar>
+
+ <StartMenu />
+
+ </StartMenuProvider>
+
+ <SystemDialogs />
+
+ </>
+}
diff --git a/source/client/view/structure/desktop/taskbar/system/system-dialogs.tsx b/source/client/view/structure/desktop/layers/shell/dialogs/system-dialogs.tsx
similarity index 77%
rename from source/client/view/structure/desktop/taskbar/system/system-dialogs.tsx
rename to source/client/view/structure/desktop/layers/shell/dialogs/system-dialogs.tsx
index 398eb80..220dfe9 100644
--- a/source/client/view/structure/desktop/taskbar/system/system-dialogs.tsx
+++ b/source/client/view/structure/desktop/layers/shell/dialogs/system-dialogs.tsx
@@ -1,17 +1,16 @@
import { type PermissionChoice, type PermissionDialog, type ServerCrashDialog } from "@server/core/dialog-manager"
import { ReactTunnel } from "@the-link/react"
-import { surfacePresencePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"
+import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"
import { useReducedMotion } from "@libs/react-motion"
import { motion } from "motion/react"
import { useEffect, useId, useRef } from "react"
import { AuthManagerContext } from "@client/view/contexts"
-import TaskbarSurface, { taskbarSurfaceClassName } from "../taskbar-surface"
-import TaskbarButton from "../taskbar-button"
+import ShellSurface, { shellSurfaceClassName } from "../shell-surface"
import usePromise from "@libs/react-promise"
import Alert from "@client/view/components/alert"
-import { useAppearance } from "@phreshos/react-ui"
+import { Button, useAppearance } from "@phreshos/react-ui"
-/** Taskbar-owned presentation of the system's authoritative dialog queue. */
+/** Centered Shell presentation of the system's authoritative dialog queue. */
export default function SystemDialogs() {
const authManager = AuthManagerContext.useValue()
@@ -64,19 +63,19 @@ export default function SystemDialogs() {
aria-describedby={description}
- initial={reducedMotion ? surfacePresencePose.entered : surfacePresencePose.entering}
+ initial={reducedMotion ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden}
- animate={surfacePresencePose.entered}
+ animate={surfaceLifecyclePose.visible}
transition={surfacePresenceTransition(reducedMotion, transaction)}
onCancel={event => event.preventDefault()}
- className={`${taskbarSurfaceClassName} inset-auto inset-be-[calc(anchor(top)+var(--desktop-gutter))] inset-s-[anchor(center)] w-[min(28rem,calc(100vw-var(--desktop-gutter)*2))] -translate-x-1/2 backdrop:bg-transparent [position-anchor:--desktop-taskbar]`}
+ className={`${shellSurfaceClassName} pointer-events-auto fixed inset-0 m-auto h-fit w-[min(28rem,calc(100vw-var(--desktop-gutter)*2))] backdrop:bg-transparent`}
>
- <TaskbarSurface material="full" label={dialog.kind === "permission" ? "Permission request" : "System error"} labelId={title}>
+ <ShellSurface material="full" label={dialog.kind === "permission" ? "Permission request" : "System error"} labelId={title}>
{dialog.kind === "permission"
@@ -84,7 +83,7 @@ export default function SystemDialogs() {
: <CrashReport key={dialog.identity} dialog={dialog} description={description} acknowledge={() => dialogManager.acknowledge(dialog.identity)} />}
- </TaskbarSurface>
+ </ShellSurface>
</motion.dialog>
}
@@ -109,11 +108,11 @@ function PermissionRequest({ dialog, description, decide }: PermissionRequestPro
<div className="col-span-full flex flex-wrap justify-end gap-2">
- <TaskbarButton small disabled={decision.isPending} onPress={() => decision.safeExecute(false)}>Deny</TaskbarButton>
+ <Button size="xsmall" disabled={decision.isPending} onPress={() => decision.safeExecute(false)}>Deny</Button>
- <TaskbarButton small autoFocus disabled={decision.isPending} onPress={() => decision.safeExecute(null)}>Later</TaskbarButton>
+ <Button size="xsmall" autoFocus disabled={decision.isPending} onPress={() => decision.safeExecute(null)}>Later</Button>
- <TaskbarButton small disabled={decision.isPending} onPress={() => decision.safeExecute(true)}>Allow for this Program</TaskbarButton>
+ <Button size="xsmall" disabled={decision.isPending} onPress={() => decision.safeExecute(true)}>Allow for this Program</Button>
</div>
@@ -138,9 +137,9 @@ function CrashReport({ dialog, description, acknowledge }: CrashReportProps) {
</div>
- <TaskbarButton
+ <Button
- small
+ size="xsmall"
autoFocus
@@ -154,7 +153,7 @@ function CrashReport({ dialog, description, acknowledge }: CrashReportProps) {
I understand
- </TaskbarButton>
+ </Button>
{acknowledgment.exception && <Alert className="col-span-full text-sm">{String(acknowledgment.exception.current)}</Alert>}
diff --git a/source/client/view/structure/desktop/taskbar/taskbar-surface.tsx b/source/client/view/structure/desktop/layers/shell/shell-surface.tsx
similarity index 55%
rename from source/client/view/structure/desktop/taskbar/taskbar-surface.tsx
rename to source/client/view/structure/desktop/layers/shell/shell-surface.tsx
index 91de0a9..7fc9650 100644
--- a/source/client/view/structure/desktop/taskbar/taskbar-surface.tsx
+++ b/source/client/view/structure/desktop/layers/shell/shell-surface.tsx
@@ -1,10 +1,10 @@
import { forwardRef, ReactNode } from "react"
import { Panel, type PanelProps } from "@phreshos/react-ui"
-/** The window-material shell shared by surfaces opened from the taskbar. */
-export const taskbarSurfaceClassName = "m-0 isolate overflow-visible border-0 bg-transparent p-0 outline-none"
+/** Reset shared by independent surfaces presented in the Shell layer. */
+export const shellSurfaceClassName = "isolate overflow-visible border-0 bg-transparent p-0 outline-none"
-export default forwardRef<HTMLDivElement, TaskbarSurfaceProps>(function TaskbarSurface({ label, labelId, contentClassName = "", className, children, ...props }, ref) {
+export default forwardRef<HTMLDivElement, ShellSurfaceProps>(function ShellSurface({ label, labelId, contentClassName = "", className, children, ...props }, ref) {
return <Panel {...props} ref={ref} className={className}>
<Panel.Header><h2 id={labelId} className="relative grid h-10 items-center px-3.5 text-window-title font-medium select-none">{label}</h2></Panel.Header>
@@ -12,7 +12,7 @@ export default forwardRef<HTMLDivElement, TaskbarSurfaceProps>(function TaskbarS
</Panel>
})
-interface TaskbarSurfaceProps extends Omit<PanelProps, "children"> {
+interface ShellSurfaceProps extends Omit<PanelProps, "children"> {
label: string
diff --git a/source/client/view/structure/desktop/taskbar/launcher/processes/process-item.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/processes/process-item.tsx
similarity index 96%
rename from source/client/view/structure/desktop/taskbar/launcher/processes/process-item.tsx
rename to source/client/view/structure/desktop/layers/shell/start-menu/processes/process-item.tsx
index 3ec53e3..e65cd7c 100644
--- a/source/client/view/structure/desktop/taskbar/launcher/processes/process-item.tsx
+++ b/source/client/view/structure/desktop/layers/shell/start-menu/processes/process-item.tsx
@@ -3,7 +3,7 @@ import type Process from "@client/core/link-manager/auth-manager/process-manager
import usePromise from "@libs/react-promise"
import type Program from "@client/core/link-manager/auth-manager/program-manager/program"
import { ApplicationContext } from "@client/view/contexts"
-import programIcon from "../../../programs/program-icon"
+import programIcon from "@client/view/structure/desktop/programs/program-icon"
/** The exit action requests authority; the live list owns removal. */
export default function ProcessItem({ process, program }: Readonly<{ process: Process, program: Program | undefined }>) {
diff --git a/source/client/view/structure/desktop/taskbar/launcher/processes/processes.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/processes/processes.tsx
similarity index 100%
rename from source/client/view/structure/desktop/taskbar/launcher/processes/processes.tsx
rename to source/client/view/structure/desktop/layers/shell/start-menu/processes/processes.tsx
diff --git a/source/client/view/structure/desktop/taskbar/launcher/programs/launcher-item.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/programs/launcher-item.tsx
similarity index 100%
rename from source/client/view/structure/desktop/taskbar/launcher/programs/launcher-item.tsx
rename to source/client/view/structure/desktop/layers/shell/start-menu/programs/launcher-item.tsx
diff --git a/source/client/view/structure/desktop/taskbar/launcher/programs/programs.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/programs/programs.tsx
similarity index 93%
rename from source/client/view/structure/desktop/taskbar/launcher/programs/programs.tsx
rename to source/client/view/structure/desktop/layers/shell/start-menu/programs/programs.tsx
index 177a67e..04fefeb 100644
--- a/source/client/view/structure/desktop/taskbar/launcher/programs/programs.tsx
+++ b/source/client/view/structure/desktop/layers/shell/start-menu/programs/programs.tsx
@@ -1,6 +1,6 @@
import LauncherItem from "./launcher-item"
-import programIcon from "../../../programs/program-icon"
-import usePrograms from "../../../programs/programs"
+import programIcon from "@client/view/structure/desktop/programs/program-icon"
+import usePrograms from "@client/view/structure/desktop/programs/programs"
import { ApplicationContext } from "@client/view/contexts"
import Program from "@client/core/link-manager/auth-manager/program-manager/program"
import usePromise from "@libs/react-promise"
diff --git a/source/client/view/structure/desktop/taskbar/launcher/search-bar.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/search-bar.tsx
similarity index 100%
rename from source/client/view/structure/desktop/taskbar/launcher/search-bar.tsx
rename to source/client/view/structure/desktop/layers/shell/start-menu/search-bar.tsx
diff --git a/source/client/view/structure/desktop/taskbar/launcher/search.ts b/source/client/view/structure/desktop/layers/shell/start-menu/search.ts
similarity index 100%
rename from source/client/view/structure/desktop/taskbar/launcher/search.ts
rename to source/client/view/structure/desktop/layers/shell/start-menu/search.ts
diff --git a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu-panel.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu-panel.tsx
new file mode 100644
index 0000000..244ad63
--- /dev/null
+++ b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu-panel.tsx
@@ -0,0 +1,36 @@
+import { type ReactNode } from "react"
+import { Surface } from "@phreshos/react-ui"
+import SystemHeader from "@client/view/components/system-header"
+
+/** The built-in Start Menu content shown by the default Shell. */
+export default function StartMenuPanel({ labelId, name, version, left, right, footer }: Readonly<{
+ labelId: string
+ name: string
+ version: string
+ left: ReactNode
+ right: ReactNode
+ footer: ReactNode
+}>) {
+
+ const spacing = 8
+
+ return <Surface material="full" style={{ display: "grid", gridTemplateRows: "auto minmax(0, 1fr)", minHeight: 0, height: "100%", maxHeight: "inherit", overflow: "hidden" }}>
+
+ <SystemHeader labelId={labelId} name={name} version={version} />
+
+ <div className="grid min-h-0 min-w-0" style={{ gridTemplateRows: "minmax(0, 1fr) auto", gap: spacing, padding: spacing, paddingTop: 0 }}>
+
+ <div className="grid min-h-0 min-w-0 grid-cols-2" style={{ gap: "inherit" }}>
+
+ <Surface material="extended" className="min-h-0 min-w-0 overflow-hidden">{left}</Surface>
+
+ <Surface material="extended" className="min-h-0 min-w-0 overflow-hidden">{right}</Surface>
+
+ </div>
+
+ {footer}
+
+ </div>
+
+ </Surface>
+}
diff --git a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx
new file mode 100644
index 0000000..c4e58f8
--- /dev/null
+++ b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx
@@ -0,0 +1,216 @@
+import logo from "@/assets/bundled/logo.png"
+import { createContext, memo, useCallback, useContext, useEffect, useId, useRef, useState, type CSSProperties, type PropsWithChildren, type RefObject } from "react"
+import Programs from "./programs/programs"
+import Processes from "./processes/processes"
+import StartMenuPanel from "./start-menu-panel"
+import { ApplicationContext } from "@client/view/contexts"
+import SearchBar from "./search-bar"
+import { searchTerms } from "./search"
+import { type AppearanceTaskbar } from "@phreshos/core"
+import { useReducedMotion } from "@libs/react-motion"
+import { motion } from "motion/react"
+import { shellSurfaceClassName } from "../shell-surface"
+import TaskbarButton from "../taskbar/taskbar-button"
+import { useAppearance } from "@phreshos/react-ui"
+import { cssEasing } from "@client/view/appearance/motion"
+import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"
+
+const StartMenuContext = createContext<StartMenuControl | null>(null)
+
+/** Shared behavior only; the Taskbar trigger and Shell surface remain siblings. */
+export function StartMenuProvider({ taskbar, spacing, children }: PropsWithChildren<{
+ taskbar: AppearanceTaskbar
+ spacing: number
+}>) {
+
+ const id = useId()
+
+ const surface = useRef<HTMLDivElement>(null)
+
+ const [open, setOpen] = useState(false)
+
+ const openAtPressStart = useRef(false)
+
+ const close = useCallback(function () {
+
+ const element = surface.current
+
+ if (element?.matches(":popover-open")) element.hidePopover()
+
+ }, [])
+
+ const beginToggle = useCallback(function () {
+
+ openAtPressStart.current = surface.current?.matches(":popover-open") ?? false
+
+ }, [])
+
+ const toggle = useCallback(function () {
+
+ const element = surface.current
+
+ if (!element) return
+
+ if (openAtPressStart.current) {
+
+ if (element.matches(":popover-open")) element.hidePopover()
+
+ return
+ }
+
+ if (!element.matches(":popover-open")) element.showPopover()
+
+ }, [])
+
+ useEffect(function () {
+
+ // Program frames are separate documents, so focus crossing the iframe
+ // boundary is the signal that replaces native popover light dismissal.
+ function closeForProgramFrame() {
+
+ if (document.activeElement instanceof HTMLIFrameElement && !surface.current?.contains(document.activeElement)) close()
+ }
+
+ window.addEventListener("blur", closeForProgramFrame)
+
+ return () => window.removeEventListener("blur", closeForProgramFrame)
+
+ }, [close])
+
+ return <StartMenuContext.Provider value={{ id, surface, taskbar, spacing, open, setOpen, close, beginToggle, toggle }}>
+
+ {children}
+
+ </StartMenuContext.Provider>
+}
+
+/** The Start Menu's Taskbar-owned anchor and toggle. */
+export const StartMenuButton = memo(function StartMenuButton({ showLabel = true }: Readonly<{ showLabel?: boolean }>) {
+
+ const application = ApplicationContext.useValue()
+
+ const control = useStartMenuControl()
+
+ return <TaskbarButton
+ icon={<img src={logo} alt="" draggable={false} className="block size-full object-contain" />}
+ label={application.displayName}
+ showLabel={showLabel}
+ color="primary:base"
+ aria-controls={control.id}
+ aria-expanded={control.open}
+ aria-haspopup="dialog"
+ aria-label={application.displayName}
+ onPressStart={control.beginToggle}
+ onPress={control.toggle}
+ />
+})
+
+/** Independent Start Menu surface in the default Shell. */
+export default memo(function StartMenu() {
+
+ const application = ApplicationContext.useValue()
+
+ const control = useStartMenuControl()
+
+ const reducedMotion = useReducedMotion()
+
+ const transaction = useAppearance().transaction
+
+ const [query, setQuery] = useState("")
+
+ const terms = searchTerms(query)
+
+ return <motion.div
+ ref={control.surface}
+ id={control.id}
+ role="dialog"
+ popover="auto"
+ aria-labelledby={`${control.id}-label`}
+ tabIndex={-1}
+ className={`${shellSurfaceClassName} pointer-events-auto fixed hidden open:block`}
+ style={{
+ ...startMenuStyle(control.taskbar, control.spacing),
+ transitionBehavior: "allow-discrete",
+ transitionDuration: reducedMotion ? "0ms" : String(transaction.duration) + "ms",
+ transitionTimingFunction: cssEasing(transaction.easing),
+ transitionProperty: "display, overlay"
+ }}
+ initial={false}
+ animate={control.open ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden}
+ transition={surfacePresenceTransition(reducedMotion, transaction)}
+ onBeforeToggle={event => control.setOpen(event.newState === "open")}
+ onToggle={event => {
+
+ if (event.newState !== "open") return
+
+ const focusTarget = event.currentTarget.querySelector<HTMLElement>("button:not(:disabled),a[href]") ?? event.currentTarget
+
+ focusTarget.focus()
+ }}
+ >
+
+ <StartMenuPanel
+ labelId={`${control.id}-label`}
+ name={application.displayName}
+ version={application.version}
+ left={<Programs onChoose={control.close} terms={terms} />}
+ right={<Processes terms={terms} />}
+ footer={<SearchBar query={query} onChange={setQuery} />}
+ />
+
+ </motion.div>
+})
+
+/**
+ * The menu occupies the leading corner beside the Taskbar: one spacing from
+ * its perpendicular screen edge and two spacings beyond the Taskbar edge.
+ */
+export function startMenuStyle(taskbar: AppearanceTaskbar, spacing: number): CSSProperties {
+ const horizontal = taskbar.position === "top" || taskbar.position === "bottom"
+ const taskbarInset = taskbar.size + spacing * 2
+ const style = {
+ position: "fixed",
+ // Taskbar positions name physical screen edges. Keep every inset in
+ // that same coordinate system: logical starts conflict with top/left
+ // and can silently replace their offsets with `auto`.
+ top: "auto",
+ right: "auto",
+ bottom: "auto",
+ left: "auto",
+ width: horizontal
+ ? `min(44rem, calc(100vw - ${spacing * 2}px))`
+ : `min(44rem, calc(100vw - ${taskbarInset + spacing}px))`,
+ height: horizontal
+ ? `min(32rem, calc(100vh - ${taskbarInset + spacing}px))`
+ : `min(32rem, calc(100vh - ${spacing * 2}px))`
+ } satisfies CSSProperties
+
+ if (taskbar.position === "bottom") return { ...style, left: spacing, bottom: taskbarInset }
+
+ if (taskbar.position === "top") return { ...style, left: spacing, top: taskbarInset }
+
+ if (taskbar.position === "left") return { ...style, left: taskbarInset, top: spacing }
+
+ return { ...style, right: taskbarInset, top: spacing }
+}
+
+function useStartMenuControl() {
+
+ const value = useContext(StartMenuContext)
+
+ if (!value) throw new Error("Start Menu parts require StartMenuProvider")
+
+ return value
+}
+
+interface StartMenuControl {
+ id: string
+ surface: RefObject<HTMLDivElement | null>
+ taskbar: AppearanceTaskbar
+ spacing: number
+ open: boolean
+ setOpen: (open: boolean) => void
+ close: () => void
+ beginToggle: () => void
+ toggle: () => void
+}
diff --git a/source/client/view/structure/desktop/taskbar/programs/overflow-row.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/programs/overflow-row.tsx
similarity index 58%
rename from source/client/view/structure/desktop/taskbar/programs/overflow-row.tsx
rename to source/client/view/structure/desktop/layers/shell/taskbar/programs/overflow-row.tsx
index 1a0ccf8..769e928 100644
--- a/source/client/view/structure/desktop/taskbar/programs/overflow-row.tsx
+++ b/source/client/view/structure/desktop/layers/shell/taskbar/programs/overflow-row.tsx
@@ -2,8 +2,8 @@ import { ComponentProps, useId, useLayoutEffect, useRef, useState } from "react"
import { useReducedMotion } from "@libs/react-motion"
import { Button } from "@phreshos/react-ui"
-/** A horizontal row that reveals its own overflow without owning its items. */
-export default function OverflowRow({ children, backwardLabel = "Scroll backward", forwardLabel = "Scroll forward", className, ...props }: OverflowRowProps) {
+/** A Taskbar-axis list that reveals its own overflow without owning its items. */
+export default function OverflowRow({ children, orientation = "horizontal", backwardLabel = "Scroll backward", forwardLabel = "Scroll forward", className, ...props }: OverflowRowProps) {
const reducedMotion = useReducedMotion()
@@ -29,16 +29,20 @@ export default function OverflowRow({ children, backwardLabel = "Scroll backward
function measure() {
- const end = Math.max(0, view!.scrollWidth - view!.clientWidth)
+ const horizontal = orientation === "horizontal"
- const offset = getComputedStyle(view!).direction === "rtl" ? -view!.scrollLeft : view!.scrollLeft
+ const end = Math.max(0, horizontal ? view!.scrollWidth - view!.clientWidth : view!.scrollHeight - view!.clientHeight)
+
+ const offset = horizontal
+ ? getComputedStyle(view!).direction === "rtl" ? -view!.scrollLeft : view!.scrollLeft
+ : view!.scrollTop
const next = {
// Compare natural content with the whole row, not the
// viewport after controls take their places. That avoids
// controls keeping themselves alive after content shrinks.
- overflowing: row!.scrollWidth > box!.clientWidth + 1,
+ overflowing: horizontal ? row!.scrollWidth > box!.clientWidth + 1 : row!.scrollHeight > box!.clientHeight + 1,
start: offset <= 1,
@@ -67,7 +71,7 @@ export default function OverflowRow({ children, backwardLabel = "Scroll backward
view.removeEventListener("scroll", measure)
}
- }, [])
+ }, [orientation])
function scroll(direction: -1 | 1) {
@@ -75,18 +79,27 @@ export default function OverflowRow({ children, backwardLabel = "Scroll backward
if (!view) return
+ if (orientation === "vertical") {
+
+ view.scrollBy({ top: direction * view.clientHeight * 0.8, behavior: reducedMotion ? "auto" : "smooth" })
+
+ return
+ }
+
const inlineDirection = getComputedStyle(view).direction === "rtl" ? -1 : 1
view.scrollBy({ left: inlineDirection * direction * view.clientWidth * 0.8, behavior: reducedMotion ? "auto" : "smooth" })
}
- return <div ref={container} role="group" className={`flex min-w-0 items-center gap-1 ${className ?? ""}`} {...props}>
+ const vertical = orientation === "vertical"
+
+ return <div ref={container} role="group" className={`flex min-h-0 min-w-0 items-center gap-1 ${vertical ? "flex-col" : ""} ${className ?? ""}`} {...props}>
- {edges.overflowing && <ScrollButton label={backwardLabel} controls={viewportId} direction="backward" disabled={edges.start} onClick={() => scroll(-1)} />}
+ {edges.overflowing && <ScrollButton label={backwardLabel} controls={viewportId} direction="backward" orientation={orientation} disabled={edges.start} onClick={() => scroll(-1)} />}
- <div id={viewportId} ref={viewport} className="-m-2 min-w-0 flex-1 overflow-x-auto p-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
+ <div id={viewportId} ref={viewport} className={`-m-2 min-h-0 min-w-0 flex-1 p-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden ${vertical ? "overflow-y-auto" : "overflow-x-auto"}`}>
- <div ref={content} className="flex w-max min-w-full items-center gap-1.5">
+ <div ref={content} className={`flex items-center gap-1.5 ${vertical ? "h-max min-h-full flex-col" : "w-max min-w-full"}`}>
{children}
@@ -94,12 +107,12 @@ export default function OverflowRow({ children, backwardLabel = "Scroll backward
</div>
- {edges.overflowing && <ScrollButton label={forwardLabel} controls={viewportId} direction="forward" disabled={edges.end} onClick={() => scroll(1)} />}
+ {edges.overflowing && <ScrollButton label={forwardLabel} controls={viewportId} direction="forward" orientation={orientation} disabled={edges.end} onClick={() => scroll(1)} />}
</div>
}
-function ScrollButton({ label, controls, direction, disabled, onClick }: ScrollButtonProps) {
+function ScrollButton({ label, controls, direction, orientation, disabled, onClick }: ScrollButtonProps) {
return <Button
aria-label={label}
@@ -108,11 +121,11 @@ function ScrollButton({ label, controls, direction, disabled, onClick }: ScrollB
onPress={onClick}
size="xsmall"
className="shrink-0"
- style={{ inlineSize: 28, paddingInline: 0 }}
+ style={{ inlineSize: 28, blockSize: 28, paddingInline: 0 }}
>
- <svg aria-hidden="true" viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" className="size-3 rtl:-scale-x-100">
+ <svg aria-hidden="true" viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" className={`size-3 ${orientation === "vertical" ? "rotate-90" : "rtl:-scale-x-100"}`}>
<path d={direction === "backward" ? "m7.5 2.5-3.5 3.5 3.5 3.5" : "m4.5 2.5 3.5 3.5-3.5 3.5"} />
@@ -123,6 +136,8 @@ function ScrollButton({ label, controls, direction, disabled, onClick }: ScrollB
interface OverflowRowProps extends ComponentProps<"div"> {
+ orientation?: "horizontal" | "vertical"
+
backwardLabel?: string
forwardLabel?: string
@@ -136,6 +151,8 @@ interface ScrollButtonProps {
direction: "backward" | "forward"
+ orientation: "horizontal" | "vertical"
+
disabled: boolean
onClick: () => void
diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/programs/taskbar-item.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/programs/taskbar-item.tsx
new file mode 100644
index 0000000..4c4fbce
--- /dev/null
+++ b/source/client/view/structure/desktop/layers/shell/taskbar/programs/taskbar-item.tsx
@@ -0,0 +1,51 @@
+import { Button, type ButtonProps } from "@phreshos/react-ui"
+import { type TaskbarPosition } from "@phreshos/core"
+import { forwardRef, type ReactNode } from "react"
+
+/**
+ * A pressable item with a raised state. What "raised" means is the caller's.
+ */
+export default forwardRef<HTMLButtonElement, TaskbarItemProps>(function TaskbarItem({ active = false, icon, position, children, className, ...props }, ref) {
+
+ const horizontal = position === "top" || position === "bottom"
+
+ const indicator = taskbarIndicatorClassName(position)
+
+ return <Button
+
+ ref={ref}
+ aria-pressed={active}
+ size="small"
+ className={`relative overflow-hidden ${horizontal ? "max-w-40 scroll-mx-8" : "w-full scroll-my-8 px-0"} ${className ?? ""}`}
+ {...props}
+
+ >
+
+ <img src={icon} alt="" draggable={false} className="size-4 shrink-0 rounded-sm object-contain" />
+
+ <span className={horizontal ? "truncate" : "sr-only"}>{children}</span>
+
+ {active && <span aria-hidden="true" className={`absolute ${indicator} rounded-full bg-sky-500 shadow-taskbar-indicator`} />}
+
+ </Button>
+})
+
+/** The active mark stays on the same screen edge as its Taskbar. */
+export function taskbarIndicatorClassName(position: TaskbarPosition) {
+ if (position === "top") return "inset-x-3 top-0 h-0.5"
+ if (position === "bottom") return "inset-x-3 bottom-0 h-0.5"
+ if (position === "left") return "inset-y-3 left-0 w-0.5"
+ return "inset-y-3 right-0 w-0.5"
+}
+
+export interface TaskbarItemProps extends Omit<ButtonProps, "children"> {
+
+ active?: boolean
+
+ // Every system entry has either its Program icon or the system default.
+ icon: string
+
+ position: TaskbarPosition
+
+ children?: ReactNode
+}
diff --git a/source/client/view/structure/desktop/taskbar/programs/window-taskbar-item.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsx
similarity index 85%
rename from source/client/view/structure/desktop/taskbar/programs/window-taskbar-item.tsx
rename to source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsx
index 57289f9..7d75f3f 100644
--- a/source/client/view/structure/desktop/taskbar/programs/window-taskbar-item.tsx
+++ b/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsx
@@ -1,11 +1,12 @@
import Process from "@client/core/link-manager/auth-manager/process-manager/process"
+import { type TaskbarPosition } from "@phreshos/core"
import { ContextMenu, Menu } from "@phreshos/react-ui"
-import { useDesktopScaleContainer } from "../../desktop-scale"
+import { useDesktopScaleContainer } from "../../../../desktop-scale"
import TaskbarItem from "./taskbar-item"
import { memo, useCallback } from "react"
/** A taskbar entry rerenders only when what that entry shows changes. */
-export default memo(function ({ record, title, icon, active, minimized, maximized, onElement, onMinimize, onShow, onFill, onClose }: WindowTaskbarItemProps) {
+export default memo(function ({ record, title, icon, position, active, minimized, maximized, onElement, onMinimize, onShow, onFill, onClose }: WindowTaskbarItemProps) {
const scaleContainer = useDesktopScaleContainer()
@@ -32,7 +33,7 @@ export default memo(function ({ record, title, icon, active, minimized, maximize
<ContextMenu.Trigger>
- <TaskbarItem ref={source} active={active} icon={icon} onPress={press}>
+ <TaskbarItem ref={source} active={active} icon={icon} position={position} onPress={press}>
{title}
@@ -67,6 +68,8 @@ interface WindowTaskbarItemProps {
icon: string
+ position: TaskbarPosition
+
active: boolean
minimized: boolean
diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/sign-out.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/sign-out.tsx
new file mode 100644
index 0000000..bbf67d7
--- /dev/null
+++ b/source/client/view/structure/desktop/layers/shell/taskbar/sign-out.tsx
@@ -0,0 +1,41 @@
+import { AuthManagerContext } from "@client/view/contexts"
+import usePromise from "@libs/react-promise"
+import { type ComponentProps, memo } from "react"
+import TaskbarButton from "./taskbar-button"
+
+export default memo(function ({ showLabel = true, ...props }: SignOutProps) {
+
+ const authManager = AuthManagerContext.useValue()
+
+ const signOut = usePromise(() => authManager.signOut())
+
+ return <TaskbarButton
+
+ icon={<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" className="block size-full">
+
+ <path d="M7 2.5H3.5v11H7" />
+
+ <path d="M6 8h6.5m-2.25-2.25L12.5 8l-2.25 2.25" />
+
+ </svg>}
+
+ label="Sign out"
+
+ showLabel={showLabel}
+
+ color="danger:base"
+
+ aria-label="Sign out"
+
+ disabled={signOut.isPending}
+
+ onPress={signOut.safeExecute}
+
+ {...props}
+
+ />
+})
+
+interface SignOutProps extends Omit<ComponentProps<typeof TaskbarButton>, "icon" | "label" | "showLabel"> {
+ showLabel?: boolean
+}
diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/taskbar-button.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/taskbar-button.tsx
new file mode 100644
index 0000000..ba66629
--- /dev/null
+++ b/source/client/view/structure/desktop/layers/shell/taskbar/taskbar-button.tsx
@@ -0,0 +1,23 @@
+import { Button, type ButtonProps } from "@phreshos/react-ui"
+import { type ReactNode } from "react"
+
+/** One visual contract for the Taskbar's fixed system controls. */
+export default function TaskbarButton({ icon, label, showLabel = true, ...props }: TaskbarButtonProps) {
+
+ return <Button type="button" size="small" {...props}>
+
+ <span aria-hidden="true" className="size-4 shrink-0">{icon}</span>
+
+ <span className={showLabel ? "hidden text-taskbar-label font-medium sm:inline" : "sr-only"}>{label}</span>
+
+ </Button>
+}
+
+interface TaskbarButtonProps extends Omit<ButtonProps, "children"> {
+
+ icon: ReactNode
+
+ label: string
+
+ showLabel?: boolean
+}
diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx
new file mode 100644
index 0000000..1716ee3
--- /dev/null
+++ b/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx
@@ -0,0 +1,71 @@
+import { type CSSProperties, type ReactNode } from "react"
+import { Surface, Toolbar, type SurfaceProps } from "@phreshos/react-ui"
+import { type AppearanceTaskbar } from "@phreshos/core"
+
+/**
+ * The Desktop's Taskbar is a Shell entity; React UI's Toolbar supplies the
+ * control-group semantics and orientation-aware keyboard navigation.
+ */
+export default function Taskbar({ leading, trailing, taskbar, spacing, className, style, children, "aria-label": label = "Taskbar", ...props }: TaskbarProps) {
+
+ const horizontal = taskbar.position === "top" || taskbar.position === "bottom"
+ const orientation = horizontal ? "horizontal" : "vertical"
+
+ return <Surface
+
+ as={Toolbar}
+ aria-label={label}
+ orientation={orientation}
+ gap="small"
+ data-orientation={orientation}
+ className={`pointer-events-auto isolate min-h-0 min-w-0 overflow-hidden p-1.5 ${className ?? ""}`}
+ style={{ ...taskbarStyle(taskbar, spacing), alignItems: "center", ...style }}
+
+ {...props}
+
+ material="full"
+
+ >
+
+ <Toolbar.Group style={{ flexShrink: 0 }}>{leading}</Toolbar.Group>
+
+ <Toolbar.Separator className="shadow-taskbar-separator" />
+
+ <Toolbar.Group style={{ flex: "1 1 0", alignSelf: "stretch", minWidth: 0, minHeight: 0, overflow: "hidden" }}>
+
+ {children}
+
+ </Toolbar.Group>
+
+ <Toolbar.Separator className="shadow-taskbar-separator" />
+
+ <Toolbar.Group style={{ flexShrink: 0 }}>{trailing}</Toolbar.Group>
+
+ </Surface>
+}
+
+interface TaskbarProps extends Omit<SurfaceProps<typeof Toolbar>, "as" | "children" | "orientation"> {
+
+ children: ReactNode
+
+ leading: ReactNode
+
+ trailing: ReactNode
+
+ taskbar: AppearanceTaskbar
+
+ spacing: number
+}
+
+/** Taskbar size is its cross-axis extent; spacing remains its outer margin. */
+export function taskbarStyle(taskbar: AppearanceTaskbar, spacing: number): CSSProperties {
+ const horizontal = taskbar.position === "top" || taskbar.position === "bottom"
+
+ return {
+ position: "absolute",
+ [taskbar.position]: spacing,
+ ...(horizontal
+ ? { left: spacing, right: spacing, width: "auto", height: taskbar.size }
+ : { top: spacing, bottom: spacing, width: taskbar.size, height: "auto" })
+ }
+}
diff --git a/source/client/view/structure/desktop/wallpaper/wallpaper.tsx b/source/client/view/structure/desktop/layers/wallpaper/wallpaper.tsx
similarity index 100%
rename from source/client/view/structure/desktop/wallpaper/wallpaper.tsx
rename to source/client/view/structure/desktop/layers/wallpaper/wallpaper.tsx
diff --git a/source/client/view/structure/desktop/taskbar/launcher/launcher.tsx b/source/client/view/structure/desktop/taskbar/launcher/launcher.tsx
deleted file mode 100644
index 25a279d..0000000
--- a/source/client/view/structure/desktop/taskbar/launcher/launcher.tsx
+++ /dev/null
@@ -1,165 +0,0 @@
-import { type ComponentPropsWithoutRef, ReactNode, useCallback, useEffect, useId, useRef, useState } from "react"
-import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"
-import { cssEasing } from "@client/view/appearance/motion"
-import { useReducedMotion } from "@libs/react-motion"
-import { motion } from "motion/react"
-import { taskbarSurfaceClassName } from "../taskbar-surface"
-import TaskbarButton from "../taskbar-button"
-import { useAppearance } from "@phreshos/react-ui"
-
-/**
- * A button and the dismissible surface it opens. Placement, contents and
- * what selecting an item means belong to the caller.
- */
-export default function ({ label, trigger, children, className, style, ...props }: LauncherProps) {
-
- const id = useId()
-
- const surface = useRef<HTMLDivElement>(null)
-
- const reducedMotion = useReducedMotion()
- const transaction = useAppearance().transaction
-
- const [open, setOpen] = useState(false)
-
- const openAtPressStart = useRef(false)
-
- const close = useCallback(function () {
-
- const element = surface.current
-
- if (element?.matches(":popover-open")) element.hidePopover()
-
- }, [])
-
- const beginToggle = useCallback(function () {
-
- openAtPressStart.current = surface.current?.matches(":popover-open") ?? false
-
- }, [])
-
- const toggle = useCallback(function () {
-
- const element = surface.current
-
- if (!element) return
-
- if (openAtPressStart.current) {
-
- if (element.matches(":popover-open")) element.hidePopover()
-
- return
- }
-
- if (!element.matches(":popover-open")) element.showPopover()
-
- }, [])
-
- useEffect(function () {
-
- // A Program frame is a separate document, so its pointer events cannot
- // participate in this document's native popover light dismissal. The
- // browser does expose the focus crossing at the browsing-context wall:
- // the iframe becomes this document's active element.
- function closeForProgramFrame() {
-
- if (document.activeElement instanceof HTMLIFrameElement && !surface.current?.contains(document.activeElement)) close()
- }
-
- window.addEventListener("blur", closeForProgramFrame)
-
- return () => window.removeEventListener("blur", closeForProgramFrame)
-
- }, [close])
-
- return <>
-
- <TaskbarButton
-
- type="button"
-
- aria-controls={id}
-
- aria-expanded={open}
-
- aria-haspopup="dialog"
-
- aria-label={label}
-
- onPressStart={beginToggle}
-
- onPress={toggle}
-
- >
-
- {trigger}
-
- </TaskbarButton>
-
- <motion.div
-
- {...props}
-
- ref={surface}
-
- id={id}
-
- role="dialog"
-
- popover="auto"
-
- aria-labelledby={`${id}-label`}
-
- tabIndex={-1}
-
- style={{
- ...style,
- transitionBehavior: "allow-discrete",
- transitionDuration: reducedMotion ? "0ms" : String(transaction.duration) + "ms",
- transitionTimingFunction: cssEasing(transaction.easing),
- transitionProperty: "display, overlay"
- }}
-
- className={`${taskbarSurfaceClassName} hidden open:block ${className ?? ""}`}
-
- initial={false}
-
- animate={open ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden}
-
- transition={surfacePresenceTransition(reducedMotion, transaction)}
-
- onBeforeToggle={event => {
-
- setOpen(event.newState === "open")
- }}
-
- onToggle={event => {
-
- const opening = event.newState === "open"
-
- if (opening) {
-
- const focusTarget = event.currentTarget.querySelector<HTMLElement>("button:not(:disabled),a[href]") ?? event.currentTarget
-
- focusTarget.focus()
- }
-
- }}
-
- >
-
- {children(close, `${id}-label`)}
-
- </motion.div>
-
- </>
-}
-
-export interface LauncherProps extends Omit<ComponentPropsWithoutRef<"div">, "children" | "id" | "onAnimationStart" | "onBeforeToggle" | "onDrag" | "onDragEnd" | "onDragStart" | "onToggle" | "popover"> {
-
- label: string
-
- trigger: ReactNode
-
- children: (close: () => void, labelId: string) => ReactNode
-}
diff --git a/source/client/view/structure/desktop/taskbar/launcher/start-menu-panel.tsx b/source/client/view/structure/desktop/taskbar/launcher/start-menu-panel.tsx
deleted file mode 100644
index 553294b..0000000
--- a/source/client/view/structure/desktop/taskbar/launcher/start-menu-panel.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import { type ReactNode } from "react"
-import { Surface } from "@phreshos/react-ui"
-import SystemHeader from "../../../../components/system-header"
-
-/** One persistent Start Menu Surface whose contents may be supplied by a Client Endpoint. */
-export default function StartMenuPanel({ labelId, name, version, left, right, footer, replacement }: Readonly<{
- labelId: string
- name: string
- version: string
- left: ReactNode
- right: ReactNode
- footer: ReactNode
- replacement?: ReactNode
-}>) {
-
- const spacing = 8
-
- return <Surface material="full" style={{ display: "grid", gridTemplateRows: "auto minmax(0, 1fr)", minHeight: 0, height: "100%", maxHeight: "inherit", overflow: "hidden" }}>
-
- {replacement ? <>
-
- <h2 id={labelId} className="sr-only">{name}</h2>
-
- {replacement}
-
- </> : <>
-
- <SystemHeader labelId={labelId} name={name} version={version} />
-
- <div className="grid min-h-0 min-w-0" style={{ gridTemplateRows: "minmax(0, 1fr) auto", gap: spacing, padding: spacing, paddingTop: 0 }}>
-
- <div className="grid min-h-0 min-w-0 grid-cols-2" style={{ gap: "inherit" }}>
-
- <Surface material="extended" className="min-h-0 min-w-0 overflow-hidden">{left}</Surface>
-
- <Surface material="extended" className="min-h-0 min-w-0 overflow-hidden">{right}</Surface>
-
- </div>
-
- {footer}
-
- </div>
-
- </>}
-
- </Surface>
-}
diff --git a/source/client/view/structure/desktop/taskbar/launcher/start-menu.tsx b/source/client/view/structure/desktop/taskbar/launcher/start-menu.tsx
deleted file mode 100644
index abc3063..0000000
--- a/source/client/view/structure/desktop/taskbar/launcher/start-menu.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import logo from "@/assets/bundled/logo.png"
-import { memo, useState, type ReactNode } from "react"
-import Launcher from "./launcher"
-import Programs from "./programs/programs"
-import Processes from "./processes/processes"
-import StartMenuPanel from "./start-menu-panel"
-import { ApplicationContext } from "@client/view/contexts"
-import SearchBar from "./search-bar"
-import { searchTerms } from "./search"
-
-/** The taskbar entry point for current and future desktop actions. */
-export default memo(function StartMenu({ replacement }: Readonly<{ replacement?: ReactNode }>) {
-
- const application = ApplicationContext.useValue()
-
- const [query, setQuery] = useState("")
-
- const terms = searchTerms(query)
-
- return <Launcher
-
- label={application.displayName}
-
- trigger={<>
-
- <img src={logo} alt="" className="size-5 shrink-0" />
-
- <span className="hidden text-xs font-semibold sm:inline">{application.displayName}</span>
-
- </>}
-
- className="inset-auto inset-be-[calc(anchor(top)+var(--desktop-gutter))] inset-s-[anchor(start)] h-[min(32rem,calc(100vh-var(--spacing-taskbar)-var(--desktop-gutter)*3))] w-[min(44rem,calc(100vw-var(--desktop-gutter)*2))] [position-anchor:--desktop-taskbar]"
-
- >
-
- {(close, labelId) => <StartMenuPanel
- labelId={labelId}
- name={application.displayName}
- version={application.version}
- left={<Programs onChoose={close} terms={terms} />}
- right={<Processes terms={terms} />}
- footer={<SearchBar query={query} onChange={setQuery} />}
- replacement={replacement}
- />}
-
- </Launcher>
-})
diff --git a/source/client/view/structure/desktop/taskbar/programs/taskbar-item.tsx b/source/client/view/structure/desktop/taskbar/programs/taskbar-item.tsx
deleted file mode 100644
index 2b23aa3..0000000
--- a/source/client/view/structure/desktop/taskbar/programs/taskbar-item.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import { Button, type ButtonProps } from "@phreshos/react-ui"
-import { forwardRef, type ReactNode } from "react"
-
-/**
- * A pressable item with a raised state. What "raised" means is the caller's.
- */
-export default forwardRef<HTMLButtonElement, TaskbarItemProps>(function TaskbarItem({ active = false, icon, children, className, ...props }, ref) {
-
- return <Button
-
- ref={ref}
- aria-pressed={active}
- size="small"
- className={`relative max-w-40 scroll-mx-8 overflow-hidden ${className ?? ""}`}
- {...props}
-
- >
-
- <img src={icon} alt="" draggable={false} className="size-4 shrink-0 rounded-sm object-contain" />
-
- <span className="truncate">{children}</span>
-
- {active && <span aria-hidden="true" className="absolute inset-x-3 bottom-0 h-0.5 rounded-full bg-sky-500 shadow-taskbar-indicator" />}
-
- </Button>
-})
-
-export interface TaskbarItemProps extends Omit<ButtonProps, "children"> {
-
- active?: boolean
-
- // Every system entry has either its Program icon or the system default.
- icon: string
-
- children?: ReactNode
-}
diff --git a/source/client/view/structure/desktop/taskbar/system/sign-out.tsx b/source/client/view/structure/desktop/taskbar/system/sign-out.tsx
deleted file mode 100644
index 102f2d1..0000000
--- a/source/client/view/structure/desktop/taskbar/system/sign-out.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { AuthManagerContext } from "@client/view/contexts"
-import usePromise from "@libs/react-promise"
-import { ComponentProps, memo } from "react"
-import TaskbarButton from "../taskbar-button"
-
-export default memo(function (props: ComponentProps<typeof TaskbarButton>) {
-
- const authManager = AuthManagerContext.useValue()
-
- const signOut = usePromise(() => authManager.signOut())
-
- return <TaskbarButton
-
- aria-label="Sign out"
-
- disabled={signOut.isPending}
-
- onPress={signOut.safeExecute}
-
- {...props}
-
- >
-
- <span className="hidden text-taskbar-label font-medium sm:inline">Sign out</span>
-
- </TaskbarButton>
-})
diff --git a/source/client/view/structure/desktop/taskbar/taskbar-button.tsx b/source/client/view/structure/desktop/taskbar/taskbar-button.tsx
deleted file mode 100644
index 4b8fd3b..0000000
--- a/source/client/view/structure/desktop/taskbar/taskbar-button.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Button, type ButtonProps } from "@phreshos/react-ui"
-
-/** A compact taskbar control whose contents define its meaning. */
-export default function TaskbarButton({ small = false, ...props }: TaskbarButtonProps) {
-
- return <Button size={small ? "xsmall" : "small"} {...props} />
-}
-
-interface TaskbarButtonProps extends ButtonProps {
-
- small?: boolean
-}
diff --git a/source/client/view/structure/desktop/taskbar/taskbar-separator.tsx b/source/client/view/structure/desktop/taskbar/taskbar-separator.tsx
deleted file mode 100644
index 202ef0d..0000000
--- a/source/client/view/structure/desktop/taskbar/taskbar-separator.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-/** A structural break between groups of taskbar controls. */
-export default function TaskbarSeparator() {
-
- return <div aria-hidden="true" className="h-6 w-px bg-white/35 shadow-taskbar-separator" />
-}
diff --git a/source/client/view/structure/desktop/taskbar/taskbar.tsx b/source/client/view/structure/desktop/taskbar/taskbar.tsx
deleted file mode 100644
index ef40469..0000000
--- a/source/client/view/structure/desktop/taskbar/taskbar.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { ReactNode } from "react"
-import { Surface, type SurfaceProps } from "@phreshos/react-ui"
-import TaskbarSeparator from "./taskbar-separator"
-
-/**
- * The desktop's persistent control surface. Leading, primary and trailing
- * regions are structural; what each region means belongs to the caller.
- */
-export default function Taskbar({ leading, trailing, dialogs, className, children, ...props }: TaskbarProps) {
-
- return <Surface
-
- className={`relative isolate grid h-taskbar min-w-0 grid-cols-[auto_auto_minmax(0,1fr)_auto_auto] items-center gap-1.5 p-1.5 [anchor-name:--desktop-taskbar] ${className ?? ""}`}
-
- {...props}
-
- material="full"
-
- >
-
- {leading}
-
- <TaskbarSeparator />
-
- {children}
-
- <TaskbarSeparator />
-
- {trailing}
-
- {dialogs}
-
- </Surface>
-}
-
-interface TaskbarProps extends SurfaceProps {
-
- leading: ReactNode
-
- trailing: ReactNode
-
- dialogs?: ReactNode
-}
diff --git a/source/client/view/structure/desktop/windows/process-window.tsx b/source/client/view/structure/desktop/windows/process-window.tsx
index 504118a..5eef4e1 100644
--- a/source/client/view/structure/desktop/windows/process-window.tsx
+++ b/source/client/view/structure/desktop/windows/process-window.tsx
@@ -3,7 +3,7 @@ import ClientState from "@client/core/link-manager/auth-manager/process-manager/
import { type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"
import { type PresentationAnimation } from "@client/view/components/desktop-host/window-presentation"
import { type PresentationGeometryRepresentation } from "@client/view/components/window-manager/window-presentations"
-import { type Position, type Size, type Theme, type WindowFrame, type WindowLayer, type WindowTransaction } from "@phreshos/core"
+import { type Position, type Size, type Theme, type WindowSurface, type WindowLayer, type WindowTransaction } from "@phreshos/core"
import Spinner from "@client/view/components/spinner"
import Window from "./window"
import ProgramFrame, { programFrameSource } from "@client/view/components/program-frame"
@@ -17,7 +17,7 @@ const settleDelay = 80
* props so memoization can see which process actually changed even though
* the peer deliberately keeps each Process instance alive and mutates it.
*/
-export default memo(function ({ identity, record, assetId, client, title, header, frame, layer, transaction, icon, position, size, frameAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, paintSurfaceSize, depth, active, minimized, maximized, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {
+export default memo(function ({ identity, record, assetId, client, title, header, surface, layer, transaction, icon, position, size, surfaceAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, paintSurfaceSize, spacing, depth, active, minimized, maximized, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {
const activate = useCallback(() => onRaise(record), [onRaise, record])
@@ -86,9 +86,9 @@ export default memo(function ({ identity, record, assetId, client, title, header
const frameLoading = programAccess === "available" && (loading.source !== frameSource || loading.phase !== "ready")
- const framed = layer === "window" || (layer === "under" || layer === "over") && frame !== false
+ const surfaced = surface !== false && layer !== "wallpaper"
- const progress = framed && (stopping || closing ? "Closing" : frameLoading ? "Loading" : null)
+ const progress = surfaced && (stopping || closing ? "Closing" : frameLoading ? "Loading" : null)
return <Window
@@ -96,7 +96,7 @@ export default memo(function ({ identity, record, assetId, client, title, header
header={header}
- frame={frame}
+ surface={surface}
layer={layer}
@@ -108,7 +108,7 @@ export default memo(function ({ identity, record, assetId, client, title, header
size={size}
- frameAnimation={frameAnimation}
+ surfaceAnimation={surfaceAnimation}
geometryAnimation={geometryAnimation}
@@ -120,6 +120,8 @@ export default memo(function ({ identity, record, assetId, client, title, header
paintSurfaceSize={paintSurfaceSize}
+ spacing={spacing}
+
active={active}
minimized={minimized}
@@ -216,7 +218,7 @@ interface ProcessWindowProps {
header: boolean
- frame: WindowFrame
+ surface: WindowSurface
layer: WindowLayer
@@ -228,18 +230,20 @@ interface ProcessWindowProps {
size: Size
- frameAnimation: PresentationAnimation | null
+ surfaceAnimation: PresentationAnimation | null
geometryAnimation: PresentationAnimation | null
minimizeAnimation: PresentationAnimation | null
- onPresentationAnimationComplete: (kind: "geometry" | "minimize" | "frame", revision: number) => void
+ onPresentationAnimationComplete: (kind: "geometry" | "minimize" | "surface", revision: number) => void
onPresentationRepresentation: (identity: string, representation: PresentationGeometryRepresentation | null) => void
paintSurfaceSize?: WindowSurfaceSize
+ spacing: number
+
depth: number
active: boolean
diff --git a/source/client/view/structure/desktop/windows/snap-preview.tsx b/source/client/view/structure/desktop/windows/snap-preview.tsx
index bf71d1b..a49ebc2 100644
--- a/source/client/view/structure/desktop/windows/snap-preview.tsx
+++ b/source/client/view/structure/desktop/windows/snap-preview.tsx
@@ -1,14 +1,13 @@
import { type CSSProperties } from "react"
import { motion } from "motion/react"
import { windowPaintInsets, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"
-import { windowPaintInset } from "../geometry"
import { type Position, type Size } from "@phreshos/core"
import { Surface, useAppearance } from "@phreshos/react-ui"
import { motionTransition } from "@client/view/appearance/motion"
import useWindowGeometryMotion from "./window-geometry-motion"
/** Preview of the placement currently offered by a drag. */
-export default function SnapPreview({ shown, visible, bare, minimumSize, paintSurfaceSize, reducedMotion, zIndex }: SnapPreviewProps) {
+export default function SnapPreview({ shown, visible, bare, minimumSize, paintSurfaceSize, paintInset, reducedMotion, zIndex }: SnapPreviewProps) {
const transaction = useAppearance().transaction
@@ -37,7 +36,7 @@ export default function SnapPreview({ shown, visible, bare, minimumSize, paintSu
material={{ opacity: "small" }}
style={{
position: "absolute",
- ...(bare ? { inset: 0 } : windowPaintInsets(shown.position, shown.size, paintSurfaceSize, windowPaintInset))
+ ...(bare ? { inset: 0 } : windowPaintInsets(shown.position, shown.size, paintSurfaceSize, paintInset))
}}
/>
</motion.div>
@@ -55,6 +54,7 @@ interface SnapPreviewProps {
bare: boolean
minimumSize?: WindowSurfaceSize
paintSurfaceSize: WindowSurfaceSize
+ paintInset: number
reducedMotion: boolean
zIndex: CSSProperties["zIndex"]
}
diff --git a/source/client/view/structure/desktop/windows/window-geometry-motion.ts b/source/client/view/structure/desktop/windows/window-geometry-motion.ts
index 78e8155..f96fa7b 100644
--- a/source/client/view/structure/desktop/windows/window-geometry-motion.ts
+++ b/source/client/view/structure/desktop/windows/window-geometry-motion.ts
@@ -56,24 +56,6 @@ export default function useWindowGeometryMotion({ position, size, animation, tra
animator.current!.stop()
}
- function listen(changed: () => void) {
- let active = true
- let queued = false
- const notify = () => {
- if (queued) return
- queued = true
- queueMicrotask(() => {
- queued = false
- if (active) changed()
- })
- }
- const cleanup = [x, y, width, height].map(value => value.on("change", notify))
- return () => {
- active = false
- for (const release of cleanup) release()
- }
- }
-
function completeGestureRestore() {
if (!restoringGesture.current) return
@@ -259,7 +241,6 @@ export default function useWindowGeometryMotion({ position, size, animation, tra
style: { x, y, width: layoutWidth, height: layoutHeight, scaleX, scaleY, transformOrigin } satisfies MotionStyle,
read,
present,
- listen,
beginGesture,
updateGesture,
restoreGesture,
diff --git a/source/client/view/structure/desktop/windows/window-panel.tsx b/source/client/view/structure/desktop/windows/window-panel.tsx
index bdec840..512b4d7 100644
--- a/source/client/view/structure/desktop/windows/window-panel.tsx
+++ b/source/client/view/structure/desktop/windows/window-panel.tsx
@@ -1,15 +1,13 @@
-import { forwardRef, type ReactNode } from "react"
-import { Surface, type SurfaceProps } from "@phreshos/react-ui"
+import { forwardRef, type ComponentProps, type ReactNode } from "react"
-/** Temporary standard-window test: header and unpadded content, without an inner Surface. */
-const WindowPanel = forwardRef<HTMLDivElement, SurfaceProps & { header: ReactNode }>(function WindowPanel(
+/** Structural header-and-content layout painted by its sibling Window surface. */
+const WindowPanel = forwardRef<HTMLDivElement, ComponentProps<"div"> & { header: ReactNode }>(function WindowPanel(
{ header, children, style, ...properties },
ref
) {
- return <Surface
+ return <div
{...properties}
ref={ref}
- material="full"
style={{
display: "grid",
gridTemplateRows: header == null ? "minmax(0, 1fr)" : "auto minmax(0, 1fr)",
@@ -23,7 +21,7 @@ const WindowPanel = forwardRef<HTMLDivElement, SurfaceProps & { header: ReactNod
<div data-window-content style={{ position: "relative", minWidth: 0, minHeight: 0, overflow: "hidden" }}>
{children}
</div>
- </Surface>
+ </div>
})
export default WindowPanel
diff --git a/source/client/view/structure/desktop/windows/window-frame.tsx b/source/client/view/structure/desktop/windows/window-surface.tsx
similarity index 53%
rename from source/client/view/structure/desktop/windows/window-frame.tsx
rename to source/client/view/structure/desktop/windows/window-surface.tsx
index beeb1da..508f154 100644
--- a/source/client/view/structure/desktop/windows/window-frame.tsx
+++ b/source/client/view/structure/desktop/windows/window-surface.tsx
@@ -1,27 +1,28 @@
import { useReducedMotion } from "@libs/react-motion"
-import { Surface, type Color, type MaterialOptions } from "@phreshos/react-ui"
+import { resolveRadius, Surface, type Appearance, type Color, type MaterialOptions } from "@phreshos/react-ui"
import { useLayoutEffect, useRef, useState } from "react"
import { motion } from "motion/react"
import { type PresentationAnimation } from "@client/view/components/desktop-host/window-presentation"
-import { type AppearanceColor, type WindowFrame as WindowFrameDefinition } from "@phreshos/core"
+import { type AppearanceColor, type WindowSurface as WindowSurfaceDefinition } from "@phreshos/core"
import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"
import { resolveWindowTransaction } from "@client/view/appearance/motion"
import { useAppearance } from "@phreshos/react-ui"
-/** Paints the optional Desktop-owned frame around an under or over presentation. */
-export default function WindowFrame({ frame, animation, onComplete }: WindowFrameProps) {
+/** Paints the optional Desktop-owned backing surface for a supported presentation. */
+export default function WindowSurface({ surface, animation, onComplete }: WindowSurfaceProps) {
const reducedMotion = useReducedMotion()
- const appearanceTransaction = useAppearance().transaction
+ const appearance = useAppearance()
+ const appearanceTransaction = appearance.transaction
const revision = animation?.revision
const transaction = animation ? resolveWindowTransaction(animation.transaction, appearanceTransaction) : null
- const visible = frame !== false
+ const visible = surface !== false
const animated = revision !== undefined && transaction !== null
const [hidden, setHidden] = useState(!visible)
const completed = useRef<number | null>(null)
- const retained = useRef<Exclude<WindowFrameDefinition, false>>(true)
+ const retained = useRef<Exclude<WindowSurfaceDefinition, false>>(true)
- if (frame !== false) retained.current = frame
+ if (surface !== false) retained.current = surface
useLayoutEffect(function () {
@@ -42,7 +43,7 @@ export default function WindowFrame({ frame, animation, onComplete }: WindowFram
onComplete(revision)
}
- if (frame === false && !animation) return null
+ if (surface === false && !animation) return null
return <motion.div
initial={animated && visible && !reducedMotion ? surfaceLifecyclePose.hidden : surfaceLifecyclePose.visible}
@@ -56,39 +57,47 @@ export default function WindowFrame({ frame, animation, onComplete }: WindowFram
>
<Surface
aria-hidden="true"
- color={frameColor(retained.current)}
- material={frameMaterial(retained.current)}
- radius={typeof retained.current === "object" ? retained.current.radius : undefined}
+ color={surfaceColor(retained.current)}
+ material={surfaceMaterial(retained.current)}
+ radius={windowSurfaceRadius(retained.current, appearance)}
style={{ position: "absolute", inset: 0 }}
/>
</motion.div>
}
-interface WindowFrameProps {
+interface WindowSurfaceProps {
- frame: WindowFrameDefinition
+ surface: WindowSurfaceDefinition
animation: PresentationAnimation | null
onComplete: (revision: number) => void
}
-function frameColor(frame: Exclude<WindowFrameDefinition, false>): Color | undefined {
+function surfaceColor(surface: Exclude<WindowSurfaceDefinition, false>): Color | undefined {
- if (frame === true || frame.color === undefined) return undefined
+ if (surface === true || surface.color === undefined) return undefined
- return appearanceColors.includes(frame.color as AppearanceColor)
- ? `${frame.color as AppearanceColor}:base`
- : frame.color
+ return appearanceColors.includes(surface.color as AppearanceColor)
+ ? `${surface.color as AppearanceColor}:base`
+ : surface.color
}
-function frameMaterial(frame: Exclude<WindowFrameDefinition, false>): "none" | "full" | MaterialOptions {
+function surfaceMaterial(surface: Exclude<WindowSurfaceDefinition, false>): "none" | "full" | MaterialOptions {
- if (frame === true || frame.material === undefined) return "full"
+ if (surface === true || surface.material === undefined) return "full"
- if (frame.material === false) return "none"
+ if (surface.material === false) return "none"
- return frame.material
+ return surface.material
}
const appearanceColors = ["background", "foreground", "default", "primary", "secondary", "success", "warning", "danger", "info"] as const satisfies readonly AppearanceColor[]
+
+/** Resolves the one boundary shared by Desktop paint and standard-window content. */
+export function windowSurfaceRadius(surface: Exclude<WindowSurfaceDefinition, false>, appearance: Appearance) {
+
+ const radius = typeof surface === "object" ? surface.radius : undefined
+
+ return resolveRadius(radius ?? "medium", appearance)
+}
diff --git a/source/client/view/structure/desktop/windows/window.tsx b/source/client/view/structure/desktop/windows/window.tsx
index 193cf49..6acf965 100644
--- a/source/client/view/structure/desktop/windows/window.tsx
+++ b/source/client/view/structure/desktop/windows/window.tsx
@@ -3,16 +3,15 @@ import { useReducedMotion } from "@libs/react-motion"
import { surfaceLifecyclePose, surfacePresencePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"
import WindowPanel from "./window-panel"
import { absoluteWindowGeometry, constrainWindowGeometry, minimumWindowSize, resolveWindowGeometry, windowPaintInsets, type WindowRegion, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"
-import { type Position, type Size, type WindowFrame as WindowFrameDefinition, type WindowLayer, type WindowTransaction } from "@phreshos/core"
+import { type Position, type Size, type WindowSurface as WindowSurfaceDefinition, type WindowLayer, type WindowTransaction } from "@phreshos/core"
import WindowHeader from "./window-header"
-import WindowFrame from "./window-frame"
+import WindowSurface, { windowSurfaceRadius } from "./window-surface"
import { type PresentationAnimation } from "@client/view/components/desktop-host/window-presentation"
import { type PresentationGeometryRepresentation } from "@client/view/components/window-manager/window-presentations"
import { motion } from "motion/react"
import { motionTransition, resolveWindowTransaction } from "@client/view/appearance/motion"
import { useAppearance } from "@phreshos/react-ui"
import SnapPreview, { type SnapTarget } from "./snap-preview"
-import { windowPaintInset } from "../geometry"
import useWindowGeometryMotion from "./window-geometry-motion"
import { physicalToDesktopPixels, useDesktopScale } from "../desktop-scale"
@@ -50,12 +49,15 @@ const edges: { edge: WindowEdge, className: string }[] = [
const minimizedSurfacePose = { scale: 0.86, y: 28, opacity: 0 }
-export default function ({ title, header = true, frame: frameDefinition = false, layer, icon, children, onClose, onClosed, onMinimize, onMaximize, onActivate, onUnavailable, onMove, onResize, onSnap, onPresentationAnimationComplete, onPresentationRepresentation, onFocusCapture, active = false, closing = false, stopping = false, minimized = false, maximized = false, entering = false, transaction = false, position = { x: 0, y: 0 }, size = { width: 520, height: 340 }, frameAnimation, geometryAnimation, minimizeAnimation, paintSurfaceSize = { width: 0, height: 0 }, minWidth = minimumWindowSize.width, minHeight = minimumWindowSize.height, className, style, ...props }: WindowProps) {
+export default function ({ title, header = true, surface, layer, icon, children, onClose, onClosed, onMinimize, onMaximize, onActivate, onUnavailable, onMove, onResize, onSnap, onPresentationAnimationComplete, onPresentationRepresentation, onFocusCapture, active = false, closing = false, stopping = false, minimized = false, maximized = false, entering = false, transaction = false, position = { x: 0, y: 0 }, size = { width: 520, height: 340 }, surfaceAnimation, geometryAnimation, minimizeAnimation, paintSurfaceSize = { width: 0, height: 0 }, spacing = 0, minWidth = minimumWindowSize.width, minHeight = minimumWindowSize.height, className, style, ...props }: WindowProps) {
const reducedMotion = useReducedMotion()
- const appearanceTransaction = useAppearance().transaction
+ const appearance = useAppearance()
+ const appearanceTransaction = appearance.transaction
const desktopScale = useDesktopScale()
const standard = layer === "window"
+ const surfaceDefinition = surface ?? standard
+ const surfaceRadius = surfaceDefinition === false ? undefined : windowSurfaceRadius(surfaceDefinition, appearance)
const presentationMinimum = standard ? { width: minWidth, height: minHeight } : undefined
function resolvePresentedGeometry(selectedPosition: Position, selectedSize: Size, surface: WindowSurfaceSize) {
@@ -93,8 +95,7 @@ export default function ({ title, header = true, frame: frameDefinition = false,
present: geometryMotion.present,
begin: () => geometryMotion.beginGesture()?.region ?? null,
finish: geometryMotion.finishGesture,
- cancel: geometryMotion.cancelGesture,
- listen: geometryMotion.listen
+ cancel: geometryMotion.cancelGesture
}
onPresentationRepresentation(representation)
@@ -438,7 +439,11 @@ export default function ({ title, header = true, frame: frameDefinition = false,
// ------------------------------------------------------------ render
- const paintedInsets = windowPaintInsets(presented.current.position, presented.current.size, paintSurfaceSize, windowPaintInset, gesture?.current)
+ // Shared geometry remains contiguous. Each neighboring Window contributes
+ // half of Appearance spacing so the painted gap equals the layer inset.
+ const paintInset = standard ? spacing / 2 : 0
+
+ const paintedInsets = windowPaintInsets(presented.current.position, presented.current.size, paintSurfaceSize, paintInset, gesture?.current)
return <>
@@ -449,6 +454,7 @@ export default function ({ title, header = true, frame: frameDefinition = false,
bare={!standard}
minimumSize={presentationMinimum}
paintSurfaceSize={paintSurfaceSize}
+ paintInset={paintInset}
reducedMotion={reducedMotion}
zIndex={style?.zIndex}
/>}
@@ -482,13 +488,12 @@ export default function ({ title, header = true, frame: frameDefinition = false,
>
- {/* The painted frame, inset inside the box. The box is where
+ {/* The painted surface, inset inside the box. The box is where
the window *is*; this is what a person sees of it, and the
difference between them is the gap.
- Bare, there is no difference: the frame fills the box, so
- the window is exactly as large as it asked to be and its
- boundaries are the ones its own content draws. */}
+ Without a Desktop surface, Program content fills the box and
+ owns its visible boundary. */}
{!standard ? <motion.div
data-window-container
initial={initialPresence}
@@ -499,10 +504,10 @@ export default function ({ title, header = true, frame: frameDefinition = false,
style={{ visibility: minimized && presenceHidden ? "hidden" : "visible" }}
>
- {(layer === "under" || layer === "over") && <WindowFrame
- frame={frameDefinition}
- animation={frameAnimation ?? null}
- onComplete={revision => onPresentationAnimationComplete?.("frame", revision)}
+ {(layer === "under" || layer === "over" || layer === "shell") && <WindowSurface
+ surface={surfaceDefinition}
+ animation={surfaceAnimation ?? null}
+ onComplete={revision => onPresentationAnimationComplete?.("surface", revision)}
/>}
<div data-window-content className="relative min-h-0">{children}</div>
@@ -515,8 +520,16 @@ export default function ({ title, header = true, frame: frameDefinition = false,
onAnimationComplete={completePresence}
style={{ position: "absolute", visibility: minimized && presenceHidden ? "hidden" : "visible", ...paintedInsets }}
>
+ <WindowSurface
+ surface={surfaceDefinition}
+ animation={surfaceAnimation ?? null}
+ onComplete={revision => onPresentationAnimationComplete?.("surface", revision)}
+ />
+
<WindowPanel
- style={{ position: "absolute", inset: 0 }}
+ // Surface paint and Program content are siblings. The content
+ // must independently clip to the same Desktop-owned boundary.
+ style={{ position: "absolute", inset: 0, borderRadius: surfaceRadius }}
header={header ? <WindowHeader
title={title}
@@ -567,8 +580,8 @@ interface WindowProps extends Omit<ComponentProps<"div">, "onAnimationStart" | "
/** Whether the Desktop-owned standard Window header is shown. */
header?: boolean
- /** Frame definition applied by under and over presentations. */
- frame?: WindowFrameDefinition
+ /** Desktop-painted Window backing surface. */
+ surface?: WindowSurfaceDefinition
/** Presentation role currently occupied by the Window. */
layer: WindowLayer
@@ -611,26 +624,29 @@ interface WindowProps extends Omit<ComponentProps<"div">, "onAnimationStart" | "
/** Whether mounting this element represents a newly opened Window. */
entering?: boolean
- /** Default transaction used by under and over presentations. */
+ /** Default transaction used by presentation operations. */
transaction?: WindowTransaction
position?: Position
size?: Size
- frameAnimation?: PresentationAnimation | null
+ surfaceAnimation?: PresentationAnimation | null
geometryAnimation?: PresentationAnimation | null
minimizeAnimation?: PresentationAnimation | null
- onPresentationAnimationComplete?: (kind: "geometry" | "minimize" | "frame", revision: number) => void
+ onPresentationAnimationComplete?: (kind: "geometry" | "minimize" | "surface", revision: number) => void
onPresentationRepresentation?: (representation: PresentationGeometryRepresentation | null) => void
/** Surface used only to decide which painted edges receive an inset. */
paintSurfaceSize?: WindowSurfaceSize
+ /** Appearance spacing shared by the layer boundary and tiled gaps. */
+ spacing?: number
+
minWidth?: number
minHeight?: number
diff --git a/source/server/core/authentication/authentication.ts b/source/server/core/authentication/authentication.ts
index d7af87e..ef76868 100644
--- a/source/server/core/authentication/authentication.ts
+++ b/source/server/core/authentication/authentication.ts
@@ -1,5 +1,6 @@
-import { readFile, writeFile } from "node:fs/promises"
-import { randomBytes, scrypt as derive, timingSafeEqual } from "node:crypto"
+import { readFile, rename, rm, writeFile } from "node:fs/promises"
+import { randomBytes, randomUUID, scrypt as derive, timingSafeEqual } from "node:crypto"
+import { parseAuthenticationCredentials, type AuthenticationRequirements } from "@phreshos/core"
import Sessions from "./sessions"
import Keyv from "keyv"
@@ -14,22 +15,22 @@ const parameters = {
keyLength: 64
} as const
-const requirements = {
+const requirements: AuthenticationRequirements = Object.freeze({
- username: {
+ username: Object.freeze({
minimumLength: 1,
maximumLength: 64
- },
+ }),
- password: {
+ password: Object.freeze({
minimumLength: 8,
maximumLength: 1_024
- }
-} as const
+ })
+})
/** Persistent credentials for the sole owner of one installation. */
export default class Authentication {
@@ -40,6 +41,8 @@ export default class Authentication {
private readonly sessions: Sessions
+ private changingCredentials: Promise<void> = Promise.resolve()
+
private constructor(path: string, owner: Owner | null, sessions: Sessions) {
this.path = path
@@ -81,37 +84,48 @@ export default class Authentication {
}
}
- public async signUp(username: string, password: string): Promise<SignUpResult> {
+ public requirements(): AuthenticationRequirements {
- if (this.owner) return { error: "signed-up" }
+ return requirements
+ }
- const normalizedUsername = normalizeUsername(username)
+ /** Replaces only the credential record; Session authority is independent. */
+ public setCredentials(value: unknown) {
- const invalid = validate(normalizedUsername, password)
+ const credentials = parseAuthenticationCredentials(value)
- if (invalid) return { error: invalid }
+ return this.changeCredentials(async () => {
- const salt = randomBytes(16)
+ const username = normalizeUsername(credentials.username)
- const hash = await hashPassword(password, salt, parameters)
+ const invalid = validate(username, credentials.password)
- const owner: Owner = {
+ if (invalid) throw new Error(`The credentials are invalid: ${invalid}`)
- version: 1,
+ const owner = await createOwner(username, credentials.password)
- username: normalizedUsername,
+ await this.replaceOwner(owner)
- password: {
+ this.owner = owner
+ })
+ }
- algorithm: "scrypt",
+ public async signUp(username: string, password: string): Promise<SignUpResult> {
- salt: salt.toString("base64"),
+ return this.changeCredentials(() => this.signUpNow(username, password))
+ }
- hash: hash.toString("base64"),
+ private async signUpNow(username: string, password: string): Promise<SignUpResult> {
- ...parameters
- }
- }
+ if (this.owner) return { error: "signed-up" }
+
+ const normalizedUsername = normalizeUsername(username)
+
+ const invalid = validate(normalizedUsername, password)
+
+ if (invalid) return { error: invalid }
+
+ const owner = await createOwner(normalizedUsername, password)
try {
@@ -134,6 +148,34 @@ export default class Authentication {
}
}
+ private changeCredentials<Result>(change: () => Promise<Result>): Promise<Result> {
+
+ const next = this.changingCredentials.then(change, change)
+
+ this.changingCredentials = next.then(() => undefined, () => undefined)
+
+ return next
+ }
+
+ private async replaceOwner(owner: Owner) {
+
+ const temporary = `${this.path}.${randomUUID()}.changing`
+
+ // Credential replacement crosses one filesystem boundary so an
+ // interrupted update cannot leave an unreadable authentication record.
+ try {
+
+ await writeFile(temporary, JSON.stringify(owner), { flag: "wx", mode: 0o600 })
+
+ await rename(temporary, this.path)
+ }
+
+ finally {
+
+ await rm(temporary, { force: true }).catch(() => undefined)
+ }
+ }
+
public async verify(username: string, password: string) {
if (!this.owner) return false
@@ -259,6 +301,31 @@ function hashPassword(password: string, salt: Buffer, parameters: ScryptParamete
})
}
+async function createOwner(username: string, password: string): Promise<Owner> {
+
+ const salt = randomBytes(16)
+
+ const hash = await hashPassword(password, salt, parameters)
+
+ return {
+
+ version: 1,
+
+ username,
+
+ password: {
+
+ algorithm: "scrypt",
+
+ salt: salt.toString("base64"),
+
+ hash: hash.toString("base64"),
+
+ ...parameters
+ }
+ }
+}
+
function parse(contents: string): Owner {
const value: unknown = JSON.parse(contents)
@@ -316,22 +383,7 @@ export interface AuthenticationState {
signedUp: boolean
- requirements: {
-
- username: {
-
- minimumLength: number
-
- maximumLength: number
- }
-
- password: {
-
- minimumLength: number
-
- maximumLength: number
- }
- }
+ requirements: AuthenticationRequirements
}
export type SignUpResult = {
diff --git a/source/server/core/link-manager/auth-manager/auth-manager.ts b/source/server/core/link-manager/auth-manager/auth-manager.ts
index 798a480..4e92767 100644
--- a/source/server/core/link-manager/auth-manager/auth-manager.ts
+++ b/source/server/core/link-manager/auth-manager/auth-manager.ts
@@ -235,7 +235,31 @@ export default class AuthManager extends TheLink {
await this.linkManager.signOutSession(session)
}
- @Subscribe("/connection/list")
+ @Subscribe("/authentication/state")
+ protected authenticationState() {
+
+ return this.linkManager.application.system.authenticationState()
+ }
+
+ @Subscribe("/authentication/requirements")
+ protected authenticationRequirements() {
+
+ return this.linkManager.application.system.authenticationRequirements()
+ }
+
+ @Subscribe("/authentication/set-credentials")
+ protected async setAuthenticationCredentials(credentials: unknown) {
+
+ await this.linkManager.application.system.setAuthenticationCredentials(credentials)
+ }
+
+ @Subscribe("/authentication/sign-out-all-sessions")
+ protected async signOutAllSessions() {
+
+ await this.linkManager.application.system.signOutAllSessions()
+ }
+
+ @Subscribe("/authentication/connections")
protected async connections() {
return this.linkManager.application.system.listConnections()
@@ -249,7 +273,7 @@ export default class AuthManager extends TheLink {
return this.linkManager.connectionSnapshot(this.linkManager.connection())
}
- @Subscribe("/connection/find")
+ @Subscribe("/authentication/connection")
protected async connectionFind(identity: unknown) {
const connection = this.linkManager.application.system.findConnection(domainIdentity(identity, "Connection"))
@@ -275,7 +299,7 @@ export default class AuthManager extends TheLink {
return this.linkManager.application.system.signInConnection(domainIdentity(identity, "Connection"))
}
- @Subscribe("/session/list")
+ @Subscribe("/authentication/sessions")
protected async sessions() {
return this.linkManager.application.system.listSessions()
@@ -283,7 +307,7 @@ export default class AuthManager extends TheLink {
.map(identity => this.linkManager.sessionSnapshot(identity))
}
- @Subscribe("/session/find")
+ @Subscribe("/authentication/session")
protected async sessionFind(identity: unknown) {
const session = this.linkManager.application.system.findSession(domainIdentity(identity, "Session"))
diff --git a/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts b/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts
index 6bebbb3..3f7a8c2 100644
--- a/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts
+++ b/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts
@@ -39,6 +39,12 @@ import type { ServerRuntime, ServerRuntimeFactory } from "@server/core/server-ru
import SystemAccess from "./system-access"
import { WebSocket } from "ws"
+type SerializedClientLayer = DesktopReplacementLayer | "shell"
+
+function isSerializedClientLayer(layer: Layer | undefined): layer is SerializedClientLayer {
+ return layer === "shell" || isDesktopReplacementLayer(layer)
+}
+
/**
* The core's processes: the wire and the collection. Each process owns
* itself — its Endpoint execution contexts and serialisation — and this manager
@@ -174,7 +180,7 @@ export default class ProcessManager extends TheLink {
return Object.freeze({
title: window.title,
header: window.header,
- frame: window.frame,
+ surface: window.surface,
transaction: window.transaction,
position: window.position,
size: window.size,
@@ -921,7 +927,7 @@ export default class ProcessManager extends TheLink {
const access = new SystemAccess(this, process)
- if (domain === "connection" || domain === "session") return access.canConnections()
+ if (domain === "connection" || domain === "session") return access.canAuthentication()
if (!subject) return false
@@ -941,18 +947,18 @@ export default class ProcessManager extends TheLink {
private window(shape: Shape) {
- const shown = { title: shape.title, header: shape.header, frame: shape.frame, transaction: shape.transaction, layer: shape.layer }
+ const shown = { title: shape.title, header: shape.header, surface: shape.surface, transaction: shape.transaction, layer: shape.layer }
return new Window(shown, shape.position, shape.size, ++this.highest, shape.minimize, shape.maximize)
}
- private readonly replacementChanges = new Map<DesktopReplacementLayer, Promise<unknown>>()
+ private readonly layerClaims = new Map<SerializedClientLayer, Promise<unknown>>()
private serializeClientLayer<Result>(layer: Layer | undefined, work: () => Promise<Result>): Promise<Result> {
- if (!isDesktopReplacementLayer(layer)) return work()
- const current = this.replacementChanges.get(layer) ?? Promise.resolve()
+ if (!isSerializedClientLayer(layer)) return work()
+ const current = this.layerClaims.get(layer) ?? Promise.resolve()
const next = current.catch(() => undefined).then(work)
- this.replacementChanges.set(layer, next.catch(() => undefined))
+ this.layerClaims.set(layer, next.catch(() => undefined))
return next
}
@@ -961,6 +967,20 @@ export default class ProcessManager extends TheLink {
for (const process of occupied) await this.exitProcess(process.identity, "complete")
}
+ private async claimShell(program: Program) {
+ // Shell ownership belongs to a Program: its sibling Processes coexist,
+ // while another Program must observe the previous owner fully stopped.
+ const displaced = [...this.processes.values()].filter(process =>
+ process.program !== program && process.client && process.clientEndpoint?.window.layer === "shell"
+ )
+ for (const process of displaced) await this.exitProcess(process.identity, "complete")
+ }
+
+ private async prepareClientLayer(layer: Layer, program: Program) {
+ if (layer === "shell") return this.claimShell(program)
+ if (isDesktopReplacementLayer(layer)) return this.replaceDesktopPresentation(layer)
+ }
+
/** Claims the role after serialized replacement has released its previous owner. */
private activateClient(process: Process, service: boolean) {
const window = process.clientEndpoint?.window
@@ -968,6 +988,9 @@ export default class ProcessManager extends TheLink {
if (isDesktopReplacementLayer(window.layer) && [...this.processes.values()].some(
current => current !== process && current.client && current.clientEndpoint?.window.layer === window.layer
)) throw new Error(`A Client Endpoint is already running in the ${window.layer} layer`)
+ if (window.layer === "shell" && [...this.processes.values()].some(
+ current => current !== process && current.program !== process.program && current.client && current.clientEndpoint?.window.layer === "shell"
+ )) throw new Error("Another Program already occupies the shell layer")
process.startClient(service)
}
@@ -990,7 +1013,7 @@ export default class ProcessManager extends TheLink {
throw new Error("This program already has a process with that name")
}
- if (client && shape && isDesktopReplacementLayer(shape.layer)) await this.replaceDesktopPresentation(shape.layer)
+ if (client && shape) await this.prepareClientLayer(shape.layer, program)
// Who had focus before this one opened, in the layer it is
// opening into. A window is born on top of its own layer and
@@ -1288,7 +1311,7 @@ export default class ProcessManager extends TheLink {
const before = this.front(window.layer)
- if (isDesktopReplacementLayer(window.layer)) await this.replaceDesktopPresentation(window.layer)
+ await this.prepareClientLayer(window.layer, process.program)
this.activateClient(process, launch.service ?? declaration.service)
@@ -1322,7 +1345,7 @@ export default class ProcessManager extends TheLink {
if (launch.header !== undefined && window.setHeader(shape.header)) this.said(process.identity, "changeHeader", window.header)
- if (launch.frame !== undefined && window.setFrame(shape.frame)) this.said(process.identity, "changeFrame", window.frame)
+ if (launch.surface !== undefined && window.setSurface(shape.surface)) this.said(process.identity, "changeSurface", window.surface)
if (launch.transaction !== undefined && window.setTransaction(shape.transaction)) this.said(process.identity, "changeTransaction", window.transaction)
@@ -1796,49 +1819,84 @@ export default class ProcessManager extends TheLink {
if (word === "host-program-list") return [this.system.listPrograms(rest[0] === true).filter(program => access.canProgram(program))]
- if (typeof word === "string" && (word.startsWith("host-connection-") || word.startsWith("host-session-"))) {
+ if (typeof word === "string" && word.startsWith("host-authentication-")) {
- if (word === "host-connection-list") {
+ if (word === "host-authentication-state") {
- if (!access.canConnections()) return [[]]
+ access.require("authentication", [])
- return [this.system.listConnections().map(connection => this.authManager.linkManager.connectionSnapshot(connection))]
+ return [this.system.authenticationState()]
}
- if (word === "host-connection-find") {
+ if (word === "host-authentication-requirements") {
- if (!access.canConnections()) return [null]
+ access.require("authentication", [])
- const connection = this.system.findConnection(String(rest[0]))
+ return [this.system.authenticationRequirements()]
+ }
- return [connection ? this.authManager.linkManager.connectionSnapshot(connection) : null]
+ if (word === "host-authentication-set-credentials") {
+
+ access.require("authentication", [])
+
+ await this.system.setAuthenticationCredentials(rest[0])
+
+ return []
}
- if (word.startsWith("host-connection-") && !access.canConnections()) throw new Error("Connection not found")
+ if (word === "host-authentication-sign-out-all-sessions") {
- if (word === "host-connection-state") return [this.system.connectionSnapshot(String(rest[0]))]
+ access.require("authentication", [])
- if (word === "host-connection-session") return [this.system.connectionSession(String(rest[0]))]
+ await this.system.signOutAllSessions()
- if (word === "host-connection-sign-in") return [await this.system.signInConnection(String(rest[0]))]
+ return []
+ }
- if (word === "host-session-list") {
+ if (word === "host-authentication-connections") {
- if (!access.canConnections()) return [[]]
+ if (!access.canAuthentication()) return [[]]
+
+ return [this.system.listConnections().map(connection => this.authManager.linkManager.connectionSnapshot(connection))]
+ }
+
+ if (word === "host-authentication-connection") {
+
+ if (!access.canAuthentication()) return [null]
+
+ const connection = this.system.findConnection(String(rest[0]))
+
+ return [connection ? this.authManager.linkManager.connectionSnapshot(connection) : null]
+ }
+
+ if (word === "host-authentication-sessions") {
+
+ if (!access.canAuthentication()) return [[]]
return [this.system.listSessions().map(identity => this.authManager.linkManager.sessionSnapshot(identity))]
}
- if (word === "host-session-find") {
+ if (word === "host-authentication-session") {
- if (!access.canConnections()) return [null]
+ if (!access.canAuthentication()) return [null]
const session = this.system.findSession(String(rest[0]))
return [session ? this.authManager.linkManager.sessionSnapshot(session) : null]
}
+ }
+
+ if (typeof word === "string" && (word.startsWith("host-connection-") || word.startsWith("host-session-"))) {
+
+ if (word.startsWith("host-connection-") && !access.canAuthentication()) throw new Error("Connection not found")
+
+ if (word === "host-connection-state") return [this.system.connectionSnapshot(String(rest[0]))]
+
+ if (word === "host-connection-session") return [this.system.connectionSession(String(rest[0]))]
+
+ if (word === "host-connection-sign-in") return [await this.system.signInConnection(String(rest[0]))]
- if (!access.canConnections()) throw new Error("Session not found")
+ if (!access.canAuthentication()) throw new Error("Session not found")
if (word === "host-session-state") return [this.system.sessionSnapshot(String(rest[0]))]
@@ -2291,11 +2349,11 @@ export default class ProcessManager extends TheLink {
return [target.identity]
}
- if (word === "setFrame") {
+ if (word === "setSurface") {
const target = heldWindow(rest[0]).process
- await this.system.setWindowFrame(target, rest[1] as never)
+ await this.system.setWindowSurface(target, rest[1] as never)
return [target.identity]
}
@@ -3212,16 +3270,16 @@ export default class ProcessManager extends TheLink {
return await this.publishWindowChange("/change-header", identity, window)
}
- @Subscribe("/set-frame")
- public async setFrame(identity: string, frame: import("@phreshos/core").WindowFrame) {
+ @Subscribe("/set-surface")
+ public async setSurface(identity: string, surface: import("@phreshos/core").WindowSurface) {
const window = this.mutableWindowOf(identity)
- if (!window.setFrame(frame)) return { identity, window }
+ if (!window.setSurface(surface)) return { identity, window }
- this.said(identity, "changeFrame", window.frame)
+ this.said(identity, "changeSurface", window.surface)
- return await this.publishWindowChange("/change-frame", identity, window)
+ return await this.publishWindowChange("/change-surface", identity, window)
}
@Subscribe("/set-transaction")
@@ -3520,7 +3578,7 @@ interface ShapeBase {
header: boolean
- frame: import("@phreshos/core").WindowFrame
+ surface: import("@phreshos/core").WindowSurface
transaction: import("@phreshos/core").WindowTransaction
diff --git a/source/server/core/link-manager/auth-manager/process-manager/process.ts b/source/server/core/link-manager/auth-manager/process-manager/process.ts
index 35607b8..09592fd 100644
--- a/source/server/core/link-manager/auth-manager/process-manager/process.ts
+++ b/source/server/core/link-manager/auth-manager/process-manager/process.ts
@@ -5,7 +5,7 @@ import ServerProcessBoundary, { type HostVisibility } from "./server-process-bou
import HostTraffic from "./host-traffic"
import ClientState from "./client-state"
import { randomUUID } from "node:crypto"
-import { type Layer, type WindowFrame, type WindowTransaction } from "@phreshos/core"
+import { type Layer, type WindowSurface, type WindowTransaction } from "@phreshos/core"
import { Tunnel } from "@the-link/core"
import type { ServerRuntime } from "@server/core/server-runtime"
@@ -316,7 +316,7 @@ export default class Process {
...this.record(),
// The trusted desktop counterpart keeps this essential fact
- // current. Framed program records are shaped separately.
+ // current. Surfaced program records are shaped separately.
server: this.server ? { ready: this.server.ready, service: this.server.service } : null,
// The trusted desktop needs the relationship in order to
@@ -372,7 +372,7 @@ export interface ProcessLaunch {
header: boolean
- frame: WindowFrame
+ surface: WindowSurface
transaction: WindowTransaction
diff --git a/source/server/core/link-manager/auth-manager/process-manager/system-access.ts b/source/server/core/link-manager/auth-manager/process-manager/system-access.ts
index c594a40..5652ff6 100644
--- a/source/server/core/link-manager/auth-manager/process-manager/system-access.ts
+++ b/source/server/core/link-manager/auth-manager/process-manager/system-access.ts
@@ -25,7 +25,7 @@ export default class SystemAccess {
return this.ownsProcess(process) || this.manager.grants(this.owner.identity, "programs", [process.program.identity])
}
- public canConnections() { return this.manager.grants(this.owner.identity, "connections", []) }
+ public canAuthentication() { return this.manager.grants(this.owner.identity, "authentication", []) }
public program<Subject extends Program>(program: Subject) {
diff --git a/source/server/core/link-manager/auth-manager/process-manager/window.ts b/source/server/core/link-manager/auth-manager/process-manager/window.ts
index 498a338..04f5176 100644
--- a/source/server/core/link-manager/auth-manager/process-manager/window.ts
+++ b/source/server/core/link-manager/auth-manager/process-manager/window.ts
@@ -1,11 +1,11 @@
import {
isRelativeValue,
- parseWindowFrame,
+ parseWindowSurface,
parseWindowTransaction,
type Position,
type Size,
type Value,
- type WindowFrame,
+ type WindowSurface,
type WindowGeometry,
type WindowLayer,
type WindowState,
@@ -22,7 +22,7 @@ export interface Shown {
header: boolean
- frame: WindowFrame
+ surface: WindowSurface
transaction: WindowTransaction
@@ -41,7 +41,7 @@ export default class Window implements Omit<WindowState, "front"> {
// Whether it is shown. A window may be born hidden, which is a
// state at birth rather than an act afterwards: hidden from the
- // first frame is not the same as shown once and then hidden.
+ // first rendered frame is not the same as shown once and then hidden.
public minimized: boolean
public maximized: boolean
@@ -55,7 +55,7 @@ export default class Window implements Omit<WindowState, "front"> {
// The Window's authoritative Desktop layer.
public layer: WindowLayer
- public frame: WindowFrame
+ public surface: WindowSurface
public transaction: WindowTransaction
@@ -65,7 +65,7 @@ export default class Window implements Omit<WindowState, "front"> {
this.header = shown.header
- this.frame = parseWindowFrame(shown.frame)
+ this.surface = parseWindowSurface(shown.surface)
this.transaction = parseWindowTransaction(shown.transaction)
@@ -164,13 +164,13 @@ export default class Window implements Omit<WindowState, "front"> {
return true
}
- public setFrame(frame: WindowFrame) {
+ public setSurface(surface: WindowSurface) {
- const parsed = parseWindowFrame(frame)
+ const parsed = parseWindowSurface(surface)
- if (JSON.stringify(this.frame) === JSON.stringify(parsed)) return false
+ if (JSON.stringify(this.surface) === JSON.stringify(parsed)) return false
- this.frame = parsed
+ this.surface = parsed
return true
}
@@ -194,7 +194,7 @@ export default class Window implements Omit<WindowState, "front"> {
header: this.header,
- frame: this.frame,
+ surface: this.surface,
transaction: this.transaction,
diff --git a/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts b/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts
index 750b68b..392857d 100644
--- a/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts
+++ b/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts
@@ -1585,7 +1585,7 @@ export default class ProgramManager extends TheLink {
header: asked.header ?? client.header ?? defaults.header,
- frame: asked.frame ?? client.frame ?? defaults.frame,
+ surface: asked.surface ?? client.surface ?? defaults.surface,
transaction: asked.transaction ?? client.transaction ?? defaults.transaction,
diff --git a/source/server/core/link-manager/auth-manager/program-manager/program.ts b/source/server/core/link-manager/auth-manager/program-manager/program.ts
index 61578ab..e06efff 100644
--- a/source/server/core/link-manager/auth-manager/program-manager/program.ts
+++ b/source/server/core/link-manager/auth-manager/program-manager/program.ts
@@ -4,7 +4,7 @@ import { dirname, isAbsolute, normalize, relative, resolve, sep } from "node:pat
import { spawn } from "node:child_process"
import { randomUUID } from "node:crypto"
import { validateIcon } from "./icon"
-import { defaultProgramVersion, parseLaunch, parseProgramDefinition, parseWindowFrame, parseWindowTransaction, type ProgramCommandChunk, type ProgramDefinition, type ProgramSnapshot } from "@phreshos/core"
+import { defaultProgramVersion, parseLaunch, parseProgramDefinition, parseWindowSurface, parseWindowTransaction, type ProgramCommandChunk, type ProgramDefinition, type ProgramSnapshot } from "@phreshos/core"
import { permissionCatalog, type DeclaredPermissions } from "@server/core/permissions"
/**
@@ -232,7 +232,7 @@ export default class Program {
header: client.header ?? null,
- frame: client.frame ?? null,
+ surface: client.surface ?? null,
transaction: client.transaction ?? null,
@@ -412,7 +412,7 @@ function coherent(config: ProgramConfig) {
if (config.client?.sandbox !== undefined && typeof config.client.sandbox !== "boolean") throw new Error("A client half's sandbox mode must be true or false")
- if (config.client?.frame !== undefined) parseWindowFrame(config.client.frame)
+ if (config.client?.surface !== undefined) parseWindowSurface(config.client.surface)
if (config.client?.transaction !== undefined) parseWindowTransaction(config.client.transaction)
diff --git a/source/server/core/link-manager/link-manager.ts b/source/server/core/link-manager/link-manager.ts
index d24a303..35b6098 100644
--- a/source/server/core/link-manager/link-manager.ts
+++ b/source/server/core/link-manager/link-manager.ts
@@ -239,6 +239,17 @@ export default class LinkManager extends TheLink {
await this.announceSessionEnd(identity, "signedOut", connections)
}
+ /** Ends the Sessions present at this operation's authoritative snapshot. */
+ public async signOutAllSessions() {
+
+ const sessions = this.application.authentication.sessionsList()
+
+ for (const identity of sessions) {
+
+ if (this.application.authentication.sessionFind(identity)) await this.signOutSession(identity)
+ }
+ }
+
@Subscribe("/owner/state")
protected authenticationState(): AuthenticationState {
diff --git a/source/server/core/permissions.ts b/source/server/core/permissions.ts
index e22fd67..85dcc06 100644
--- a/source/server/core/permissions.ts
+++ b/source/server/core/permissions.ts
@@ -167,7 +167,7 @@ export class PermissionCatalog {
if (name === "desktopConnection") {
- if (this.allows("connections", [], permissions)) return true
+ if (this.allows("authentication", [], permissions)) return true
}
const assigned = permissions[name]
@@ -296,7 +296,7 @@ export const permissionCatalog = new PermissionCatalog({
layers: {
default: [],
title: "Window layers",
- description: "Select the under, over, wallpaper, and start-menu layers in Client Endpoint launches."
+ description: "Select the under, over, wallpaper, and shell layers in Client Endpoint launches."
},
network: {
default: [],
@@ -328,9 +328,9 @@ export const permissionCatalog = new PermissionCatalog({
title: "Desktop connection",
description: "Access the browser Connection carrying this Desktop and its Session."
},
- connections: {
+ authentication: {
default: [],
- title: "Connections",
- description: "Access every browser Connection and its Session."
+ title: "Authentication",
+ description: "Access and manage owner authentication, browser Connections, and Sessions."
}
})
diff --git a/source/server/core/system.ts b/source/server/core/system.ts
index c5f56a7..7ddaaf7 100644
--- a/source/server/core/system.ts
+++ b/source/server/core/system.ts
@@ -4,6 +4,8 @@ import type Program from "./link-manager/auth-manager/program-manager/program"
import type Process from "./link-manager/auth-manager/process-manager/process"
import type {
ClientLaunch,
+ AuthenticationRequirements,
+ AuthenticationState,
Launch,
ProgramInstallOptions,
ProgramUninstallOptions,
@@ -13,7 +15,7 @@ import type {
ServerLaunch,
ShellOptions,
Size,
- WindowFrame,
+ WindowSurface,
WindowGeometry,
WindowTransaction
} from "@phreshos/core"
@@ -225,6 +227,26 @@ export default class System {
return this.application.linkManager.connections()
}
+ public authenticationState(): AuthenticationState {
+
+ return Object.freeze({ username: this.application.authentication.username })
+ }
+
+ public authenticationRequirements(): AuthenticationRequirements {
+
+ return this.application.authentication.requirements()
+ }
+
+ public setAuthenticationCredentials(credentials: unknown) {
+
+ return this.application.authentication.setCredentials(credentials)
+ }
+
+ public signOutAllSessions() {
+
+ return this.application.linkManager.signOutAllSessions()
+ }
+
public findConnection(identity: string) {
return this.application.linkManager.findConnection(identity)
@@ -350,9 +372,9 @@ export default class System {
await this.processManager.setHeader(process.identity, header)
}
- public async setWindowFrame(process: Process, frame: WindowFrame) {
+ public async setWindowSurface(process: Process, surface: WindowSurface) {
- await this.processManager.setFrame(process.identity, frame)
+ await this.processManager.setSurface(process.identity, surface)
}
public async setWindowTransaction(process: Process, transaction: WindowTransaction) {
@@ -384,7 +406,7 @@ export default class System {
service: program.client.service,
title: program.client.title ?? null,
header: program.client.header ?? null,
- frame: program.client.frame ?? null,
+ surface: program.client.surface ?? null,
transaction: program.client.transaction ?? null,
size: program.client.size ?? null,
position: program.client.position ?? null,
diff --git a/source/shared/permission-state.ts b/source/shared/permission-state.ts
index 47b9e05..3086230 100644
--- a/source/shared/permission-state.ts
+++ b/source/shared/permission-state.ts
@@ -13,7 +13,7 @@ export function allowsSynchronizedPermission<Name extends PermissionName>(
requested: readonly PermissionValue<Name>[]
) {
- if (name === "desktopConnection" && allowsSynchronizedPermission(permissions, "connections", [])) return true
+ if (name === "desktopConnection" && allowsSynchronizedPermission(permissions, "authentication", [])) return true
const assigned = permissions[name]
diff --git a/source/shared/window-layers.ts b/source/shared/window-layers.ts
index 12580bb..48a94fc 100644
--- a/source/shared/window-layers.ts
+++ b/source/shared/window-layers.ts
@@ -4,7 +4,7 @@ import type { WindowLayer, WindowTransaction } from "@phreshos/core"
export type WindowPresentationProperty =
| "title"
| "header"
- | "frame"
+ | "surface"
| "position"
| "size"
| "minimized"
@@ -24,70 +24,52 @@ type WindowLayerPresentation = Readonly<{
/** Facts the Desktop can apply from authoritative state and emit. */
applicable: readonly WindowPresentationProperty[]
- /** Whether a Program may directly mutate this Desktop presentation. */
- mutable: boolean
- /** Whether projection from the authoritative Window is optional, required, or forbidden. */
- following: "optional" | "required" | "forbidden"
defaults: Readonly<{
- frame: boolean
+ surface: boolean
header: boolean
transaction: WindowTransaction
}>
fixed: boolean
- exclusive: boolean
transactions: boolean
}>
export const windowLayerModel: Readonly<Record<WindowLayer, WindowLayerPresentation>> = Object.freeze({
- window: Object.freeze({
- readable: Object.freeze(["title", "header", "frame", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
- applicable: Object.freeze(["title", "header", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
- mutable: false,
- following: "required",
- defaults: Object.freeze({ frame: true, header: true, transaction: false }),
- fixed: false,
- exclusive: false,
+ wallpaper: Object.freeze({
+ readable: Object.freeze(["layer"] satisfies WindowPresentationProperty[]),
+ applicable: Object.freeze(["layer"] satisfies WindowPresentationProperty[]),
+ defaults: Object.freeze({ surface: false, header: false, transaction: false }),
+ fixed: true,
transactions: false
}),
under: Object.freeze({
- readable: Object.freeze(["frame", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
- applicable: Object.freeze(["frame", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
- mutable: true,
- following: "optional",
- defaults: Object.freeze({ frame: false, header: false, transaction: false }),
+ readable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
+ applicable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
+ defaults: Object.freeze({ surface: false, header: false, transaction: false }),
fixed: false,
- exclusive: false,
transactions: true
}),
- over: Object.freeze({
- readable: Object.freeze(["frame", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
- applicable: Object.freeze(["frame", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
- mutable: true,
- following: "optional",
- defaults: Object.freeze({ frame: false, header: false, transaction: false }),
+ window: Object.freeze({
+ readable: Object.freeze(["title", "header", "surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
+ applicable: Object.freeze(["title", "header", "surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
+ // Standard Window motion uses the shared Appearance transaction unless
+ // its authoritative Window value explicitly selects another behavior.
+ defaults: Object.freeze({ surface: true, header: true, transaction: true }),
fixed: false,
- exclusive: false,
transactions: true
}),
- wallpaper: Object.freeze({
- readable: Object.freeze(["layer"] satisfies WindowPresentationProperty[]),
- applicable: Object.freeze(["layer"] satisfies WindowPresentationProperty[]),
- mutable: false,
- following: "forbidden",
- defaults: Object.freeze({ frame: false, header: false, transaction: false }),
- fixed: true,
- exclusive: true,
- transactions: false
+ over: Object.freeze({
+ readable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
+ applicable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
+ defaults: Object.freeze({ surface: false, header: false, transaction: false }),
+ fixed: false,
+ transactions: true
}),
- "start-menu": Object.freeze({
- readable: Object.freeze(["layer"] satisfies WindowPresentationProperty[]),
- applicable: Object.freeze(["layer"] satisfies WindowPresentationProperty[]),
- mutable: false,
- following: "forbidden",
- defaults: Object.freeze({ frame: false, header: false, transaction: false }),
- fixed: true,
- exclusive: true,
- transactions: false
+ shell: Object.freeze({
+ readable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
+ applicable: Object.freeze(["surface", "position", "size", "minimized", "maximized", "front", "layer"] satisfies WindowPresentationProperty[]),
+ defaults: Object.freeze({ surface: false, header: false, transaction: false }),
+ fixed: false,
+ transactions: true
})
})
@@ -119,27 +101,19 @@ export function requireWindowPresentationApplication(layer: WindowLayer, propert
}
}
-/** Rejects public local control while preserving application for following and Desktop ownership. */
export function requireWindowPresentationMutation(layer: WindowLayer, property: WindowPresentationProperty) {
- if (!windowLayerModel[layer].mutable) {
- throw new Error(`The ${layer} layer does not allow direct presentation changes`)
- }
requireWindowPresentationApplication(layer, property)
}
-export function windowPresentationFollowing(layer: WindowLayer) {
- return windowLayerModel[layer].following
-}
-
export function supportsWindowPresentationTransactions(layer: WindowLayer) {
return windowLayerModel[layer].transactions
}
/** Window roles that own one fixed Desktop presentation at a time. */
-export type DesktopReplacementLayer = Extract<WindowLayer, "wallpaper" | "start-menu">
+export type DesktopReplacementLayer = Extract<WindowLayer, "wallpaper">
export function isDesktopReplacementLayer(layer: WindowLayer | undefined): layer is DesktopReplacementLayer {
- return layer !== undefined && windowLayerModel[layer].exclusive
+ return layer === "wallpaper"
}
export function isFixedWindowPresentationLayer(layer: WindowLayer) {
@@ -152,4 +126,4 @@ export function requireWindowPresentationTransactions(layer: WindowLayer) {
}
}
-const presentationProperties = ["title", "header", "frame", "position", "size", "minimized", "maximized", "front", "layer"] as const satisfies readonly WindowPresentationProperty[]
+const presentationProperties = ["title", "header", "surface", "position", "size", "minimized", "maximized", "front", "layer"] as const satisfies readonly WindowPresentationProperty[]
diff --git a/tests/authentication-domains.test.ts b/tests/authentication-domains.test.ts
index 8790ed3..fc6b350 100644
--- a/tests/authentication-domains.test.ts
+++ b/tests/authentication-domains.test.ts
@@ -28,6 +28,9 @@ test("browser Connections and Sessions form one authoritative lifecycle", async
let secondRemoved = false
try {
+ expect(await application.authentication.signUp("owner", "initial-password")).toEqual({ signedUp: true })
+ expect(application.system.authenticationState()).toEqual({ username: "owner" })
+ expect(await application.authentication.verify("owner", "initial-password")).toBe(true)
expect(await connection.publish("/session-authenticate", null)).toEqual([false])
expect(application.system.listConnections()).toEqual([connection])
expect(application.system.connectionSession(connection.identity)).toBeNull()
@@ -45,7 +48,17 @@ test("browser Connections and Sessions form one authoritative lifecycle", async
expect(application.system.connectionSession(secondConnection.identity)).toEqual(created)
expect(application.system.sessionConnections(created.identity)).toEqual([connection, secondConnection])
- await application.system.signOutSession(created.identity)
+ await application.system.setAuthenticationCredentials({ username: "next-owner", password: "next-password" })
+
+ // Credential replacement changes future authentication only; existing
+ // Session authority remains valid until an explicit sign-out operation.
+ expect(application.system.authenticationState()).toEqual({ username: "next-owner" })
+ expect(await application.authentication.verify("owner", "initial-password")).toBe(false)
+ expect(await application.authentication.verify("next-owner", "next-password")).toBe(true)
+ expect(application.system.listSessions()).toEqual([created.identity])
+ expect(application.system.sessionConnections(created.identity)).toEqual([connection, secondConnection])
+
+ await application.system.signOutAllSessions()
expect(signedOut).toBe(2)
expect(application.system.listSessions()).toEqual([])
diff --git a/tests/client-layer-permissions.test.ts b/tests/client-layer-permissions.test.ts
index 430bb8a..10f836c 100644
--- a/tests/client-layer-permissions.test.ts
+++ b/tests/client-layer-permissions.test.ts
@@ -11,7 +11,7 @@ function fixture() {
const program: ProgramSnapshot & { readonly permissions: Permissions } = {
identity: "owner", reference: "program-reference", assetId: "assets", name: "Owner",
version: "0.0.0", description: null, hasAgent: false, server: null,
- client: { sandbox: true, start: true, service: false, title: null, header: null, frame: null, transaction: null, size: null, position: null, layer: "over", minimize: null, maximize: null },
+ client: { sandbox: true, start: true, service: false, title: null, header: null, surface: null, transaction: null, size: null, position: null, layer: "over", minimize: null, maximize: null },
get permissions() { return permissions }
}
const process = { identity: "caller", reference: "process-reference", program: program.identity, name: null, startedAt: 0, options: {}, server: null, client: null }
@@ -42,11 +42,18 @@ function fixture() {
if (operation === "connections") return connections.filter(value => value.session === identity)
return sessions.find(value => value.identity === identity) ?? null
})
+ const authentication = vi.fn(async (operation: string, identity?: string) => {
+ if (operation === "connections") return connections
+ if (operation === "connection") return connections.find(value => value.identity === identity) ?? null
+ if (operation === "sessions") return sessions
+ if (operation === "session") return sessions.find(value => value.identity === identity) ?? null
+ return null
+ })
const command = vi.fn(async function* () {})
const auth = {
programManager: { programs: new Map([[program.identity, program]]), createProcess, findOrCreateProcess, startup, command },
processManager: { processes: new Map([[process.identity, process]]), startEndpoint, ownFrame: vi.fn(), releaseFrame: vi.fn() },
- connection, session,
+ authentication, connection, session,
grantsPermission: async <Name extends PermissionName>(_pane: string, name: Name, values: readonly PermissionValue<Name>[]) => permissionCatalog.allows(name, values, permissions)
} as unknown as AuthManager
const answer = host(auth, process.identity, () => ({ size: { width: 100, height: 100 } }), () => "frame", {} as never)
@@ -56,7 +63,7 @@ function fixture() {
}
}
-const restrictedLayers = ["under", "over", "wallpaper", "start-menu"] as const
+const restrictedLayers = ["under", "over", "wallpaper", "shell"] as const
test.each(restrictedLayers)("Client launch routes check %s before delegation", async layer => {
const f = fixture()
@@ -90,27 +97,30 @@ test("Connection permissions define one opaque accessible scope", async () => {
const f = fixture()
await expect(f.answer("desktop-connection")).rejects.toThrow("Execution is not permitted")
- await expect(f.answer("host-connection-list")).resolves.toEqual([[]])
- await expect(f.answer("host-session-list")).resolves.toEqual([[]])
- await expect(f.answer("host-connection-find", "desktop-connection")).resolves.toEqual([null])
- await expect(f.answer("host-session-find", "desktop-session")).resolves.toEqual([null])
+ await expect(f.answer("host-authentication-state")).rejects.toThrow("Execution is not permitted")
+ await expect(f.answer("host-authentication-connections")).resolves.toEqual([[]])
+ await expect(f.answer("host-authentication-sessions")).resolves.toEqual([[]])
+ await expect(f.answer("host-authentication-connection", "desktop-connection")).resolves.toEqual([null])
+ await expect(f.answer("host-authentication-session", "desktop-session")).resolves.toEqual([null])
await expect(f.answer("host-connection-state", "desktop-connection")).rejects.toThrow("Connection not found")
await expect(f.answer("host-session-state", "desktop-session")).rejects.toThrow("Session not found")
f.permissions({ desktopConnection: [] })
await expect(f.answer("desktop-connection")).resolves.toEqual([expect.objectContaining({ identity: "desktop-connection" })])
- await expect(f.answer("host-connection-list")).resolves.toEqual([[expect.objectContaining({ identity: "desktop-connection" })]])
- await expect(f.answer("host-session-list")).resolves.toEqual([[expect.objectContaining({ identity: "desktop-session" })]])
- await expect(f.answer("host-connection-find", "outside-connection")).resolves.toEqual([null])
- await expect(f.answer("host-session-find", "outside-session")).resolves.toEqual([null])
+ await expect(f.answer("host-authentication-connections")).resolves.toEqual([[expect.objectContaining({ identity: "desktop-connection" })]])
+ await expect(f.answer("host-authentication-sessions")).resolves.toEqual([[expect.objectContaining({ identity: "desktop-session" })]])
+ await expect(f.answer("host-authentication-connection", "outside-connection")).resolves.toEqual([null])
+ await expect(f.answer("host-authentication-session", "outside-session")).resolves.toEqual([null])
await expect(f.answer("host-session-connections", "desktop-session")).resolves.toEqual([[expect.objectContaining({ identity: "desktop-connection" })]])
+ await expect(f.answer("host-authentication-state")).rejects.toThrow("Execution is not permitted")
- f.permissions({ connections: [] })
+ f.permissions({ authentication: [] })
await expect(f.answer("desktop-connection")).resolves.toEqual([expect.objectContaining({ identity: "desktop-connection" })])
- await expect(f.answer("host-connection-list")).resolves.toEqual([connectionsNamed("desktop-connection", "outside-connection")])
- await expect(f.answer("host-session-list")).resolves.toEqual([connectionsNamed("desktop-session", "outside-session")])
+ await expect(f.answer("host-authentication-connections")).resolves.toEqual([connectionsNamed("desktop-connection", "outside-connection")])
+ await expect(f.answer("host-authentication-sessions")).resolves.toEqual([connectionsNamed("desktop-session", "outside-session")])
+ await expect(f.answer("host-authentication-state")).resolves.toEqual([null])
expect(f.connection).toHaveBeenCalledWith("current")
})
@@ -161,7 +171,7 @@ test("the layer catalog uses exact assignments before all", () => {
expect(permissionCatalog.allows("layers", ["under"], { layers: ["under"] })).toBe(true)
expect(permissionCatalog.allows("layers", ["under", "over"], { layers: [] })).toBe(true)
expect(permissionCatalog.allows("layers", ["wallpaper"], { layers: [] })).toBe(true)
- expect(permissionCatalog.allows("layers", ["start-menu"], { layers: [] })).toBe(true)
+ expect(permissionCatalog.allows("layers", ["shell"], { layers: [] })).toBe(true)
expect(permissionCatalog.allows("layers", ["over"], { all: [], layers: false })).toBe(false)
expect(permissionCatalog.allows("layers", ["over"], { all: [] })).toBe(true)
expect(() => permissionCatalog.declarations({ layers: false })).toThrow()
diff --git a/tests/client-sandbox.test.ts b/tests/client-sandbox.test.ts
index b48ba3f..c7a0665 100644
--- a/tests/client-sandbox.test.ts
+++ b/tests/client-sandbox.test.ts
@@ -24,7 +24,7 @@ test("client sandbox contract", async () => {
new Window(
- { title: "Client", header: true, frame: true, transaction: false, layer: "window" },
+ { title: "Client", header: true, surface: true, transaction: false, layer: "window" },
{ x: 0, y: 0 },
@@ -49,7 +49,7 @@ test("client sandbox contract", async () => {
null,
{} as HostTraffic,
new Window(
- { title: "Client", header: true, frame: true, transaction: false, layer: "window" },
+ { title: "Client", header: true, surface: true, transaction: false, layer: "window" },
{ x: 0, y: 0 },
{ width: 640, height: 480 },
1,
diff --git a/tests/client-system-access.test.ts b/tests/client-system-access.test.ts
index eb2fadc..e772753 100644
--- a/tests/client-system-access.test.ts
+++ b/tests/client-system-access.test.ts
@@ -68,7 +68,7 @@ test("client system access contract", async () => {
await assert.rejects(access.require("appearance", []), /Execution is not permitted/)
await assert.rejects(access.require("desktopPreferences", []), /Execution is not permitted/)
await assert.rejects(access.require("desktopConnection", []), /Execution is not permitted/)
- await assert.rejects(access.require("connections", []), /Execution is not permitted/)
+ await assert.rejects(access.require("authentication", []), /Execution is not permitted/)
assert.equal(permissionChecks, 0)
assert.equal(await access.canConnection("desktop-connection"), false)
assert.equal(await access.canSession("desktop-session"), false)
@@ -101,11 +101,11 @@ test("client system access contract", async () => {
assert.equal(await access.program(outsideProgram as never), outsideProgram)
await assert.rejects(access.service(outsideService), /Execution is not permitted/)
- permissions = { appearance: [], desktopPreferences: [], connections: [] }
+ permissions = { appearance: [], desktopPreferences: [], authentication: [] }
await access.require("appearance", [])
await access.require("desktopPreferences", [])
- await access.require("connections", [])
+ await access.require("authentication", [])
await access.require("desktopConnection", [])
assert.equal(await access.canConnection("desktop-connection"), true)
assert.equal(await access.canConnection("another-connection"), true)
@@ -116,7 +116,7 @@ test("client system access contract", async () => {
permissions = { desktopConnection: [] }
await access.require("desktopConnection", [])
- await assert.rejects(access.require("connections", []), /Execution is not permitted/)
+ await assert.rejects(access.require("authentication", []), /Execution is not permitted/)
assert.equal(await access.canConnection("desktop-connection"), true)
assert.equal(await access.canConnection("another-connection"), false)
assert.equal(await access.canSession("desktop-session"), true)
@@ -153,7 +153,7 @@ test("client system access contract", async () => {
assert.equal(await access.service(outsideService), outsideService)
await access.require("appearance", [])
await access.require("desktopPreferences", [])
- await access.require("connections", [])
+ await access.require("authentication", [])
await access.requireNetwork("wss://events.example.com/socket")
await access.requireStorage("/any/native/path", "delete")
await access.require("uploads", [])
diff --git a/tests/desktop-replacement-lifecycle.test.ts b/tests/desktop-replacement-lifecycle.test.ts
index b5ad9c7..b41ca7b 100644
--- a/tests/desktop-replacement-lifecycle.test.ts
+++ b/tests/desktop-replacement-lifecycle.test.ts
@@ -7,15 +7,17 @@ import ProcessManager from "@server/core/link-manager/auth-manager/process-manag
import type { ServerRuntimeFactory } from "@server/core/server-runtime"
import type { DesktopReplacementLayer } from "@shared/window-layers"
-const replacementLayers = ["wallpaper", "start-menu"] as const satisfies readonly DesktopReplacementLayer[]
+const replacementLayers = ["wallpaper"] as const satisfies readonly DesktopReplacementLayer[]
function fixture(replacementLayer: DesktopReplacementLayer) {
const auth = new TheLink() as unknown as AuthManager
const manager = new ProcessManager(auth)
const program = new Program({ identity: "replacement-test", client: { location: "https://example.test/" } })
+ const other = new Program({ identity: "other-test", client: { location: "https://example.test/" } })
vi.spyOn(program, "validate").mockResolvedValue()
+ vi.spyOn(other, "validate").mockResolvedValue()
const shape = (layer: Layer = replacementLayer) => ({
- title: "Replacement", header: layer === "window", frame: false, transaction: false,
+ title: "Replacement", header: layer === "window", surface: false, transaction: false,
position: { x: 20, y: 30 }, size: { width: 320, height: 240 },
layer, minimize: false, maximize: false
})
@@ -25,11 +27,11 @@ function fixture(replacementLayer: DesktopReplacementLayer) {
clientShape(_program: Program, launch: ClientLaunch) { return shape(launch.layer) }
}
})
- const register = (identity: string, layer: Layer | null = replacementLayer, runtime: ServerRuntimeFactory<Program> | null = null) => manager.register(
- identity, null, program, {}, { server: null, client: null, options: {} },
+ const register = (identity: string, layer: Layer | null = replacementLayer, runtime: ServerRuntimeFactory<Program> | null = null, owner = program) => manager.register(
+ identity, null, owner, {}, { server: null, client: null, options: {} },
runtime, layer !== null, shape(layer ?? replacementLayer), null
)
- return { manager, register }
+ return { manager, program, other, register }
}
test.each(replacementLayers)("concurrent %s launches replace the incumbent Process in order", async replacementLayer => {
@@ -97,3 +99,38 @@ test.each(replacementLayers)("failed activation releases the %s claim", async re
await manager.startClient("existing", { layer: replacementLayer })
expect(manager.processes.get("existing")!.clientEndpoint?.window.layer).toBe(replacementLayer)
})
+
+test("shell ownership keeps sibling Processes and terminates a displaced Program", async () => {
+ const { manager, program, other, register } = fixture("wallpaper")
+ await Promise.all([
+ register("first", "shell", null, program),
+ register("second", "shell", null, program)
+ ])
+ await register("ordinary", "window", null, program)
+
+ expect(manager.processes.has("first")).toBe(true)
+ expect(manager.processes.has("second")).toBe(true)
+
+ const runtime: ServerRuntimeFactory<Program> = vi.fn(() => {
+ expect(manager.processes.has("first")).toBe(false)
+ expect(manager.processes.has("second")).toBe(false)
+ throw new Error("runtime creation failed")
+ })
+ await expect(register("failed", "shell", runtime, other)).rejects.toThrow("runtime creation failed")
+ await register("replacement", "shell", null, other)
+
+ expect(runtime).toHaveBeenCalledOnce()
+ expect(manager.processes.has("ordinary")).toBe(true)
+ expect(manager.processes.has("replacement")).toBe(true)
+})
+
+test("starting a shell Client claims the layer for its Program", async () => {
+ const { manager, program, other, register } = fixture("wallpaper")
+ await register("incumbent", "shell", null, program)
+ await register("waiting", null, null, other)
+
+ await manager.startClient("waiting", { layer: "shell" })
+
+ expect(manager.processes.has("incumbent")).toBe(false)
+ expect(manager.processes.get("waiting")!.clientEndpoint?.window.layer).toBe("shell")
+})
diff --git a/tests/desktop-replacements.test.tsx b/tests/desktop-replacements.test.tsx
index 730d5b4..6878cf4 100644
--- a/tests/desktop-replacements.test.tsx
+++ b/tests/desktop-replacements.test.tsx
@@ -3,12 +3,16 @@ import { renderToStaticMarkup } from "react-dom/server"
import { UIProvider } from "@phreshos/react-ui"
import type Process from "@client/core/link-manager/auth-manager/process-manager/process"
import Workspace from "@client/view/structure/desktop/desktop"
+import { windowSurfaceInsets } from "@client/view/structure/desktop/layers/desktop-layers"
+import { taskbarStyle } from "@client/view/structure/desktop/layers/shell/taskbar/taskbar"
+import { startMenuStyle } from "@client/view/structure/desktop/layers/shell/start-menu/start-menu"
+import { taskbarIndicatorClassName } from "@client/view/structure/desktop/layers/shell/taskbar/programs/taskbar-item"
import type { ReactNode } from "react"
import { defaultAppearance } from "@phreshos/core"
const fixture = vi.hoisted(() => ({
processes: new Map<string, Process>(),
- pane: vi.fn(), fallback: vi.fn(), startMenu: vi.fn()
+ pane: vi.fn(), fallback: vi.fn()
}))
vi.mock("@client/view/contexts", () => ({
@@ -17,7 +21,7 @@ vi.mock("@client/view/contexts", () => ({
processManager: { processes: fixture.processes },
programManager: { programs: new Map([
["wallpaper-program", { assetId: "wallpaper-assets" }],
- ["start-menu-program", { assetId: "start-menu-assets" }]
+ ["shell-program", { assetId: "shell-assets" }]
]) }
}) },
LinkManagerContext: { useValue: () => ({ appearance: { value: defaultAppearance } }) }
@@ -29,16 +33,10 @@ vi.mock("@the-link/react", () => ({
vi.mock("@client/view/components/desktop-host/client-host", () => ({ default: () => ({}) }))
vi.mock("@client/view/components/program-access", () => ({ default: () => null }))
vi.mock("@libs/readiness", () => ({ useRequirement: () => () => {} }))
-vi.mock("@client/view/structure/desktop/taskbar/taskbar", () => ({
- default: ({ leading }: { leading: ReactNode }) => <div data-taskbar>{leading}</div>
+vi.mock("@client/view/structure/desktop/layers/shell/default-shell", () => ({
+ default: ({ children }: { children: ReactNode }) => <><div data-taskbar>{children}</div><div data-default-start-menu /></>
}))
-vi.mock("@client/view/structure/desktop/taskbar/launcher/start-menu", () => ({
- default: ({ replacement }: { replacement?: ReactNode }) => {
- fixture.startMenu(replacement)
- return <div data-start-menu>{replacement ?? <div data-default-start-menu />}</div>
- }
-}))
-vi.mock("@client/view/structure/desktop/wallpaper/wallpaper", () => ({
+vi.mock("@client/view/structure/desktop/layers/wallpaper/wallpaper", () => ({
WallpaperBackground: (props: unknown) => { fixture.fallback(props); return <div data-default-wallpaper /> },
ReadyWallpaper: () => null
}))
@@ -49,6 +47,65 @@ vi.mock("@client/view/structure/desktop/windows/process-window", () => ({
}
}))
+test("Desktop composes five full-bound stacked layers without a layout track", () => {
+ fixture.processes.clear()
+ const markup = renderToStaticMarkup(<UIProvider preferences={{ theme: "light", animations: true }}><Workspace /></UIProvider>)
+ const layers = [...markup.matchAll(/data-desktop-layer="([^"]+)"/g)].map(match => match[1])
+ expect(layers).toEqual(["wallpaper", "under", "window", "over", "shell"])
+
+ const display = markup.match(/<div[^>]*data-desktop-layers=""[^>]*>/)?.[0]
+ const windowLayer = markup.match(/<div[^>]*data-desktop-layer="window"[^>]*>/)?.[0]
+ expect(display).toContain("absolute inset-0")
+ expect(display).not.toContain("grid")
+ expect(windowLayer).toContain("absolute inset-0")
+ const windowSurface = markup.match(/<div[^>]*data-window-surface=""[^>]*>/)?.[0]
+ expect(windowSurface).not.toContain("overflow-hidden")
+ expect(windowSurface).toContain(`top:${defaultAppearance.spacing}px`)
+ expect(windowSurface).toContain(`right:${defaultAppearance.spacing}px`)
+ expect(windowSurface).toContain(`bottom:${defaultAppearance.spacing * 2 + defaultAppearance.taskbar.size}px`)
+ expect(windowSurface).toContain(`left:${defaultAppearance.spacing}px`)
+})
+
+test.each(["top", "right", "bottom", "left"] as const)("standard window surface reserves the %s Taskbar edge", position => {
+ const spacing = 12
+ const size = 44
+ const insets = windowSurfaceInsets(spacing, { position, size })
+
+ expect(insets).toEqual({
+ top: position === "top" ? 68 : 12,
+ right: position === "right" ? 68 : 12,
+ bottom: position === "bottom" ? 68 : 12,
+ left: position === "left" ? 68 : 12
+ })
+})
+
+test.each(["top", "right", "bottom", "left"] as const)("Taskbar occupies its configured %s edge and Start Menu opens inward", position => {
+ const spacing = 12
+ const size = 44
+ const taskbar = { position, size }
+ const bar = taskbarStyle(taskbar, spacing)
+ const menu = startMenuStyle(taskbar, spacing)
+
+ expect(bar).toMatchObject({ position: "absolute", [position]: spacing })
+
+ if (position === "top" || position === "bottom") expect(bar).toMatchObject({ left: spacing, right: spacing, height: size })
+ else expect(bar).toMatchObject({ top: spacing, bottom: spacing, width: size })
+
+ const taskbarInset = size + spacing * 2
+
+ if (position === "top") expect(menu).toMatchObject({ top: taskbarInset, right: "auto", bottom: "auto", left: spacing })
+ if (position === "bottom") expect(menu).toMatchObject({ top: "auto", right: "auto", bottom: taskbarInset, left: spacing })
+ if (position === "left") expect(menu).toMatchObject({ top: spacing, right: "auto", bottom: "auto", left: taskbarInset })
+ if (position === "right") expect(menu).toMatchObject({ top: spacing, right: taskbarInset, bottom: "auto", left: "auto" })
+
+ expect(menu).not.toHaveProperty("insetInlineStart")
+ expect(menu).not.toHaveProperty("insetBlockStart")
+})
+
+test.each(["top", "right", "bottom", "left"] as const)("active Taskbar indicator stays on the configured %s edge", position => {
+ expect(taskbarIndicatorClassName(position)).toContain(`${position}-0`)
+})
+
test("Desktop replaces its default wallpaper with the running Client and restores the fallback after stop", () => {
const render = () => renderToStaticMarkup(<UIProvider preferences={{ theme: "light", animations: true }}><Workspace /></UIProvider>)
fixture.processes.clear()
@@ -61,7 +118,7 @@ test("Desktop replaces its default wallpaper with the running Client and restore
identity: "wallpaper-process", program: "wallpaper-program",
client: { window: {
layer: "wallpaper", title: "Internal", position: { x: 200, y: 300 },
- header: false, frame: false, transaction: false,
+ header: false, surface: false, transaction: false,
size: { width: 100, height: 100 }, minimized: true, maximized: false, depth: 20
} }
} as unknown as Process
@@ -72,7 +129,7 @@ test("Desktop replaces its default wallpaper with the running Client and restore
expect(running).not.toContain("data-default-wallpaper")
expect(fixture.fallback).not.toHaveBeenCalled()
expect(fixture.pane.mock.lastCall?.[0]).toMatchObject({
- layer: "wallpaper", frame: false, minimized: false, maximized: true, entering: false,
+ layer: "wallpaper", surface: false, minimized: false, maximized: true, entering: false,
position: { x: 0, y: 0 }, size: { width: "100%", height: "100%" }, depth: 0
})
@@ -83,29 +140,30 @@ test("Desktop replaces its default wallpaper with the running Client and restore
expect(fixture.fallback).toHaveBeenCalledOnce()
})
-test("Desktop replaces the built-in Start Menu in its existing host and restores the fallback after stop", () => {
+test("Desktop replaces the complete built-in Shell and restores it after stop", () => {
const render = () => renderToStaticMarkup(<UIProvider preferences={{ theme: "light", animations: true }}><Workspace /></UIProvider>)
fixture.processes.clear()
fixture.pane.mockClear()
- fixture.startMenu.mockClear()
expect(render()).toContain("data-default-start-menu")
+ expect(render()).toContain("data-taskbar")
const record = {
- identity: "start-menu-process", program: "start-menu-program",
+ identity: "shell-process", program: "shell-program",
client: { window: {
- layer: "start-menu", title: "Internal", position: { x: 200, y: 300 },
- header: false, frame: false, transaction: false,
+ layer: "shell", title: "Internal", position: { x: 200, y: 300 },
+ header: false, surface: false, transaction: false,
size: { width: 100, height: 100 }, minimized: true, maximized: false, depth: 20
} }
} as unknown as Process
fixture.processes.set(record.identity, record)
fixture.pane.mockClear()
const running = render()
- expect(running).toContain('title="start-menu Client"')
+ expect(running).toContain('title="shell Client"')
expect(running).not.toContain("data-default-start-menu")
+ expect(running).not.toContain("data-taskbar")
expect(fixture.pane.mock.lastCall?.[0]).toMatchObject({
- layer: "start-menu", frame: false, minimized: false, maximized: true, entering: false,
- position: { x: 0, y: 0 }, size: { width: "100%", height: "100%" }, depth: 0
+ layer: "shell", surface: false, minimized: true, maximized: false, entering: false,
+ position: { x: 200, y: 300 }, size: { width: 100, height: 100 }, depth: 20
})
record.client = null
diff --git a/tests/link-request-routing.test.ts b/tests/link-request-routing.test.ts
index 1aaf9a0..b299d68 100644
--- a/tests/link-request-routing.test.ts
+++ b/tests/link-request-routing.test.ts
@@ -18,7 +18,7 @@ test("an RPC result returns only to its requesting boundary", async () => {
const stop = link.$outbound.forwardTo((event, ...values) => { broadcasts.push([event, ...values]) })
try {
- assert.deepEqual(await boundary.publish("/auth/connection/list"), [[]])
+ assert.deepEqual(await boundary.publish("/auth/authentication/connections"), [[]])
assert.equal(broadcasts.length, 0)
const identity = "request-routing"
diff --git a/tests/panel.test.tsx b/tests/panel.test.tsx
index 5ee62e7..5aaefe7 100644
--- a/tests/panel.test.tsx
+++ b/tests/panel.test.tsx
@@ -2,12 +2,12 @@ import assert from "node:assert/strict"
import type { ReactNode } from "react"
import { renderToStaticMarkup } from "react-dom/server"
import { defaultAppearance } from "@phreshos/core"
-import { UIProvider } from "@phreshos/react-ui"
+import { resolveRadius, UIProvider } from "@phreshos/react-ui"
import CredentialsForm from "@client/view/structure/authentication/credentials-form"
-import TaskbarSurface, { taskbarSurfaceClassName } from "@client/view/structure/desktop/taskbar/taskbar-surface"
-import Launcher from "@client/view/structure/desktop/taskbar/launcher/launcher"
+import ShellSurface, { shellSurfaceClassName } from "@client/view/structure/desktop/layers/shell/shell-surface"
import Window from "@client/view/structure/desktop/windows/window"
-import StartMenuPanel from "@client/view/structure/desktop/taskbar/launcher/start-menu-panel"
+import StartMenuPanel from "@client/view/structure/desktop/layers/shell/start-menu/start-menu-panel"
+import Taskbar from "@client/view/structure/desktop/layers/shell/taskbar/taskbar"
import { ApplicationContext } from "@client/view/contexts"
import Application from "@client/core/application"
import { test } from "vitest"
@@ -33,10 +33,10 @@ test("panel contract", async () => {
assert.match(html, /margin:6px;margin-top:0/)
}
- const taskbar = markup(<TaskbarSurface label="Title" labelId="title"><button>Action</button></TaskbarSurface>)
- panel(taskbar)
- assert.match(taskbar, /<h2 id="title"/)
- assert.match(taskbar, /<button>Action<\/button>/)
+ const shell = markup(<ShellSurface label="Title" labelId="title"><button>Action</button></ShellSurface>)
+ panel(shell)
+ assert.match(shell, /<h2 id="title"/)
+ assert.match(shell, /<button>Action<\/button>/)
const window = markup(<Window layer="window" icon="/icon.svg" title="Window"><iframe title="Content" /></Window>)
assert.equal(window.match(/data-material=""/g)?.length, 1)
@@ -47,6 +47,13 @@ test("panel contract", async () => {
assert.match(window, /data-window-container/)
assert.match(window, /<iframe title="Content"/)
assert.doesNotMatch(window, /class="p-px"/)
+ const windowPanel = window.match(/<div style="([^"]*grid-template-rows:auto minmax\(0, 1fr\)[^"]*)">/)?.[1] ?? ""
+ assert.match(windowPanel, /overflow:hidden/)
+ assert.match(windowPanel, new RegExp(`border-radius:${resolveRadius("medium", defaultAppearance)}`))
+
+ const surfaceFreeWindow = markup(<Window layer="window" surface={false} icon="/icon.svg" title="Window"><iframe title="Content" /></Window>)
+ const surfaceFreePanel = surfaceFreeWindow.match(/<div style="([^"]*grid-template-rows:auto minmax\(0, 1fr\)[^"]*)">/)?.[1] ?? ""
+ assert.doesNotMatch(surfaceFreePanel, /border-radius:/)
const bare = markup(<Window layer="over" icon="/icon.svg" title="Bare"><iframe title="Content" /></Window>)
assert.doesNotMatch(bare, /data-material/)
@@ -79,8 +86,8 @@ test("panel contract", async () => {
assert.match(authenticationFailure, /role="alert"/)
assert.match(authenticationFailure, /The request failed\./)
- const launcher = markup(<Launcher label="Example System" trigger="Open">{(_close, labelId) => <StartMenuPanel labelId={labelId} name="Example System" version="1.2.3" left={<button>Programs</button>} right={<p>Processes</p>} footer={<input type="search" aria-label="Search Programs and Processes" />} />}</Launcher>)
- assert.equal(launcher.match(/data-material=""/g)?.length, 4)
+ const launcher = markup(<StartMenuPanel labelId="start-menu-label" name="Example System" version="1.2.3" left={<button>Programs</button>} right={<p>Processes</p>} footer={<input type="search" aria-label="Search Programs and Processes" />} />)
+ assert.equal(launcher.match(/data-material=""/g)?.length, 3)
assert.match(launcher, /grid-cols-2/)
assert.match(launcher, /grid-template-rows:auto minmax\(0, 1fr\);min-height:0/)
assert.match(launcher, /grid-template-rows:minmax\(0, 1fr\) auto;gap:8px;padding:8px;padding-top:0/)
@@ -92,26 +99,17 @@ test("panel contract", async () => {
assert.match(launcher, /type="search"/)
assert.doesNotMatch(launcher, /<(?:main|section|article|aside|nav|header|footer)\b/)
assert.match(launcher, /size-4 rounded-sm object-contain/)
- // Native popover visibility belongs to the outer host, not Panel's grid.
- const popover = launcher.match(/<div[^>]*popover="auto"[^>]*>/)?.[0]
- assert(popover)
- assert.match(popover, /overflow-visible/)
- assert.doesNotMatch(popover, /\bgrid\b/)
- // Popovers and native dialogs share a non-clipping host for independently owned outer effects.
- assert(taskbarSurfaceClassName.split(" ").includes("overflow-visible"))
+ // Independent Shell overlays share a non-clipping host for outer effects.
+ assert(shellSurfaceClassName.split(" ").includes("overflow-visible"))
+
+ const taskbar = markup(<Taskbar
+ leading={<button>Start</button>}
+ trailing={<button>Sign out</button>}
+ taskbar={{ position: "bottom", size: 44 }}
+ spacing={8}
+ ><button>Window</button></Taskbar>)
+ assert.match(taskbar, /role="toolbar"/)
+ assert.match(taskbar, /aria-label="Taskbar"/)
+ assert.match(taskbar, /aria-orientation="horizontal"/)
- const replacement = markup(<StartMenuPanel
- labelId="start-menu"
- name="Example System"
- version="1.2.3"
- left={<button>Programs</button>}
- right={<p>Processes</p>}
- footer={<input type="search" />}
- replacement={<iframe title="Client Start Menu" />}
- />)
- assert.equal(replacement.match(/data-material=""/g)?.length, 1)
- assert.match(replacement, /<iframe title="Client Start Menu"/)
- assert.doesNotMatch(replacement, /<button>Programs<\/button>/)
- assert.doesNotMatch(replacement, /<p>Processes<\/p>/)
- assert.doesNotMatch(replacement, /type="search"/)
}, 120_000)
diff --git a/tests/permission-requests.test.ts b/tests/permission-requests.test.ts
index 06a3cb1..5149322 100644
--- a/tests/permission-requests.test.ts
+++ b/tests/permission-requests.test.ts
@@ -23,7 +23,7 @@ test("permission requests contract", async () => {
let dialogProgram: Program | null = null
const process = new Process("process", null, program, {}, { server: null, client: null, options: {} }, null, {} as HostTraffic,
- new Window({ title: "Client", header: true, frame: true, transaction: false, layer: "window" }, { x: 0, y: 0 }, { width: 640, height: 480 }, 1, false))
+ new Window({ title: "Client", header: true, surface: true, transaction: false, layer: "window" }, { x: 0, y: 0 }, { width: 640, height: 480 }, 1, false))
process.startClient(false)
const authManager = {
diff --git a/tests/permissions.test.ts b/tests/permissions.test.ts
index 06f88be..e8cf8f2 100644
--- a/tests/permissions.test.ts
+++ b/tests/permissions.test.ts
@@ -23,7 +23,7 @@ test("permissions contract", async () => {
layers: {
default: [],
title: "Window layers",
- description: "Select the under, over, wallpaper, and start-menu layers in Client Endpoint launches."
+ description: "Select the under, over, wallpaper, and shell layers in Client Endpoint launches."
},
network: {
default: [],
@@ -55,10 +55,10 @@ test("permissions contract", async () => {
title: "Desktop connection",
description: "Access the browser Connection carrying this Desktop and its Session."
},
- connections: {
+ authentication: {
default: [],
- title: "Connections",
- description: "Access every browser Connection and its Session."
+ title: "Authentication",
+ description: "Access and manage owner authentication, browser Connections, and Sessions."
}
})
@@ -136,11 +136,11 @@ test("permissions contract", async () => {
assert(!catalog.allows("programs", ["browser"], { services: [] }))
assert(!catalog.allows("services", ["browser"], { programs: [], services: false }))
assert(catalog.allows("desktopConnection", [], { desktopConnection: [] }))
- assert(catalog.allows("desktopConnection", [], { connections: [] }))
- assert(catalog.allows("desktopConnection", [], { connections: [], desktopConnection: false }))
- assert(!catalog.allows("connections", [], { desktopConnection: [] }))
- assert(catalog.allows("desktopConnection", [], { all: [], connections: false }))
- assert(!catalog.allows("desktopConnection", [], { all: [], connections: false, desktopConnection: false }))
+ assert(catalog.allows("desktopConnection", [], { authentication: [] }))
+ assert(catalog.allows("desktopConnection", [], { authentication: [], desktopConnection: false }))
+ assert(!catalog.allows("authentication", [], { desktopConnection: [] }))
+ assert(catalog.allows("desktopConnection", [], { all: [], authentication: false }))
+ assert(!catalog.allows("desktopConnection", [], { all: [], authentication: false, desktopConnection: false }))
assert(!catalog.allows("network", ["https://elsewhere.example"], { all: [], network: ["https://api.example.com"] }))
assert(catalog.allows("network", ["https://api.example.com/v1"], { all: [], network: ["https://api.example.com"] }))
assert(catalog.allowsStorage([], null, "Documents/report.txt", "read"))
@@ -175,7 +175,7 @@ test("permissions contract", async () => {
appearance: catalog.definition("appearance"),
desktopPreferences: catalog.definition("desktopPreferences"),
desktopConnection: catalog.definition("desktopConnection"),
- connections: catalog.definition("connections")
+ authentication: catalog.definition("authentication")
} as never), /invalid default/)
assert.deepEqual(permissionCatalog.resolve("all", true), [])
diff --git a/tests/process-lifecycle.test.ts b/tests/process-lifecycle.test.ts
index 5f686f4..40f1f81 100644
--- a/tests/process-lifecycle.test.ts
+++ b/tests/process-lifecycle.test.ts
@@ -29,7 +29,7 @@ test("process lifecycle contract", async () => {
return {
title: launch.title ?? "Client",
header: launch.header ?? true,
- frame: launch.frame ?? true,
+ surface: launch.surface ?? true,
transaction: launch.transaction ?? false,
position: launch.position ?? { x: 0, y: 0 },
size: launch.size ?? { width: 640, height: 480 },
@@ -76,7 +76,7 @@ test("process lifecycle contract", async () => {
const initial = {
title: "Initial",
header: true,
- frame: true,
+ surface: true,
transaction: false,
position: { x: 12, y: 24 },
size: { width: 640, height: 480 },
@@ -105,13 +105,13 @@ test("process lifecycle contract", async () => {
await manager.move(process.identity, { x: 80, y: 90 })
await manager.setHeader(process.identity, false)
- await manager.setFrame(process.identity, { radius: "full", color: "primary" })
+ await manager.setSurface(process.identity, { radius: "full", color: "primary" })
await manager.startClient(process.identity)
assert.deepEqual(process.clientEndpoint.window.position, { x: 80, y: 90 })
assert.equal(process.clientEndpoint.window.header, false)
- assert.deepEqual(process.clientEndpoint.window.frame, { radius: "full", color: "primary" })
+ assert.deepEqual(process.clientEndpoint.window.surface, { radius: "full", color: "primary" })
await manager.stopClient(process.identity)
await manager.startClient(process.identity, { layer: "over", title: "Overlay" })
@@ -129,7 +129,7 @@ test("process lifecycle contract", async () => {
assert.equal(process.clientEndpoint.window.layer, "window")
assert.equal(process.clientEndpoint.window.header, true)
assert.deepEqual(process.clientEndpoint.window.position, { x: 140, y: 150 })
- assert.deepEqual(process.clientEndpoint.window.frame, { radius: "full", color: "primary" })
+ assert.deepEqual(process.clientEndpoint.window.surface, { radius: "full", color: "primary" })
}
function program(identity: string) {
@@ -165,7 +165,7 @@ test("process lifecycle contract", async () => {
{
title: "Client",
header: true,
- frame: true,
+ surface: true,
transaction: false,
position: { x: 0, y: 0 },
size: { width: 640, height: 480 },
@@ -260,10 +260,10 @@ test("process lifecycle contract", async () => {
null,
client,
{},
- { ...launch, client: { title: "Partial", header: true, frame: true, transaction: false, position: null, size: null, layer: "window", minimize: false, maximize: false, service: false } },
+ { ...launch, client: { title: "Partial", header: true, surface: true, transaction: false, position: null, size: null, layer: "window", minimize: false, maximize: false, service: false } },
null,
true,
- { title: "Partial", header: true, frame: true, transaction: false, position: { x: 0, y: 0 }, size: { width: 320, height: 240 }, layer: "window", minimize: false, maximize: false },
+ { title: "Partial", header: true, surface: true, transaction: false, position: { x: 0, y: 0 }, size: { width: 320, height: 240 }, layer: "window", minimize: false, maximize: false },
null
), /creation publication failed/)
diff --git a/tests/start-menu-search.test.tsx b/tests/start-menu-search.test.tsx
index f3f34ca..55bb84b 100644
--- a/tests/start-menu-search.test.tsx
+++ b/tests/start-menu-search.test.tsx
@@ -3,8 +3,8 @@ import { renderToStaticMarkup } from "react-dom/server"
import { UIProvider } from "@phreshos/react-ui"
import { defaultAppearance } from "@phreshos/core"
import Program from "@server/core/link-manager/auth-manager/program-manager/program"
-import SearchBar from "@client/view/structure/desktop/taskbar/launcher/search-bar"
-import { matchesProcess, matchesProgram, searchTerms } from "@client/view/structure/desktop/taskbar/launcher/search"
+import SearchBar from "@client/view/structure/desktop/layers/shell/start-menu/search-bar"
+import { matchesProcess, matchesProgram, searchTerms } from "@client/view/structure/desktop/layers/shell/start-menu/search"
import { test } from "vitest"
test("start menu search contract", async () => {
diff --git a/tests/wallpaper-source.test.tsx b/tests/wallpaper-source.test.tsx
index f576eba..43403f5 100644
--- a/tests/wallpaper-source.test.tsx
+++ b/tests/wallpaper-source.test.tsx
@@ -4,7 +4,7 @@ import { UIProvider } from "@phreshos/react-ui"
import { defaultAppearance } from "@phreshos/core"
import { ApplicationContext } from "@client/view/contexts"
import Application from "@client/core/application"
-import { WallpaperBackground } from "@client/view/structure/desktop/wallpaper/wallpaper"
+import { WallpaperBackground } from "@client/view/structure/desktop/layers/wallpaper/wallpaper"
import { test } from "vitest"
test("wallpaper source contract", () => {
diff --git a/tests/window-geometry.test.ts b/tests/window-geometry.test.ts
index 75adc3d..2e458fc 100644
--- a/tests/window-geometry.test.ts
+++ b/tests/window-geometry.test.ts
@@ -3,7 +3,8 @@ import ClientWindow from "@client/core/link-manager/auth-manager/process-manager
import ClientProcessManager from "@client/core/link-manager/auth-manager/process-manager/process-manager"
import ProcessManager from "@server/core/link-manager/auth-manager/process-manager/process-manager"
import ServerWindow from "@server/core/link-manager/auth-manager/process-manager/window"
-import { constrainWindowGeometry, minimumWindowSize, resolveWindowGeometry } from "@client/view/components/window-manager/window-geometry"
+import { constrainWindowGeometry, minimumWindowSize, resolveWindowGeometry, windowPaintInsets } from "@client/view/components/window-manager/window-geometry"
+import { defaultAppearance } from "@phreshos/core"
import { TheLink } from "@the-link/core"
import { test } from "vitest"
@@ -20,6 +21,17 @@ test("a standard presentation enforces its minimum after resolving authoritative
})
})
+test("tiled standard windows share the Appearance gap inside the equally inset surface", () => {
+ const surface = { width: 1000, height: 600 }
+ const half = defaultAppearance.spacing / 2
+ const left = windowPaintInsets({ x: 0, y: 0 }, { width: "1/2", height: "1/1" }, surface, half)
+ const right = windowPaintInsets({ x: "1/2", y: 0 }, { width: "1/2", height: "1/1" }, surface, half)
+
+ assert.deepEqual(left, { top: 0, right: half, bottom: 0, left: 0 })
+ assert.deepEqual(right, { top: 0, right: 0, bottom: 0, left: half })
+ assert.equal(left.right + right.left, defaultAppearance.spacing)
+})
+
test("window geometry contract", async () => {
const initial = {
position: { x: 10, y: 20 },
@@ -27,7 +39,7 @@ test("window geometry contract", async () => {
}
const authority = new ServerWindow(
- { title: "Geometry", header: true, frame: true, transaction: false, layer: "window" },
+ { title: "Geometry", header: true, surface: true, transaction: false, layer: "window" },
initial.position,
initial.size,
1,
diff --git a/tests/window-presentation-layers.test.ts b/tests/window-presentation-layers.test.ts
index 171f997..76c1a2d 100644
--- a/tests/window-presentation-layers.test.ts
+++ b/tests/window-presentation-layers.test.ts
@@ -7,7 +7,7 @@ function fixture(layer: WindowLayer) {
layer: selected,
title: "Original",
header: selected === "window",
- frame: selected === "window",
+ surface: selected === "window",
transaction: false,
position: { x: 20, y: 30 },
size: { width: 320, height: 240 },
@@ -23,11 +23,12 @@ function fixture(layer: WindowLayer) {
return { own, entries, presentations }
}
-test.each(["wallpaper", "start-menu"] as const)("%s exposes only concepts understood by its presentation", async layer => {
+test("wallpaper exposes only concepts understood by its presentation", async () => {
+ const layer = "wallpaper"
const { own, entries, presentations } = fixture(layer)
expect(presentations.read("own", "layer")).toBe(layer)
- for (const property of ["title", "position", "size", "minimized", "maximized", "header", "frame", "front"] as const) {
+ for (const property of ["title", "position", "size", "minimized", "maximized", "header", "surface", "front"] as const) {
expect(() => presentations.read("own", property)).toThrow(new RegExp(`${layer} layer has no`))
}
@@ -39,10 +40,10 @@ test.each(["wallpaper", "start-menu"] as const)("%s exposes only concepts unders
() => presentations.maximize("own", false),
() => presentations.setTitle("own", "Changed"),
() => presentations.setHeader("own", false),
- () => presentations.setFrame("own", true),
+ () => presentations.setSurface("own", true),
() => presentations.raise("own")
]
- for (const operation of unsupported) expect(operation).toThrow(new RegExp(`${layer} layer does not allow direct`))
+ for (const operation of unsupported) expect(operation).toThrow(new RegExp(`${layer} layer cannot apply`))
own.window.position = { x: 500, y: 600 }
own.window.title = "Changed"
@@ -50,12 +51,13 @@ test.each(["wallpaper", "start-menu"] as const)("%s exposes only concepts unders
expect(presentations.projection("own").position).toEqual({ x: 0, y: 0 })
expect(presentations.projection("own").title).toBe("Original")
- expect(() => presentations.follow("own")).toThrow(new RegExp(`${layer} layer cannot follow`))
+ await expect(presentations.follow("own")).resolves.toBeUndefined()
+ await expect(presentations.unfollow("own")).resolves.toBeUndefined()
expect(presentations.projection("own").title).toBe("Original")
expect(presentations.projection("own").position).toEqual({ x: 0, y: 0 })
})
-test.each(["under", "over"] as const)("%s presents geometry and frame without a header", async layer => {
+test.each(["under", "over", "shell"] as const)("%s presents geometry and surface without a header", async layer => {
const { own, entries, presentations } = fixture(layer)
expect(() => presentations.read("own", "header")).toThrow(new RegExp(`${layer} layer has no header`))
@@ -63,15 +65,15 @@ test.each(["under", "over"] as const)("%s presents geometry and frame without a
expect(() => presentations.setHeader("own", false)).toThrow(new RegExp(`${layer} layer cannot apply header`))
expect(() => presentations.setTitle("own", "Changed")).toThrow(new RegExp(`${layer} layer cannot apply title`))
- await presentations.setFrame("own", { color: "primary", radius: "full" })
- expect(presentations.read("own", "frame")).toEqual({ color: "primary", radius: "full" })
+ await presentations.setSurface("own", { color: "primary", radius: "full" })
+ expect(presentations.read("own", "surface")).toEqual({ color: "primary", radius: "full" })
await presentations.follow("own")
own.window.position = { x: 100, y: 200 }
- own.window.frame = true
+ own.window.surface = true
presentations.reconcile(entries)
expect(presentations.projection("own").position).toEqual({ x: 100, y: 200 })
- expect(presentations.projection("own").frame).toBe(true)
+ expect(presentations.projection("own").surface).toBe(true)
await presentations.unfollow("own")
own.window.position = { x: 900, y: 900 }
@@ -79,34 +81,31 @@ test.each(["under", "over"] as const)("%s presents geometry and frame without a
expect(presentations.projection("own").position).toEqual({ x: 100, y: 200 })
})
-test("a standard presentation is observed locally and controlled through its authoritative Window", async () => {
+test("a standard presentation can leave authoritative following and take local control", async () => {
const { presentations } = fixture("window")
- expect(presentations.read("own", "frame")).toBe(true)
- const mutations = [
- () => presentations.move("own", { x: 1, y: 2 }),
- () => presentations.resize("own", { width: 300, height: 200 }),
- () => presentations.setGeometry("own", { x: 1, y: 2, width: 300, height: 200 }),
- () => presentations.minimize("own", true),
- () => presentations.maximize("own", true),
- () => presentations.setTitle("own", "Changed"),
- () => presentations.setHeader("own", false),
- () => presentations.setFrame("own", false),
- () => presentations.raise("own")
- ]
- for (const mutation of mutations) expect(mutation).toThrow(/window layer does not allow direct/)
+ expect(presentations.read("own", "surface")).toBe(true)
+ await presentations.unfollow("own")
+ await presentations.setGeometry("own", { x: 1, y: 2, width: 300, height: 200 })
+ presentations.setTitle("own", "Changed")
+ presentations.setHeader("own", false)
+ await presentations.setSurface("own", false)
+ expect(presentations.state("own")).toMatchObject({
+ title: "Changed", header: false, surface: false,
+ position: { x: 1, y: 2 }, size: { width: 300, height: 200 }
+ })
await expect(presentations.follow("own")).resolves.toBeUndefined()
- expect(() => presentations.unfollow("own")).toThrow(/window layer cannot unfollow/)
+ await expect(presentations.unfollow("own")).resolves.toBeUndefined()
})
-test("unsupported presentation events remain silent", () => {
+test("unsupported presentation events remain silent", async () => {
const { own, entries, presentations } = fixture("wallpaper")
const received: string[] = []
presentations.observe("own", null, event => received.push(event))
own.window.position = { x: 500, y: 600 }
own.window.title = "Changed"
- expect(() => presentations.follow("own")).toThrow(/wallpaper layer cannot follow/)
+ await expect(presentations.follow("own")).resolves.toBeUndefined()
presentations.reconcile(entries)
expect(received).toEqual([])
diff --git a/tests/window-presentation.test.ts b/tests/window-presentation.test.ts
index 5f2dd97..af8fb92 100644
--- a/tests/window-presentation.test.ts
+++ b/tests/window-presentation.test.ts
@@ -2,7 +2,7 @@ import assert from "node:assert/strict"
import ClientProcessBoundary from "@client/view/components/desktop-host/client-process-boundary"
import { presentationTransaction } from "@client/view/components/desktop-host/window-presentation"
import WindowPresentations, { type WindowPresentationEntry } from "@client/view/components/window-manager/window-presentations"
-import { requireWindowPresentationTransactions } from "@shared/window-layers"
+import { requireWindowPresentationTransactions, windowLayerDefaults } from "@shared/window-layers"
import type { WindowLayer, WindowTransaction } from "@phreshos/core"
import { test } from "vitest"
@@ -17,7 +17,8 @@ test("Window presentation transactions remain independent from Appearance limits
assert.throws(() => presentationTransaction(true, "yes"), /true or false/)
assert.doesNotThrow(() => requireWindowPresentationTransactions("under"))
assert.doesNotThrow(() => requireWindowPresentationTransactions("over"))
- assert.throws(() => requireWindowPresentationTransactions("window"), /does not support/)
+ assert.doesNotThrow(() => requireWindowPresentationTransactions("window"))
+ assert.doesNotThrow(() => requireWindowPresentationTransactions("shell"))
assert.throws(() => requireWindowPresentationTransactions("wallpaper"), /does not support/)
})
@@ -32,10 +33,11 @@ test("each Desktop owns an independent Window presentation", async () => {
const first = new WindowPresentations(entries, identity => byProcess.get(identity) as never ?? null)
const second = new WindowPresentations(entries, identity => byProcess.get(identity) as never ?? null)
- assert.throws(() => first.move("ordinary", { x: 40, y: 50 }), /does not allow direct/)
+ await first.unfollow("ordinary")
+ await first.move("ordinary", { x: 40, y: 50 })
await first.move("overlay", { x: 60, y: 70 })
- assert.deepEqual(first.state("ordinary").position, { x: 0, y: 0 })
+ assert.deepEqual(first.state("ordinary").position, { x: 40, y: 50 })
assert.deepEqual(first.state("overlay").position, { x: 60, y: 70 })
assert.deepEqual(second.state("ordinary").position, { x: 0, y: 0 })
assert.deepEqual(ordinary.window.position, { x: 0, y: 0 })
@@ -44,7 +46,7 @@ test("each Desktop owns an independent Window presentation", async () => {
overlay.window.position = { x: 20, y: 30 }
first.reconcile(entries)
- assert.deepEqual(first.state("ordinary").position, { x: 15, y: 25 })
+ assert.deepEqual(first.state("ordinary").position, { x: 40, y: 50 })
assert.deepEqual(first.state("overlay").position, { x: 60, y: 70 })
await first.follow("overlay")
@@ -77,11 +79,11 @@ test("transactionAndWait semantics resolve on completion and reject on interrupt
await presentations.move("overlay", { x: 70, y: 80 })
await assert.rejects(interrupted, /interrupted/)
- const changingFrame = presentations.setFrame("overlay", { color: "primary", radius: "full" }, request)
- const frameRevision = presentations.projection("overlay").frameAnimation?.revision
- presentations.complete("overlay", "frame", frameRevision!)
- await changingFrame
- assert.deepEqual(presentations.state("overlay").frame, { color: "primary", radius: "full" })
+ const changingSurface = presentations.setSurface("overlay", { color: "primary", radius: "full" }, request)
+ const surfaceRevision = presentations.projection("overlay").surfaceAnimation?.revision
+ presentations.complete("overlay", "surface", surfaceRevision!)
+ await changingSurface
+ assert.deepEqual(presentations.state("overlay").surface, { color: "primary", radius: "full" })
})
test("transaction-capable presentations use the authoritative Window transaction by default", async () => {
@@ -112,8 +114,9 @@ test("transaction-capable presentations use the authoritative Window transaction
await inherited
})
-test("authoritative standard Window geometry uses the Desktop Appearance transaction", async () => {
+test("standard Window presentation uses its authoritative default transaction", async () => {
const ordinary = client("window")
+ ordinary.window.transaction = { duration: 160, easing: "ease-out" }
const entries = new Map([
["ordinary", { identity: "ordinary:0", client: ordinary }]
]) as unknown as ReadonlyMap<string, WindowPresentationEntry>
@@ -121,35 +124,44 @@ test("authoritative standard Window geometry uses the Desktop Appearance transac
ordinary.window.position = { x: 80, y: 90 }
presentations.reconcile(entries)
- assert.equal(presentations.projection("ordinary").geometryAnimation?.transaction, true)
+ assert.deepEqual(presentations.projection("ordinary").geometryAnimation?.transaction, ordinary.window.transaction)
})
-test("presentation geometry events expose each applied representation change", () => {
+test("standard Windows default to the shared Appearance transaction", () => {
+ assert.equal(windowLayerDefaults("window").transaction, true)
+ assert.equal(windowLayerDefaults("under").transaction, false)
+ assert.equal(windowLayerDefaults("over").transaction, false)
+ assert.equal(windowLayerDefaults("shell").transaction, false)
+})
+
+test("presentation state and events do not expose renderer measurements", () => {
const ordinary = client("window")
const entries = new Map([
["ordinary", { identity: "ordinary:0", client: ordinary }]
]) as unknown as ReadonlyMap<string, WindowPresentationEntry>
const presentations = new WindowPresentations(entries, () => ordinary as never)
const moves: unknown[] = []
- let changed: () => void = () => undefined
- let geometry = { x: 0, y: 0, width: 300, height: 200 }
presentations.observe("ordinary", "move", (_event, value) => moves.push(value))
presentations.represent("ordinary", {
- read: () => geometry,
- present: value => { geometry = value },
- begin: () => geometry,
+ read: () => ({ x: 0, y: 0, width: 1200, height: 800 }),
+ present() {},
+ begin: () => null,
finish() {},
- cancel() {},
- listen: listener => { changed = listener; return () => undefined }
+ cancel() {}
})
- geometry = { ...geometry, x: 10 }
- changed()
- geometry = { ...geometry, x: 20 }
- changed()
+ // A maximized renderer may occupy the viewport, but those measurements are
+ // not presentation values and cannot overwrite the retained geometry.
+ ordinary.window.maximized = true
+ presentations.reconcile(entries)
+ assert.deepEqual(presentations.state("ordinary").position, { x: 0, y: 0 })
+ assert.deepEqual(presentations.state("ordinary").size, { width: 300, height: 200 })
+ assert.deepEqual(moves, [])
- assert.deepEqual(moves, [{ x: 10, y: 0 }, { x: 20, y: 0 }])
+ ordinary.window.position = { x: 20, y: 30 }
+ presentations.reconcile(entries)
+ assert.deepEqual(moves, [{ x: 20, y: 30 }])
})
test("a Client boundary begins each document from authoritative presentation state without resetting on release", async () => {
@@ -175,7 +187,7 @@ function client(layer: WindowLayer) {
window: {
title: "Window",
header: layer === "window",
- frame: layer === "window",
+ surface: layer === "window",
transaction: false as WindowTransaction,
position: { x: 0, y: 0 },
size: { width: 300, height: 200 },