@@ -34,7 +34,7 @@ public protocol PromptToCodeCustomizedUI {
3434 )
3535
3636 func callAsFunction< V: View > (
37- state: Shared < PromptToCodeState > ,
37+ state: Shared < ModificationState > ,
3838 isInputFieldFocused: Binding < Bool > ,
3939 @ViewBuilder view: @escaping ( PromptToCodeCustomizedViews ) -> V
4040 ) -> PromptToCodeCustomizationContextWrapper < V >
@@ -44,7 +44,7 @@ struct NoPromptToCodeCustomizedUI: PromptToCodeCustomizedUI {
4444 private class Context { }
4545
4646 func callAsFunction< V: View > (
47- state: Shared < PromptToCodeState > ,
47+ state: Shared < ModificationState > ,
4848 isInputFieldFocused: Binding < Bool > ,
4949 @ViewBuilder view: @escaping ( PromptToCodeCustomizedViews ) -> V
5050 ) -> PromptToCodeCustomizationContextWrapper < V > {
@@ -59,78 +59,3 @@ struct NoPromptToCodeCustomizedUI: PromptToCodeCustomizedUI {
5959 }
6060}
6161
62- public struct PromptToCodeState : Equatable {
63- public typealias Source = ModificationAgentRequest . ModificationSource
64-
65- public var source : Source
66- public var history : [ ModificationHistoryNode ] = [ ]
67- public var snippets : IdentifiedArrayOf < ModificationSnippet > = [ ]
68- public var isGenerating : Bool = false
69- public var instruction : String
70- public var extraSystemPrompt : String
71- public var isAttachedToTarget : Bool = true
72-
73- public init (
74- source: Source ,
75- history: [ ModificationHistoryNode ] = [ ] ,
76- snippets: IdentifiedArrayOf < ModificationSnippet > ,
77- instruction: String ,
78- extraSystemPrompt: String ,
79- isAttachedToTarget: Bool
80- ) {
81- self . history = history
82- self . snippets = snippets
83- isGenerating = false
84- self . instruction = instruction
85- self . isAttachedToTarget = isAttachedToTarget
86- self . extraSystemPrompt = extraSystemPrompt
87- self . source = source
88- }
89-
90- public init (
91- source: Source ,
92- originalCode: String ,
93- attachedRange: CursorRange ,
94- instruction: String ,
95- extraSystemPrompt: String
96- ) {
97- self . init (
98- source: source,
99- snippets: [
100- . init(
101- startLineIndex: 0 ,
102- originalCode: originalCode,
103- modifiedCode: originalCode,
104- description: " " ,
105- error: nil ,
106- attachedRange: attachedRange
107- ) ,
108- ] ,
109- instruction: instruction,
110- extraSystemPrompt: extraSystemPrompt,
111- isAttachedToTarget: !attachedRange. isEmpty
112- )
113- }
114-
115- public mutating func popHistory( ) {
116- if !history. isEmpty {
117- let last = history. removeLast ( )
118- snippets = last. snippets
119- instruction = last. instruction
120- }
121- }
122-
123- public mutating func pushHistory( ) {
124- history. append ( . init( snippets: snippets, instruction: instruction) )
125- let oldSnippets = snippets
126- snippets = IdentifiedArrayOf ( )
127- for var snippet in oldSnippets {
128- snippet. originalCode = snippet. modifiedCode
129- snippet. modifiedCode = " "
130- snippet. description = " "
131- snippet. error = nil
132- snippets. append ( snippet)
133- }
134- }
135- }
136-
0 commit comments