Skip to content

Commit e67960f

Browse files
committed
Show room names instead of room IDs in activity log
Resolve room IDs to display names using the room list from MatrixService. The room filter picker, event rows, and free-text search now use human-readable room names. The inspector detail pane shows both the room name and the raw room ID for debugging. Falls back to the raw room ID when a room name cannot be resolved (e.g. for rooms no longer in the room list). Also fix free-text search to use localizedStandardContains per project conventions. Assisted-By: OpenCode (claude-opus-4-6)
1 parent 5c4eadc commit e67960f

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

Relay/RelayApp.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct RelayApp: App {
8787

8888
Window("Activity Log", id: "activity-log") {
8989
ActivityLogView()
90+
.environment(\.matrixService, matrixService)
9091
.environment(\.activityLog, matrixService.activityLog)
9192
.preferredColorScheme(appearanceMode.colorScheme)
9293
}

Relay/Views/ActivityLog/ActivityLogView.swift

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import UniformTypeIdentifiers
2424
/// Selecting an event reveals its full detail and metadata in a trailing inspector panel.
2525
struct ActivityLogView: View {
2626
@Environment(\.activityLog) private var activityLog
27+
@Environment(\.matrixService) private var matrixService
2728

2829
@State private var selectedEventId: UUID?
2930
@State private var showingInspector = false
@@ -41,18 +42,25 @@ struct ActivityLogView: View {
4142
return false
4243
}
4344
if !searchText.isEmpty {
44-
let haystack = "\(event.summary) \(event.detail ?? "") \(event.source) \(event.roomId ?? "")"
45-
if !haystack.localizedCaseInsensitiveContains(searchText) {
45+
let roomDisplay = event.roomId.flatMap { roomName(for: $0) } ?? event.roomId ?? ""
46+
let haystack = "\(event.summary) \(event.detail ?? "") \(event.source) \(roomDisplay)"
47+
if !haystack.localizedStandardContains(searchText) {
4648
return false
4749
}
4850
}
4951
return true
5052
}
5153
}
5254

53-
/// Unique room IDs present in the current event buffer, for the room filter menu.
55+
/// Unique room IDs present in the current event buffer, sorted by display name.
5456
private var availableRoomIds: [String] {
55-
Array(Set(activityLog.events.compactMap(\.roomId))).sorted()
57+
Array(Set(activityLog.events.compactMap(\.roomId)))
58+
.sorted { roomName(for: $0) ?? $0 < roomName(for: $1) ?? $1 }
59+
}
60+
61+
/// Returns the display name for a room ID, or `nil` if the room is unknown.
62+
private func roomName(for roomId: String) -> String? {
63+
matrixService.rooms.first { $0.id == roomId }?.name
5664
}
5765

5866
private var selectedEvent: ActivityEvent? {
@@ -83,7 +91,7 @@ struct ActivityLogView: View {
8391
private var eventTable: some View {
8492
ScrollViewReader { proxy in
8593
List(filteredEvents, selection: $selectedEventId) { event in
86-
ActivityLogRow(event: event)
94+
ActivityLogRow(event: event, roomName: event.roomId.flatMap { roomName(for: $0) })
8795
.tag(event.id)
8896
}
8997
.listStyle(.inset(alternatesRowBackgrounds: true))
@@ -120,9 +128,14 @@ struct ActivityLogView: View {
120128

121129
if let roomId = event.roomId {
122130
Section("Room") {
123-
Text(roomId)
124-
.font(.system(.body, design: .monospaced))
125-
.textSelection(.enabled)
131+
if let name = roomName(for: roomId) {
132+
LabeledContent("Name", value: name)
133+
}
134+
LabeledContent("ID") {
135+
Text(roomId)
136+
.font(.system(.body, design: .monospaced))
137+
.textSelection(.enabled)
138+
}
126139
}
127140
}
128141

@@ -208,7 +221,7 @@ struct ActivityLogView: View {
208221
if !availableRoomIds.isEmpty {
209222
Divider()
210223
ForEach(availableRoomIds, id: \.self) { roomId in
211-
Text(roomId).tag(String?.some(roomId))
224+
Text(roomName(for: roomId) ?? roomId).tag(String?.some(roomId))
212225
}
213226
}
214227
}
@@ -268,6 +281,7 @@ struct ActivityLogView: View {
268281
/// A single row in the activity log event table.
269282
private struct ActivityLogRow: View {
270283
let event: ActivityEvent
284+
var roomName: String?
271285

272286
var body: some View {
273287
HStack(spacing: 8) {
@@ -296,9 +310,9 @@ private struct ActivityLogRow: View {
296310
.truncationMode(.tail)
297311
.frame(maxWidth: .infinity, alignment: .leading)
298312

299-
if let roomId = event.roomId {
300-
Text(roomId)
301-
.font(.system(.caption2, design: .monospaced))
313+
if event.roomId != nil {
314+
Text(roomName ?? event.roomId!)
315+
.font(.caption2)
302316
.foregroundStyle(.tertiary)
303317
.lineLimit(1)
304318
.truncationMode(.middle)
@@ -326,5 +340,6 @@ private struct ActivityLogRow: View {
326340

327341
#Preview("Activity Log") {
328342
ActivityLogView()
343+
.environment(\.matrixService, PreviewMatrixService())
329344
.frame(width: 900, height: 600)
330345
}

0 commit comments

Comments
 (0)