Galaxy Shell / docs

Plan for themes with a manifest and multiple effects

openspec/changes/archive/2026-10-28-themes-implementation-plan/design.md · Editar no GitHub ↗

Esta página ainda não tem tradução em português. O conteúdo abaixo está em inglês.

Este documento registra decisões, planejamento ou evidências de uma etapa do projeto. Não implica que todos os itens estejam implementados ou validados na versão atual.

Nesta página

Plan for themes with a manifest and multiple effects

Doc status: history. Plan of 2026-10-27 with its delivery record; the contract is docs/themes.md. Checked 2026-11-10.

Date: 2026-10-27, America/Sao_Paulo. This plan was written before the implementation changes. The project owner authorized the theme structure with theme.json and effects that load without recompiling. The owner asked Luna high to implement it, and clarified that black flame is an effect, not the name or the identity of a theme.

Result

A theme groups a presentation and a list of independent effects. The existing CSS/GLSL engine will be extended to load an ordered chain of effects, each with its own parameters, transitions and program. Switching theme, enabling/disabling effects in the manifest, changing the order, CSS or GLSL requires a reload, not a rebuild, after the initial installation of the engine.

Reuse the dedicated worktree css-window-effects, currently clean at 0c6b41b. Preserve the old effect.css + effect.frag mode and the workspace previews. Luna high will do the implementation; the main agent will review the contract and the proofs. Publish to main after validating and reconciling concurrent advances.

Proposed structure

~/.config/agent-native-os/
  active-theme.json
  themes/
    studio/
      theme.json
      shell/
        style.css
      effects/
        elastic/
          effect.css
          effect.frag
        wave/
          effect.css
          effect.frag
        black-flame/
          effect.css
          effect.frag
      assets/
        README.txt

The name studio identifies the example theme. The names elastic, wave and black-flame identify reusable effects. Do not put the formulas of these effects in Rust. assets is a folder of local resources; do not announce auxiliary shader textures or automatic wallpaper switching without effective support. Files and operations that are not implemented must be refused or clearly described as resources for import, never silently accepted as working configuration.

Manifest and selection

Proposed initial version, to confirm in the technical inspection:

{
  "version": 1,
  "id": "studio",
  "name": "Studio",
  "shell": { "stylesheet": "shell/style.css" },
  "effects": [
    { "id": "elastic", "path": "effects/elastic", "target": "overview-f9", "enabled": true },
    { "id": "wave", "path": "effects/wave", "target": "overview-f9", "enabled": false },
    { "id": "black-flame", "path": "effects/black-flame", "target": "overview-f9", "enabled": true }
  ]
}
  • The order in the array is the order of the passes. enabled defines participation. IDs are stable and unique; parameters and transitions are isolated per effect instance.
  • The first version keeps the existing real target overview-f9. Do not invent drag triggers or apply it to the Super web overview by accident. Unknown targets fail explicitly.
  • The local selection persists in active-theme.json with a version and an ID. The default root respects XDG_CONFIG_HOME; a root override for development/testing is not authority granted to the renderer.
  • The private selection command accepts a validated ID, not an arbitrary path. Reloading rereads the manifest and the effects. Adding/removing/reordering effects must work without restarting the process.
  • Status reports the loaded theme, the active chain, the enabled effects, the requested/applied generation, pending and error. Tell apart request received, programs compiled and visible application on the target.
  • The persistent selection changes only after the whole candidate is validated and compiled. A persistence failure must also preserve the previous theme. Disabling and compatibility with the old package have an explicit, documented and tested precedence.

Interface CSS and resources

The manifest can reference shell/style.css. This does not authorize the compositor to change the profile or to run web code. Implement authenticated reading/import of this CSS through the existing read_ui/replace_ui flow, with the same revision, React preview, journal, lock and recovery; with no direct write to interface.json, checkpoints or the profile ui/style.css. The import must be an explicit action, separate from selecting the GPU chain, so that it does not pretend to be atomic across processes and the journal. Provide a way the authenticated agent can use to inspect/import the CSS, and tests for preservation when the preview is rejected.

Theme JavaScript/HTML do not run in the host. Do not give tokens, commands, shaders or theme selection to generated HTML. Local resources do not become public endpoints for arbitrary files. In this delivery, assets can hold documented resources for import; sampling of auxiliary textures by shaders and automatic wallpaper application are not part of the contract.

Composition pipeline

Compose the application tree once into the source texture and apply the enabled effects in sequence. Use at most two alternating intermediate targets, besides the per-window source, so that memory does not grow with the number of passes. All passes, including the last, are rendered into an offscreen texture, and the chain returns a raw texture only after it finishes; this way, a shader error in any pass falls back to the original drawing without interrupting the frame. Respect premultiplied alpha, orientation, scale and order; do not declare opaque regions after a shader that can produce transparency.

Keep the current limits of 32 windows and 320x200 per thumbnail. Limit a manifest to eight effects, and limit sizes per file/set; the limit of textures per window must be documented and tested. Compile once per reload. Do not read pixels on the CPU in normal use. Process effects and previews offscreen before binding the final framebuffer in DRM and Winit.

Each effect has its own map of animated parameters; uniforms with the same name in two effects do not share values. u_time and u_size remain common inputs. While F9 is active, time-based shaders require continuous updates; outside the target, release the caches and preserve the original path. Disabling everything must skip the passes and keep the visual identity. An allocation/rendering error must use the original drawing, without leaving a partially applied chain on the screen.

Validation and expected problems

  1. Strict manifest: version, unknown fields, types, repeated IDs, effect limit, targets and booleans. Do not accept absolute paths, traversal through .., NUL, URL schemes or symlinks that escape the root; check regular files and limits during reading.
  2. Transactional reload: read and compile the candidate in separate structures. An invalid effect must not replace the other active programs. The content of the last valid theme stays in memory, without depending on rereading files that already changed.
  3. Persistence: private and atomic write, selection only after success; do not erase the previous selection on a failure. Test a missing directory, a nonexistent theme, a write error and a reload after a manifest change.
  4. Chain: test the non-commutative order of two passes, uniform isolation, inclusion/removal/reordering without a rebuild, enabled=false and identity with an empty chain. Do not accept multiple effects only as a catalog while the renderer keeps using just one.
  5. Images: a real offscreen EGL test with a frozen clock and two asymmetric synthetic layers; check identity, alpha, Normal/Flipped180 orientation, distinct effects and pixel preservation after an invalid reload. Inspect before/after, including black flame as an independent effect. Media stays out of Git.
  6. Recovery: trusted GLSL is not a sandbox and has no guaranteed GPU timeout. Preserve the disable and fallback commands. Do not promise conversation availability during a driver/compositor failure.
  7. CLI/IPC: keep the requested/applied generation and supersession detection; unknown commands or an old compositor give a useful error. Preserve the existing client when possible and add theme selection/listing/inspection with relevant tests.
  8. UI: the shell CSS follows the interface change flow, separate from the GPU selection; test a valid theme, invalid CSS and recovery, without applying anything to the real profile during development.

Execution and delivery

  1. This plan comes before code. Luna high inspects the integration points and confirms the final names/schema before the contract grows.
  2. Implement the manifest/selection/validation and the full pipeline; then the client, the Studio package with independent effects and the protected CSS import. Keep the implementation in suitable modules, avoiding endless growth of the existing CSS parser.
  3. The main agent reviews the error paths, pass order, memory, interface journal and isolation. Luna high keeps implementing the fixes.
  4. Run fmt, the default and session Rust tests, Clippy --all-targets with warnings as errors, and the build; the existing and new EGL tests will be run explicitly. Run npm ci, format:check, check and the Node tests; run the project Python suite. Prove the CSS import in the synthetic React host and inspect the rendering through the UI when applicable.
  5. Prepare an isolated production build, check manifest/sources/artifacts and smoke checks without opening the compositor or an extra graphical host. Publish validated commits to main, without a PR.
  6. Discover the real state and read coordination.log before any runtime operation. Do not end the session or start a nested session. The active folder will be synchronized only under coordination.lock and when clean, with a build and preservation of the runtime; if the sources and an open process are incompatible, record the pending step and its reason. Do not declare the next login updated just by publishing/preparing another worktree.

Completion criteria

An example theme contains theme.json, shell CSS and at least three distinct effects, including black flame. Selection, reload and ordered composition of more than one effect work without a rebuild. An invalid reload preserves the whole previous chain, and the status confirms generations and IDs. The shell CSS has a real import path through the existing journal. The tests show real effects in the pixels and the images are inspected. The profile, applications and processes of the real session stay preserved; the delivery reports separately published code, prepared build and activation on the desktop.

Implemented delivery and evidence

  • Strict v1 manifest, byte-limited reading, XDG root/absolute override, private active-theme.json selection, per-generation CLI, the Studio theme and chain integration in F9 are implemented.
  • The production chain pre-composes the whole tree into a source texture and applies each pass in order with two ping-pong targets. Each effect has its own program and its own map of CSS parameters; a selection/reload failure keeps the previous runtime. Only eligible F9 thumbnails receive effects; a consumed click preserves the input policy.
  • read_theme_style and import_theme_style are authenticated in MCP. The import requests the current revision and calls the full Store operation (journal, lock, React preview, commit and recovery), including when the previous stylesheet is empty.
  • The Studio theme contains elastic, wave and black-flame as independent external shaders. The shell stylesheet uses tokens from the active UI. Auxiliary assets are not read.
  • The EGL proof of the production chain passed: 320×200, two layers and transparency, Flipped180 orientation, own CSS parameters, non-commutative passes, frozen time, reload after CSS/GLSL/order changes, black-flame and preservation of the previous pixels after invalid GLSL. Artifacts outside Git: /tmp/anos-theme-qa/baseline.ppm, /tmp/anos-theme-qa/after.ppm, /tmp/anos-theme-qa/black-flame.ppm.
  • After integrating origin/main with workspace transitions, the order/motion snapshots and the scene animation path were preserved; the scene also ends/prunes the effect cache on the early return during transitions. cargo fmt --check, default and session tests (49 passed, 4 EGL ignored in each), Clippy with -D warnings, and default and session builds passed.
  • The four ignored EGL tests were run explicitly and passed, including the multipass pipeline, workspace transition composition and the offscreen preview. Black flame also started to keep premultiplied RGB in transparent pixels; the test composes it over a synthetic blue layer.
  • The catalog and per-operation errors limit diagnostics to 512 bytes. Tests cover an invalid manifest with a huge Unicode key without exceeding the response, and preservation of the pre-existing modes of the root/configuration directory.
  • Final evidence from the main agent after the integration: npm run format:check, npm run check/build check, 170/170 Node tests and 49/49 Python tests passed. The synthetic UI imported the Studio CSS, refused invalid CSS and restored the original stylesheet while keeping the four messages.
  • Rust commands run: cargo fmt --all -- --check; cargo test --locked --features session; cargo test --locked; cargo clippy --locked --all-targets --features session -- -D warnings; cargo build --locked --features session; cargo build --locked. All ignored EGL tests were also run explicitly with cargo test --locked --features session -- --ignored --nocapture and the variables ANOS_THEMES_EGL_BASELINE_PPM=/tmp/anos-theme-qa/baseline.ppm, ANOS_THEMES_EGL_AFTER_PPM=/tmp/anos-theme-qa/after.ppm and ANOS_THEMES_EGL_BLACK_FLAME_PPM=/tmp/anos-theme-qa/black-flame.ppm; 4/4 tests passed. The PPMs were regenerated in that last run with the alpha fix and stay out of Git.
  • The isolated production build finished with scripts/prepare-project.py: optimized release with the session feature, compiled UI, Electron dependencies verified by the smoke check in Node mode, the compositor --help and ldd with no missing libraries. The hashes of sources and artifacts match .project-build.json; the marker and the binaries stay out of Git.
  • Visual QA: final EGL images inspected in /tmp/anos-theme-qa/; capture of the synthetic import in /tmp/agent-native-theme-ui-_x2udbtw/theme-import.jpg. The synthetic processes were ended. The proof uses trusted React in the browser and offscreen EGL; it does not prove physical acceptance in the Electron host or on the real desktop.
  • No shared runtime or user session was changed during the initial implementation. The active folder /home/naaando/agent-native-os stayed clean at 1bdaef4, while this worktree holds the new build.

Visual adjustment of black-flame (authorized on 2026-10-28)

The local reference /tmp/shadow-fire-steam-reference.png (a frame of the official APNG, for consultation only) shows a frame: a thin black core, a glowing violet outline and short organic tongues on all four sides and corners. The current implementation, which concentrates the flame in the center, does not match this silhouette.

Correction plan:

  1. Change only native/smithay/themes/studio/effects/black-flame/effect.css and .frag, plus the EGL test in effect_pipeline.rs; do not include or copy the reference asset.
  2. Reserve a frame margin inside the 320×200 texture: slightly shrink and center the content sampling in the shader, using u_size for proportions and thicknesses in pixels. Reduce the padding limits so that they never invert in small thumbnails. Generate in GLSL a ring with a dark core and a violet edge, with animated noise/short tentacles spread over all sides and corners, keeping the central region legible. Expose thickness, brightness and intensity as CSS parameters with a transition; zero intensity must reproduce the identity exactly.
  3. Keep the premultiplied alpha contract: transparent pixels have zero RGB, every visible contribution has RGB bounded by alpha, and the frame can create alpha only where the shader really draws. Keep deformation and color outside the Rust compositor.
  4. Adapt the EGL proof to wide and square screens; compare identity at zero intensity, presence of the frame on the four sides/corners, preserved center, alpha/premultiplication and animation at different frozen times. Generate before/after PPMs outside Git for visual inspection.

Later update: the main agent confirmed the earlier activation of the Studio theme in Smithay login 287, with black-flame enabled and a stable session. The user is switching F9 manually. This correction will be validated offscreen in this worktree; publishing and updating the shader at runtime remain the main agent's responsibility.