Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dlauer
Copy link
Contributor

@dlauer dlauer commented Jan 22, 2026

Problem

Local file avatars configured in identity.avatar display as text instead of images in the webchat UI.

Root Cause (3-layer bug)

1. Frontend - URL validation too strict

isAvatarUrl() only accepted http://, https://, or data: URLs:

// Before: didn't accept relative paths
/^https?:\/\//i.test(value) || /^data:image\//i.test(value)

2. Backend HTML injection

serveIndexHtml() injected the raw avatar filename into HTML instead of the resolved URL.

3. Backend RPC

agent.identity.get returned the raw filename, which overwrote the HTML-injected value when the frontend fetched identity.

Fix

  1. Frontend: Accept relative paths starting with /
  2. Backend (control-ui.ts): Resolve local file avatars to /avatar/{agentId} URL before injection
  3. Backend (agent.ts): Resolve local file avatars in RPC response

Testing

  • Configure identity.avatar: "myavatar.png" in agent config
  • Place image in workspace
  • Avatar now displays correctly in webchat

Regression from #1329 refactor in 8544df3.

The isAvatarUrl check only accepted http://, https://, or data: URLs,
but the /avatar/{agentId} endpoint returns relative paths like /avatar/main.
This caused local file avatars to display as text instead of images.

Fixes avatar display for locally configured avatar files.
The frontend fix alone wasn't enough because:
1. serveIndexHtml() was injecting the raw avatar filename into HTML
2. agent.identity.get RPC was returning raw filename, overwriting the
   HTML-injected value

Now both paths resolve local file avatars (*.png, *.jpg, etc.) to the
/avatar/{agentId} endpoint URL.
@steipete
Copy link
Contributor

  • High: agent.identity.get rewrites to /avatar/${agentId} without controlUiBasePath; when base path is set, avatar endpoint is ${basePath}/avatar/..., so the RPC refresh will 404 and overwrite the injected URL. src/gateway/server-methods/agent.ts:407, src/ gateway/control-ui.ts:101, src/gateway/control-ui.ts:119
  • Medium: looksLikeLocalAvatarPath only keys off extensions; values like avatars/profile (accepted by looksLikeAvatarPath) won’t be converted and will still render as text. src/gateway/control-ui.ts:206, src/gateway/assistant-identity.ts:33

@steipete steipete self-assigned this Jan 22, 2026
@steipete steipete merged commit 6c7f224 into openclaw:main Jan 22, 2026
17 of 22 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: 482fcd2\n- Merge commit: 6c7f224\n\nThanks @dlauer!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants