Commit graph

72 commits

Author SHA1 Message Date
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
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
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
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
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
1928ffb661
fix(pack): never delete a data directory that was not moved
weft-pack uninstall moved earlier app data only when the package
manifest could be read and declared an app-data capability, and only
when the store path was spelled exactly as the user store; otherwise it
removed the package directory with the data in it. A directory left
holding only data by an earlier weft-appd, which has no manifest, was
deleted that way.

A data directory is now never removed with a package. In the user
store, recognised by its real location rather than its spelling, it is
moved when the package declares app data or its manifest cannot be
read; in every other case uninstall stops and changes nothing. Tests
cover a directory holding only data, a store reached through '..', a
symbolically linked home, an app without the capability and another
store.

weft-appd reports both locations when a move fails with an I/O error and
creates the data directory with mode 0700 instead of tightening it
afterwards.
2026-10-09 09:01:28 +00:00
a508f1ebe4
fix(appd): move only real app data and never replace a directory
weft-pack treated any top-level data directory in a package as app
data from the earlier layout, in every store and for every app: a
package shipping data/ lost that content to the app data directory on
uninstall and could then no longer be uninstalled. Data is now moved
only from ~/.local/share/weft/apps/<id>/data, the only place earlier
versions wrote it, and only for packages declaring an app-data
capability; packages may no longer contain a top-level data entry.

The move left an empty package directory behind, which then blocked
weft-pack install although nothing was listed; an emptied package
directory is now removed, and install accepts an empty leftover. The
rename uses RENAME_NOREPLACE, so a target created after the check is
reported as a conflict instead of being replaced, and a move across
filesystems is refused with a message naming both locations instead of
a bare OS error. Directories moved by weft-pack are made private too,
and a symbolic link at the target is refused rather than followed.

The system UI now shows launch refusals, which it only logged, and the
weft-appd unit may write under ~/.local/share/weft, which
ProtectSystem=strict made read-only. check_app_data.py also types into
Notes after the move and requires the save to reach the moved file, and
checks that no empty package directory remains.
2026-10-09 08:52:09 +00:00
cc69c048c0
fix(appd): keep app data apart from installed packages
App data lived in ~/.local/share/weft/apps/<id>/data, inside the user
package store under the installed package directory. Uninstalling a
package deleted its data, and launching a package installed elsewhere
created that directory, after which installing the package for the user
failed because its directory already existed.

App data now lives in $XDG_DATA_HOME/weft/app-data/<id>, one shared
rule in weft_ipc_types::package, and is made private (0700) on every
launch. Data in the earlier location is moved there in one rename on the
first launch with an app-data capability, and by weft-pack before it
uninstalls a package or installs over a directory holding only data. If
both locations hold data, nothing is moved: the launch is refused with
409 and weft-pack stops, so neither copy is lost or merged.

tests/frame/check_app_data.py launches the Notes demo on the nested
desktop with notes in the earlier location and checks that they arrive
byte for byte (including a literal backslash sequence and non-ASCII
text), that the old directory is gone, that the new one is 0700 and that
a second copy makes the next launch fail with 409 without changing
either. The weft-pack tests that change the environment now share a lock.
2026-10-09 08:43:42 +00:00
51ca194acb
fix(runtime): close fetch and preopen gaps in grant enforcement
A component with a host-specific fetch grant could reach another origin
by setting its own Host header, and could inject request lines through
the method string, which ureq writes unvalidated. Fetch now accepts only
standard methods and refuses Host, framing and hop-by-hop headers. Fetch
grants accept canonical DNS names and dotted IPv4 addresses only, so a
grant can never be written in a form that silently never matches.

--preopen split host and guest at the first `::`, so a host path
containing `::` widened the preopened directory; it now splits from the
right, and appd refuses host paths that are not UTF-8 or contain `::`.

appd validated capabilities one at a time, creating the data directory
before a later capability was refused, and required HOME even for
packages without filesystem capabilities. It now checks every capability
first, resolves host directories only when needed, validates the app ID
with the rule weft-pack uses (now shared in weft_ipc_types::package), and
reports 400, 404, 403 or 500 according to the cause. user-dirs.dirs is
read as a shell would: the last assignment wins, $HOME must be followed
by a slash, escaped values are ignored and a relative XDG_CONFIG_HOME is
not used.

The grants probe now also overwrites, renames, removes and creates
directories in read-only data, and sends a forged Host header, an
injected method and a file: URL; it fails when directory permissions of
a read-only preopen are widened or the header check is removed. A new
CI job builds the runtime with its engine and fetch support and runs the
check. The mount test that sets WEFT_APP_STORE now holds the env lock.

Package images are still located separately from directory installs;
deriving grants from the verified image is part of resolving one package
descriptor.
2026-10-09 08:25:40 +00:00
c28a829624
fix(runtime): enforce effective capability grants per session
Every host import was registered and callable whatever the package
declared, read-only directory capabilities were preopened read-write,
and appd launched packages whose capabilities it could not satisfy. The
fetch import also could not be linked: the host returned a tuple where
the WIT declares the response record, so any component importing
weft:app/fetch failed to instantiate.

One capability vocabulary now lives in weft_ipc_types::capability and
is used by weft-pack, weft-appd and weft-runtime. weft-appd derives a
session's grants once, before the session exists, and refuses the launch
with error 403 when a capability is unknown, unsupported (hw:gpu:*) or
unsatisfiable (documents without an XDG documents directory). The
documents directory now comes from user-dirs.dirs instead of a guessed
~/Documents.

The runtime receives grants explicitly (--grant CAP, --preopen
HOST::GUEST::ro|rw), preopens read-only directories read-only, and checks
the grant on every notifications, clipboard and fetch call. Fetch accepts
only http and https to granted hosts, returns redirects and HTTP error
statuses as responses instead of following or failing them, and bounds
connect time, total time and response size. The file portal takes
read-only directories with --allow-read and refuses writes there.

tests/runtime/check_grants.py runs the real runtime on a probe component
under each kind of grant and checks the outcome of every operation; it
fails when read-only data is writable or an import ignores its grant.
The appd dispatch tests that read WEFT_RUNTIME_BIN now hold the env lock
shared with the tests that set it.
2026-10-09 08:08:58 +00:00
3875650226
fix(app-shell): refuse encoded separators in the UI scope
A file URL whose path holds an encoded slash or backslash keeps the UI
directory prefix while a loader may decode it into a path outside that
directory. Navigation and the bridge now refuse such URLs.

appd removes the system token file at shutdown only while it still holds
its own token, and the HELLO deadline in unit tests is one second.
2026-10-09 07:53:23 +00:00
db712e056e
fix(appd): authorize WebSocket clients by role and session
The browser-facing WebSocket accepted requests from any local page, so a
page could launch or terminate apps and inject messages into any session.

Every connection now completes the upgrade and sends HELLO within five
seconds. The system role authenticates with a token appd writes to
$XDG_RUNTIME_DIR/weft/appd.systoken (mode 0600) and may manage sessions,
but never sees or sends application messages. The app role authenticates
with a per-session bridge token passed to weft-app-shell in
WEFT_BRIDGE_TOKEN and exchanges APP_MESSAGE envelopes with its own
session only; it is disconnected when that session stops.

weft-servo-shell hands the system endpoint only to the system UI
document and denies navigation away from it. weft-app-shell installs the
bridge only in top-level documents inside the application's UI
directory and denies navigation outside it. The launcher renders package
names as text.

tests/frame/check_counter.py drives the Counter demo end to end through
the compositor, appd, the Wasm runtime and the app shell.
2026-10-09 07:45:49 +00:00
f9945c055c
fix(appd): report sessions running only after the UI host is ready
weft-appd marked a session Running and broadcast APP_READY as soon as the
runtime printed READY, then started weft-app-shell with its output
discarded and never watched it. A session with no UI, a UI host that
failed to start, or one that crashed was still reported running. Early
failure paths skipped parts of the cleanup: the image mount was not
unmounted, the compositor association was not released, and the abort
sender leaked on spawn failure. Readiness was any stdout line equal to
READY, which a Wasm guest (inherited stdout) or a page (window.alert
writes to the app shell's stdout) could print.

Now a session becomes Running only after the runtime and then the app
shell report readiness, each within 30 s; WEFT_APP_SHELL_BIN is required
and checked before anything starts. After that, the runtime exiting, the
app shell exiting or a terminate request ends the session. Every exit
path goes through one teardown that kills both children, releases the
compositor association, unmounts the image, stops the file portal and
broadcasts Stopped.

Readiness uses a per-session random token passed to both children in
WEFT_READY_TOKEN. weft-runtime and weft-app-shell print READY <token>,
and appd accepts only a line ending with it; guests receive only the
variables the runtime names and pages cannot read the host environment.
Child output is read in bounded, lossily decoded lines, so invalid UTF-8
or long lines no longer stop the readers. Compositor notifications use
try_send so a disconnected compositor cannot stall teardown, and all
children are killed if the supervisor is dropped.

The IPC relay is not yet owned by the session, and children are killed
without a graceful period.

Validation:
- cargo test -p weft-appd (43 passed); new tests cover: not ready until
  the app shell is ready, runtime exit before that, no app shell
  configured (runtime never starts), app shell exit ending a running
  session with the runtime process gone, and READY lines without the
  token; they fail against the previous supervisor
- end to end with weft-compositor (nested), weft-appd, weft-runtime
  (wasmtime-runtime) and weft-app-shell: the Counter demo reaches
  APP_READY and is on screen; a page that prints a READY line through
  alert and never loads is stopped after 30 s without APP_READY;
  terminate leaves no child processes
- clippy -D warnings and fmt --check for weft-appd and weft-runtime
2026-10-09 01:41:09 +00:00
cb48227906
fix(appd): drop --wait from the systemd-run scope launch
When a systemd user manager was detected, weft-appd launched the runtime
with `systemd-run --user --scope --wait ...`. systemd rejects that
combination while parsing options ("--wait may not be combined with
--scope"), so every app launch on such a host exited immediately and the
session stopped without the runtime ever starting.

A scope already runs the command in the foreground: systemd-run registers
the scope and then executes the command in its own process, so stdout and
the exit status still reach appd without --wait.

The options now live in one constant. A Linux test runs the installed
systemd-run with them against an empty runtime directory and bus address
and requires it to reach the manager connection; option and combination
errors stop it earlier. The test does not validate the -p property values
or start a scope. It requires systemd-run to be installed.

This keeps the existing ownership scope for the runtime only; placing the
app shell and helpers under the same owner is separate lifecycle work.

Validation:
- systemd-run 255: the test passes with the new options and fails with
  the old --wait (and with --pty) using systemd's own message
- cargo test -p weft-appd (38 passed), clippy -D warnings, fmt --check
2026-10-09 01:29:24 +00:00
cd13f4cd3a fix(appd): combine set_state and broadcast into one lock acquisition on READY
The two consecutive registry lock acquisitions after READY left a window
where session state was Running but the AppReady broadcast had not yet
been sent. A concurrent reader winning the lock in that window would
observe Running without a corresponding event. Combining into one
acquisition closes the window.
2026-03-13 14:07:06 +01:00
e02ce5722d fix(appd,runtime): harden session lifecycle and IPC mutex safety
- supervise: in the stdout-read-error-before-READY case, immediately
  kill the child process, tear down the file portal, mark the session
  Stopped, and return; previously the function fell through to child.wait()
  leaving the session in Starting state with no guaranteed cleanup path
- supervise: restructure app_shell binding as a match expression so the
  compiler can verify the initial None value is not silently discarded
- weft-runtime: replace Mutex::lock().unwrap() with unwrap_or_else in
  the weft:app/ipc send, recv, and connect host functions so a poisoned
  mutex does not panic inside the Wasmtime host-call context
2026-03-13 14:05:31 +01:00
67f54c39be fix(ci): restore cross-platform and linux checks 2026-03-13 13:44:44 +01:00
a46af65e6e fix(appd): stabilize tests and unix-gate sd-notify 2026-03-13 12:52:39 +01:00
51eccc30de fix(ci): clippy lints in weft-appd, remove unused sd-notify dep, add missing apt packages 2026-03-13 10:58:40 +01:00
2beebf13d2 style: apply rustfmt to all workspace crates 2026-03-13 10:38:01 +01:00
379d0886bd fix(appd): set WEFT_DISABLE_CGROUP in supervisor test
In environments where XDG_RUNTIME_DIR/systemd/private exists but the
user systemd session is not functional, systemd_cgroup_available()
returns true and the test script is wrapped with systemd-run, which
fails immediately, causing ChildStdout to return EOF before READY.

Set WEFT_DISABLE_CGROUP=1 for the duration of the test and restore
it on exit.
2026-03-12 20:16:58 +01:00
4d0089a107 feat: appd IPC relay, WIT interfaces, UI kit, gesture routing, and CI hardening
- weft-appd: per-session IPC socket paths; bidirectional Wasm-HTML JSON relay
  via spawn_ipc_relay; SO_PEERCRED UID check on Unix socket connections;
  PanelGesture request and NavigationGesture broadcast for compositor gestures
- weft-runtime: weft:app/ipc, weft:app/fetch, weft:app/notifications WIT
  interfaces; IpcState non-blocking Unix socket host functions; ureq-backed
  net:fetch host function (net-fetch feature); notify-send notifications host
- weft-file-portal: spawn a thread per accepted connection for concurrent access
- weft-app-shell: weft-system:// URL translation; WEFT UI Kit UserScript
  injection; resolve_weft_system_url helper
- weft-servo-shell: forward compositor navigation gestures to weft-appd
  WebSocket as PanelGesture; WEFT UI Kit UserScript injection
- infra/shell: weft-ui-kit.js with 11 custom elements (weft-button, weft-card,
  weft-dialog, weft-icon, weft-list, weft-list-item, weft-menu, weft-menu-item,
  weft-progress, weft-input, weft-label); system-ui.html handles
  NAVIGATION_GESTURE messages and dispatches weft:navigation-gesture CustomEvent
- infra/systemd: add missing env vars to weft-appd.service; correct
  servo-shell.service binary path and system-ui.html argument
- .github/workflows/ci.yml: exclude weft-servo-shell and weft-app-shell from
  cross-platform job; add them to linux-only job with libsystemd-dev dependency
2026-03-12 12:49:45 +01:00
a401510b88 feat(appd): per-app process isolation via weft-app-shell
Add weft-app-shell binary: takes <app_id> <session_id> args, connects to
zweft_shell_manager_v1 as an application window, resolves the app UI URL,
and runs a single Servo WebView in an isolated process. Prints READY to
stdout after the window is initialised so weft-appd can track the session
lifecycle.

weft-appd runtime.rs: after weft-runtime emits READY, spawn weft-app-shell
(WEFT_APP_SHELL_BIN env var) alongside it. The app shell is killed when the
session ends via abort or natural runtime exit.

weft-servo-shell: remove in-process app WebView management. The shell now
manages the system UI WebView only; all app rendering happens in dedicated
weft-app-shell processes.
2026-03-12 10:58:45 +01:00
a3f60910d5 fix(appd): remove abort_sender on READY timeout early-return path
The READY timeout branch killed the process and returned Ok(()) without
calling remove_abort_sender(), leaving a spent entry in abort_senders.
Add the call to keep it consistent with all other exit paths.
2026-03-11 19:01:59 +01:00
a5846c1317 test(appd): verify session transitions to Stopped when WEFT_RUNTIME_BIN absent 2026-03-11 18:47:29 +01:00
0fea8f58e4 fix(appd): mark session Stopped when WEFT_RUNTIME_BIN is absent
Previously the supervisor returned Ok(()) without updating the session
state, leaving it in Starting indefinitely. Now it sets state to
Stopped, removes the abort sender, and broadcasts AppState:stopped
before returning, consistent with every other early-exit path.
2026-03-11 18:43:16 +01:00
6f43490192 fix(appd): remove abort_sender entry when session supervisor exits
When a runtime process exits naturally (not via TerminateApp) the
oneshot Sender remained in abort_senders until shutdown_all().
Add remove_abort_sender() and call it at the normal exit path in
supervise() to release the entry immediately.
2026-03-11 18:38:35 +01:00
4445b57a7c fix(appd): downgrade WS parse failure from warn to debug
App-level weftIpc messages from the system UI routinely fail Request
deserialization since they are not system commands. Using warn generates
log noise during normal operation.
2026-03-11 18:36:32 +01:00
9448cc5140 test(appd): assert LaunchAck is broadcast as well as returned directly 2026-03-11 18:28:59 +01:00
55b80ea2b3 fix(appd): broadcast LaunchAck to all WebSocket clients on app launch
Previously LaunchAck was sent only as a direct response to the
requesting connection. The servo-shell appd_ws listener thread is a
separate WebSocket connection and would never receive LaunchAck for
UI-initiated launches, causing those sessions to have no WebView.

Now dispatch() broadcasts LaunchAck over the registry broadcast channel
immediately after returning the direct response, so all connected
WebSocket clients (including the shell listener) learn about every new
session regardless of which connection triggered the launch.
2026-03-11 18:27:56 +01:00
8eb7211998 refactor(appd): consolidate portal cleanup through kill_portal in normal exit path 2026-03-11 18:21:43 +01:00
0877bd970d fix(appd): kill file portal process on all early-return paths in supervise()
Runtime spawn failure, READY timeout, and abort-during-startup all
previously returned without killing the portal child process or removing
its socket file. Extracted kill_portal() to consolidate cleanup and
call it in each of those three paths.
2026-03-11 18:20:16 +01:00
cd876b49b0 test(appd): session persistence save/load roundtrip tests
Three tests covering the save_session / load_session helpers:
- session_save_load_roundtrip: full write-then-read cycle verifying
  content, and that a second load returns None (file deleted).
- session_save_empty_load_returns_empty_vec: edge case of empty list.
- load_session_no_file_returns_none: missing file returns None.

Also fixes save_session to create_dir_all on the parent directory
before writing, which was the root cause of test failures.
2026-03-11 18:16:37 +01:00
5061310d63 feat(appd): session persistence across clean restarts
On clean shutdown (SIGINT/SIGTERM), save the list of running app IDs to
/weft/last-session.json before calling shutdown_all().

On the next startup, load_session() reads and immediately deletes that
file, then dispatches a LaunchApp for each saved app ID. This restores
the previous session after a system restart or orderly service stop.

If the file does not exist (crash, first boot, or deliberate reset) no
auto-launch occurs. Duplicate detection relies on the existing fact that
the saved processes are gone before appd starts again.
2026-03-11 18:12:38 +01:00
92920984bd feat(appd): auto-launch weft-file-portal per session
spawn_file_portal() checks WEFT_FILE_PORTAL_BIN; if set, creates a
per-session Unix socket at /weft/portal-<id>.sock and
spawns weft-file-portal with --allow args derived from the same host
paths that resolve_preopens() produces for the session.

WEFT_FILE_PORTAL_SOCKET is added to the runtime environment so
weft-runtime (and the WASM app) can locate the socket.

The portal process is killed and the socket cleaned up at the end of
supervise(), after the runtime exits and the mount is torn down.

When WEFT_FILE_PORTAL_BIN is unset the behaviour is unchanged.
2026-03-11 18:09:38 +01:00
d2cb693c55 feat(appd): MountOrchestrator -- EROFS+dm-verity image mount on app launch
Add crates/weft-appd/src/mount.rs with MountOrchestrator.

On each app launch, supervise() calls MountOrchestrator::mount_if_needed
which looks for <app_id>.app.img, <app_id>.hash, and <app_id>.roothash
in the app store roots. If all three exist and weft-mount-helper is
available (WEFT_MOUNT_HELPER env or /usr/lib/weft/ default paths), it:

  - creates /tmp/weft-mnt-<session_id>/<app_id>/
  - invokes weft-mount-helper mount to set up dm-verity and EROFS mount
  - sets WEFT_APP_STORE=/tmp/weft-mnt-<session_id> in the child env so
    the runtime resolves the package from the mounted read-only image

After the process exits, umount() invokes weft-mount-helper umount and
removes the temporary directory.

Falls back to directory-based install silently if no image is found,
mount-helper is absent, or the mount fails.

Test: find_image_returns_none_when_absent.
2026-03-11 15:47:23 +01:00
71b7bdf657 feat(appd): wrap runtime in systemd-run cgroup scope when user session is active
supervise() checks /systemd/private to detect an active
user systemd session. When present (and WEFT_DISABLE_CGROUP is unset),
the runtime binary is launched via:

  systemd-run --user --scope --wait --collect --slice=weft-apps.slice     -p CPUQuota=200% -p MemoryMax=512M -- <bin> ...

This places each app in a transient weft-apps.slice scope with default
resource limits from the blueprint. The --wait flag keeps systemd-run
alive so child.wait()/child.kill() remain correct.

When no user session is present the command is built directly as before.
WEFT_DISABLE_CGROUP=1 bypasses the wrapping unconditionally.
2026-03-11 15:25:04 +01:00
c5a47a05b4 feat(appd,pack): capability dispatch -- map wapp.toml capabilities to --preopen args
Add capabilities field to weft-pack PackageMeta (optional Vec<String>).
Print cap: lines in weft-pack info output when capabilities are declared.

In weft-appd:
- Make app_store_roots pub(crate) so runtime.rs can use it.
- Add resolve_preopens(app_id) in runtime.rs: reads wapp.toml from the
  package store, extracts capabilities, maps each to a (host, guest) pair:
    fs:rw:app-data / fs:read:app-data -> ~/.local/share/weft/apps/<id>/data :: /data
    fs:rw:xdg-documents / fs:read:xdg-documents -> ~/Documents :: /xdg/documents
  Unknown capabilities are logged at debug level and skipped.
- supervise() calls resolve_preopens() and appends --preopen HOST::GUEST
  flags before spawning the runtime binary.
2026-03-11 15:20:51 +01:00
b2ac279dc5 feat(runtime): add --preopen and --ipc-socket CLI arguments
weft-runtime now parses optional flags after <app_id> <session_id>:
  --preopen HOST::GUEST  pre-opens a host directory at GUEST path in the
                         WASI filesystem (HOST::GUEST or HOST for same path)
  --ipc-socket PATH      sets WEFT_IPC_SOCKET env var inside the component

wasmtime-runtime path applies preopened dirs via cap_std and WasiCtxBuilder,
and injects WEFT_IPC_SOCKET when --ipc-socket is present. Stub path ignores
both flags.

weft-appd: SessionRegistry gains ipc_socket field (set to the appd Unix
socket path in run()), extracted alongside compositor_tx in dispatch(), and
forwarded to supervise() as ipc_socket_path. supervise() passes
--ipc-socket <path> to the spawned runtime when present.

cap-std added as optional dep under wasmtime-runtime feature.
2026-03-11 15:10:11 +01:00
6b428e5a47 feat(appd): add compositor IPC client; send AppSurfaceCreated/Destroyed on session lifecycle
Adds crates/weft-appd/src/compositor_client.rs: async Tokio client that connects to the
compositor's Unix socket (/weft/compositor.sock or WEFT_COMPOSITOR_SOCKET),
retrying every 2s on failure and 500ms on write error. Incoming CompositorToAppd frames are
decoded and logged (SurfaceReady, ClientDisconnected).

Wires compositor_tx into SessionRegistry. The supervise task now sends AppSurfaceCreated
(with child PID) immediately after process spawn, and AppSurfaceDestroyed when the process
exits. All three existing supervisor tests updated to pass None for compositor_tx.
2026-03-11 14:40:55 +01:00
5d7c0bdf79 feat(appd): add version field to AppInfo; surface it in launcher tile tooltip
WappPackage and AppInfo both gain a version field. scan_installed_apps()
reads it from wapp.toml and includes it in InstalledApps responses.
system-ui.html shows it in the title tooltip as 'com.example.app v1.0.0'.
All roundtrip and integration tests updated.
2026-03-11 13:15:09 +01:00
c88c948575 fix(appd): exclude Stopped sessions from running_sessions; add regression test
running_sessions() was returning all sessions regardless of state.
Stopped sessions would reappear in the taskbar on reconnect since
QUERY_RUNNING is sent on every WebSocket open. The filter now matches
the UI expectation: only Starting and Running sessions are returned.
2026-03-11 12:53:07 +01:00
de8939a72e test(appd): add ws_port default and override tests 2026-03-11 12:46:15 +01:00
bded9455f5 test(appd): add appd_socket_path tests; run appd tests single-threaded
Two new tests cover appd_socket_path():
- appd_socket_path_uses_override_env: WEFT_APPD_SOCKET takes precedence
- appd_socket_path_errors_without_xdg_and_no_override: returns error when
  both WEFT_APPD_SOCKET and XDG_RUNTIME_DIR are unset

wsl-test.sh: add --test-threads=1 for weft-appd to prevent WEFT_RUNTIME_BIN
races between the supervisor integration tests.
2026-03-11 12:40:05 +01:00
71597580ba fix(appd): abort TerminateApp during startup phase promptly
Before this fix, TerminateApp sent while a process was waiting for its
READY signal was not acted on until the 30-second timeout fired.
abort_rx is now included in the tokio::select! that wraps wait_for_ready,
so the child is killed and AppState::Stopped broadcast as soon as the
abort is received, regardless of where in the startup sequence it fires.

test: supervisor_abort_during_startup_broadcasts_stopped
2026-03-11 12:30:21 +01:00
488900a5db test(appd): add supervisor spawn-failure test; verifies Stopped broadcast when binary is missing 2026-03-11 12:24:03 +01:00
dbcc9965e9 test(appd): add roundtrip tests for TerminateApp, Error, and AppState IPC variants 2026-03-11 12:12:20 +01:00
826f144d9d test(appd): add roundtrip tests for AppInfo and InstalledApps IPC variants 2026-03-11 11:51:04 +01:00
abdefa3388 test(appd): add QueryAppState dispatch test for unknown session returning NotFound 2026-03-11 11:48:22 +01:00