Bento Spaces documentation
Roadmap
Each phase is shippable on its own. Do not start a phase before the previous one's acceptance criteria are green, and update this file when a phase completes. The live backlog is Open work; this file keeps the phase history and acceptance criteria.
P0 — Shelf engine ✅ done
Space → blocks → containers, patterns, gaps, drag, resize, undo, local persistence.
- ✓1-box grid, minimum 1×1, whole boxes only
- ✓8 patterns, each exactly 16 boxes, inserted as a rigid group
- ✓add at start / end shifting whole blocks
- ✓drag with snapping, collision ghost, group-rigid moves, spring-back
- ✓resize with minimums, pattern unlink with toast
- ✓empty space as a first-class box with a grouped "Fill this space" popup
- ✓delete / duplicate
- ✓undo/redo (100 snapshots)
- ✓localStorage persistence and restore
- ✓39 model assertions (
node --test tests/*.test.js) - ✓headless-Chromium end-to-end pass, zero page errors
Known gap: the engine is client-only; nothing is validated server-side yet.
P1 — Webtop shell ✅ done
Accounts, spaces, dock, the private/data split, edit/view, wallpapers, offline shell.
Built: storage split with atomic writes · accounts (PBKDF2, sessions, throttle) · spaces API + dock (create, rename, colour, delete, duplicate, switch) · layout.json v3 joined with widget instances · server-side layout validation · anonymous mode with IndexedDB layouts · first-login import that reuses empty starters · rev + If-Match with keep-mine / use-theirs · edit/view modes · free-plan entitlement · wallpaper presets (free) and uploads (Plus, signature-checked) · service worker shell cache with offline navigation.
Open, moved to later phases: signed-in offline queueing (edits wait for the network) belongs with the sync work in P4/P6.
Acceptance
- ✓Anonymous: create 3 spaces, switch, reload — layouts are per space and come back
- ✓Sign up, then import the local spaces into the account, reusing empty starters
- ✓A stale save opens the conflict dialog; "use theirs" loads the server version
- ✓A 4th space is refused with a clear upgrade message (403
space_limit) - ✓Space rename, colour and wallpaper persist; delete removes it from the dock
- ✓Duplicating a space copies its layout and container ids
- ✓
publish.shproducespublished/with noApp_Dataand an archive zip - ✓The shell opens with the network offline (verified with
/?sw=1on localhost) - ✓Wallpaper upload is gated to Plus and rejected for the free plan
P2 — Widget runtime ✅ done (with two gaps noted)
Browser tests live in the repo: scripts/e2e/{shelf,shell,widgets}.e2e.mjs, driven by a Chromium with remote debugging (see scripts/e2e/README.md).
The board comes alive: slots, sizes, drag and swap, persistence, undo.
Built: registry of eight built-in widgets (clock, stat, note, links, image, progress, countdown, weather) · slot + on empty containers with a fit-filtered picker · widget mount/update/destroy host with container-query sizing · widget drag between containers with 50% + red refusal · swap on filled targets · filled containers locked (no move, resize or delete) · delete removes the widget and keeps the box · undo/redo snapshots both layout and widgets · widgets persist server-side (PUT /widgets/{containerId}) and in IndexedDB locally · visibility change tears widgets down (timers stop) and remounts on return.
Built-ins are trusted in-page modules (our code), not the JSON declarative format. The JSON runtime, installs and the proxy arrive with registries in P4 — see Widgets.
Acceptance
- ✓Dropping a widget onto a box of an unsupported size: 50% + red border, refused
- ✓Dropping onto another compatible box moves it; the source shows
+ - ✓Dropping onto a filled box swaps both widgets when they fit each other
- ✓A filled container has no handles and cannot be dragged; emptying restores them
- ✓Deleting a filled box removes the widget and keeps the container
- ✓Widgets survive a reload, locally and through the API
- ✓Undo restores a removed widget
- ✓Visual sweep of every built-in at every declared size (
scripts/e2e/widget-sweep.e2e.mjs: 21 built-ins, 96 mounts) - ✓Scheduled refresh is configurable per placement (
Refresh…: Default/Off/30 s–1 h), stored with the space; the shared timer is unit-tested
P3 — Space sharing ✅ done (revised: per space, not per person)
One space on a wall, read-only, with an optional PIN that unlocks it after idle.
Built: share links per space (/v/{token}) exchanged for a 12-hour read-only session · the owner chooses idle (30 s–15 min), PIN or no lock, and sets the PIN at creation, stored PBKDF2-hashed · lastOpenedAt, revocation, "Exit view" · idle lock removes widgets from the DOM and unlocks with the link PIN (throttled) · Share dialog: create/copy/revoke links.
Profiles and connect links were removed after review: sharing is per space, so there is no per-person credential intake (D37 revised).
Acceptance
- ✓The Share dialog creates a read-only link for the current space, with a PIN
- ✓Opening the link shows only the shelf; docks, account and edit are hidden
- ✓Idle lock unmounts widgets; wrong PIN refused; right PIN unlocks
- ✓Writes from a view session are refused (401)
- ✓Revoking a link 404s it;
lastOpenedAtis recorded - ✓Exit view returns the browser to the account
- ✓
{{var:…}}proxy resolution — built with declarative data - Charging for extra share capacity — billing in P7
P4 — Registries ✅ done
Installable widgets without executing code.
Built: registry.json spec + server-side fetch/cache · per-user sources (add/remove) · install with sha256 verification into the user's data/ tree · installed list, uninstall, pinned versions · declarative JSON runtime (stat, badge, text, list, image, progress, clock, link) with one shared validator · installed widgets appear in the slot picker with a registry tag · Widget sources dialog (add source, browse index, install/remove) · bundled example registry at /registry-example.json · developer harness at /harness.html · scripts/check-widgets.mjs validating manifests and registry hashes.
Acceptance
- ✓Add a registry hosted anywhere reachable; its index is fetched server-side (no CORS)
- ✓Install verifies the hash; a version not in the index is refused
- ✓The installed widget appears in the picker and renders from its manifest
- ✓It survives a reload and uninstall removes it from the picker
- ✓A shared view can render the owner's registry widgets
- ✓
check-widgets.mjsvalidates manifests and the example registry's hashes - ✓Declarative
datafetching (the host proxy) - ✓Sandboxed module widgets and publisher flow
P5 — Sandboxed module widgets ✅ done
Built: module manifests with inline source (≤64 KB) · a server-served frame document with its own CSP (sandbox allow-scripts; connect-src 'none') · sandbox="allow-scripts" iframes with an opaque origin · a postMessage bridge (props, size, setProps, emit, plus the P5.5 request/action capabilities) · 12-hour frame tokens so an opaque-origin frame can load without cookies · install validation · the bundled pulse module · harness and E2E coverage.
Acceptance
- ✓A module cannot read the parent document (
contentDocumentis null) - ✓The frame is sandboxed without
allow-same-origin - ✓The frame's own CSP sets
sandbox allow-scriptsand forbids network (connect-src 'none') - ✓The module paints and completes the mount handshake
- ✓It survives a view/edit round trip and uninstalls cleanly
- ✓
ctx.request()/{{var:…}}proxy and real action capabilities — P5.5
P5.5 — Widget data and actions ✅ done
Built: a host proxy at /api/widgets/{id}/{version}/data (installed manifest, declared origins, GET only, no cookies or redirects, 8 s, 256 KB, JSON/text, public addresses only, optional TTL cache) · declarative data with a dot path and {{data}} / {{data:path}} / {{var:name}} · install-time consent driven by the registry index, with the server rejecting a manifest broader than the index · module ctx.request, ctx.open, ctx.refresh and gated ctx.setProps · the bundled site-status declarative widget and the pulse module now reads through the proxy.
Acceptance
- ✓A declarative widget renders a value fetched through the host
- ✓An undeclared origin and a
self/api/*path are refused - ✓A manifest cannot widen the permissions advertised by the registry index
- ✓Refusing consent installs nothing; allowing installs and reads
- ✓Modules call
ctx.requestfrom inside the sandbox and receive the data - ✓Permission requests name the host and actions before install
- ✓The proxy sends no cookies, follows no redirects and caps size/time
- ✓Proxied values survive a reload
Known gaps: no POST/headers/JSONPath in declarative data; the proxy is not per-user rate-limited yet; DNS rebinding is mitigated best-effort only.
P5.6 — Connectors and the first IoT widget ✅ done (first slice)
Built: account connectors (base URL + write-only bearer token) · AES-GCM secret storage · server-side connector proxy with GET/POST, origin/path confinement, no cookies or redirects, 8 s/256 KB caps and link-local refusal · Settings → Connectors dialog with test/remove · the built-in Gree AC widget (power, temperatures, 5 s poll, toggle through /api/power) · API smoke and a browser suite against a mock bridge.
Acceptance
- ✓A connector is added from Settings and tested
- ✓Tokens are encrypted and never returned by the API
- ✓A relative request goes through the proxy and stays on the connector origin
- ✓The Gree widget auto-binds, shows state and toggles the bridge
- ✓Removing the connector degrades the widget safely
- ✓Run against the real
gree-acbridge and all six ACs - ✓Multi-device Bento Bridge (P5.7); setup wizard remains
- Generic HTTP widget and declarative connector templates
P5.7 — Multi-device Bento Bridge ✅ done (supervisor slice)
Built: source/Bento.Bridge, an ASP.NET supervisor with /api/devices, per-device state, power and generic request proxying · one public bearer token, per-child internal tokens · devices.json configuration · a compose example with one gree-ac child per AC · the Gree widget's device picker and legacy fallback · scripts/bridge-smoke.mjs and scripts/e2e/bridge.e2e.mjs.
Acceptance
- ✓One bridge exposes two or more devices
- ✓State/control proxy only to configured child URLs
- ✓The bridge token is required; child tokens stay internal
- ✓The widget lists devices, remembers the selection and controls only that device
- ✓A single-device
gree-acstill works through/api/state - ✓The supervisor works against the real
.110child - ✓The six-child compose (all six units reachable from the bridge)
- The setup/pairing wizard
P5.8 — Tier A widgets ✅ done
The secret-free widgets that can be shared and exported: weather with a forecast, an RSS/Atom feed, markets (coins + FX) and a photo-frame slideshow, plus a two-timezone clock and a yearly countdown. All upstream text is escaped, failures paint a message, and the data path is either a CSP-allowed public host or the same-origin feed proxy.
Acceptance
- ✓Weather shows current, feels-like, today's high/low and two more days
- ✓Feed parses RSS 2.0, Atom and RDF; refuses non-feeds and private hosts
- ✓Markets shows coins with 24 h change plus FX rates
- ✓Photo frame rotates two or more images with a cross-fade
- ✓Clock shows a second timezone; countdown repeats yearly
- ✓The picker offers every new widget at a size it fits
- ✓Widgets work in a shared view and survive a reload
- ✓QR code: local encoder, versions 1–10, all four levels, decoded by macOS Vision
- ✓Sun & moon: sunrise/sunset, daylight left, phase and illumination
- ✓Unit converter: eight categories, sentence input
- ✓Dice & picker: d2–d100, up to 12 dice, list picking, all local
- ✓Holidays: next public holidays, two years merged, country switch
- ✓Crypto: price, percent change and a sparkline for 1–365 days
- ✓Air quality: European AQI band plus PM2.5/PM10
- Public transport departures (per-city adapter; next in the catalogue)
P6 — Surfaces ✅ done
Built: a density-aware viewport unit (80 px at a laptop, ~142 on a 32:9 panel) · automatic vertical stacking below 720 px · a display pairing (/display/{token}) that boots read-only with left/right rails, no top chrome, hidden cursor, wake lock and no idle lock · a single-file HTML export with inlined tokens/styles and snapshotted widgets · 44 px dock targets and pan-to-scroll on phones · one device-wide zoom in Settings, scaling boxes and widget contents.
Acceptance
- ✓2560×720 shows ~4 blocks with rails, no vertical chrome (unit ~142, square ~605)
- ✓A paired panel boots straight into the shelf and survives a reboot (30-day cookie + stable URL)
- ✓A phone shows one block per screen and scrolls through them (unit from width, vertical default)
- ✓Export is a single HTML file with no JS, matching the space
Long-press drag while editing on a touch device is deliberately deferred: view mode pans, edit mode still drags immediately.
P6.5 — Split docks ✅
Space controls left the shared actions row. The space dock (top centre) is anchored by the space name and expands on hover, focus or tap; the account dock (top right) holds settings and account. Share and export moved into the space dock, and export opens a popup that is the future home for viewer permissions. The pencil opens space details and the grid/✓ toggles edit. On a phone the expanded dock becomes a full-width toolbar; edit mode pins it open.
Acceptance
- ✓View mode shows only the space name until hover/focus/tap
- ✓Zoom and fullscreen are reachable in view; undo/redo only in edit
- ✓Account/settings stay in their own dock
- ✓Paired displays keep the right rail (fullscreen only)
P7 — Commercial surface — tracked in Open work
- Merchant of record integration (Paddle, built against a mock), plan changes, invoices
- and the customer portal.
- Share capacity pricing (included with Plus for now).
- Publisher plan (€50) with push + verified badge — the badge needs the plan to show.
- Grandfathering: a new price id does not migrate existing subscriptions.
Acceptance
- ✓Upgrade/downgrade changes entitlements within one request (operator + Paddle checkout)
- ✓A lapsed subscription drops to 3 spaces read-only, never deletes data
- ✓Publisher plan unlocks push for that user's published widgets only
- ✓A verified publisher shows the badge only while the Publisher plan is active
P5.9 — Automations ✅ done
Built 2026-11-26. Personal rules over connectors, built for the owner first and only generalized if it earns it. The first rule is a thermostat for the Gree ACs: profiles own the thresholds, a rule per device picks one, and a server-side tick decides. See 16 — Automations.
How it works
- runs in
Bento.Api, never in the browser — a rule must work with no tab open and the phone asleep - it reads through the connector proxy and acts with
POST /api/devices/{id}/power, so it inherits - the token handling and never sees a secret in the widget
- one rule per device:
{ connectorId, deviceId, enabled, season, min, max } - hysteresis: winter/heat turns on below
minand off abovemax; summer/cool turns on above maxand off belowmin; between the two it does nothing. The gap is the point — a bare- setpoint flaps the compressor
- cooldown: no second command for ~5 minutes after any command
- stale guard: an
offlinedevice or an oldupdatedAtmeans do nothing, not guess - manual override: a hand change pauses the rule for an hour instead of fighting the user
- every action is logged with the reading that caused it
Profiles and weather brackets
A rule points at a profile, and a profile is the thing that owns numbers. This keeps the thresholds in one place and lets the weather choose between them.
profile: { id, name, season, min, max, cooldownMinutes }
rule: { connectorId, deviceId, enabled, profileId,
weather: { metric: "outdoorTemp", brackets: [{ max: 15, profileId: "cold" },
{ max: 25, profileId: "mild" },
{ profileId: "hot" }] } }
- brackets are ordered, first match wins, the last entry is the fallback; a rule with no
- weather block uses its own
profileIdalways - the bracket boundary gets its own hysteresis (±1°) — otherwise 15.0/15.1° makes the profile
- flip and the AC follow it
- a profile switch never sends a command by itself; the next tick evaluates the new profile
- against the current reading, and the cooldown still applies. Switching profiles is not a reason
- to toggle a compressor
- the active profile, the metric value and the bracket that matched are all written to the action
- log, so "why is it cooling at 19°" has an answer
- v1 uses the AC's own
outdoorTempfrom the bridge — free, no extra provider, no key. Several - units report it (
20°on.110), but some reportnull, so a missing metric means fall back - to the rule's default profile rather than guess
- an external forecast (a plain HTTPS JSON call, no package) is a later opt-in, and it needs a
- provider key in the secret store like any other connector token
Seasonal schedule
- a
seasonper profile, plus optional date windows (e.g. heat 15 Oct → 15 Apr, cool otherwise) - so the same AC flips behaviour without editing numbers twice a year
- the seasonal window chooses the default profile; a weather bracket overrides it while it
- matches, and the season resumes when the weather leaves every bracket
- season changes are a rule edit, logged like any other action
Known limits to state in the UI
- the AC's
currentTempis intake air, so it reads high while heating and low while cooling — - fine for on/off, not for ±0.5° regulation
- some Gree firmware reports a stale
currentTempwhile powered off; treat that as no data outdoorTempis the unit's own outside sensor, not the forecast; it is fine for brackets, not- for predicting the afternoon
- v1 has no time-of-day windows, no multi-device orchestration and no scenes
Acceptance
- ✓A rule toggles one AC from a server tick with the browser closed
- ✓Hysteresis, cooldown and manual override each have a test that proves no flapping
- ✓A stale or offline reading produces no command
- ✓The seasonal window flips heat/cool without a second rule
- ✓A weather bracket selects a different profile and the boundary does not flap at 15.0/15.1°
- ✓A profile switch alone never sends a command; a missing
outdoorTempuses the default - ✓The dialog shows profiles, rules and the last action, with Run now
- A notification when a rule acts