@@ -17,8 +17,19 @@ function toMessageFromInput(s: string): string {
17
17
return s ;
18
18
}
19
19
20
- function setFileContent ( items : EditorItem [ ] , name : string , content : string , full : boolean = false ) {
21
- const existing = items . find ( ( f ) => f . id === name ) ;
20
+ function setFileContent (
21
+ items : EditorItem [ ] ,
22
+ name : string ,
23
+ content : string ,
24
+ full : boolean = false ,
25
+ opts : {
26
+ threadID ?: string ;
27
+ taskID ?: string ;
28
+ runID ?: string ;
29
+ } = { }
30
+ ) {
31
+ const id = opts . runID ? `${ opts . taskID } /${ opts . runID } /${ name } ` : `${ opts . threadID } /${ name } ` ;
32
+ const existing = items . find ( ( f ) => f . id === id ) ;
22
33
if ( existing && existing . file ) {
23
34
if ( full ) {
24
35
existing . file . contents = content ;
@@ -29,7 +40,7 @@ function setFileContent(items: EditorItem[], name: string, content: string, full
29
40
}
30
41
} else {
31
42
items . push ( {
32
- id : name ,
43
+ id : id ,
33
44
name : name ,
34
45
file : {
35
46
contents : content ,
@@ -107,7 +118,16 @@ function getFilenameAndContent(content: string) {
107
118
} ;
108
119
}
109
120
110
- function reformatWriteMessage ( items : EditorItem [ ] , msg : Message , last : boolean ) {
121
+ function reformatWriteMessage (
122
+ items : EditorItem [ ] ,
123
+ msg : Message ,
124
+ last : boolean ,
125
+ opts : {
126
+ threadID ?: string ;
127
+ taskID ?: string ;
128
+ runID ?: string ;
129
+ } = { }
130
+ ) {
111
131
msg . icon = 'Pencil' ;
112
132
msg . done = ! last || msg . toolCall !== undefined ;
113
133
msg . sourceName = msg . done ? 'Wrote to Workspace' : 'Writing to Workspace' ;
@@ -129,17 +149,25 @@ function reformatWriteMessage(items: EditorItem[], msg: Message, last: boolean)
129
149
}
130
150
131
151
if ( last && msg . file ?. filename && msg . file ?. content ) {
132
- setFileContent ( items , msg . file . filename , msg . file . content , msg . toolCall !== undefined ) ;
152
+ setFileContent ( items , msg . file . filename , msg . file . content , msg . toolCall !== undefined , opts ) ;
133
153
}
134
154
}
135
155
136
- export function buildMessagesFromProgress ( items : EditorItem [ ] , progresses : Progress [ ] ) : Messages {
156
+ export function buildMessagesFromProgress (
157
+ items : EditorItem [ ] ,
158
+ progresses : Progress [ ] ,
159
+ opts : {
160
+ threadID ?: string ;
161
+ taskID ?: string ;
162
+ runID ?: string ;
163
+ }
164
+ ) : Messages {
137
165
const messages = toMessages ( progresses ) ;
138
166
139
167
// Post Process for much more better-ness
140
168
messages . messages . forEach ( ( item , i ) => {
141
169
if ( item . tool && item . sourceName == 'workspace_write' ) {
142
- reformatWriteMessage ( items , item , i == messages . messages . length - 1 ) ;
170
+ reformatWriteMessage ( items , item , i == messages . messages . length - 1 , opts ) ;
143
171
return ;
144
172
} else if ( item . sent ) {
145
173
reformatInputMessage ( item ) ;
0 commit comments