Skip to content

fix(ui): consistently load and cache user avatars - #114444

Merged
steipete merged 2 commits into
mainfrom
codex/fix-control-ui-user-avatar-cache
Jul 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-control-ui-user-avatar-cache

Conversation

@steipete

@steipete steipete commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where people using the Control UI would see a user's avatar in one place but missing or stale in the online-user list, profile, sidebar, or attributed chat, especially when gateway authentication requires a bearer token.

Why This Change Was Made

Use the durable user-profile ID and one canonical gateway avatar route across roster, profile, and chat. Fetch protected images with the connected gateway's current device/token/password authorization; deduplicate concurrent requests in a bounded, revision-aware blob cache; keep blobs alive until their images settle; and preserve existing avatar image elements while Lit live() restores fallback state during image, profile, or credential changes.

Pin every credentialed request to the exact normalized connected Gateway origin and canonical profile-avatar pathname before calling fetch. Reject external hosts, lookalike hosts, userinfo spoofing, protocol-relative origins, and unrelated Gateway endpoints.

Keep uploaded-avatar storage, ETag revalidation, and Gravatar caching in the existing gateway endpoint.

User Impact

A user's uploaded avatar or gateway-proxied Gravatar loads consistently in the sidebar, online-user list, profile preview, and shared chat. The same avatar is fetched once, profile updates invalidate the correct cached image, and missing or failed images still show readable initials.

Evidence

  • Reproduced the original roster bug: the old code passed the email instead of the durable profile ID and rendered no image.
  • Focused Control UI regression suite: 8 files, 399 tests passing, including the existing sidebar image-element identity contract, a 130-concurrent-user cache stress test, credential rotation, revision invalidation, transient failure recovery, MIME and size validation, sender fallback state, and hostile external-origin credential-boundary cases.
  • Gateway avatar and production-CSP contracts: 2 files, 34 tests passing.
  • Real Chromium product proof: 2 files, 6 tests passing. The profile scenario applies the actual shipped gateway CSP, verifies the canonical avatar request includes the fixture device bearer token, confirms the image actually decodes, navigates back into the product sidebar, and proves both surfaces reuse the exact same blob with only one network request.
  • UI TypeScript typecheck, focused type-aware lint, changed-file formatting, and whitespace: passing.
  • Structured autoreview and TruffleHog: clean; final independent review reports “patch is correct” with 0.94 confidence.
  • Blacksmith Testbox workflow dispatch returned HTTP 500, so browser and validation proof used the repository-documented trusted-source local fallback.

AI-assisted; source, gateway contracts, browser behavior, cache lifecycle, credential-origin security, and regression coverage were independently reviewed.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: L maintainer Maintainer-authored PR labels Jul 27, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 4:53 AM ET / 08:53 UTC.

ClawSweeper review

What this changes

This PR makes Control UI roster, profile, sidebar, and attributed-chat avatars use a shared authenticated, revision-aware blob cache backed by the connected Gateway’s canonical user-avatar route.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

Keep this protected PR open for maintainer handling. The revised branch appears to address the earlier credential-origin blocker and has strong focused test coverage, but the supplied Chromium run is described rather than attached as inspectable redacted after-fix evidence; the PR should retain its real-behavior-proof gate until that artifact is visible on the PR.

Likely related people: steipete is the current Control UI avatar implementation contributor (low-confidence routing signal; current-main history could not be read in this read-only execution environment).

Priority: P1
Reviewed head: 8bd25d6a1dba5b8f46a40e2bf008db75c8981a4c
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and targeted coverage look solid from the supplied diff, but the external PR’s required real-behavior proof is not independently inspectable in the provided discussion.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The contributor reports real Chromium tests against a mocked Gateway and names local capture paths, but no inspectable redacted screenshot, recording, logs, live output, or linked artifact is included in the supplied PR discussion; attach that after-fix evidence before merge and redact endpoints, IP addresses, and credentials. Updating the PR body should trigger re-review automatically; otherwise a maintainer can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The contributor reports real Chromium tests against a mocked Gateway and names local capture paths, but no inspectable redacted screenshot, recording, logs, live output, or linked artifact is included in the supplied PR discussion; attach that after-fix evidence before merge and redact endpoints, IP addresses, and credentials. Updating the PR body should trigger re-review automatically; otherwise a maintainer can comment @clawsweeper re-review.
Evidence reviewed 5 items Previous credential-boundary blocker addressed: The follow-up commit updates the shared avatar loader and its tests to accept only the connected Gateway origin and canonical /api/users/<id>/avatar paths before a credentialed fetch; the supplied follow-up comment lists hostile-origin, lookalike-host, userinfo-spoofing, protocol-relative, and unrelated-route no-fetch coverage.
Connected credentials feed the shared loader: The diff updates Gateway connection handling to refresh the avatar loader’s trusted origin and resolved authorization header both on connection setup and after hello/bootstrap state is available.
Cross-surface behavior is covered: The PR changes the roster and chat rendering paths to resolve cached image URLs while preserving initials fallback, and adds focused tests for durable profile IDs, cache sharing, credential rotation, revisions, failure recovery, and image state changes.
Findings None None.
Security None None.

How this fits together

The Control UI receives presence and user-profile data from its connected Gateway, then renders avatars in roster, profile, sidebar, and chat components. This change validates the connected Gateway avatar URL, fetches protected images with the current connection authorization, and shares the resulting browser blob across those components.

flowchart LR
  A[Gateway connection and credentials] --> B[Avatar origin and auth state]
  C[Presence and profile avatar route] --> D[Canonical route validation]
  B --> D
  D --> E[Authenticated blob cache]
  E --> F[Sidebar roster and profile]
  E --> G[Attributed chat avatars]
  F --> H[Initials fallback on failure]
  G --> H
Loading

Decision needed

Question Recommendation
Does the protected PR have sufficient independently inspectable live browser proof to merge its new credentialed avatar-fetch boundary? Request attached redacted proof: Ask for a screenshot, recording, terminal/network output, or linked artifact showing the authenticated canonical request, image decode, and cross-surface cache reuse; this is recommended.

Why: The patch changes where Control UI browser credentials may be sent. The contributor describes robust tests and a Chromium scenario, but the supplied discussion does not include the claimed redacted artifact for a maintainer to inspect directly.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The contributor reports real Chromium tests against a mocked Gateway and names local capture paths, but no inspectable redacted screenshot, recording, logs, live output, or linked artifact is included in the supplied PR discussion; attach that after-fix evidence before merge and redact endpoints, IP addresses, and credentials. Updating the PR body should trigger re-review automatically; otherwise a maintainer can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Credential-bearing browser fetches are security-boundary-sensitive: maintainers should verify an attached redacted browser/network artifact proves that only the normalized connected Gateway origin receives the authorization header.
  • Resolve merge risk (P1) - The branch is reported cleanly mergeable but behind main; refresh the merge result and required checks on the exact head before landing.
  • Complete next step (P2) - The remaining blocker is contributor-supplied real-behavior evidence and protected maintainer review, not a concrete mechanical repair that an automated fix lane can safely perform.
Agent review details

Security

None.

PR surface

Source +201, Tests +349. Total +550 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 246 45 +201
Tests 5 371 22 +349
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 617 67 +550

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: ui/src/lib/identity-avatar.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Attach credential-boundary browser proof (recommended)
    Before merge, add redacted real-browser evidence that the authorization header is sent only to the connected Gateway’s canonical avatar route and that the image is reused across UI surfaces.
  2. Accept the documented evidence
    A maintainer may accept the contributor’s reported Chromium run after reviewing the exact head and deciding the absent attached artifact is not required for this protected security boundary.

Technical review

Best possible solution:

Attach a redacted after-fix Chromium artifact that visibly shows the canonical authenticated Gateway request, successful image decode, and one-request blob reuse across profile and sidebar, then merge only after the refreshed exact-head checks and protected review are satisfactory.

Do we have a high-confidence way to reproduce the issue?

No high-confidence independent reproduction was run in this review. The reported defect is source-reproducible from the prior roster path using an email where the Gateway avatar route requires the durable profile ID, and the contributor supplies focused regression coverage for that path.

Is this the best way to solve the issue?

Yes, conditionally: one shared, route-validating avatar loader is a narrower maintainable solution than separate credential and cache behavior in each Control UI surface. The merge gate remains inspectable real-browser evidence for the credential boundary, not another parallel implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bc54710daf38.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P1: The patch addresses a recurring user-visible Control UI failure where identity avatars can be missing or stale across active product surfaces.
  • merge-risk: 🚨 security-boundary: The new shared loader makes credentialed browser fetches and must continue rejecting every route or origin other than the connected Gateway’s canonical avatar endpoint.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The contributor reports real Chromium tests against a mocked Gateway and names local capture paths, but no inspectable redacted screenshot, recording, logs, live output, or linked artifact is included in the supplied PR discussion; attach that after-fix evidence before merge and redact endpoints, IP addresses, and credentials. Updating the PR body should trigger re-review automatically; otherwise a maintainer can comment @clawsweeper re-review.

Evidence

What I checked:

  • Previous credential-boundary blocker addressed: The follow-up commit updates the shared avatar loader and its tests to accept only the connected Gateway origin and canonical /api/users/<id>/avatar paths before a credentialed fetch; the supplied follow-up comment lists hostile-origin, lookalike-host, userinfo-spoofing, protocol-relative, and unrelated-route no-fetch coverage. (ui/src/lib/identity-avatar.ts:1, 8bd25d6a1dba)
  • Connected credentials feed the shared loader: The diff updates Gateway connection handling to refresh the avatar loader’s trusted origin and resolved authorization header both on connection setup and after hello/bootstrap state is available. (ui/src/app/gateway-store.ts:273, 8bd25d6a1dba)
  • Cross-surface behavior is covered: The PR changes the roster and chat rendering paths to resolve cached image URLs while preserving initials fallback, and adds focused tests for durable profile IDs, cache sharing, credential rotation, revisions, failure recovery, and image state changes. (ui/src/components/viewer-facepile.ts:142, 8bd25d6a1dba)
  • Browser proof claim is not directly inspectable in supplied context: The contributor reports Chromium proof and names locally captured artifacts, but the supplied PR body/comment contains no attached or linked redacted screenshot, recording, terminal output, or artifact that independently shows the authenticated request, decoded image, and cache reuse after the patch. (8bd25d6a1dba)
  • Current PR workflow status: The provided check summary shows the dedicated Real behavior proof checks succeeded while several ordinary compact-check and QA checks were still running; pending checks alone are not treated as a defect or priority escalation. (8bd25d6a1dba)

Likely related people:

  • steipete: Authored both commits on this PR and the detailed follow-up verification covering the changed Control UI avatar and credential-boundary paths; this is a low-confidence routing signal rather than current-main ownership provenance. (role: current Control UI avatar contributor; confidence: low; commits: 7efb3f7cffd0, 8bd25d6a1dba; files: ui/src/lib/identity-avatar.ts, ui/src/app/gateway-store.ts, ui/src/components/viewer-facepile.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted Chromium screenshot, recording, network trace, terminal output, or linked artifact proving the authenticated canonical request, decoded avatar, and single shared blob request.
  • Refresh the exact-head merge result and remaining required checks before a maintainer lands this protected PR.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-27T08:35:53.198Z sha 7efb3f7 :: needs real behavior proof before merge. :: [P1] Restrict credentialed avatar fetches to the Gateway origin

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer verification for head 8bd25d6a1db:

The credential boundary is enforced before fetch: ui/src/lib/identity-avatar.ts normalizes the connected Gateway origin, accepts only /api/users/<id>/avatar, and rejects any absolute URL whose parsed origin differs. ui/src/lib/identity-avatar.test.ts supplies an external host, a Gateway-lookalike host, userinfo host spoofing, a protocol-relative external URL, and a non-avatar Gateway route. All resolve to initials/null, and fetch is called zero times.

Exact local proof:

node_modules/.bin/vitest run --config test/vitest/vitest.ui.config.ts \
  ui/src/components/app-sidebar.test.ts \
  ui/src/components/viewer-facepile.test.ts \
  ui/src/lib/identity-avatar.test.ts \
  ui/src/app/user-profile.test.ts \
  ui/src/pages/chat/chat-avatar.test.ts \
  ui/src/pages/profile/identity-section.test.ts \
  ui/src/app/gateway-store.test.ts \
  ui/src/pages/chat/components/chat-message.test.ts

Test Files  8 passed (8)
     Tests  399 passed (399)

OPENCLAW_CAPTURE_UI_PROOF=1 node_modules/.bin/vitest run \
  --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner \
  ui/src/e2e/profile-page.e2e.test.ts \
  ui/src/e2e/chat-attributed-identity.e2e.test.ts

Test Files  2 passed (2)
     Tests  6 passed (6)

.agents/skills/autoreview/scripts/autoreview --mode uncommitted

trufflehog: clean
autoreview clean: no accepted/actionable findings reported
overall: patch is correct (0.94)

The real Chromium scenario applies the gateway’s production CSP, proves exactly one authenticated request to the connected Gateway-origin route, verifies the PNG actually decodes (naturalWidth === 1), returns to the product sidebar, and proves the identical blob is reused with one total avatar request. The bearer value is a local fixture, not a live credential. The run captures .artifacts/control-ui-e2e/profile-identity/03-authenticated-profile-avatar.png and .artifacts/control-ui-e2e/profile-identity/03-authenticated-user-avatar-cache.png.

Both the hostile-origin no-fetch regression and the browser's network, image-decoding, and cache-sharing assertions are directly inspectable in the PR.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer disposition of the current ClawSweeper rank-up moves:

  • Exact-head checks: full GitHub CI for 8bd25d6a1db completed successfully, including the final openclaw/ci-gate; scripts/pr prepare-run 114444 independently accepted that exact-head hosted evidence.
  • Real-browser proof: I re-ran the actual Chromium cases on the prepared exact head with the verbose reporter. The redacted, inspectable terminal output is:
OPENCLAW_CAPTURE_UI_PROOF=1 node_modules/.bin/vitest run \
  --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner \
  --reporter verbose \
  ui/src/e2e/profile-page.e2e.test.ts \
  ui/src/e2e/chat-attributed-identity.e2e.test.ts

✓ Control UI profile page mocked Gateway E2E
  > renders hero identity, lifetime stats, heatmap, and insights
✓ Control UI profile page mocked Gateway E2E
  > shares one authenticated avatar between the sidebar and profile preview
✓ Control UI profile page mocked Gateway E2E
  > retries the missing identity bootstrap and opens the profile editor
✓ Control UI profile page mocked Gateway E2E
  > keeps the loading note while a cold usage cache is still rebuilding
✓ Control UI profile page mocked Gateway E2E
  > shows the fresh-shell empty state when no tokens were spent
✓ Control UI attributed chat identity
  > uses one avatar placement and keeps shared-thread authors readable

exit status: 0

No migration is involved: this is a bounded in-memory browser blob cache, not a persistent cache or database schema.

@steipete
steipete merged commit a2ff6cb into main Jul 27, 2026
101 of 103 checks passed
@steipete
steipete deleted the codex/fix-control-ui-user-avatar-cache branch July 27, 2026 09:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant