Commit graph

250 commits

Author SHA1 Message Date
80d7451abf
fix(appd): close a running session as a user close would before terminating it
TERMINATE_APP, which the taskbar sends, killed the session's processes
at once, so an application had no chance to finish, for example to
save. A running session is now asked to close through the compositor
(AppCloseRequest, which sends xdg_toplevel close to its windows) and
the app shell is given five seconds to exit by itself before what
remains is terminated. The stop reason records whether the app closed
or was terminated after the timeout. TERMINATE_APP replies stopping and
the session stays registered until it settles; a starting session is
stopped at once, and appd shutting down terminates sessions without a
close.

check_counter.py requires the compositor to ask the session's window
to close and the app shell to exit with status 0 on the close; a unit
test requires an app that ignores the close to be terminated after the
timeout and not before.
2026-10-09 16:36:29 +00:00
102c20d2b4
fix(shells): release the rendering context and window before the display goes away
The software rendering path (softbuffer) and the EGL path keep their
own Wayland objects on winit's display, so dropping the rendering
context after the event loop could destroy proxies on a disconnected
display just like the shell client did. Both hosts now release the
rendering context and the window in winit's exiting handler as well.

The compositor records the keys whose press a shortcut took and takes
only those releases, so no client sees a release without its press or
keeps a key pressed. check_activation.py watches the panel for six
seconds after Alt+F4 instead of sampling it once.
2026-10-09 16:29:22 +00:00
828984be4b
fix(compositor): close the focused window on Alt+F4 and let the shells exit without crashing
There was no compositor-owned way to close an application window. Alt+F4
is now taken by the compositor: it sends xdg_toplevel close to the
focused application window, never the panel, and the key does not reach
the client.

Closing exposed a crash in both Servo hosts: their shell-protocol
client, created on winit's Wayland display, was dropped after that
display was torn down, so wl_proxy_destroy touched freed memory and
the process ended with SIGSEGV. The hosts now release Servo and the
shell client in winit's exiting handler, while the display is alive.

check_activation.py closes the focused application with Alt+F4 and
requires its session to stop with the app shell exiting with status 0,
the window to disappear, and Alt+F4 with the panel focused to leave
the panel in place.
2026-10-09 16:22:59 +00:00
c8bae1cc4d
fix(compositor): hand focus on when a registering panel is lowered
A shell restarted while applications run took keyboard focus before it
registered as the panel and kept it after being lowered beneath them;
the window in front now gets it. Without an output, windows are still
reordered, so a window that maps without taking focus does not cover
the one in front.
2026-10-09 16:14:31 +00:00
cdc4a9e15d
fix(compositor): keep the stacking order through layout changes
Laying windows out re-mapped every application window, which smithay
puts on top, so a session mapping another window, an exclusive zone
change or an output resize pushed the shell's home back under the
applications while it kept keyboard focus. Placement now re-maps every
window in its current order. Panels are lowered only when they
register, and a window that maps without taking focus goes beneath the
window in front, so a session cannot cover the shell's home or another
application by creating windows. A panel's zweft window that is
destroyed while its surface lives also removes its window slot.
2026-10-09 16:11:20 +00:00
8399914dfa
fix(compositor): show the shell's home on a panel click and release a dead panel's strip
With applications filling the work area, the system UI's launcher, drawn
in the panel beneath them, could not be seen while any application was
open. Clicking the panel now brings it to the front as the shell's home
until an application is activated again.

A panel that is destroyed, or whose client goes away, releases its
reserved strip and the applications are laid out again; dead panels no
longer count toward the work area, so a restarted shell does not reserve
the strip twice. A work area is never configured with a zero size. The
zweft_shell configure for an application window, at creation and in
reply to set_geometry, reports the work area the layout gives it, and a
panel's reports the output.

check_activation.py now clicks the taskbar strip, requires the panel to
cover both applications, and activates one back.
2026-10-09 16:06:19 +00:00
5253eaf251
fix(compositor): reserve the taskbar strip and lay app windows out in the work area
Application windows opened at the client's default size at the origin,
so one as large as the output hid the taskbar with no way back.

zweft_shell_window_v1 version 3 adds set_exclusive_zone: a panel
reserves a strip along an output edge, and other windows get the new
invalid_exclusive_zone error. weft-servo-shell reserves its 48-pixel
taskbar at the bottom (TASKBAR_HEIGHT, matching --taskbar-height in the
system UI). The compositor computes the work area as the output less the
reserved strips and configures every application window to fill it,
again when the output or a reservation changes.

The desktop harness now uses a 1400x900 X screen so the nested
compositor's whole 1280x800 output is captured. check_activation.py
requires both applications to fill the work area and end at the
reserved strip; check_notes.py finds the Discard button from the window's
right edge and check_confinement.py samples its probes from the measured
page instead of a fixed 800x600 window.
2026-10-09 16:00:38 +00:00
16af8d2a8c
fix(compositor): give a session focus on map only once in its lifetime
Unmapping a closed window made a session with no mapped window count
as new again, so destroying and recreating its only window took
keyboard focus from the application the user had activated. The
compositor now remembers which sessions already received focus on map
until the session ends.
2026-10-09 15:45:52 +00:00
65c02231a0
fix(compositor): restore focus when a window closes and keep later windows from taking it
When the focused window closed, keys went to a dead surface until the
next click; the topmost remaining application window, or the panel,
now gets focus. Only a session's first window takes focus when it
maps, so a client cannot take keystrokes meant for another application
by creating windows. A panel is fitted and kept beneath however the
shell orders its requests, and focusing the panel clears the
applications' activated state. ACTIVATE_APP is refused while the
compositor is not connected rather than queued.

check_activation.py now also ends the focused application and checks
that keys reach the remaining one.
2026-10-09 15:42:42 +00:00
aa67e7f190
fix(compositor): own stacking and focus, and activate app windows on request
The system shell's panel was an ordinary toplevel at winit's default
size, stacked by map order with the applications, and clicking or the
taskbar could never bring an application back to the front.

The compositor now sizes the panel to the output and keeps it beneath
every application window. A newly mapped, clicked or activated
application window is raised, marked activated and given keyboard
focus. weft-appd accepts ACTIVATE_APP for a running session and asks
the compositor to activate that session's window (AppFocusRequest),
and the system UI's taskbar entries send it when chosen.

check_activation.py runs the system shell with a solid panel page and
two test applications: the panel fills the output beneath them, each
launch comes to the front with keyboard focus, ACTIVATE_APP switches
between the sessions with focus, and activating a session that is not
running is refused.
2026-10-09 15:36:55 +00:00
db042fcb5c
fix(appd): keep the previous session when shutdown interrupts its restore
The session file is read and removed at startup, and restoring now runs
in its own task, so a shutdown during the restore would have saved only
the apps launched so far. Until the restore finishes, a shutdown stops
it and saves the restored list unchanged.
2026-10-09 15:25:57 +00:00
2e27adc4f6
fix(compositor): retry queued appd frames until sent and restore sessions in the background
Frames queued for a slow appd were sent only on later traffic, so the
end of a burst could wait indefinitely. A timer now retries the flush
every 20 ms, armed only while frames are queued. weft-appd restores the
previous session in its own task, so waiting for the compositor no
longer delays clients or shutdown, and the security docs describe the
launch refusal and the backlog limit exactly.
2026-10-09 15:23:41 +00:00
d6a2f94a1d
fix(compositor): buffer appd-bound frames and ignore stale session disconnects
A full socket buffer toward a stalled appd closed the connection and
with it every app. Frames for appd are now queued whole and flushed on
each send and read, and only a backlog beyond the frame limit or a
write error ends the connection. A disconnect report is applied only
when it comes from the session's current client, so a client closed
with an earlier appd cannot remove the mapping of a new session that
reused its ID. A failure to watch a new appd connection no longer
leaves the compositor refusing every later one.

weft-appd refuses a launch with 503 before anything starts while the
compositor is not connected, and waits up to 10 s for the connection
before restoring the previous session.
2026-10-09 15:20:29 +00:00
4c778330a3
fix(compositor): keep shell-level interfaces from sessions and harden the appd connection
Session clients could still create layer-shell surfaces, including
full-screen overlays with exclusive keyboard input, and bind the input
method, which bypassed the refusal of shell roles. Both globals are now
hidden from clients bound to a session.

The compositor IPC connection is tracked by its read source, so a write
error can no longer let a second peer feed the same buffers; a failed
write shuts the connection down. An undecodable or oversized frame ends
the connection, since descriptors could otherwise pair with the wrong
messages, and the descriptor limit counts only descriptors no message
claims, so a burst of launches is not taken for abuse. When appd's
connection ends, the compositor closes the clients of the sessions it
attached.

weft-appd notices when the compositor closes the connection, resends a
message whose write failed after reconnecting, and refuses a launch
while the compositor is not connected instead of starting an app shell
that can never connect.
2026-10-09 15:15:01 +00:00
7cf8639ae3
fix(compositor): bind each app session's Wayland client to its session through appd
The compositor stored appd's (pid, session) announcements and never used
them, so no surface could be attributed to a session and any client
could claim any app ID or the panel role.

weft-appd now creates a connected socket pair for each session, gives
the app shell one end as standard input with WAYLAND_SOCKET=0 and no
WAYLAND_DISPLAY, and sends the other end to the compositor with the
session and app ID over the compositor IPC socket (SCM_RIGHTS). The
compositor inserts it as a client bound to that session: holding the
connection is the session's identity. A session's zweft_shell windows
carry its app ID, the panel and overlay roles are refused to sessions
with a new role_not_permitted error, the session's first toplevel is
reported to appd, an ended session's client is closed, and a client's
disconnection is reported. The compositor accepts one appd connection
at a time.

The counter desktop check now requires the compositor to bind the app's
client to its session and to close it when the session is terminated.
2026-10-09 15:07:33 +00:00
5c82b540e6
Merge fix/resolve-verified-package: resolve each launch to one package and fail closed on images (#16)
weft-appd resolves each launch once: a verified image in any store wins over a directory install and must mount or the launch is refused, with no fallback to a mutable directory. The manifest must declare the requested ID and its entries must be contained regular files without links. weft-runtime receives --module and weft-app-shell --ui; neither searches the stores. Grants come from the same manifest and the mount belongs to the session. The manifest parser and image file names are shared through weft-ipc-types with weft-pack.
2026-10-09 14:53:49 +02:00
cad8c016d6
Merge remote-tracking branch 'origin/main' into fix/resolve-verified-package 2026-10-09 12:50:31 +00:00
c0fdca18b6
Merge fix/confine-app-renderer: confine application pages to their UI files and bridge (#15)
weft-app-shell checks every resource load: files inside the UI directory, also after resolving links, inline data: and blob: resources, about:blank and the session bridge are allowed; other files and network destinations, redirects and loads not tied to the webview fail before a request leaves the renderer. The Servo pin moves to e5d9a51, which keeps pending classic scripts traced until they run and withholds navigator.servo from about:blank and about:srcdoc documents.
2026-10-09 14:50:24 +02:00
ba82535ae2
Merge remote-tracking branch 'origin/main' into fix/confine-app-renderer 2026-10-09 12:33:46 +00:00
8214c12d7e
Merge fix/session-owned-ipc-relay: make the IPC relay part of the session it serves (#14)
The session supervisor opens and owns each session's IPC relay; every exit path stops the relay task, removes its socket and unregisters its sender. A session ends when its IPC connection closes. IPC_FORWARD never waits on a component and reports an error for a missing relay or a full queue. appd's runtime directory is created mode 0700 and the relay socket 0600.
2026-10-09 14:33:28 +02:00
969f719d2d
Merge remote-tracking branch 'origin/main' into fix/session-owned-ipc-relay 2026-10-09 12:18:43 +00:00
84930b13d8
Merge fix/separate-app-data: keep app data apart from installed packages (#13)
App data lives in $XDG_DATA_HOME/weft/app-data/<id>, private to the user, and is moved from the earlier layout in one no-replace rename; conflicting or cross-filesystem data is never moved or deleted. weft-pack never removes a data directory with a package. Notes stores text exactly, refuses saves edited from a stale revision and writes through a locked, synced staging file.
2026-10-09 14:18:28 +02:00
1f58a7be11
Merge remote-tracking branch 'origin/main' into fix/separate-app-data 2026-10-09 11:57:17 +00:00
744acc8164
Merge fix/enforce-session-grants: enforce effective capability grants per session (#12)
weft-appd derives each session's grants once, before the session exists, from one shared capability vocabulary and refuses packages it cannot satisfy. weft-runtime receives them as --grant and --preopen arguments, preopens read-only directories read-only and checks every notifications, clipboard and fetch call. Fetch is limited to http and https to granted hosts, standard methods, no Host or hop-by-hop headers, unfollowed redirects and bounded time and size.
2026-10-09 13:56:57 +02:00
6f2f566fe4
Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package
# Conflicts:
#	crates/weft-runtime/src/main.rs
2026-10-09 11:43:01 +00:00
b45fe27e9b
Merge remote-tracking branch 'origin/fix/session-owned-ipc-relay' into fix/confine-app-renderer 2026-10-09 11:37:44 +00:00
cda9c14426
Merge remote-tracking branch 'origin/fix/separate-app-data' into fix/session-owned-ipc-relay 2026-10-09 11:37:17 +00:00
b17b74f310
Merge remote-tracking branch 'origin/fix/enforce-session-grants' into fix/separate-app-data 2026-10-09 11:36:27 +00:00
12e4c1d91a
Merge remote-tracking branch 'origin/main' into fix/enforce-session-grants
# Conflicts:
#	.gitignore
#	README.md
#	docs/building.md
2026-10-09 11:30:01 +00:00
0ab429b2ea
Merge fix/authorize-session-messages: authorize WebSocket clients by role and session (#11)
weft-appd's WebSocket requires HELLO within 5 seconds. A system role authenticated with appd.systoken manages sessions; an app role authenticated with a per-session bridge token exchanges APP_MESSAGE envelopes with its own session only. The Servo hosts hand credentials only to their own top-level documents and deny navigation outside them.
2026-10-09 13:28:43 +02:00
8eed654be7
fix(appd): let no directory shadow an image, and refuse linked roots
- A verified image in any store now takes precedence over a directory
  install in any store, so a user's directory cannot shadow a system
  image of the same app.
- The package root must be a directory and wapp.toml a regular file,
  not links to content outside the root the entries are checked in.
- Incomplete or malformed image metadata is refused with 403; a
  missing helper, a failed mount or an unreadable manifest with 500.
- A supervisor test records the arguments of both children and
  requires the resolved component and UI document.

The documentation states that the root hash is read from the store
and not yet authenticated.
2026-10-09 11:08:41 +00:00
04cde8901c
Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package 2026-10-09 10:29:32 +00:00
fecf4c5b55
fix(app-shell): report a UI path that is not absolute 2026-10-09 10:29:32 +00:00
1641bf31a8
build(servo): trace pending classic scripts instead of rooting them
Servo e5d9a51 replaces the root that kept a pending classic script
alive with tracing through the document that holds it. A root also
kept the script's global alive, so a document dropped while a script
was pending would leak. The crash the root fixed stays fixed.
2026-10-09 10:29:24 +00:00
e2f9746fb5
Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package
# Conflicts:
#	docs/architecture.md
2026-10-09 10:18:47 +00:00
d056045ad8
test(appd): launch complete packages in the supervisor tests
Launch tests wrote manifests without names, versions or entries, which
the shared parser rejects. They now write complete packages.
2026-10-09 10:18:36 +00:00
687439a2a3
test(frame): make the worker and srcdoc confinement probes observable
Servo refuses worker scripts for file: pages, blob: ones included, so
the worker probe now requires only that no worker fetch succeeds, and
the worker is built from the page itself. The srcdoc frame reports to a
listener installed before the frame exists. Band failures and requests
that reached the servers are reported together, so a run without the
policy shows every leak.
2026-10-09 10:16:22 +00:00
2148ffc8ae
fix(appd): resolve each launch to one package and fail closed on images
The runtime, the app shell and grant derivation each searched the
package stores and parsed wapp.toml on their own, so they could use
different roots; the runtime ignored [runtime].module, the image loader
looked for companion files the builder never wrote, and a failed image
mount fell back to the mutable directory install.

weft-appd now resolves a launch once: a verified image wins over a
directory in the same store, and when any image file exists the image
must mount or the launch is refused. The manifest must declare the
requested ID, and both entries must be plain relative paths to regular
files without links. The runtime receives --module and the app shell
--ui; neither looks for the package. Grants come from the same
manifest, and the mount belongs to the session.

The manifest parser and the image file names move to weft-ipc-types,
shared with weft-pack, whose check now applies the same entry rules.
Mapper devices are named after their per-launch mountpoint, so
concurrent sessions no longer collide.
2026-10-09 10:03:40 +00:00
16a184ad9e
fix(app-shell): close the remaining paths out of the application page
Review of the renderer policy found loads it did not see or judged
wrongly:

- Loads Servo does not attribute to the webview, such as
  navigator.sendBeacon(), reached the network. They are all refused.
- On a redirect Servo reports the first URL again, so every redirect
  is refused.
- A symbolic link inside the UI directory led anywhere on disk; file
  loads are checked again after resolving links.
- Only about:blank is allowed among about: URLs.

The Servo pin moves to 5d90f51, which keeps compiled classic scripts
rooted until they run (a parser-blocking script waiting for a failed
stylesheet import crashed the content process) and withholds
navigator.servo from about:blank and about:srcdoc documents.

The confinement check gains probes for links, workers, beacons,
imports, fonts and srcdoc frames, and its WebSocket server completes
the handshake. The slow stylesheet's delay now starts when the host
first tries to open it.
2026-10-09 10:03:30 +00:00
d60152f443
fix(app-shell): confine application pages to their UI files and bridge
An application page could load any local file through file: URLs and
reach any network destination with images, fetch, XHR or WebSockets,
bypassing the component's fetch grants. The shell now checks every
resource load: files inside the UI directory, inline data:, blob: and
about: resources and the session bridge are allowed; anything else
fails with a network error before a request leaves the renderer.

tests/frame/check_confinement.py probes each path on the nested desktop
and requires that no HTTP request or TCP connection reaches the host.
The frame check's slow stylesheet becomes a file next to the page held
back with a file lease, so it stays inside the confined scope.
2026-10-09 09:39:37 +00:00
010573eb16
fix(appd): create the runtime directory private wherever it is made
appd created $XDG_RUNTIME_DIR/weft with the umask mode when it opened
its own socket, wrote its port or system token, or opened a portal
socket, so the 0700 mode requested for session sockets never applied.
All of them now use one helper that creates the directory 0700 and
tightens an existing one.
2026-10-09 09:27:28 +00:00
ec00531c75
test(appd): give each test process its own runtime directory
Session sockets are named by session ID and every test registry starts
at 1, so test processes running at the same time shared one socket path
in the common test runtime directory and broke each other's sessions.
Each test process now uses its own directory under the system temporary
directory, and directories of ended test processes are removed. The
test of a closed IPC connection connects to the socket itself instead
of relying on python3 in a child script.

A session whose component closes its IPC connection during startup now
stops before it is reported ready. The weft runtime directory is
created with mode 0700, and the socket is removed if its permissions
cannot be restricted.
2026-10-09 09:24:49 +00:00
67bce2fb22
Merge branch 'main' into fix/authorize-session-messages 2026-10-09 09:19:26 +00:00
5174a58d47
Merge pull request #9: report sessions running only after the UI host is ready
Sessions become Running only after token-authenticated READY from the runtime and the app shell, and every exit path shares one teardown.
2026-10-09 11:19:16 +02:00
818a831895
Merge pull request #6: stop reporting readiness without an engine
A runtime built without wasmtime-runtime now exits with an error instead of printing READY; its env-dependent tests are serialised.
2026-10-09 11:19:13 +02:00
26bd5b5079
fix(appd): end sessions whose IPC connection closes and never block on it
IPC_FORWARD held the registry lock while awaiting a send to the
component; with a full queue it stalled appd, and once the relay was
closed it locked the registry again and deadlocked. It now sends without
waiting and reports an error when the session has no relay or its queue
is full.

A relay whose component disconnected left the session running with no
way to exchange messages. The session now stops when its IPC connection
closes. The relay releases its task and socket when dropped, so a
cancelled supervisor leaks neither, and the socket is created with mode
0600.

New tests fail against the previous code: IPC_FORWARD against a missing
relay and a full queue must answer at once, and a runtime that closes
its IPC connection while still running must end its session. The test
runtime directory lives under target/ instead of one directory per run.
2026-10-09 09:18:39 +00:00
ac6559a814
Merge pull request #10: add the stability blueprint, engineering contract and contributor toolkit
BLUEPRINT.md defines the 0.1.0 target; AGENTS.md and .agents/ give the contribution procedures and checks.
2026-10-09 11:14:20 +02:00
d9d9d24205
fix(appd): make the IPC relay part of the session it serves
dispatch opened each session's IPC socket and registered its sender
before the supervisor existed, and nothing released them: a relay whose
runtime never connected waited forever with its socket file in place,
and every stopped session left its sender registered, so app messages
for it were still accepted and queued.

The supervisor now opens the relay after its early checks, and the
session owns it: every exit path stops the relay task, removes the
socket and unregisters the sender. A session whose socket cannot be
opened does not start. The relay accepts a single connection.

A dispatch-level test launches a package whose runtime reports ready
and exits without connecting; it requires the stopped session to leave
no sender and no socket, and fails against the previous code. The
Counter and Notes checks pass end to end.
2026-10-09 09:11:35 +00:00
481495d929
fix(notes): show loading status and check the editor after a failed load
The first load showed an empty status while the editor was read-only;
it now says loading. check_notes.py also types and saves after a failed
load and requires the stored file to stay unchanged.
2026-10-09 09:07:27 +00:00
c1ea57fbef
fix(notes): keep Discard usable after a failed load
Discard waited for a stored revision, so after a load failed (stored
notes not valid UTF-8, a read error, a lost reply) the editor stayed
read-only with no way to reload. The page now tracks the outstanding
load itself: Discard is refused only while a load or save is in flight,
a load error or a ten-second timeout ends the load, and Discard retries.

A save acknowledgement arriving after its timeout and after Discard had
started a reload replaced the saved state while the editor still showed
older text, so the next save would silently revert it. Acknowledgements
are ignored while a load is outstanding, and a reload forgets the last
save.

The component removes a lock whose token could not be written and
cleans up renamed stale locks with the abandoned staging files.
check_notes.py adds a failed load followed by a repaired file and
Discard; the previous package stays read-only there and fails.
2026-10-09 09:05:25 +00:00