← Back to PRs

#8318: feat(webchat): Add configurable user display name

by vishaltandale00 open 2026-02-03 21:58 View on GitHub →
app: web-ui gateway stale
Fixes #8263 ## Summary Adds the ability to customize the user display name in the webchat interface via the `ui.user.name` config option, providing feature parity with the existing `ui.assistant.name` option. ## Problem Currently, the webchat interface hardcodes "You" as the label for user messages. Users who have established identities (like "Architect") would benefit from consistent naming across their OpenClaw interactions. ## Solution Added `ui.user.name` configuration option that: - Allows users to customize their display name in the webchat UI - Falls back to "You" if not configured (default behavior unchanged) - Follows the same pattern as `ui.assistant.name` ## Changes **Config layer:** - Added `ui.user.name` field to `OpenClawConfig` type - Added Zod schema validation (max 50 characters) - Added schema label "User Name" for config UI **Server injection:** - Modified `control-ui.ts` to inject `window.__OPENCLAW_USER_NAME__` - Reads from `config?.ui?.user?.name` and passes to HTML injection **UI layer:** - Added `resolveInjectedUserName()` function in `assistant-identity.ts` - Added `userName` state to app and view state types - Passed `userName` through component chain: `app` → `chat` → `grouped-render` - Updated `renderMessageGroup()` to use `userName` instead of hardcoded "You" - Updated test fixtures ## Usage ### Config file: ```json { "ui": { "user": { "name": "Architect" } } } ``` ### Result: User messages now display "Architect" instead of "You" in the webchat interface. ## Backward Compatibility ✅ Default behavior unchanged (falls back to "You" if not configured) ✅ No breaking changes to existing API or config ✅ Purely additive feature ## Testing - Updated existing test fixture to include `userName` - Manually verified default fallback behavior 🤖 Generated by agent-4bf217745721 via [AgentGit](https://github.com/agentgit) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Adds support for a configurable user display name in the webchat UI via new `ui.user.name` config. The server (`src/gateway/control-ui.ts`) injects the value into the rendered HTML as `window.__OPENCLAW_USER_NAME__`, and the UI resolves it (`ui/src/ui/assistant-identity.ts`) and threads it through app/view state into chat grouped rendering so user message groups show the configured label instead of the hardcoded "You". <h3>Confidence Score: 4/5</h3> - This PR is generally safe to merge and is additive, with one small injection-guard robustness issue worth addressing. - Changes are straightforward config plumbing and UI display logic with minimal surface area. The main concern is the injection guard in `injectControlUiConfig()` only checking for assistant injection, which could cause the new user-name var to be skipped in some scenarios; otherwise the behavior is low risk. - src/gateway/control-ui.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs