Skip to content

Commit 726f9e6

Browse files
committed
Update chat tab instruction
1 parent 54a9aff commit 726f9e6

File tree

1 file changed

+59
-38
lines changed

1 file changed

+59
-38
lines changed

Core/Sources/ChatGPTChatTab/ChatPanel.swift

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -105,54 +105,75 @@ private struct StopRespondingButton: View {
105105

106106
private struct Instruction: View {
107107
@AppStorage(\.useSelectionScopeByDefaultInChatContext)
108-
var useSelectionScopeByDefaultInChatContext
109-
@AppStorage(\.chatFontSize) var chatFontSize
108+
var useCodeScopeByDefaultInChatContext
110109

111110
var body: some View {
112111
Group {
113-
if useSelectionScopeByDefaultInChatContext {
114-
Markdown(
115-
"""
116-
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
112+
Markdown(
113+
"""
114+
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
115+
116+
\(
117+
useCodeScopeByDefaultInChatContext
118+
? "Scope **`@code`** is enabled by default."
119+
: "Scope **`@file`** is enabled by default."
120+
)
121+
"""
122+
)
123+
.modifier(InstructionModifier())
117124

118-
Currently, I have the ability to read the following details from the active editor:
119-
- The **selected code**.
120-
- The **relative path** of the file.
121-
- The **error and warning** labels.
122-
- The text cursor location.
125+
Markdown(
126+
"""
127+
You can use scopes to give the bot extra abilities.
123128
124-
If you'd like me to examine the entire file, simply add `@file` to the beginning of your message.
129+
| Scope Name | Abilities |
130+
| --- | --- |
131+
| `@file` | Read the metadata of the editing file |
132+
| `@code` | Read the code and metadata in the editing file |
133+
| `@web` (beta) | Search on Bing or query from a web page |
125134
126-
To use plugins, you can start a message with `/pluginName`.
127-
"""
128-
)
129-
} else {
130-
Markdown(
131-
"""
132-
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
135+
To use scopes, you can prefix a message with `@code`.
133136
134-
Currently, I have the ability to read the following details from the active editor:
135-
- The **relative path** of the file.
136-
- The **error and warning** labels.
137-
- The text cursor location.
137+
You can use shorthand to represent a scope, such as `@c`, and enable multiple scopes with `@c+web`.
138+
"""
139+
)
140+
.modifier(InstructionModifier())
141+
142+
Markdown(
143+
"""
144+
You can use plugins to perform various tasks.
145+
146+
| Plugin Name | Description |
147+
| --- | --- |
148+
| `/run` | Runs a command under the project root |
149+
| `/math` | Solves a math problem in natural language |
150+
| `/search` | Searches on Bing and summarizes the results |
151+
| `/shortcut(name)` | Runs a shortcut from the Shortcuts.app, with the previous message as input |
152+
| `/shortcutInput(name)` | Runs a shortcut and uses its result as a new message |
153+
154+
To use plugins, you can prefix a message with `/pluginName`.
155+
"""
156+
)
157+
.modifier(InstructionModifier())
158+
}
159+
}
138160

139-
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`.
161+
struct InstructionModifier: ViewModifier {
162+
@AppStorage(\.chatFontSize) var chatFontSize
140163

141-
To use plugins, you can start a message with `/pluginName`.
142-
"""
143-
)
144-
}
145-
}
146-
.textSelection(.enabled)
147-
.markdownTheme(.custom(fontSize: chatFontSize))
148-
.opacity(0.8)
149-
.frame(maxWidth: .infinity, alignment: .leading)
150-
.padding()
151-
.overlay {
152-
RoundedRectangle(cornerRadius: 8)
153-
.stroke(Color(nsColor: .separatorColor), lineWidth: 1)
164+
func body(content: Content) -> some View {
165+
content
166+
.textSelection(.enabled)
167+
.markdownTheme(.custom(fontSize: chatFontSize))
168+
.opacity(0.8)
169+
.frame(maxWidth: .infinity, alignment: .leading)
170+
.padding()
171+
.overlay {
172+
RoundedRectangle(cornerRadius: 8)
173+
.stroke(Color(nsColor: .separatorColor), lineWidth: 1)
174+
}
175+
.scaleEffect(x: -1, y: -1, anchor: .center)
154176
}
155-
.scaleEffect(x: -1, y: -1, anchor: .center)
156177
}
157178
}
158179

0 commit comments

Comments
 (0)