Skip to main content

Module presence

Module presence 

Modules§

capability
Widgets that publish where their user is (caret, selection) to peers.

Structs§

AgentActionMarker
Geometry and phase of one paint-only agent action marker.
EdgeMist
A resolved off-screen wayfinding cue: which edge to paint on, where along that edge the peer projects to, and how far off-screen they are.
InteractionCardPlacement
Geometry of one generic fallback card. Public so app hosts and tests can reserve the same non-overlapping activity rail without copying constants.
LayerMarks
Where a PresenceLayer paints, on screen and this frame (PresenceLayer::marks), in the layer’s scene coordinates.
PeerCursor
PillPlacement
Where a pill ended up; tethered means the caller should draw a line back to its pointer.
PillRequest
PresenceCtx
PresenceLayer
The presence a window paints over its widgets, kept from frame to frame so the next frame damages only what changed. Retains draw caches only.
PresenceUser
RemoteCursor
SelectionRange
WidgetPresence
Everything in a PresenceCtx a widget may paint from, as of one frame.

Enums§

MistEdge
Which screen edge a mist band hugs — i.e. the direction an off-screen peer is relative to the viewport.
ParticipantKind
The kind of participant behind a live presence stream. This comes from the authenticated room context, never from a display-name convention.
PathSegment
PointerOwner
Which layer paints a peer’s pointer — a screen position, so only one layer may place it correctly (an app painting a desktop coordinate into its own window space is right only at the origin). The compositor owns desktop-scoped pointers, since it alone spans the strip, chrome and gaps between windows continuously; an app owns presence inside its own content (caret, selection, typing swipe), since the compositor has no access to the text.
PointerSpace
The coordinate space a pointer position is measured in.
PresenceKey
RemotePresenceEffect
What a subscriber still has to do after PresenceCtx::apply_remote_presence folds a frame in, beyond the presence stores. A subscriber with no document (the compositor) ignores it.

Constants§

ACTIVE_INTERACTION_EXPIRY
A live phase that has not been restated stops occupying the app surface. The durable Task Center remains the place to diagnose a stalled run.
DIGEST_KEY_FIELD
First path field of a PresenceKey::digest_form key.
PEER_PALETTE
Every colour a peer can be drawn in: the design language’s twelve presence hues (tokens::colors::PRESENCE_HUES, 30° apart) at the dark material’s presence lightness and chroma (OKLCH L 0.74, C 0.14, gamut mapped), as sRGB. Equal lightness and chroma, so no participant looks more important than another; a closed ring rather than a hash over all 360 hues, so two people never land a few degrees apart.
POINTER_EASE_MAX
Longest a peer’s pointer takes to glide to a newly heard position. Peers publish at ~30 Hz, so a moving pointer glides over the gap between its last two samples (~33 ms) and arrives as the next one is due; this caps the glide after a pause, so a pointer that sat still for a while does not drift lazily to where it was just put. See PresenceCtx::pointer_position_at.
POINTER_FADE
How long a quiet peer’s pointer takes to fade out, ending at POINTER_IDLE. See PresenceCtx::pointer_opacity.
POINTER_IDLE
How long a peer’s pointer stays painted after it was last heard about. Comfortably past the ~1s restate interval a live peer keeps, so this notices a peer gone quiet rather than blinking one whose keepalive was briefly delayed. See PresenceCtx::prune_pointers.
TERMINAL_INTERACTION_DWELL
A terminal edge remains perceptible even when an immediate action starts and completes between two rendered frames.
TYPING_FADE
How long a “just typed” highlight lingers before fading out.

Functions§

assign_peer_colors
Give everyone in a room a colour nobody else in it is wearing.
color_distance
How far apart two colours are, weighted the way an eye weights them (the “redmean” approximation).
contrast_ink
Black or white ink for text on bg, by luma — a fixed white label is unreadable on over half the peer palette (11 of 24 entries under 2:1, palest 1.24:1 against white).
draw_peer_cursors
Paint pointers, then tethers, then pills — in that layer order so a later peer’s halo can’t wash over an earlier peer’s name. viewport bounds the pills; positions are assumed already filtered to it.
draw_peer_presence
Paint already-resolved peer cursors in one coordinate space. On-screen peers get moving dots and collision-free name pills; off-screen peers become directional edge mist. This is the compositor-facing sibling of draw_remote_presence, which resolves cursors from a PresenceCtx.
draw_remote_cursors
Paint every entry in presence.remote_cursors as a dot + name pill, for non-shell apps drawing cross-process ghost cursors without reimplementing the geometry. No viewport, so pills are de-overlapped but not clamped — prefer draw_remote_presence, which keeps names on screen.
draw_remote_presence
The one call the app makes each frame to render all cross-process peer presence: on-screen peers get a dot + pill, off-screen peers get an edge mist. viewport is the visible rect in the same (logical) space as cursor positions.
edge_mist_for
Compute the edge-mist cue for target relative to viewport.
identity_rgb
A presence hue as the identity colour it travels as.
layout_peer_pills
Place one name pill per peer so none overlap and none leaves viewport. Each pill tries the four corners around its pointer, taking the first clear of the viewport and every already-placed pill; only when all four are taken does it slide along the vertical and get marked tethered. Placement order is by position, not arrival, so a peer reconnecting doesn’t reshuffle everyone else’s names.
parse_hex_color
Parse a #rgb / #rrggbb / #rrggbbaa colour string to an RGB triple (see crate::color::parse_hex). Alpha is discarded; None for anything unparseable.
user_color
Stable identity colour for a collaborator who has not chosen one: the presence hue crate::tokens::PresenceHue::of_identity derives from their id, as the sRGB colour in PEER_PALETTE. A pure function of the id alone: two hosts painting the same room see different peer sets (everyone but themselves), so a colour derived from who’s present couldn’t agree across machines.

Type Aliases§

PointerPositions
A pointer’s last-known (x, y) per user, at each PresenceKey.