Skip to content

Editor: Add a collaborator avatar with an inactive state - #87889

Draft
ciampo wants to merge 6 commits into
trunkfrom
add/editor-collaborator-avatar-inactive-state
Draft

ciampo wants to merge 6 commits into
trunkfrom
add/editor-collaborator-avatar-inactive-state

Conversation

@ciampo

@ciampo ciampo commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What?

Follow-up to #87841 (follow-up 2) and #87862.

Adds CollaboratorAvatar, an editor wrapper around the @wordpress/ui Avatar with the dimmed state that the editor Avatar uses for disconnected collaborators. Nothing uses it yet.

Why?

The collaborator UI is moving to the ui Avatar, but the ui Avatar has no inactive state. The collaborators list dims the avatar of a collaborator who disconnected. This PR keeps that state in the editor, so the move doesn't need a new ui prop. Whether dimmed belongs in the ui Avatar itself is open for discussion here.

How?

  • dimmed drops the collaborator color, so the avatar uses the neutral fill and ring of the theme. It also turns the image gray and fades the avatar to 50%. The text around the avatar has to describe the inactive state.
  • Other props go to the ui Avatar. The import has an inline exception for @wordpress/use-recommended-components, as core-fields does.
  • The wrapper doesn't carry the editor Avatar's statusIndicator prop. It came in with [Real-time collaboration] Refine collaborator overlay with Avatar component integration #75595 and no caller has ever passed it. The editor Avatar keeps it until a later step removes that component.

Testing Instructions

  1. Run npm run storybook:dev and open Editor / Collaborator Avatar.
  2. In Dimmed, the dimmed avatars should be gray and faded, next to the active ones.
  3. In the Storybook toolbar, set the color theme to Dark. The dimmed avatars should follow the theme.

Testing Instructions for Keyboard

No interaction. The wrapper adds no focusable element.

Screenshots or screencast

Rendered in a browser test, not part of this PR. The first row is the editor Avatar on trunk, the second is CollaboratorAvatar. In each row: active initials, dimmed initials, active image, dimmed image.

Light theme Dark theme
Editor Avatar and CollaboratorAvatar in the light theme Editor Avatar and CollaboratorAvatar in the dark theme

Points to discuss:

  • Initials color. On trunk, a dimmed avatar with initials keeps the collaborator color. The editor SCSS asks for a gray fill, but a more specific rule overrides it. CollaboratorAvatar uses the neutral fill, as the SCSS intended.
  • Contrast. At 50% opacity, the initials of a dimmed avatar are faint, most of all on the dark theme. The name next to the avatar in the list stays readable.
  • Status indicator. This PR drops it, since nothing uses it. If the collaborator UI needs one, it can come back with that use case, in the editor or in the ui Avatar.

Follow-ups

Use of AI Tools

Written with Claude Code (Claude Opus 5.5), at my direction: Claude made the change, captured the screenshots, and drafted this description.

🤖 Generated with Claude Code

Wrap the @wordpress/ui Avatar in the editor and add the inactive state that
the editor Avatar has: `dimmed` drops the collaborator color, turns the
avatar gray and fades it, and `statusIndicator` shows an icon over a dimmed
avatar at full opacity. The collaborator UI can then move to the ui Avatar
without adding these props to the ui component.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ciampo ciampo added [Type] Code Quality Issues or PRs that relate to code quality [Package] Editor /packages/editor labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

📦 Bundle size

Size Change: 0 B

Total Size: 8.85 MB

d4dd04b Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 6985d9c trunk % Change
timeToFirstByte 59.15 ms +6.85% -2.45% 58.75 ms +12% -3.4% 0.68%
largestContentfulPaint 92 ms +8.7% -4.35% 92 ms +4.35% -6.52% 0%
lcpMinusTtfb 31.15 ms +24.4% -3.85% 28.95 ms +31.61% -4.32% 7.6%
wpBeforeTemplate 31.09 ms +11.74% -2.03% 30.84 ms +14.14% -2.43% 0.81%
wpTemplate 23.81 ms +5.63% -2.6% 23.72 ms +4.81% -4.43% 0.38%
wpTotal 55.37 ms +6.65% -3.34% 54.36 ms +13.61% -2.59% 1.86%
wpMemoryUsage 7.76 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 6985d9c trunk % Change
timeToFirstByte 48.3 ms +9.73% -1.14% 48.85 ms +6.14% -2.66% -1.13%
largestContentfulPaint 84 ms +7.14% -0% 84 ms +4.76% -0% 0%
lcpMinusTtfb 36.25 ms +3.31% -1.1% 35.7 ms +1.26% -4.48% 1.54%
wpBeforeTemplate 28.04 ms +6.13% -0.86% 27.81 ms +8.23% -1.11% 0.83%
wpTemplate 17 ms +6.82% -2.59% 17.17 ms +2.39% -2.8% -0.99%
wpTotal 45.17 ms +9.05% -1.57% 45.38 ms +6.13% -2.2% -0.46%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 6985d9c trunk % Change
mediaProcessingJpeg 397.9 ms +0.38% -0.22% 400.12 ms +1.04% -0.22% -0.55%
mediaProcessingAvif 6157.32 ms +0.37% -0.24% 6148.79 ms +0.36% -0.29% 0.14%
mediaProcessingJpegToAvif 4246.78 ms +0.18% -0.28% 4230.12 ms +0.25% -0.16% 0.39%

media-upload

Metric 6985d9c trunk % Change
jpegUploadProcessing 1995.64 ms +2.02% -23.02% 1508.4 ms +30.19% -0.34% 32.3%
pngUploadProcessing 283.08 ms +2.43% -3.05% 277.99 ms +2.63% -2.97% 1.83%
largeJpegUploadProcessing 1535.01 ms +29.35% -2.21% 1961.47 ms +2.36% -23.77% -21.74%
multipleImageUploadProcessing 2091.1 ms +0.35% -1.64% 2079.36 ms +0.92% -1.17% 0.56%

post-editor

Metric 6985d9c trunk % Change
serverResponse 476.19 ms +1.78% -0.16% 476.71 ms +1.44% -9.25% -0.11%
firstPaint 433.28 ms +11.72% -11.41% 389.93 ms +10.52% -6.24% 11.12%
domContentLoaded 824.19 ms +3.46% -2.96% 812.38 ms +0.77% -1.12% 1.45%
loaded 825.83 ms +3.46% -2.97% 814.09 ms +0.75% -1.13% 1.44%
firstContentfulPaint 473.23 ms +2.28% -6.46% 450.99 ms +3.41% -1.97% 4.93%
firstBlock 2212.21 ms +4.01% -1.56% 2223.12 ms +0.18% -0.49% -0.49%
type 17.71 ms +7.51% -5.87% 16.73 ms +4.66% -9.5% 5.86%
typeWithoutInspector 17.58 ms +5.8% -2.62% 17.15 ms +3.32% -4.43% 2.51%
typeWithTopToolbar 21.38 ms +9.31% -2.81% 22.21 ms +7.43% -2.7% -3.74%
typeContainer 8.1 ms +1.73% -3.95% 8.49 ms +4.83% -13.55% -4.59%
focus 110.15 ms +8.99% -7.14% 105.39 ms +4.31% -4.23% 4.52%
firstFocus 262.67 ms +0% -0% 256.73 ms +0% -0% 2.31%
selectAll 389.4 ms +3.75% -1.69% 401.74 ms +1.01% -0.47% -3.07%
undo 28.86 ms +3.05% -4.44% 29.7 ms +2.93% -7.21% -2.83%
listViewOpen 38.48 ms +7.15% -8.21% 38.02 ms +6.23% -8.36% 1.21%
inserterOpen 41 ms +4.59% -7.12% 39.82 ms +10.02% -4.87% 2.96%
inserterHover 11.03 ms +8.61% -12.33% 10.52 ms +11.88% -4.94% 4.85%
inserterSearch 8.13 ms +2.83% -11.32% 7.81 ms +3.07% -7.3% 4.1%
loadPatterns 635.11 ms +3.97% -4.32% 604.67 ms +11.13% -1.84% 5.03%
wpTotal 466.42 ms +1.86% -0.12% 467.27 ms +1.45% -9.51% -0.18%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 6985d9c trunk % Change
serverResponse 410.29 ms +3.12% -10.21% 404.28 ms +3.59% -7.12% 1.49%
firstPaint 463.32 ms +5.02% -11.97% 475.84 ms +4.9% -20.21% -2.63%
domContentLoaded 837.84 ms +1.66% -2% 859.27 ms +0.92% -2.59% -2.49%
loaded 839.31 ms +1.67% -2.01% 861.12 ms +0.93% -2.57% -2.53%
firstContentfulPaint 478.33 ms +1.73% -4.52% 485.44 ms +2.83% -3.24% -1.46%
firstBlock 2551.71 ms +1.44% -1.49% 2607.19 ms +0.87% -1.1% -2.13%
type 17.51 ms +1.6% -4.34% 19.93 ms +3.31% -3.86% -12.14%
navigate 115.3 ms +6.08% -9.09% 120.05 ms +1.76% -3.54% -3.96%
loadPatterns 1499.41 ms +9.33% -16.78% 1504.01 ms +1.1% -0.92% -0.31%
loadPages 932.04 ms +1.33% -2.51% 956.48 ms +0.72% -4.2% -2.56%
wpTotal 399.71 ms +3.21% -10.59% 393.38 ms +3.59% -7.29% 1.61%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

d4dd04b Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

As a user I want to be able to create a navigation overlay for a specific navigation block in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: /(Editor publish|Save panel)/ }).getByRole('button', { name: 'Save', exact: true })

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:48:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:91:4
templates can be registered and edited (Site Editor v2) in /test/e2e/specs/site-editor/template-registration.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByText('AuthorGutenberg')
Expected: visible
Error: strict mode violation: getByText('AuthorGutenberg') resolved to 3 elements:
    1) <div data-wp-c16t="true" data-wp-component="Flex" class="_463056a1846babdd__flex eefcc0383f58d3a1__items-row _8a741740b23dfb57__expanded-row components-flex dataviews-view-grid__field">…</div> aka getByRole('row', { name: 'Row 1' }).getByText('AuthorGutenberg')
    2) <div data-wp-c16t="true" data-wp-component="Flex" class="_463056a1846babdd__flex eefcc0383f58d3a1__items-row _8a741740b23dfb57__expanded-row components-flex dataviews-view-grid__field">…</div> aka locator('[id="emptytheme//page"]').getByText('AuthorGutenberg')
    3) <div data-wp-c16t="true" data-wp-component="Flex" class="_463056a1846babdd__flex eefcc0383f58d3a1__items-row _8a741740b23dfb57__expanded-row components-flex dataviews-view-grid__field">…</div> aka locator('[id="emptytheme//plugin-template"]').getByText('AuthorGutenberg')

Call log:
  - Expect "toBeVisible" getByText('AuthorGutenberg') with timeout 5000ms
  - waiting for getByText('AuthorGutenberg')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/template-registration.spec.js:60:55

d4dd04b Run

The status indicator is decorative, but custom JSX could add its text to
the accessible name of a surrounding control. Also check that an avatar
that isn't dimmed keeps its color.
… opacity

Opacity fades a whole group, so the indicator's own opacity doesn't show
whether it is faded.
… containers

A flex or grid container stretched the wrapper, but not the avatar inside
it, so the indicator centered on the wrapper instead of the avatar. Keep
the wrapper at the size of the avatar.
@ciampo ciampo self-assigned this Dec 3, 2026
No caller has ever passed `statusIndicator`, to this wrapper or to the
editor Avatar it comes from. Without it, the wrapper returns the ui Avatar
directly, with no extra element to position or size.
@ciampo

ciampo commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@WordPress/gutenberg-components @WordPress/gutenberg-design @Mamaduka

This PR is part of a larger refactor that removes custom editor Avatar styles (which also didn't use WPDS tokens) in favour of reusing the shared Avatar component.

One feature that the shared ui/Avatar component doesn't expose is the dimmed prop. Before deciding whether dimmed belongs in the ui Avatar, I'd like us to agree on how a disconnected collaborator should behave.

Other collaborators. I think we can keep the fade as the cue while someone disconnects. It only lasts 5 seconds: after that, the collaborator is removed from the list, and the "%s has left the post." snackbar already says it in text. The list row should still expose the state to screen readers during those 5 seconds, since the fade is visual only.

Ourselves. This case needs a different cue. Today, our own avatar never dims, because nothing marks our own client as disconnected. The "Connection lost" modal only appears once background retries fail, so nothing tells us we're offline while the editor retries. We could add either:

  • a text status, for example next to the save status, or
  • a visual status on our avatar, such as a badge or a shape.

Either way, it's a separate treatment from the fade. I'd lean toward the text status: it's a single state, it's easier to notice than a badge on a 24px avatar, and it reads the same for everyone.

Where it lives. If we keep the fade only for other collaborators, it's a short exit cue specific to the collaborator UI, so it can stay in the editor wrapper this PR adds. A badge would be the part worth considering for the ui Avatar, if other places need a presence state too.

What do you think?

More context
  • Removal delay: core-data keeps a disconnected collaborator for REMOVAL_DELAY_IN_MS (5000 ms in packages/core-data/src/awareness/config.ts), so the UI can show people who just left.
  • Leave snackbar: useCollaboratorNotifications in collaborators-presence/use-collaborator-notifications.ts shows it. It depends on the showCollaborationLeaveNotifications setting, which edit-post and edit-site set to true.
  • Our own state: setConnectionStatus() in awareness-state.ts marks our own client as disconnected, but only tests call it, so isMe collaborators always stay connected.
  • Connection lost modal: SyncConnectionErrorModal shows when the connection is lost and background retries fail, or when no retry is possible. It waits 20 seconds after load before it can show.
  • Accessibility: the fade isn't exposed to assistive technology, which WCAG 1.3.1 asks for.
  • Other design systems: Fluent 2, Atlassian, Genesys and ServiceNow show presence with a small badge that has a different glyph for each state. They have several lasting states, such as available, away, busy and offline. Fluent notes that people may struggle to see these badges on avatars of 32px and smaller.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Editor /packages/editor [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant