Skip to content

Commit 61e76d2

Browse files
committed
Display instructions in the chat panel
1 parent d1121aa commit 61e76d2

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

Core/Sources/SuggestionWidget/SuggestionPanelContent/ChatPanel.swift

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ struct ChatPanelToolbar: View {
6161

6262
struct ChatPanelMessages: View {
6363
@ObservedObject var chat: ChatProvider
64+
@AppStorage(\.chatFontSize) var chatFontSize
65+
@AppStorage(\.useSelectionScopeByDefaultInChatContext)
66+
var useSelectionScopeByDefaultInChatContext
6467

6568
var body: some View {
6669
List {
@@ -74,12 +77,46 @@ struct ChatPanelMessages: View {
7477
}
7578

7679
if chat.history.isEmpty {
77-
Text("New Chat")
78-
.frame(maxWidth: .infinity, alignment: .center)
79-
.padding(.vertical)
80-
.scaleEffect(x: -1, y: -1, anchor: .center)
81-
.foregroundStyle(.secondary)
82-
.listRowInsets(EdgeInsets(top: 0, leading: -8, bottom: 0, trailing: -8))
80+
Group {
81+
if useSelectionScopeByDefaultInChatContext {
82+
Markdown(
83+
"""
84+
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
85+
86+
Currently, I have the ability to read the following details from the active editor:
87+
- The **selected code**.
88+
- The **relative path** of the file.
89+
- The **error and warning** labels.
90+
- The text cursor location.
91+
92+
If you'd like me to examine the entire file, simply add `/file` to the beginning of your message.
93+
"""
94+
)
95+
} else {
96+
Markdown(
97+
"""
98+
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
99+
100+
Currently, I have the ability to read the following details from the active editor:
101+
- The **relative path** of the file.
102+
- The **error and warning** labels.
103+
- The text cursor location.
104+
105+
If you would like me to examine the selected code, please prefix your message with `/selection`. If you would like me to examine the entire file, please prefix your message with `/file`.
106+
"""
107+
)
108+
}
109+
}
110+
.textSelection(.enabled)
111+
.markdownTheme(.custom(fontSize: chatFontSize))
112+
.opacity(0.8)
113+
.frame(maxWidth: .infinity, alignment: .leading)
114+
.padding()
115+
.overlay {
116+
RoundedRectangle(cornerRadius: 8)
117+
.stroke(Color(nsColor: .separatorColor), lineWidth: 1)
118+
}
119+
.scaleEffect(x: -1, y: -1, anchor: .center)
83120
}
84121

85122
ForEach(chat.history.reversed(), id: \.id) { message in
@@ -177,7 +214,7 @@ private struct UserMessage: View {
177214
Button("Send Again") {
178215
chat.resendMessage(id: id)
179216
}
180-
217+
181218
Button("Set as Extra System Prompt") {
182219
chat.setAsExtraPrompt(id: id)
183220
}
@@ -234,7 +271,7 @@ private struct BotMessage: View {
234271
NSPasteboard.general.clearContents()
235272
NSPasteboard.general.setString(text, forType: .string)
236273
}
237-
274+
238275
Button("Set as Extra System Prompt") {
239276
chat.setAsExtraPrompt(id: id)
240277
}

0 commit comments

Comments
 (0)