Galaxy Shell / docs
Docs / Decisions and plans

External effects plan with CSS and shaders

openspec/changes/archive/2026-10-27-css-window-effects-plan/design.md · Edit on GitHub ↗

This document records decisions, plans or evidence from a project stage. It does not imply that every item is implemented or validated in the current version.

On this page

External effects plan with CSS and shaders

Doc status: history. The plan of 2026-10-27 was implemented; see css-window-effects.md and themes.md. Checked 2026-11-10.

Date: 2026-10-27. The project owner authorized the implementation after a discussion about loadable shaders and CSS transitions for wobbly. The plan comes before the code changes. GPT-6 Luna with high reasoning does the implementation. The main agent does the review and checks the integration.

Expected result

Define effects in external files and reload them in a compositor that already contains the engine. CSS describes states and transitions of numeric parameters. GLSL defines the deformation and the appearance. Adding another effect that uses this contract must not require recompiling Rust. The first installation of the engine requires a new compositor process. It will not be done by ending the session in use.

The first delivery includes a demonstrable elastic effect, an example external definition, explicit reload, disabling, diagnostics and preservation of the last valid effect. The UI and the controls stay web. Generated HTML gets no access to the engine or to the application textures.

Initial state and isolation

The original worktree contains WIP on workspace previews, including in scene.rs and desktop.rs. It will be preserved. The implementation starts from origin/main, initially 1bdaef4, in a dedicated worktree named css-window-effects. Concurrent updates to main will be integrated before publishing. Do not overwrite sources from other work.

The current renderer uses GlesRenderer, scaling, repositioning and clipping. There are DRM and nested backends, its own capture and a private Unix bridge. Free window dragging is not implemented. The effect must not advertise a drag gesture that the product does not offer yet. Existing movements and presentation changes can feed the deformation. A demonstration state lets the team check the contract without inventing application control.

Contract of the first version

  1. Define an explicit package folder, selected at startup by configuration or an environment variable. Local CSS and shader files are trusted maintenance resources. The engine stays disabled without configuration, and existing profiles do not change.
  2. Use a documented CSS subset. Do not advertise support for full CSS. Simple selectors identify the eligible window and states that actually exist, such as overview and geometry change. Custom numeric parameters map to uniforms. Declare names, units, limits and precedence.
  3. Interpret transition-property/duration/timing-function/delay, or the equivalent shorthand, for the supported parameters. Support linear, the usual curves and cubic-bezier. A linear() curve with multiple points allows an elastic return. The exact grammar can be reduced after inspection, but every unsupported construct must produce an explicit error. It must never be ignored in a way that produces a different animation.
  4. Provide the time, size and progress/state that the shader needs. Parameters must be finite and bounded. When a transition is interrupted, start from the current visual value to avoid jumps. The engine does not promise to preserve the physical velocity of a spring.
  5. The deformation formula belongs to the external shader. Rust provides generic loading, interpolation, state and rendering. It must not contain a switch per effect name or formulas specific to wobbly or flame.
  6. Deliver a private operation for reload, disabling and query. Prefer the Unix bridge authenticated by UID and a simple maintenance client. Do not add tools to the HTML and do not change the model/provider.

Graphics integration

Inspect the pinned Smithay 0.7 API before choosing between a custom texture element and an offscreen stage. The effect of a window must treat its surface tree as one unit. It must respect transparency, subsurfaces, scale and orientation. If rendering offscreen is necessary, keep the buffers on the GPU during normal use and limit dimensions, count and memory. Do not read from GPU to CPU on every frame.

The same path must serve DRM and EGL. Prepare/import textures before binding the final framebuffer, following the renderer contract. Animations must produce damage while they change and stop invalidating when they end. Release the resources of closed windows and replaced configurations. Do not recompile shaders on every frame.

Preserve the existing window compositor, focus and layout. The protected shell, recovery, bars and cursor stay out of the deformation by default. The web overview can trigger the effect state, but the engine does not create native controls. Do not present an animation applied to hidden windows as a visible effect in the overview. Document the implemented target precisely.

Problems to solve

  • CSS syntax and semantics: parsing of blocks, comments, lists and functions cannot depend on naively splitting by commas. cubic-bezier and linear use commas internally. Reject unknown selectors, units and functions. Test zero duration, delay and interruption.
  • Wobbly and input: distorting pixels does not update hit testing automatically. Limit the decorative deformation, offer immediate disabling and avoid clicks forwarded to wrong coordinates. Do not block the keyboard, recovery or exit shortcuts. A physical mesh with free dragging is outside this first delivery.
  • Margins and clipping: a UV distortion inside the rectangle can be enough for the proof, but it is not the same as an arbitrary silhouette outside it. If this is the chosen path, record the limitation and protect edges/transparency. Do not promise a mesh expansion that was not implemented.
  • Cost and damage: limit resources, avoid work on invisible windows and offer reduced motion/disabling. Do not state FPS or latency without physical measurement.
  • Package failure: validate everything before switching the active effect. Invalid CSS, a missing file or a shader that does not compile preserve the previous package and record a bounded error. Do not depend on rereading the old files after a defective reload.
  • GPU failure: an arbitrary shader is not a sandbox. Size limits do not guarantee an execution deadline and do not prevent a driver hang. Loading is trusted maintenance. Recovery from a hung GPU depends on external supervision, and hot reload must not promise it.
  • Configuration and access: do not let a renderer select paths or inject GLSL. Resolve resources inside the package folder, limit size, reject links and unexpected paths that leave the folder, and do not log pixels or window content.
  • Compatibility: follow concurrent changes to previews and capture, without degrading the path without effects. Do not change profile behavior or run legacy app.js.

Steps

  1. Write this plan, inspect the APIs and confirm the viable contract.
  2. Luna high implements the parser, interpolation and tests without starting the compositor or the host.
  3. Luna high integrates external shaders into the renderer and the private reload. It adds an example package and usage documentation.
  4. Review error paths, resource retention, damage, orientation and isolation. Fix the problems found.
  5. Run Rust tests with session, formatting, Clippy and build. Run npm ci, format:check, check and the shell tests. Graphics integration tests use offscreen EGL and synthetic data, without opening a nested session or another host.
  6. Inspect synthetic images produced by the real graphics path to check deformation, transparency and orientation. Record unit tests, EGL proof, browser/Electron and real session separately. Captures and artifacts stay out of Git.
  7. Publish validated commits directly to main, integrating concurrent advances. Check sourceRoot and coordination before any synchronization of the active folder. Do a fast-forward only if the folder is clean, and prepare the build under lock. Do not replace the compositor process and do not end the current session.

Acceptance criteria

  • Changing the package CSS and GLSL and reloading changes the effect without rebuilding the compositor that already contains the engine.
  • The elastic demonstration uses external CSS interpolation and a GLSL formula, with pixel evidence from the real renderer.
  • An invalid reload keeps the last valid package. Disabling returns to the original drawing.
  • The surface tree, alpha, orientation, the end of the animation and the path without effects have relevant checks.
  • State/diagnostics distinguish requested configuration, compiled shader, error and disabling.
  • The profile, history, applications and processes of the session in use stay preserved.
  • The delivery states clearly whether it was only published/prepared for the next login. Synthetic proof is not the same as physical wobbly on the user's desktop.

Evidence and scope adjustments

Technical adjustments after the Smithay 0.7 inspection

  • WaylandSurfaceRenderElement does not expose the textures to a shader wrapper. The viable path is to compose the tree of each toplevel with OutputDamageTracker into an offscreen GlesTexture, then draw a TextureShaderElement. The Winit/EGL renderer and the DRM/GLES renderer share this path.
  • The target applied in this version is only the native F9 overview, and only external applications registered by the compositor. The web workspace overview does not trigger the rule. Focus/click actions stay on the original rectangle, and the old path continues when the package does not exist or fails.
  • The offscreen integration keeps at most 32 textures of up to 320x200 (8,192,000 bytes, 7.8125 MiB RGBA at the limit), identified by window ID. It removes unused caches and clears them when leaving F9. u_time requires continuous recomposition of thumbnails while F9 is active. The deformation is UV inside the rectangle, with no mesh expansion.
  • The CSS contract was deliberately reduced to one .window optionally followed by one .window:overview. :geometry-change was removed because no real trigger exists. Mixed shorthand/longhands, duplicate rules, and unknown selectors and syntax fail. There are at most 16 parameters --[a-z][a-z0-9-]*, values -4..4, and files of 32 KiB. u_time and u_size are built-in uniforms. CSS uses --name -> u_name.
  • The package is discovered in ~/.config/agent-native-os/effects (or through AGENT_NATIVE_EFFECTS_DIR before the process starts). Without a package, the engine stays inactive. Maintenance uses the commands effects_status, effects_reload and effects_disable on the existing socket with UID authentication. The requested/applied generation is explicit. Parse/compilation replaces the state only after success.

Evidence and observed limits

  • Parser/interpolation tests include functions with nested commas, rejection of unknown tokens, repeated rules, names without NUL, linear() stops, delay, zero duration, curve and interruption. The Python client has tests for generation confirmation, timeout and supersession.
  • A real offscreen EGL test, with no Wayland compositor, creates two layered synthetic elements with an asymmetric shape and transparent regions. It checks identity with value zero, repeatability with fixed time, identity in Transform::Flipped180, pixel change with CSS/GLSL progress, reload of an edited shader, preservation of the last package on a compile error, and alpha. Private before/after PPMs were inspected at 320x200.
  • The final checks passed: cargo fmt --check; cargo test --locked --features session (31 ok, 2 EGL tests ignored by default); Clippy --all-targets --features session -- -D warnings; cargo build --locked --features session; the Python client suite 3/3 and the full Node suite (npm ci, format/check/test) 148/148. The EGL test was run explicitly and passed. It is synthetic and does not create a Wayland session.
  • The EGL proof confirms only the synthetic offscreen GLES path. There is no GPU measurement, no orientation check on physical DRM, no interaction in a visible window and no performance measurement. The deformation stays inside the rectangle, and the shader does not synchronize hit testing. The team did not start a nested session, did not start an extra host and did not touch the shared runtime.

Integration with workspace previews

Main received 490af73 during the implementation. The integration preserves the offscreen previews and processes both them and the effects before binding the final framebuffer in DRM and Winit. The F9 effects stay separate from the web overview images.

After the integration, the default Rust tests and the Rust tests with session passed (35 in each run, three EGL tests ignored by default). The three EGL tests passed when run explicitly. Formatting, Clippy with warnings as errors and the session build passed. Formatting and the shell check/build passed again, as did 155 Node tests and 45 Python tests. The main agent also inspected the synthetic before/after images at 320x200.

Activation requires a coordinated update of the active folder and an authorized next login. The running core still serves the assets of the previous revision. Updating only its files while it stays open can leave incompatible routes on a reload. For this reason, the preparation of the delivery stays isolated in this worktree. It does not synchronize the active folder, change its profile, install the example package in it or restart processes. Publishing to main and isolated preparation do not mean the next login is updated.

The preparer scripts/prepare-project.py finished in this worktree with the lockfile dependencies, the native Electron check in Node mode, the host build/check and the Rust release build with session. The .project-build.json marker, dependencies and binaries stay out of Git. The preparation did not open any additional compositor or graphical host.