fix: show translated chat messages in world nametag bubbles (#8552)#8993
fix: show translated chat messages in world nametag bubbles (#8552)#8993biotech77 wants to merge 5 commits into
Conversation
When auto-translation is enabled for a conversation, the in-world nametag chat bubble now mirrors the chat panel and displays the translated text, instead of always showing the original message.
|
Windows and Mac build successful in Unity Cloud! You can find a link to the downloadable artifact below. |
|
@claude review |
This comment has been minimized.
This comment has been minimized.
|
|
||
| // Mirror automatic translations only. A manual translate from the chat panel targets a conversation | ||
| // where auto-translate is off (or an older message whose bubble is already gone), so it is ignored here. | ||
| if (!translationSettings.GetAutoTranslateForConversation(bubble.ChannelId)) |
There was a problem hiding this comment.
Bug: global feature flag not checked
The per-conversation check is here but the global IsTranslationFeatureActive() guard is missing. If a translation is still in-flight when the user disables the global flag, OnMessageTranslated will still fire (the async work was already kicked off) and the bubble text will be swapped — contradicting the documented behaviour ("global translation feature flag … respected").
ChatMessageFeedPresenter correctly gates on both:
// from ChatMessageFeedPresenter, line ~119 / 354
if (!translationSettings.IsTranslationFeatureActive()) …
if (!translationSettings.GetAutoTranslateForConversation(…)) …Fix:
| if (!translationSettings.GetAutoTranslateForConversation(bubble.ChannelId)) | |
| // Guard against in-flight translations arriving after the global feature is disabled. | |
| if (!translationSettings.IsTranslationFeatureActive()) | |
| return; | |
| // Mirror automatic translations only. A manual translate from the chat panel targets a conversation | |
| // where auto-translate is off (or an older message whose bubble is already gone), so it is ignored here. | |
| if (!translationSettings.GetAutoTranslateForConversation(bubble.ChannelId)) | |
| return; |
| /// </summary> | ||
| public static bool TryGetSenderWalletAddress(string messageId, out string walletAddress) | ||
| { | ||
| int separator = messageId.IndexOf(':'); |
There was a problem hiding this comment.
Potential NullReferenceException
messageId.IndexOf(':') throws if messageId is null. TranslationEvents.MessageTranslated.MessageId is a struct field — its default is null — so any caller that forgets to set it will crash here.
All current callers always set it, so this is low risk today, but since the method is public static a null guard is cheap insurance:
| int separator = messageId.IndexOf(':'); | |
| public static bool TryGetSenderWalletAddress(string messageId, out string walletAddress) | |
| { | |
| if (string.IsNullOrEmpty(messageId)) | |
| { | |
| walletAddress = string.Empty; | |
| return false; | |
| } | |
| int separator = messageId.IndexOf(':'); |
|
@claude re-review |
This comment has been minimized.
This comment has been minimized.
Ludmilafantaniella
left a comment
There was a problem hiding this comment.
Tested on Windows and Mac. ✅
- Auto-translate enabled: nametag bubble swaps from original to translated text correctly for Korean, Japanese, Chinese, Russian, Spanish ✅
- Glyphs render correctly, no □ boxes ✅
- Emoji renders as sprites in the bubble ✅
- Auto-translate disabled: bubble stays in original language ✅
- Manual translation from chat panel context menu does not affect the bubble ✅
- Late translation (arriving after bubble auto-hides) does not resurrect the bubble ✅
- Chat panel translation regression: working correctly ✅
LGTM 🚀
8993-evi.mp4
✅Smoke test performed:
- ✔️ Backpack and wearables in world
- ✔️ Emotes in world and in backpack
- ✔️ Teleport with map/coordinates/Jump In
- ✔️ Chat and multiplayer
|
Claude finished @pravusjif's task in 2m 26s —— View job PR Review: fix/8552-world-chat-bubble-translations
Root-cause checkIssue #8552: world nametag bubbles always showed the original message text, even when auto-translation was enabled in the chat panel, because Prior blocking issues — resolution statusIssue 1 — Global feature flag not checked in
|
|
🔍 Claude reviewed this PR and found no blocking issues, but assessed it as complex — human DEV review is still required before merging. |
Pull Request Description
What does this PR change?
Closes #8552.
When auto-translation is enabled for a conversation, the in-world nametag chat bubble now mirrors the chat panel and shows the translated text, instead of always showing the original message.
Behavior
How it works
ChatWorldBubbleServicesubscribes toTranslationEvents.MessageTranslated, resolves the sender's avatar entity via the existingentityParticipantTable(sender wallet derived from the message id), gates on the per-conversation auto-translate setting (read from the bubble's ownChannelId), and updates the entity'sChatBubbleComponent.NametagPlacementSystemdistinguishes a translation swap (in-place text, visible-only) from a fresh message (fullDisplayMessage) via a flag on the component.ChatUtils.TryGetSenderWalletAddress(the inverse ofGetId).Glyph coverage (so translated / foreign text renders instead of tofu boxes)
.ttfso Latin-Extended/Cyrillic/Greek render.emojis32_uitksprite asset.Test Instructions
Steps (standard run):
metaforge explorer run XXXX # ← replace with this PR numberExpected result:
Test Steps
Additional Testing Notes
Quality Checklist