Skip to content

Commit 91c6f81

Browse files
committed
Fix that new chat tab was not starting at the bottom
1 parent 146d72a commit 91c6f81

1 file changed

Lines changed: 31 additions & 21 deletions

File tree

Core/Sources/ChatGPTChatTab/ChatPanel.swift

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ struct ChatPanelMessages: View {
5353
List {
5454
Group {
5555
Spacer(minLength: 12)
56-
56+
5757
Instruction()
58-
58+
5959
ChatHistory(chat: chat)
6060
.listItemTint(.clear)
61-
61+
6262
WithViewStore(chat, observe: \.isReceivingMessage) { viewStore in
6363
if viewStore.state {
6464
StopRespondingButton(chat: chat)
@@ -71,8 +71,14 @@ struct ChatPanelMessages: View {
7171
))
7272
}
7373
}
74-
74+
7575
Spacer(minLength: 12)
76+
.onAppear {
77+
withAnimation {
78+
proxy.scrollTo(bottomID, anchor: .bottom)
79+
}
80+
}
81+
.id(bottomID)
7682
.background(GeometryReader { geo in
7783
let offset = geo.frame(in: .named(scrollSpace)).minY
7884
Color.clear
@@ -85,7 +91,6 @@ struct ChatPanelMessages: View {
8591
key: ListHeightPreferenceKey.self,
8692
value: listGeo.size.height
8793
)
88-
.id(bottomID)
8994
}
9095
.modify { view in
9196
if #available(macOS 13.0, *) {
@@ -115,7 +120,12 @@ struct ChatPanelMessages: View {
115120
Image(systemName: "arrow.down")
116121
.padding(4)
117122
.background {
118-
Circle().fill(.thickMaterial)
123+
Circle()
124+
.fill(.thickMaterial)
125+
.shadow(color: .black.opacity(0.2), radius: 2)
126+
}
127+
.overlay {
128+
Circle().stroke(Color(nsColor: .separatorColor), lineWidth: 1)
119129
}
120130
.foregroundStyle(.secondary)
121131
.padding(4)
@@ -127,7 +137,7 @@ struct ChatPanelMessages: View {
127137
if isInitialLoad {
128138
isInitialLoad = false
129139
}
130-
withAnimation(.easeInOut(duration: 0.1)) {
140+
withAnimation {
131141
proxy.scrollTo(bottomID, anchor: .bottom)
132142
}
133143
}
@@ -137,7 +147,7 @@ struct ChatPanelMessages: View {
137147
}
138148
}
139149
}
140-
150+
141151
func updatePinningState() {
142152
if scrollOffset > listHeight + 24 + 100 || scrollOffset <= 0 {
143153
pinnedToBottom = false
@@ -216,19 +226,6 @@ private struct Instruction: View {
216226

217227
var body: some View {
218228
Group {
219-
Markdown(
220-
"""
221-
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
222-
223-
\(
224-
useCodeScopeByDefaultInChatContext
225-
? "Scope **`@code`** is enabled by default."
226-
: "Scope **`@file`** is enabled by default."
227-
)
228-
"""
229-
)
230-
.modifier(InstructionModifier())
231-
232229
Markdown(
233230
"""
234231
You can use scopes to give the bot extra abilities.
@@ -263,6 +260,19 @@ private struct Instruction: View {
263260
"""
264261
)
265262
.modifier(InstructionModifier())
263+
264+
Markdown(
265+
"""
266+
Hello, I am your AI programming assistant. I can identify issues, explain and even improve code.
267+
268+
\(
269+
useCodeScopeByDefaultInChatContext
270+
? "Scope **`@code`** is enabled by default."
271+
: "Scope **`@file`** is enabled by default."
272+
)
273+
"""
274+
)
275+
.modifier(InstructionModifier())
266276
}
267277
}
268278

0 commit comments

Comments
 (0)