Skip to content

Commit 2717f5d

Browse files
adalpariclaude
andauthored
Support: give the conversation screen a title and reorder its header (#26455)
* Support: give the conversation screen a title and reorder its header The navigation bar was bound to an empty string until the ticket's subject scrolled out of view, so the screen arrived with no name at all, and an AI Assistant chat — which has no subject of its own — never got one. It now falls back to the screen's name, and still swaps to the subject once that scrolls away, so the two are never shown at once. The ticket header also read backwards: the status and the time of the last update sat above the subject they describe. The subject comes first now, with both underneath it, matching a row of the conversations list. "Last updated" drops to .footnote to share a size with the status label beside it, and the two stack at accessibility type sizes instead of squeezing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * Support: fall back to the description when a subject is blank The conversation screen read `conversation.title` raw, so a subject the server left as whitespace named the screen with whitespace: the navigation bar fell back to "Conversation" on arrival but went blank again once the subject scrolled away, and the header rendered an invisible title line. `UnifiedSupportConversationSummary.displayTitle` already handles this for the conversations list, but `UnifiedSupportConversation` has no equivalent, and the view model preferred the loaded value unconditionally. Prefer it only when it isn't blank, so both the bar and the header fall back the way the list's row does. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 6e51d61 commit 2717f5d

7 files changed

Lines changed: 67 additions & 15 deletions

‎Modules/Sources/Support/Unified Support/Model/UnifiedSupportConversation.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ enum UnifiedSupportReplyAction: Sendable {
190190
}
191191
}
192192

193-
private extension String {
193+
extension String {
194194
var isBlank: Bool {
195195
trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
196196
}

‎Modules/Sources/Support/Unified Support/UI/UnifiedSupportConversationView.swift‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ struct UnifiedSupportConversationView: View {
6666
.safeAreaInset(edge: .top) { disclosure }
6767
.unifiedSupportNotice($viewModel.notice)
6868
// A ticket's subject scrolls away with the conversation, so the bar picks it up once it's gone.
69-
// Showing it in both places at once would just say the same thing twice.
70-
.navigationTitle(isTitleVisible ? "" : viewModel.title)
69+
// Showing it in both places at once would just say the same thing twice, and leaving the bar empty
70+
// until then gives the screen no name at all.
71+
.navigationTitle(navigationTitle)
7172
.navigationBarTitleDisplayMode(.inline)
7273
.unifiedSupportAutoRefresh(every: .seconds(60)) {
7374
await viewModel.refreshSilently()
@@ -93,6 +94,14 @@ struct UnifiedSupportConversationView: View {
9394
}
9495
}
9596

97+
/// The subject once it has scrolled out of the conversation, and the name of the screen until then. A chat
98+
/// with the AI Assistant has no subject of its own, so it keeps the screen's name throughout.
99+
private var navigationTitle: String {
100+
isTitleVisible || viewModel.title.isEmpty
101+
? UnifiedSupportLocalization.conversationTitle
102+
: viewModel.title
103+
}
104+
96105
@ViewBuilder
97106
private var content: some View {
98107
if viewModel.isBot {

‎Modules/Sources/Support/Unified Support/UI/UnifiedSupportConversationViewModel.swift‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ final class UnifiedSupportConversationViewModel: ObservableObject {
7171
conversation?.isBot ?? summary?.isBot ?? true
7272
}
7373

74+
/// The conversation's subject. A subject the server left blank falls back to the description, the way the
75+
/// row in the conversations list does, so the screen is never named with whitespace.
7476
var title: String {
75-
conversation?.title ?? summary?.displayTitle ?? ""
77+
if let title = conversation?.title, !title.isBlank {
78+
return title
79+
}
80+
return summary?.displayTitle ?? ""
7681
}
7782

7883
var status: UnifiedSupportConversationStatus {

‎Modules/Sources/Support/Unified Support/UI/UnifiedSupportTicketContentView.swift‎

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ struct UnifiedSupportTicketContentView: View {
88
/// Whether the subject is still on screen, which is what tells the navigation bar to leave it alone.
99
@Binding var isTitleVisible: Bool
1010

11+
@Environment(\.dynamicTypeSize)
12+
private var dynamicTypeSize
13+
1114
var body: some View {
1215
VStack(alignment: .leading, spacing: 16) {
1316
header
1417

15-
if !viewModel.title.isEmpty {
16-
Text(viewModel.title)
17-
.font(.title2)
18-
.fontWeight(.bold)
19-
.accessibilityAddTraits(.isHeader)
20-
.onScrollVisibilityChange { isTitleVisible = $0 }
21-
}
22-
2318
ForEach(viewModel.messages) { message in
2419
if message.authorRole == .system {
2520
UnifiedSupportSystemMessage(message: message)
@@ -32,19 +27,44 @@ struct UnifiedSupportTicketContentView: View {
3227
.padding(.bottom, 16)
3328
}
3429

30+
/// The subject, with the status and the time of the last update read underneath it: the ticket is named
31+
/// first, and what's said about it follows.
3532
private var header: some View {
36-
HStack(alignment: .firstTextBaseline) {
33+
VStack(alignment: .leading, spacing: 6) {
34+
if !viewModel.title.isEmpty {
35+
Text(viewModel.title)
36+
.font(.title2)
37+
.fontWeight(.bold)
38+
.accessibilityAddTraits(.isHeader)
39+
.onScrollVisibilityChange { isTitleVisible = $0 }
40+
}
41+
42+
statusAndLastUpdate
43+
}
44+
}
45+
46+
private var statusAndLastUpdate: some View {
47+
// At accessibility sizes the two lines no longer fit side by side, so they stack instead of shrinking
48+
// to fit, the way a row of the conversations list does.
49+
let layout =
50+
dynamicTypeSize.isAccessibilitySize
51+
? AnyLayout(VStackLayout(alignment: .leading, spacing: 2))
52+
: AnyLayout(HStackLayout(alignment: .firstTextBaseline, spacing: 8))
53+
54+
return layout {
3755
UnifiedSupportStatusLabel(status: viewModel.status)
3856

39-
Spacer(minLength: 8)
57+
if !dynamicTypeSize.isAccessibilitySize {
58+
Spacer(minLength: 0)
59+
}
4060

4161
Text(
4262
String.localizedStringWithFormat(
4363
UnifiedSupportLocalization.lastUpdated,
4464
UnifiedSupportRelativeTime.format(viewModel.lastActivityAt)
4565
)
4666
)
47-
.font(.subheadline)
67+
.font(.footnote)
4868
.foregroundStyle(.secondary)
4969
}
5070
}

‎Modules/Sources/Support/Unified Support/UnifiedSupportLocalization.swift‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ enum UnifiedSupportLocalization {
119119
value: "Start Conversation",
120120
comment: "Button that starts the user's first support conversation."
121121
)
122+
static let conversationTitle = NSLocalizedString(
123+
"com.jetpack.support.unified.conversation.title",
124+
value: "Conversation",
125+
comment: "Navigation bar title of a single support conversation, shown while its subject is on screen."
126+
)
122127
static let loadingConversation = NSLocalizedString(
123128
"com.jetpack.support.unified.conversation.loading",
124129
value: "Loading conversation…",

‎Modules/Tests/SupportTests/UnifiedSupport/UnifiedSupportConversationViewModelTests.swift‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ struct UnifiedSupportConversationViewModelTests {
3939
#expect(tracker.trackedEvents.contains { if case .failToLoadConversation = $0 { true } else { false } })
4040
}
4141

42+
@Test func fallsBackToTheDescriptionWhenTheLoadedSubjectIsBlank() async {
43+
let conversation = UnifiedSupportConversation.make(title: " \n", description: "I can't log in")
44+
let viewModel = makeViewModel(
45+
.existing(conversation.summary),
46+
MockUnifiedSupportDataProvider(.init(fetchedConversation: .success(conversation)))
47+
)
48+
49+
await viewModel.load()
50+
51+
#expect(viewModel.title == "I can't log in")
52+
}
53+
4254
@Test func aNewConversationLoadsNothingAndStartsAsAChat() async {
4355
let provider = MockUnifiedSupportDataProvider()
4456
let viewModel = makeViewModel(.newBotConversation, provider)

‎RELEASE-NOTES.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* [*] Fix signing in to WordPress.com taking longer than it needs to, and waiting on the login screen while the device is busy [#26121]
55
* [*] Notifications: Comment and like notifications from private sites you can't access now show their content instead of an error [#26432]
66
* [*] Support: The chat keyboard's return key no longer looks like a send button [#26451]
7+
* [*] Support: A conversation now has a title in the navigation bar, and its subject reads above the status instead of below it
78

89

910
27.5

0 commit comments

Comments
 (0)