Skip to content

Commit aea86c5

Browse files
committed
Add a toggle to disable LazyVStack
1 parent 1be42a1 commit aea86c5

File tree

5 files changed

+66
-7
lines changed

5 files changed

+66
-7
lines changed

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
C83B2B82293DC38400C5ACCD /* LaunchAgentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83B2B81293DC38400C5ACCD /* LaunchAgentView.swift */; };
3232
C841BB242994CAD400B0B336 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C841BB232994CAD400B0B336 /* SettingsView.swift */; };
3333
C8520301293C4D9000460097 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8520300293C4D9000460097 /* Helpers.swift */; };
34+
C85AF32D29CF0C170031E18B /* DebugView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85AF32C29CF0C170031E18B /* DebugView.swift */; };
3435
C861E6112994F6070056CB02 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C861E6102994F6070056CB02 /* AppDelegate.swift */; };
3536
C861E6152994F6080056CB02 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C861E6142994F6080056CB02 /* Assets.xcassets */; };
3637
C861E61E2994F6150056CB02 /* Service in Frameworks */ = {isa = PBXBuildFile; productRef = C861E61D2994F6150056CB02 /* Service */; };
@@ -178,6 +179,7 @@
178179
C841BB232994CAD400B0B336 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
179180
C8520300293C4D9000460097 /* Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = "<group>"; };
180181
C8520308293D805800460097 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
182+
C85AF32C29CF0C170031E18B /* DebugView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugView.swift; sourceTree = "<group>"; };
181183
C861E60E2994F6070056CB02 /* CopilotForXcodeExtensionService.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CopilotForXcodeExtensionService.app; sourceTree = BUILT_PRODUCTS_DIR; };
182184
C861E6102994F6070056CB02 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
183185
C861E6142994F6080056CB02 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -312,6 +314,7 @@
312314
C8EE079E29CC25C20043B6D9 /* OpenAIView.swift */,
313315
C83B2B7F293DA1B600C5ACCD /* InstructionView.swift */,
314316
C841BB232994CAD400B0B336 /* SettingsView.swift */,
317+
C85AF32C29CF0C170031E18B /* DebugView.swift */,
315318
C87F3E61293DD004008523E8 /* Styles.swift */,
316319
C8189B1D2938973000C9DCDA /* Assets.xcassets */,
317320
C8189B222938973000C9DCDA /* Copilot_for_Xcode.entitlements */,
@@ -551,6 +554,7 @@
551554
C841BB242994CAD400B0B336 /* SettingsView.swift in Sources */,
552555
C83B2B80293DA1B600C5ACCD /* InstructionView.swift in Sources */,
553556
C83B2B7C293D9FB400C5ACCD /* CopilotView.swift in Sources */,
557+
C85AF32D29CF0C170031E18B /* DebugView.swift in Sources */,
554558
C83B2B7A293D9C8C00C5ACCD /* LaunchAgentManager.swift in Sources */,
555559
C8189B1A2938972F00C9DCDA /* App.swift in Sources */,
556560
);

Copilot for Xcode/ContentView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct ContentView: View {
1717
AccountView()
1818
SettingsView()
1919
InstructionView()
20+
DebugSettingsView()
2021
Spacer()
2122
}
2223
.padding(.all, 12)
@@ -41,6 +42,6 @@ struct ContentView: View {
4142
struct ContentView_Previews: PreviewProvider {
4243
static var previews: some View {
4344
ContentView()
44-
.frame(height: 800)
45+
.frame(height: 1200)
4546
}
4647
}

Copilot for Xcode/DebugView.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import LaunchAgentManager
2+
import Preferences
3+
import SwiftUI
4+
5+
final class DebugSettings: ObservableObject {
6+
@AppStorage(\.disableLazyVStack)
7+
var disableLazyVStack: Bool
8+
init() {}
9+
}
10+
11+
struct DebugSettingsView: View {
12+
@StateObject var settings = DebugSettings()
13+
14+
var body: some View {
15+
Section {
16+
Form {
17+
Toggle(isOn: $settings.disableLazyVStack) {
18+
Text("Disable LazyVStack")
19+
}
20+
.toggleStyle(.switch)
21+
}
22+
}.buttonStyle(.copilot)
23+
}
24+
}
25+
26+
struct DebugSettingsView_Preview: PreviewProvider {
27+
static var previews: some View {
28+
DebugSettingsView()
29+
.background(.purple)
30+
}
31+
}

Core/Sources/Preferences/Keys.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,39 +64,48 @@ public struct UserDefaultPreferenceKeys {
6464
}
6565

6666
public var widgetColorScheme: WidgetColorSchemeKey { .init() }
67-
67+
6868
public struct OpenAIAPIKey: UserDefaultPreferenceKey {
6969
public let defaultValue = ""
7070
public let key = "OpenAIAPIKey"
7171
}
7272

7373
public var openAIAPIKey: OpenAIAPIKey { .init() }
74-
74+
7575
public struct ChatGPTEndpoint: UserDefaultPreferenceKey {
7676
public let defaultValue = ""
7777
public let key = "ChatGPTEndpoint"
7878
}
7979

8080
public var chatGPTEndpoint: ChatGPTEndpoint { .init() }
81-
81+
8282
public struct ChatGPTModel: UserDefaultPreferenceKey {
8383
public let defaultValue = ""
8484
public let key = "ChatGPTModel"
8585
}
8686

8787
public var chatGPTModel: ChatGPTModel { .init() }
88-
88+
8989
public struct ChatGPTMaxToken: UserDefaultPreferenceKey {
9090
public let defaultValue = 2048
9191
public let key = "ChatGPTMaxToken"
9292
}
9393

9494
public var chatGPTMaxToken: ChatGPTMaxToken { .init() }
95-
95+
9696
public struct ChatGPTLanguage: UserDefaultPreferenceKey {
9797
public let defaultValue = ""
9898
public let key = "ChatGPTLanguage"
9999
}
100100

101101
public var chatGPTLanguage: ChatGPTLanguage { .init() }
102+
103+
public var disableLazyVStack: FeatureFlags.DisableLazyVStack { .init() }
104+
}
105+
106+
public enum FeatureFlags {
107+
public struct DisableLazyVStack: UserDefaultPreferenceKey {
108+
public let defaultValue = false
109+
public let key = "FeatureFlag-DisableLazyVStack"
110+
}
102111
}

Core/Sources/SuggestionWidget/SuggestionPanelContent/ChatPanel.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,24 @@ struct ChatPanel: View {
4141
struct ChatPanelMessages: View {
4242
@ObservedObject var chat: ChatRoom
4343
var inputAreaNamespace: Namespace.ID
44+
@AppStorage(\.disableLazyVStack) var disableLazyVStack
4445

46+
@ViewBuilder
47+
func vstack(@ViewBuilder content: () -> some View) -> some View {
48+
if disableLazyVStack {
49+
VStack {
50+
content()
51+
}
52+
} else {
53+
LazyVStack {
54+
content()
55+
}
56+
}
57+
}
58+
4559
var body: some View {
4660
ScrollView {
47-
LazyVStack {
61+
vstack {
4862
if chat.isReceivingMessage {
4963
Button(action: {
5064
chat.stop()

0 commit comments

Comments
 (0)