Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1ay1 Agentty Published Appearance Prefs

From Leeroopedia
Knowledge Sources
Domains UI, Appearance
Last Updated 2026-10-28 12:00 GMT

Overview

Per-frame published snapshot of appearance preferences readable from view code and background workers, so free functions deep in the render tree can read prefs without a Model.

Description

The agentty::ui_prefs::live module is the published appearance prefs seam. The prefs live on the Model, and the view is a pure function of it — but consumers like `panel_viewport_h()` (a free function called from twenty panel builders) and the StreamingMarkdown setup in `turn.cpp` can't be handed a Model without rewriting the world. So the prefs are PUBLISHED once per frame via `publish()`, and everything downstream reads `current()`.

Not a place to stash mutable UI state — it holds a COPY of one field of the Model, refreshed every frame. A reducer must never call publish(). The lock is for background workers that build tool previews off-frame: they get a consistent snapshot rather than a torn read.

Convenience readers (`animations_on()`, `reveal_decoration_on()`, `motion_frame_divisor()`, `panel_rows()`) are named for the QUESTION each consumer asks, not for the field it reads — so `animations_on()` keeps working if the motion model grows a fourth level.

Usage

Import this when you need to read appearance prefs from view code, panel builders, or background workers without threading a Model through.

Code Reference

Source Location

Signature

namespace agentty::ui_prefs {

// Publish the prefs every consumer sees. Called once per frame by view().
inline void publish(const Prefs& p);

// The prefs in force. Defaults until first publish().
[[nodiscard]] inline Prefs current();

// Convenience readers (named for the question, not the field):
[[nodiscard]] inline bool animations_on();
[[nodiscard]] inline bool reveal_decoration_on();
[[nodiscard]] inline int  motion_frame_divisor();  // 1=Full, 4=Reduced, 1=Off
[[nodiscard]] inline int  panel_rows();           // viewport height ceiling

// Path roots for tool card path display:
struct PathRoots { std::string cwd, home; std::vector<std::string> project_agents; };
inline void publish_path_roots(PathRoots r);
[[nodiscard]] inline PathRoots path_roots();
}

Import

#include "agentty/domain/ui_live.hpp"

I/O Contract

Inputs

Name Type Required Description
p Prefs Yes (publish) The Model's current prefs, published once per frame

Outputs

Name Type Description
current() Prefs The prefs in force (snapshot, atomic load)
animations_on() bool Whether any motion is allowed
motion_frame_divisor() int Frame rate divisor (1=Full, 4=Reduced)

Usage Examples

Read Prefs from a Free Function

#include "agentty/domain/ui_live.hpp"

// Deep in the render tree, no Model available:
int max_rows = agentty::ui_prefs::panel_rows();  // 10/14/22 by density
if (agentty::ui_prefs::animations_on()) {
    // Show the streaming reveal typewriter
}

Publish from view()

// view() publishes before building anything:
agentty::ui_prefs::publish(model.d.persisted.ui);
agentty::ui_prefs::publish_path_roots({
    .cwd = model.env.cwd,
    .home = model.env.home,
    .project_agents = model.ui.library.agents
});
// Everything downstream reads current() / path_roots()

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment