@@ -92,7 +92,7 @@ class FilePickerModel: ObservableObject {
92
92
do throws ( ClientError) {
93
93
rootFiles = try await client
94
94
. listAgentDirectory ( . init( path: [ ] , relativity: . root) )
95
- . toModels ( client: Binding ( get : { self . client } , set : { _ in } ) , path: [ ] )
95
+ . toModels ( client: client, path: [ ] )
96
96
} catch {
97
97
self . error = error
98
98
}
@@ -173,10 +173,7 @@ class FilePickerItemModel: Identifiable, ObservableObject {
173
173
let absolute_path : String
174
174
let dir : Bool
175
175
176
- // This being a binding is pretty important performance-wise, as it's a struct
177
- // that would otherwise be recreated every time the the item row is rendered.
178
- // Removing the binding results in very noticeable lag when scrolling a file tree.
179
- @Binding var client : AgentClient
176
+ let client : AgentClient
180
177
181
178
@Published var contents : [ FilePickerItemModel ] ?
182
179
@Published var isLoading = false
@@ -197,14 +194,14 @@ class FilePickerItemModel: Identifiable, ObservableObject {
197
194
198
195
init (
199
196
name: String ,
200
- client: Binding < AgentClient > ,
197
+ client: AgentClient ,
201
198
absolute_path: String ,
202
199
path: [ String ] ,
203
200
dir: Bool = false ,
204
201
contents: [ FilePickerItemModel ] ? = nil
205
202
) {
206
203
self . name = name
207
- _client = client
204
+ self . client = client
208
205
self . path = path
209
206
self . dir = dir
210
207
self . absolute_path = absolute_path
@@ -227,7 +224,7 @@ class FilePickerItemModel: Identifiable, ObservableObject {
227
224
do throws ( ClientError) {
228
225
contents = try await client
229
226
. listAgentDirectory ( . init( path: path, relativity: . root) )
230
- . toModels ( client: $ client, path: path)
227
+ . toModels ( client: client, path: path)
231
228
} catch {
232
229
self . error = error
233
230
}
@@ -237,7 +234,7 @@ class FilePickerItemModel: Identifiable, ObservableObject {
237
234
238
235
extension LSResponse {
239
236
@MainActor
240
- func toModels( client: Binding < AgentClient > , path: [ String ] ) -> [ FilePickerItemModel ] {
237
+ func toModels( client: AgentClient , path: [ String ] ) -> [ FilePickerItemModel ] {
241
238
contents. compactMap { file in
242
239
// Filter dotfiles from the picker
243
240
guard !file. name. hasPrefix ( " . " ) else { return nil }
0 commit comments