From 0d9e371d4f46facfec0e6f26ddcaa949fec64dea Mon Sep 17 00:00:00 2001 From: tomastiminskas Date: Fri, 13 Mar 2026 18:34:05 +0000 Subject: [PATCH] Simplify RoomContext color lookup to key by sender name for consistent colors --- .../Dashboard/Live Kit/Views/RoomContext.swift | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/com.stakwork.sphinx.desktop/Scenes/Dashboard/Live Kit/Views/RoomContext.swift b/com.stakwork.sphinx.desktop/Scenes/Dashboard/Live Kit/Views/RoomContext.swift index 2fdb0d57..b6d58ff0 100644 --- a/com.stakwork.sphinx.desktop/Scenes/Dashboard/Live Kit/Views/RoomContext.swift +++ b/com.stakwork.sphinx.desktop/Scenes/Dashboard/Live Kit/Views/RoomContext.swift @@ -438,19 +438,9 @@ extension RoomContext { return randomColor } - /// Returns the color for a chat message sender, matching the live participant - /// box color when the sender name corresponds to a connected participant. func getColorForMessage(senderName: String?) -> Color { - // Try to find a live participant whose name or identity matches the sender - if let senderName = senderName, - let match = room.allParticipants.values.first(where: { - $0.name == senderName || $0.identity?.stringValue == senderName - }) { - // Use the same key as participant boxes so colors stay in sync - let participantKey = match.sid?.stringValue ?? match.identity?.stringValue - return getColorForParticipan(participantId: participantKey) - } - // No live participant match — key by sender name + // Always key by senderName so history and live messages + // from the same sender share the same cached color. return getColorForParticipan(participantId: senderName) } }