# User Identity Display

## Objective

Show who someone is the same way on every screen, including when the record is gone.

A single component that renders a person's avatar, name, secondary label, and role wherever a human is referenced.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Identify every surface that names a person — assignees, comment authors, audit entries, member lists, mentions, hover cards, activity feeds — and replace each bespoke rendering with the shared component.
2. Define the fallback chain once and apply it everywhere: display name, then full name, then the email local part, then a neutral placeholder. Never fall through to a raw identifier.
3. Generate initials and a placeholder avatar deterministically from the stable account identifier, so the same person keeps the same colour and shape across sessions and screens.
4. Give the component explicit variants for account states — active, invited, deactivated, deleted — so callers pick a variant rather than each screen inventing its own way to grey someone out.
5. Do not have every instance fetch its own profile. A table of two hundred rows must resolve the people it references in one request and hand the resolved records to the component.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- Users who are deleted, still pending an invitation, or suspended must still render as something recognisable. A comment written by someone who has since left should say so plainly rather than showing a blank space or the word 'null'.
- Privacy rules decide what a given viewer may see. Someone outside a workspace may be entitled to a display name and nothing else — never let an email address reach a viewer who has no right to it just because the component happened to receive one.
- Long names, names that are a single very long token, and names in scripts with no spaces will all overflow. Truncate visually with the full value available on hover and in the accessible name, and never truncate mid-grapheme.
- Identity must be keyed on the immutable account identifier, not the display name, so a person who renames themselves does not appear as two different people in the same thread.
- Names carry scripts, diacritics, right-to-left text, and emoji. Initials derived by taking the first letter of each word will produce nonsense for some of them, so degrade to a neutral placeholder rather than a wrong initial.
- System and automation actors — the scheduler, an integration, an API key — appear in the same lists as people and need their own variant instead of being dressed as a user.
- Avatar images fail to load, and the fallback must occupy exactly the same box so nothing reflows when it does.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] Every reference to a person in the app renders through the shared component.
- [ ] Deleted, invited, and suspended accounts each render in a distinct, legible state rather than blank.
- [ ] No field is displayed that the current viewer is not permitted to see.
- [ ] The same person shows the same placeholder colour and initials on every screen and after a rename.
- [ ] Long and non-Latin names truncate without breaking layout, with the full value accessible.
- [ ] A list of many people resolves their profiles in bulk rather than one request per row.
- [ ] A failed avatar image leaves the layout unchanged.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
