Skip to content

Commit cd3ff1d

Browse files
committed
Make chat instruction always visible
1 parent be9c57b commit cd3ff1d

1 file changed

Lines changed: 50 additions & 45 deletions

File tree

Core/Sources/SuggestionWidget/SuggestionPanelContent/ChatPanel.swift

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

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

6865
var body: some View {
6966
List {
@@ -76,48 +73,7 @@ struct ChatPanelMessages: View {
7673
.listRowInsets(EdgeInsets(top: 0, leading: -8, bottom: 0, trailing: -8))
7774
}
7875

79-
if chat.history.isEmpty {
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)
120-
}
76+
Instruction()
12177

12278
ForEach(chat.history.reversed(), id: \.id) { message in
12379
let text = message.text.isEmpty && !message.isUser ? "..." : message
@@ -172,6 +128,55 @@ private struct StopRespondingButton: View {
172128
}
173129
}
174130

131+
private struct Instruction: View {
132+
@AppStorage(\.useSelectionScopeByDefaultInChatContext)
133+
var useSelectionScopeByDefaultInChatContext
134+
@AppStorage(\.chatFontSize) var chatFontSize
135+
136+
var body: some View {
137+
Group {
138+
if useSelectionScopeByDefaultInChatContext {
139+
Markdown(
140+
"""
141+
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
142+
143+
Currently, I have the ability to read the following details from the active editor:
144+
- The **selected code**.
145+
- The **relative path** of the file.
146+
- The **error and warning** labels.
147+
- The text cursor location.
148+
149+
If you'd like me to examine the entire file, simply add `/file` to the beginning of your message.
150+
"""
151+
)
152+
} else {
153+
Markdown(
154+
"""
155+
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
156+
157+
Currently, I have the ability to read the following details from the active editor:
158+
- The **relative path** of the file.
159+
- The **error and warning** labels.
160+
- The text cursor location.
161+
162+
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`.
163+
"""
164+
)
165+
}
166+
}
167+
.textSelection(.enabled)
168+
.markdownTheme(.custom(fontSize: chatFontSize))
169+
.opacity(0.8)
170+
.frame(maxWidth: .infinity, alignment: .leading)
171+
.padding()
172+
.overlay {
173+
RoundedRectangle(cornerRadius: 8)
174+
.stroke(Color(nsColor: .separatorColor), lineWidth: 1)
175+
}
176+
.scaleEffect(x: -1, y: -1, anchor: .center)
177+
}
178+
}
179+
175180
private struct UserMessage: View {
176181
let id: String
177182
let text: String

0 commit comments

Comments
 (0)