# The Desktop Service

---

# GXWI Service

_Peios / Using Peios / The Desktop Service_

> Understand how GXWI connects browser clients to Peios desktop sessions.

The Graphical Extensible Web Interface (GXWI) provides browser access to
Peios desktop sessions. It handles TLS,
authentication conversations, session connections, and installation or setup
overlays. The compositor and desktop shell are separate programs.

## Service and desktop responsibilities

The programs divide responsibility as follows:

| Program | Responsibility |
|---|---|
| `gxwid` | Machine identity, privileged setup, and session lifetime |
| `gxwi-server` | Restricted network-facing HTTP and TLS worker |
| Configured compositor | Desktop presentation and application surfaces |
| Desktop shell | Panels, launchers, settings, and other desktop tools |

Fenestra is a compositor. Fenesh is a desktop shell. GXWI does not require
those names in its protocol; the configured compositor determines the
session program. `gxwi-hello` provides a diagnostic session when no
compositor is configured.

## Authentication and authority

GXWI asks authd to authenticate an account for a Remote Interactive logon.
The resulting access token controls the desktop job. Applications inherit
session authority unless another explicit mechanism changes it.

Rendering a button does not grant permission to perform its action. The
service or kernel handling an operation still checks access. A disabled
button is a usability choice, not an authorization boundary.

## Persistent sessions

A session can continue after browser connections disappear. A later
successful sign-in can reconnect to the same running session. Session
persistence is not disk persistence: restarting a compositor or ending its
job loses process state that applications have not saved.

The service keeps normal sessions separate from
[machine overlays](/peios/using-peios/desktop-service/overlays.md).

---

# Configuring the GXWI Service

_Peios / Using Peios / The Desktop Service_

> Set the listener, compositor, and public sign-in labels with the registry.

Configure GXWI through `Machine\Software\GXWI`. The registry's access
checks determine who can change these values. The complete types,
defaults, and validation rules are in `regman` for that path.

## Before you start

Use an account with write access to the required registry values. Keep a
trusted console available when changing remote access. A failed listener
or compositor change can prevent browser access.

## Change the listener

1. Set `Listen` to the numeric address and port to bind, such as
   `127.0.0.1:7780` for local access. Hostnames are not accepted.
2. If other machines need access, configure the corresponding network
   policy under `Machine\System\Network\Rules\Flow`.
3. Restart the `gxwid` service to apply the listener change.
4. Verify that the configured address accepts HTTPS and presents the
   expected certificate before entering credentials.

Changing the listener does not add a name or address to the certificate.
Verify both reachability and certificate identity.

## Choose the compositor

1. Set `Compositor` to the absolute path of the session program.
2. Start a separate test session to verify that the program can start and
   serve a desktop.
3. End and reopen existing sessions when they need the changed compositor.

The value applies to sessions created after the change. A missing executable
fails session startup; GXWI does not validate program availability when the
registry value is written.

Anyone who can change `Compositor` chooses a program that runs with the
authority of users who start sessions. Protect this value as carefully as
the executable itself.

## Set public labels

Under `Machine\Software\GXWI\Logon`, `Name` supplies a machine label and
`Notice` supplies paragraphs displayed before authentication. Restart
`gxwid` to apply changes. Both are plain text and visible to anyone who
can reach the service. Do not put secrets in them.

---

# Machine Overlays

_Peios / Using Peios / The Desktop Service_

> Understand shared setup programs, their account authority, and failure behavior.

A GXWI overlay replaces normal browser sign-in and desktop access with one
shared program. Installation and first-boot setup can use this mechanism.
An overlay is separate from an application overlay surface inside a desktop.

## Shared authority

`OverlaySession` under `Machine\Software\GXWI` names the program.
`OverlayUsername` names its account. GXWI requests a credential-free
Remote Interactive logon for that account. authd must permit that logon;
GXWI does not bypass an account's credential requirement.

Everyone who reaches the service shares the overlay program and its
account authority. Choose an account with only the rights the setup program
needs. Browser visitors do not authenticate individually before using it.

Write access to either registry value therefore controls a public program
and the authority it receives. Protect both values and the executable.

## Activation and failure

GXWI watches the configuration. Setting an overlay starts it. Changing its
program or account replaces it. Removing `OverlaySession` restores normal
sign-in and access to existing sessions.

Normal desktop sessions continue behind the overlay but cannot be reached
through the browser while it is active. The overlay has its own job,
socket, and runtime directory.

If a configured overlay cannot start, GXWI shows a not-ready page and
retries. The delay increases from 1 second to at most 30 seconds. It does
not expose normal sign-in as a fallback. Read the service log to identify
an unavailable program, missing account, or refused credential-free logon.

An invalidly typed or malformed registry value is rejected according to
the setting's validation rules. Read `regman` for the distinction between
invalid configuration and a valid program path that cannot run.

---

# Reconnection and the Waiting Page

_Peios / Using Peios / The Desktop Service_

> Distinguish browser reconnection, session lifetime, and the cached waiting page.

A browser connection and a desktop session have different lifetimes.
Losing network access does not save or end applications. Reconnection works
only while the relevant service, session, and application state remain
available.

## The waiting page

GXWI supplies a service worker at `/.gxwi/sw.js`. When browser policy
permits registration, it caches the waiting page and that page's assets.
It does not cache ordinary application content as an offline desktop.
Requests marked `cache: "no-store"` bypass its interception. Cache cleanup
removes only obsolete GXWI waiting-page caches, preserving unrelated caches.

A failed navigation or a navigation taking more than 10 seconds can show
the waiting page. A navigation timeout aborts the underlying fetch rather
than leaving it running. Caller cancellation remains cancellation.
The page checks for the machine every 1.5 seconds and
returns when it can reach it. A browser that cannot register the service
worker can show its own network error instead.

Trust the machine's certificate through the browser's supported controls.
An exception at a certificate warning does not guarantee that the service
worker can run.

## Worker and session recovery

`gxwid` retains the listening socket when `gxwi-server` restarts. This
allows connections to queue while the worker is unavailable, within the
operating system's backlog limits. It does not guarantee that every client
request survives a restart.

The privileged daemon retains session jobs independently of the network
worker. A browser might need to authenticate again after worker state is
lost. Reconnecting to a surviving session differs from restoring a stopped
application.

## Diagnose a failed connection

Check the failure in order:

1. Confirm that the machine is reachable at the configured address and port.
2. Verify the certificate through a trusted console.
3. Check the `gxwid` service log for worker, authentication, or compositor
   startup failures.
4. Check whether a machine overlay intentionally hides normal sessions.
5. Verify that the compositor and application processes remain running.

---

# Certificate Identity and Renewal

_Peios / Using Peios / The Desktop Service_

> Understand certificate storage, renewal, and changes to browser trust.

GXWI keeps a private key and a certificate in `/var/state/gxwi`. The private
key identifies the machine cryptographically. A renewed certificate uses
the same key but has a different fingerprint.

## Stored identity

The identity files have different access requirements:

| File | Purpose | Intended read access |
|---|---|---|
| `key.pem` | Private ECDSA P-256 key | SYSTEM |
| `certificate.pem` | Public certificate | Everyone |
| `certificate.sha256` | Public SHA-256 fingerprint | Everyone |

Protect the private key when backing up or restoring machine state. Sharing
one key between machines also shares their cryptographic identity. GXWI
does not silently replace an unreadable key; startup fails instead.

## Renewal

A generated certificate starts 1 day before creation and expires 1 year
after creation. GXWI checks certificates at startup, every 24 hours, and
on service reload. It renews a certificate with fewer than 30 days left.
It also replaces certificates outside the accepted lifetime policy.

Renewal uses the machine's hostname at that time. Renaming the machine does
not itself renew an otherwise acceptable certificate.

An authorized operator can request the reload check with:

```sh
svctl reload gxwid
```

This requests the normal check; it does not force renewal of an otherwise
acceptable certificate or end existing desktop sessions.

Existing TLS connections continue. Subsequent connections receive the
replacement certificate. A browser that trusted the preceding certificate
can require verification and import again. See
[Verifying the Machine's Certificate](/peios/signing-in/the-certificate.md).

## Renewal records

The event `gxwid.certificate.renewed` records the preceding fingerprint,
the replacement fingerprint, and the certificate subject. Consult
`evman gxwid.certificate.renewed` for its fields. Initial certificate
creation is distinct from renewal.

A renewal record identifies the certificate change; it does not prove that
a browser has imported the replacement. Use the trusted fingerprint file
when verifying a connection.

## Browser policy

GXWI does not send a `Strict-Transport-Security` header. HTTPS remains the
only transport for desktop content. Browser name, expiry, and trust checks
still apply.

---

# Configuring the Session Shell

_Peios / Using Peios / The Desktop Service_

> Choose shell programs and understand their permissions and restart policy.

The machine's shell setting controls which programs Fenestra starts for
every desktop session. Shell programs receive desktop-wide capabilities,
so choose trusted programs and preserve an independent administrative way
to recover a broken configuration.

## Choose shell programs

Before changing the configuration, install the intended programs and
confirm that your account can write the machine's Fenestra settings.
Desktop Settings provides an **Advanced** section when Fenesh is installed.

To change the shell with the Registry Editor:

1. Open `Machine\Software\Fenestra`.
2. Set `Shell` to a `REG_MULTI_SZ` containing the absolute path of each
   shell program. Use a separate entry for each program.
3. Start another desktop session and check that the expected controls
   appear. Existing sessions keep their shell selection.

The list accepts up to 16 programs. Entries are executable paths, not
commands with arguments. One invalid relative path invalidates the whole
value. An absent, unreadable, or mistyped value selects the companion
`fenestra-taskbar` and `fenestra-launcher` beside the compositor executable.

An explicitly empty list starts no shell. It does not restore the default.
Delete the value to restore the fallback programs. A valid path whose
program cannot start is reported; Fenestra does not replace that entry with
a fallback program.

## Understand the authority granted

Configured shell processes receive the surface list and can ask Fenestra
to start programs, close another application's surfaces, or end the
session. Their browser surfaces can control focus, overlays, and global
shortcuts. Shell programs retain the session account's operating-system
permissions; their desktop role does not make them administrators.

Fenestra identifies a shell connection from a tracked child process and
kernel-reported peer identity. A surface title, role, or application name
does not grant that role. Protect write access to the machine's `Shell`
value as carefully as access to the selected executables.

## Restart behavior

Fenestra restarts a shell program after it exits, with a 1-second delay.
It stops retrying after three consecutive runs shorter than 5 seconds.
A run lasting at least 5 seconds resets that consecutive-failure count.
A failure to start the executable stops that program's supervisor without
retrying.

Correct the program or configuration, then start another desktop session
after the supervisor has stopped. Configuration changes are read at
session startup rather than while a supervisor is running.

## Icons and keyboard shortcuts

Fenestra reads the shared icon-theme chain at session startup and serves
icons for desktop pages. Changes to the chain apply to another session.
The base theme remains the final fallback. The detailed icon contract
belongs to the Peios General System Standards, rather than this guide.

Keyboard shortcuts use personal overrides, then machine overrides, then
built-in defaults. An empty value turns off an action's shortcut; removing
the value restores its fallback. Fenestra watches shortcuts while running.
The installed registry reference lists the actions and accepted values.
