@@ -12,28 +12,23 @@ import { IDecorationOptions } from '../../../../../editor/common/editorCommon.js
12
12
import { Command , isLocation } from '../../../../../editor/common/languages.js' ;
13
13
import { Action2 , registerAction2 } from '../../../../../platform/actions/common/actions.js' ;
14
14
import { ICommandService } from '../../../../../platform/commands/common/commands.js' ;
15
- import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js' ;
16
- import { IInstantiationService , ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js' ;
15
+ import { ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js' ;
17
16
import { ILabelService } from '../../../../../platform/label/common/label.js' ;
18
17
import { IChatRequestVariableValue , IDynamicVariable } from '../../common/chatVariables.js' ;
19
- import { PromptsConfig } from '../../common/promptSyntax/config/config.js' ;
20
18
import { IChatWidget } from '../chat.js' ;
21
19
import { IChatWidgetContrib } from '../chatWidget.js' ;
22
20
import { ChatFileReference } from './chatDynamicVariables/chatFileReference.js' ;
23
21
24
22
export const dynamicVariableDecorationType = 'chat-dynamic-variable' ;
25
23
26
- /**
27
- * Type of dynamic variables. Can be either a file reference or
28
- * another dynamic variable (e.g., a `#sym`, `#kb`, etc.).
29
- */
30
- type TDynamicVariable = IDynamicVariable | ChatFileReference ;
24
+
31
25
32
26
export class ChatDynamicVariableModel extends Disposable implements IChatWidgetContrib {
33
27
public static readonly ID = 'chatDynamicVariableModel' ;
34
28
35
- private _variables : TDynamicVariable [ ] = [ ] ;
36
- get variables ( ) : ReadonlyArray < TDynamicVariable > {
29
+ private _variables : IDynamicVariable [ ] = [ ] ;
30
+
31
+ get variables ( ) : ReadonlyArray < IDynamicVariable > {
37
32
return [ ...this . _variables ] ;
38
33
}
39
34
@@ -46,18 +41,16 @@ export class ChatDynamicVariableModel extends Disposable implements IChatWidgetC
46
41
constructor (
47
42
private readonly widget : IChatWidget ,
48
43
@ILabelService private readonly labelService : ILabelService ,
49
- @IConfigurationService private readonly configService : IConfigurationService ,
50
- @IInstantiationService private readonly instantiationService : IInstantiationService ,
51
44
) {
52
45
super ( ) ;
53
46
54
47
this . _register ( widget . inputEditor . onDidChangeModelContent ( e => {
55
48
56
- const removed : TDynamicVariable [ ] = [ ] ;
49
+ const removed : IDynamicVariable [ ] = [ ] ;
57
50
let didChange = false ;
58
51
59
52
// Don't mutate entries in _variables, since they will be returned from the getter
60
- this . _variables = coalesce ( this . _variables . map ( ( ref , idx ) : TDynamicVariable | null => {
53
+ this . _variables = coalesce ( this . _variables . map ( ( ref , idx ) : IDynamicVariable | null => {
61
54
const model = widget . inputEditor . getModel ( ) ;
62
55
63
56
if ( ! model ) {
@@ -115,7 +108,7 @@ export class ChatDynamicVariableModel extends Disposable implements IChatWidgetC
115
108
116
109
getInputState ( ) : any {
117
110
return this . variables
118
- . map ( ( variable : TDynamicVariable ) => {
111
+ . map ( ( variable : IDynamicVariable ) => {
119
112
// return underlying `IDynamicVariable` object for file references
120
113
if ( variable instanceof ChatFileReference ) {
121
114
return variable . reference ;
@@ -143,26 +136,9 @@ export class ChatDynamicVariableModel extends Disposable implements IChatWidgetC
143
136
}
144
137
145
138
addReference ( ref : IDynamicVariable ) : void {
146
- // use `ChatFileReference` for file references and `IDynamicVariable` for other variables
147
- const promptSnippetsEnabled = PromptsConfig . enabled ( this . configService ) ;
148
- const variable = ( ref . id === 'vscode.file' && promptSnippetsEnabled )
149
- ? this . instantiationService . createInstance ( ChatFileReference , ref )
150
- : ref ;
151
-
152
- this . _variables . push ( variable ) ;
139
+ this . _variables . push ( ref ) ;
153
140
this . updateDecorations ( ) ;
154
141
this . widget . refreshParsedInput ( ) ;
155
-
156
- // if the `prompt snippets` feature is enabled, and file is a `prompt snippet`,
157
- // start resolving nested file references immediately and subscribe to updates
158
- if ( variable instanceof ChatFileReference && variable . isPromptFile ) {
159
- // subscribe to variable changes
160
- variable . onUpdate ( ( ) => {
161
- this . updateDecorations ( ) ;
162
- } ) ;
163
- // start resolving the file references
164
- variable . start ( ) ;
165
- }
166
142
}
167
143
168
144
private updateDecorations ( ) : void {
0 commit comments