0002: Typed ids that serialize to strings
Date: 2026-10-11. Status: accepted.
Context
Commands, menus, panels, zones, blocks, plugins, services and settings are
all named by strings that end up in files (keymaps, layouts, settings) and
in the agent surface. With plain Strings a command id slips into a menu
id parameter, a typo in a zone name compiles, and nothing tells the reader
which namespace a string belongs to.
Decision
Every kind of id is a newtype: CommandId, MenuId, PanelId,
ZoneId, BlockId, PluginId, OwnerId, SettingId, ServiceId.
They are generated by one macro in egui-pop-model::ids, share one
syntax (ASCII letters, digits and . _ - / :, not empty, at most 128
bytes) and:
- serialize and deserialize as plain strings (
"view.palette"), so files and JSON stay readable; deserializing checks the syntax; - build at compile time from literals,
const SIDEBAR: ZoneId = ZoneId::from_static("app.sidebar"), where an invalid literal is a compile error, and at run time withZoneId::new(text)returning aResult; - are cheap to clone (a
Cow<'static, str>: literals are never copied).
Well-known ids (the shell’s zones, its menus) are typed constants, so a typo is a compile error rather than a block that never shows.
Consequences
- APIs say what they take:
fn block(&mut self, zone: ZoneId, ...). - Converting from a user-provided string is explicit and fallible.
- The syntax keeps ids usable in file names, JSON keys and when-clauses.