Skip to content

Commit 87b4992

Browse files
committed
Update UI to support continuous prompt to code
1 parent f72bd66 commit 87b4992

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

Core/Sources/PromptToCodeService/PromptToCodeService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public final class PromptToCodeService: ObservableObject {
1515
@Published public var code: String
1616
@Published public var isResponding: Bool = false
1717
@Published public var description: String = ""
18+
@Published public var isContinuous = false
1819
public var oldDescription: String?
1920
public var canRevert: Bool { oldCode != nil }
2021
public var selectionRange: CursorRange
2122
public var language: CopilotLanguage
2223
public var indentSize: Int
2324
public var usesTabsForIndentation: Bool
24-
public var isContinuous = false
2525

2626
public init(
2727
code: String,

Core/Sources/Service/GUI/PromptToCodeProvider+Service.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extension PromptToCodeProvider {
1717
service.$code.sink(receiveValue: set(\.code)).store(in: &cancellables)
1818
service.$isResponding.sink(receiveValue: set(\.isResponding)).store(in: &cancellables)
1919
service.$description.sink(receiveValue: set(\.description)).store(in: &cancellables)
20+
service.$isContinuous.sink(receiveValue: set(\.isContinuous)).store(in: &cancellables)
2021
service.$oldCode.map { $0 != nil }
2122
.sink(receiveValue: set(\.canRevert)).store(in: &cancellables)
2223

@@ -52,6 +53,10 @@ extension PromptToCodeProvider {
5253
await handler.acceptSuggestion()
5354
}
5455
}
56+
57+
onContinuousToggleClick = {
58+
service.isContinuous.toggle()
59+
}
5560
}
5661

5762
func set<T>(_ keyPath: WritableKeyPath<PromptToCodeProvider, T>) -> (T) -> Void {

Core/Sources/SuggestionWidget/PromptToCodeProvider.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ public final class PromptToCodeProvider: ObservableObject {
1313
@Published public var requirement: String
1414
@Published public var errorMessage: String
1515
@Published public var canRevert: Bool
16+
@Published public var isContinuous: Bool
1617

1718
public var onRevertTapped: () -> Void
1819
public var onStopRespondingTap: () -> Void
1920
public var onCancelTapped: () -> Void
2021
public var onAcceptSuggestionTapped: () -> Void
2122
public var onRequirementSent: (String) -> Void
23+
public var onContinuousToggleClick: () -> Void
2224

2325
public init(
2426
code: String = "",
@@ -30,11 +32,13 @@ public final class PromptToCodeProvider: ObservableObject {
3032
requirement: String = "",
3133
errorMessage: String = "",
3234
canRevert: Bool = false,
35+
isContinuous: Bool = false,
3336
onRevertTapped: @escaping () -> Void = {},
3437
onStopRespondingTap: @escaping () -> Void = {},
3538
onCancelTapped: @escaping () -> Void = {},
3639
onAcceptSuggestionTapped: @escaping () -> Void = {},
37-
onRequirementSent: @escaping (String) -> Void = { _ in }
40+
onRequirementSent: @escaping (String) -> Void = { _ in },
41+
onContinuousToggleClick: @escaping () -> Void = {}
3842
) {
3943
self.code = code
4044
self.language = language
@@ -45,11 +49,13 @@ public final class PromptToCodeProvider: ObservableObject {
4549
self.requirement = requirement
4650
self.errorMessage = errorMessage
4751
self.canRevert = canRevert
52+
self.isContinuous = isContinuous
4853
self.onRevertTapped = onRevertTapped
4954
self.onStopRespondingTap = onStopRespondingTap
5055
self.onCancelTapped = onCancelTapped
5156
self.onAcceptSuggestionTapped = onAcceptSuggestionTapped
5257
self.onRequirementSent = onRequirementSent
58+
self.onContinuousToggleClick = onContinuousToggleClick
5359
}
5460

5561
func revert() {
@@ -70,4 +76,6 @@ public final class PromptToCodeProvider: ObservableObject {
7076
}
7177

7278
func acceptSuggestion() { onAcceptSuggestionTapped() }
79+
80+
func toggleContinuous() { onContinuousToggleClick() }
7381
}

Core/Sources/SuggestionWidget/SuggestionPanelContent/PromptToCodePanel.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ struct PromptToCodePanel: View {
7575
.buttonStyle(.plain)
7676
} else {
7777
HStack {
78+
Toggle("Continuous Mode", isOn: $provider.isContinuous)
79+
.toggleStyle(.checkbox)
80+
7881
Button(action: {
7982
provider.cancel()
8083
}) {

0 commit comments

Comments
 (0)