Expand description
The UI error-code scheme (facet-<component>-<n>) — the stable, unique code
every facett UI part carries so tests + consumers react to the CODE, not a matched
string. See errcode::FacetError, the facet_err! macro, the canonical
errcode::REGISTRY, and the pink errcode::code_color renderer.
The DEV-ID badge — every pane says who it is, in non-release builds only.
Rickard’s ask, verbatim: “show an uniqe ID on each pane/component in non release mode … make it easy to copy this one to claude and explain where i am”.
§Why this is the errcode scheme’s other half
crate::errcode already answers “what went wrong” with a stable
facet-<component>-<n>, and its REGISTRY maps a
component to the crate dir, the source file and a Codeberg URL. This module answers
the sibling question — “where am I” — with the same vocabulary, so a badge
pasted into a chat resolves to a crate and a file with no guessing on either side.
It is not an error; a pane showing its dev-id is perfectly healthy.
§The trap this is built to avoid
facett-core/tests/errcode_raise_sites.rs found that facet_err! fabricates its
code with concat! and never asks the registry whether it exists, so
facet_err!(map, 99, …) compiles and yields an authoritative-looking facet-map-99
that lookup cannot resolve. A dev-id badge has exactly that hole: an id that looks
canonical but names nothing wastes the time of whoever pastes it AND whoever reads it.
So the badge is honest about its own confidence, and the two cases are rendered so they cannot be mistaken for each other:
- registered —
facet-geomapin the registry’s own colour. [resolve] hands back the crate dir + source file, so the id is actionable on arrival. - unregistered —
⟨unregistered⟩ Some Title, dimmed and bracketed. It still identifies the pane (better than nothing when you are staring at a bug), while saying plainly that it will not resolve to a file. Every one of these is a pane waiting to declareFacet::component— the badge doubles as the to-do list.
Two failures that render identically make a bug immortal (the ⚒ Build Thing
post-mortem, quoted in errcode_raise_sites.rs). The same reasoning applies to two
confidences that render identically.
§When it shows
ON in debug builds. In a RELEASE build it is off by default but can be switched on
with FACETT_DEVID=1 — because the binaries people actually run on this fleet
are release builds. Gating on debug_assertions ALONE made the whole feature
invisible to the person who asked for it: every pane was wired, every test was
green, and the installed korp-ui painted nothing, because badge had compiled to
an empty function. A debug-only debugging aid is not a debugging aid. The function is
always present so no call site needs a cfg.
Constants§
- DEVID_
ATOM - The prefix every dev-id atom carries in the a11y tree, so a headless test can find the chip among a pane’s own atoms without matching on the id text itself.
- FOCUSED_
MARK - The suffix the chip’s atom carries when its pane is the one the pointer is in.
- UNREGISTERED
- The marker a pane that has not declared a component renders instead of an id.
Deliberately not id-shaped — it can never be mistaken for a
facet-*code.
Functions§
- badge
- Paint the dev-id chip in the top-right of
rect, and copy the id to the clipboard when clicked (so it lands in a chat with one click, which is the entire point). - badge_
text - What the badge should say for a pane — the pure decision, split out from any painting so it is testable without a GPU (and so the release build’s no-op cannot silently diverge from what debug shows).
- chip_
colors - The chip’s colours —
(foreground, background plate), split out so the OPACITY of the plate is assertable without a GPU. - chip_
colors_ focused - The chip’s colours when its pane HAS focus — brighter foreground, a lifted plate.
- enabled
- Is the dev-id chip switched on? Debug builds: yes. Release builds: only with
FACETT_DEVID=1, so the aid is reachable in the binaries that actually ship.FACETT_DEVID=0turns it off even in debug. Read once and cached — this is called per pane per frame. - gate_
json - The gate, as observable data — folded into
FacetDeck::state_jsonandfacett_app::scene::render’s state under the keydevid, so a headless oracle can report why there are no chips without anyone opening a window. - is_
registered - Is this component known to the
errcoderegistry? - normalize
- Normalise a raw dev-id to a registry component.
- resolve
- Resolve a dev-id to its source —
(crate_dir, src_file)for a component that theerrcoderegistry knows,Noneotherwise. - resolve_
enabled - The gate decision, as a pure function —
$FACETT_DEVID(if set and understood) wins, otherwise the build profile decides.