Unify the CoS avatar-style vocabulary into one exported registry - #6259
Merged
Conversation
AVATAR_STYLE_LABELS, LAZY_AVATARS, CANVAS_AVATAR_STYLES, and the server's
avatarStyle zod enum were four hand-maintained lists with nothing enforcing
agreement between them — a style added to one but not the enum was a
settings 400 at runtime.
Add client/src/lib/avatarStyles.js as the single source of truth
(AVATAR_STYLES = [{id, label, webgl}]), with AVATAR_STYLE_IDS,
AVATAR_STYLE_LABELS, and WEBGL_AVATAR_STYLE_IDS derived from it. The picker
labels, the WebGL-stage set, and the server's zod enum now derive from the
registry directly; the server imports the client leaf module at runtime the
way server/lib/personaTraitBlend.js already imports `clamp` from
client/src/utils/formatters.js, since it carries no transitive dependencies.
LAZY_AVATARS stays a hand-written id->lazy() map (it holds real component
references, not data), so a new completeness test in ChiefOfStaff.test.jsx
fails loudly if a registry style is missing from both LAZY_AVATARS and the
new INLINE_RENDERED_AVATAR_STYLES set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
client/src/lib/avatarStyles.jsas the single source of truth for the CoS avatar-style vocabulary (AVATAR_STYLES = [{ id, label, webgl }]), withAVATAR_STYLE_IDS,AVATAR_STYLE_LABELS, andWEBGL_AVATAR_STYLE_IDSderived from it.client/src/components/cos/constants.js'sAVATAR_STYLE_LABELSandclient/src/pages/ChiefOfStaff.jsx'sCANVAS_AVATAR_STYLESnow derive from the registry instead of hand-maintaining parallel lists.server/routes/cosStatusRoutes.js'savatarStylezod enum now builds fromAVATAR_STYLE_IDS, importing the client leaf module directly at runtime — the same cross-workspace patternserver/lib/personaTraitBlend.jsalready uses forclampfromclient/src/utils/formatters.js, safe because the leaf has zero transitive dependencies.LAZY_AVATARSstays a hand-writtenid -> lazy()map (it holds real component references, not data). A new completeness test inChiefOfStaff.test.jsxfails loudly if a registry style is missing from bothLAZY_AVATARSand the newINLINE_RENDERED_AVATAR_STYLESset (['svg', 'ascii']), so a style added to the registry alone can no longer silently fall through to the default avatar render.Closes #6253
Test plan
server/routes/cosStatusRoutesAvatar.test.js— asserts every registry id parses through the schema.client/src/lib/avatarStyles.test.js— registry shape and derived-export parity.client/src/pages/ChiefOfStaff.test.jsx— new avatar-style registry coverage test.node_modulesabsent).serverandclientsuites run locally; only 2 pre-existing, unrelated failures (a LoRA trigger-words test and an imageGen watermark hook timeout).