Writing apps
Web debugging
SpectreOS includes a debug-only WebAssembly workbench (tools/bhoo-web-debug/) so you can inspect layouts, gestures, state transitions, Persian (Shabnam) typography, system notifications, and D-Bus calls in any desktop browser without flashing a phone.
#Zero overhead in production phone builds
The browser debugger is strictly isolated from release builds:
- tools/bhoo-web-debug/ is a standalone
wasm32-unknown-unknowncdylibcrate that is never a dependency ofspectre-files,spectre-settings,spectre-calendar,spectre-keyboard, orwisp. - Any browser-only helpers inside an app crate (such as Files' in-memory seeded virtual filesystem in codes/apps/files/src/wasm_fs.rs, Calendar's injected wall clock, or Wisp's debug notification state snapshot) are gated behind
#[cfg(target_arch = "wasm32")]. Native Linux and ARM64 phone builds (cargo release) compile 0 bytes of debug-web code. - Per-app Cargo features let
cargo test-webinside an app directory compile only that app andlibbhoo.
#Running the debugger
# Inside a single app directory (fast single-app debug build)
cd codes/apps/files
cargo test-web # build once and serve http://127.0.0.1:8768/?app=files
cargo test-web-watch # auto-rebuild & hot-reload on .rs edits
cargo test-web-check # headless WASM + canvas-painter + test/web-tests.json & desktop check
# From the repository root (all apps in one switcher)
cargo test-web # serves files, settings, calendar, keyboard, notifications
cargo test-web keyboard # single app from root
cargo test-web-watch all --port 8770#Workbench capabilities
- Card-based App Picker (
K): Click the App button in the topbar (or pressK) to open a searchable modal of app cards powered by each app'sassets/*.desktopmetadata andtest/web-tests.jsoncount. - Visual Feedback Draw Mode (
Alt+F): Click the phone stage and pressAlt+F(or click the Feedback · Alt+F button) to enter Draw Mode, drag a Box, Freehand mark, or Arrow over the phone UI, type your feedback, and pressEnter. Saved feedbacks appear in a compact bottom dock with annotated thumbnails plus one-click Copy for AI (structured Markdown with app, viewport, region coordinates, overlappingbhoo::SemanticNodetargets, and state JSON) and Copy Image (copies the 2× annotated PNG—or combined contact sheet for multiple items—straight to your clipboard for pasting into AI chat). - Appearance & Settings modal (
,): Click the gear icon in the top-right corner to open the Notion-style settings modal (menu on the left, content on the right) to toggle the Debugger UI theme (Dark / Light / System), App theme (Dark / Light), dot-grid backdrop, pointer simulation, reduced motion, font diagnostics, and saved layout resets. - Viewports & overlays: Switch between Poco F1 (
400×832), Compact Phone (360×740), Tablet, Desktop, CustomW×H, Rotate (832×400landscape), Bounds overlay forbhoo::SemanticNodehit-boxes, and draggable vertical/horizontal Inspector splitters. - System Notifications & D-Bus monitor (
Sys & D-Bustab):- Outbound actions from every app (
org.freedesktop.Notifications,org.spectreos.OSK0,org.freedesktop.portal.FileChooser/OpenURI,org.freedesktop.NetworkManager,org.bluez,org.freedesktop.login1,org.spectreos.Shiraz1) appear in real time withCALL/SIGNAL/NOTIFYbadges. - System notifications emitted by or injected into any app slide in as interactive banners over the top of the phone frame; clicking action pills or dismissing emits
ActionInvoked/NotificationClosedback onto the D-Bus monitor. - Use the built-in simulator to inject custom notifications or D-Bus method calls directly into the running app.
- Outbound actions from every app (
- Persian / Farsi typography (
Shabnam): Mirrors codes/apps/wisp/src/services/fonts.rs and codes/os/specrte-nix-f1/modules/fonts.nix by serving SIL-OFL-1.1 Shabnam Without-Latin (WOL) weights so Persian text renders in Shabnam without altering Latin metrics.
#Creating reusable Input & State Test Case buttons
You can define test cases in three ways — every saved or repo-defined test case appears as a one-click button in the Test Bar and the Tests tab:
- Interactive builder: Click New Test in the Test Bar (or Tests → New), pick a button name, target app, optional reset-before-run, and add steps (
tapNode,tap,type,key,viewport,theme,filesMode,notifMode,kbLayout,pushNotif,dbus,back,wait,assertState). - Live input recorder: Click Record, interact with the app directly on the canvas, then click Stop Rec to turn the recorded steps into a saved test button.
- Per-app
test/web-tests.json(recommended for repo fixtures): Place a JSON array atcodes/apps/<app>/test/web-tests.json(see App structure, assets, and tests). The debug server automatically loads and serves it at/__debug/testswhenever that app is active, andcargo test-web-checkvalidates its schema.
Example codes/apps/files/test/web-tests.json:
[
{
"id": "files-images-picker",
"name": "Images Picker",
"app": "files",
"pinned": true,
"resetBefore": true,
"steps": [
{ "type": "filesMode", "value": "2" },
{ "type": "wait", "ms": 60 },
{ "type": "assertState", "path": "picker", "expected": "true" }
]
}
]Supported assertState operators in expected: exact match ("true", "ir"), numeric comparison (">=1", ">0", "<=5"), and case-insensitive substring match ("~downloads").
For programmatic extensions in browser devtools or custom scripts, call:
window.bhooDebug.registerTestCase({
name: 'My Smoke Test',
app: 'files',
pinned: true,
resetBefore: true,
steps: [
{ type: 'tapNode', label: 'Images' },
{ type: 'assertState', path: 'location', expected: '~Images' },
],
});#Wiring a new app into cargo test-web
- Keep OS-specific I/O behind
#[cfg(not(target_arch = "wasm32"))](or behind a host trait/context) and provide a small#[cfg(target_arch = "wasm32")]demo state or virtual backend if needed. - Expose a
#[cfg(target_arch = "wasm32")] pub fn debug_state_json(&self) -> Stringhelper so Live App State andassertStatework automatically. - Add an optional dependency and Cargo feature in tools/bhoo-web-debug/Cargo.toml with
default-features = false, handle the newAppKindin tools/bhoo-web-debug/src/lib.rs, and add the slug toALL_APPSin tools/debug-bhoo-app.py. - Add
codes/apps/<app>/assets/org.spectreos.<App>.desktopandcodes/apps/<app>/test/web-tests.json, then runcd codes/apps/<app> && cargo test-web-check.