Coverage for app / services / appearance.py: 100%
18 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-10-31 11:21 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-10-31 11:21 +0000
1"""Presentation vocabulary shared by resources the user can style.
3Dashboards, agents and knowledge repositories all let the user pick a *lucide
4icon name* and an *accent key*, and all can have those proposed by a model
5during generative setup. The palette is one platform-wide set — a board and an
6agent tinted ``emerald`` must read as the same colour — while the icon set is
7per resource type, because a dashboard's glyphs (``Newspaper``, ``CloudSun``)
8say nothing useful about an agent or a shelf of sources.
10Stored values are deliberately *not* constrained by the database or the CRUD
11schemas: the frontend falls back to a default glyph and a neutral tone for
12anything it does not recognise, so these lists can grow without a migration.
13They exist to bound what a *model* may return — :func:`one_of` clamps a
14generated value to the allowed set rather than letting a hallucinated icon
15reach a row.
16"""
18from __future__ import annotations
20from typing import Any
22#: The accent palette, mirroring `TONES` in the frontend's appearance module.
23ACCENTS = [
24 "violet",
25 "blue",
26 "sky",
27 "amber",
28 "emerald",
29 "indigo",
30 "rose",
31 "slate",
32]
34#: Neutral tone used when nothing was chosen or the choice is unknown.
35DEFAULT_ACCENT = "slate"
37#: Icons offered for a dashboard, mirroring `BOARD_ICONS` in the frontend.
38DASHBOARD_ICONS = [
39 "LayoutGrid",
40 "Home",
41 "Sunrise",
42 "Newspaper",
43 "Activity",
44 "CloudSun",
45 "Scale",
46 "Bookmark",
47 "ShieldCheck",
48 "Library",
49 "Bot",
50]
52DEFAULT_DASHBOARD_ICON = "LayoutGrid"
54#: Icons offered for an agent, mirroring `AGENT_ICONS` in the frontend. The
55#: set is chosen to say something about an agent's *job* — support, research,
56#: automation — rather than to be a general-purpose glyph picker.
57AGENT_ICONS = [
58 "Bot",
59 "Brain",
60 "Sparkles",
61 "MessageSquare",
62 "Compass",
63 "Telescope",
64 "PenLine",
65 "Gavel",
66 "Stethoscope",
67 "Rocket",
68 "ShieldCheck",
69 "Cog",
70]
72DEFAULT_AGENT_ICON = "Bot"
74#: Icons offered for a knowledge repository, mirroring
75#: `REPOSITORY_ICON_REGISTRY` in the frontend. A repository is a themed shelf
76#: of sources, so the set names *what kind of material* it holds — reference,
77#: legal, research, operational — rather than the file types inside it.
78REPOSITORY_ICONS = [
79 "FolderGit2",
80 "Library",
81 "BookOpen",
82 "Archive",
83 "Landmark",
84 "Scroll",
85 "FlaskConical",
86 "GraduationCap",
87 "Briefcase",
88 "Database",
89 "Globe",
90 "Boxes",
91 # The kinds of method and update the built-in repositories hold.
92 "Network",
93 "Workflow",
94 "Lightbulb",
95 "Microscope",
96 "ShieldCheck",
97 "Telescope",
98 "BellRing",
99]
101DEFAULT_REPOSITORY_ICON = "FolderGit2"
104def one_of(value: Any, allowed: list[str], fallback: str) -> str:
105 """Clamp a model-supplied value to `allowed`, else `fallback`."""
106 return value if isinstance(value, str) and value in allowed else fallback
109def agent_icon(value: Any) -> str:
110 return one_of(value, AGENT_ICONS, DEFAULT_AGENT_ICON)
113def repository_icon(value: Any) -> str:
114 return one_of(value, REPOSITORY_ICONS, DEFAULT_REPOSITORY_ICON)
117def accent(value: Any) -> str:
118 return one_of(value, ACCENTS, DEFAULT_ACCENT)