Skip to content

Commit 1ef6359

Browse files
committed
Change title to "Code Block" when the message starts with ```
1 parent 2b19a55 commit 1ef6359

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Core/Sources/ChatTab/ChatGPT/ChatProvider.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ public final class ChatProvider: ObservableObject {
1717
.last?
1818
.text else { return defaultTitle }
1919
if lastMessageText.isEmpty { return defaultTitle }
20-
return lastMessageText
20+
let trimmed = lastMessageText
2121
.trimmingCharacters(in: .punctuationCharacters)
2222
.trimmingCharacters(in: .whitespacesAndNewlines)
23+
if trimmed.starts(with: "```") {
24+
return "Code Block"
25+
} else {
26+
return trimmed
27+
}
2328
}
2429

2530
public var extraSystemPrompt = ""

0 commit comments

Comments
 (0)