Skip to content

Commit 6aabb41

Browse files
committed
address comments
1 parent dc35299 commit 6aabb41

File tree

7 files changed

+44
-38
lines changed

7 files changed

+44
-38
lines changed

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export async function presentAssistantMessage(cline: Task) {
146146
}
147147
}
148148

149-
await cline.say("text", content, undefined, undefined, block.partial)
149+
await cline.say("text", content, undefined, undefined, block.partial) // kilocode_change
150150
break
151151
}
152152
case "tool_use":

src/core/prompts/responses.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Otherwise, if you have not completed the task and do not need additional informa
8080
invalidMcpToolArgumentError: (serverName: string, toolName: string) =>
8181
`Invalid JSON argument used with ${serverName} for ${toolName}. Please retry with a properly formatted JSON argument.`,
8282

83+
// kilocode_change start
8384
toolResult: (
8485
text: string,
8586
images?: string[],
@@ -102,8 +103,8 @@ Otherwise, if you have not completed the task and do not need additional informa
102103
const fileBlock: Anthropic.TextBlockParam = { type: "text", text: fileString }
103104
toolResultOutput.push(fileBlock)
104105
}
105-
106106
return toolResultOutput
107+
// kilocode_change end
107108
},
108109

109110
imageBlocks: (images?: string[]): Anthropic.ImageBlockParam[] => {

src/core/task/Task.ts

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export type TaskOptions = {
114114
consecutiveMistakeLimit?: number
115115
task?: string
116116
images?: string[]
117-
files?: string[]
117+
files?: string[] // kilocode_change
118118
historyItem?: HistoryItem
119119
experiments?: Record<string, boolean>
120120
startTask?: boolean
@@ -177,7 +177,7 @@ export class Task extends EventEmitter<ClineEvents> {
177177
private askResponse?: ClineAskResponse
178178
private askResponseText?: string
179179
private askResponseImages?: string[]
180-
private askResponseFiles?: string[]
180+
private askResponseFiles?: string[] // kilocode_change
181181
public lastMessageTs?: number
182182

183183
// Tool Use
@@ -214,7 +214,7 @@ export class Task extends EventEmitter<ClineEvents> {
214214
consecutiveMistakeLimit = 3,
215215
task,
216216
images,
217-
files,
217+
files, // kilocode_change
218218
historyItem,
219219
startTask = true,
220220
rootTask,
@@ -226,6 +226,7 @@ export class Task extends EventEmitter<ClineEvents> {
226226
this.context = context // kilocode_change
227227

228228
if (startTask && !task && !images && !files && !historyItem) {
229+
// kilocode_change
229230
throw new Error("Either historyItem or task/images must be provided")
230231
}
231232

@@ -268,6 +269,7 @@ export class Task extends EventEmitter<ClineEvents> {
268269

269270
if (startTask) {
270271
if (task || images || files) {
272+
// kilocode_change
271273
this.startTask(task, images, files)
272274
} else if (historyItem) {
273275
this.resumeTaskFromHistory()
@@ -289,11 +291,12 @@ export class Task extends EventEmitter<ClineEvents> {
289291

290292
static create(options: TaskOptions): [Task, Promise<void>] {
291293
const instance = new Task({ ...options, startTask: false })
292-
const { images, task, historyItem, files } = options
294+
const { images, task, historyItem, files } = options // kilocode_change
293295
let promise
294296

295297
if (images || task || files) {
296-
promise = instance.startTask(task, images, files)
298+
// kilocode_change
299+
promise = instance.startTask(task, images, files) // kilocode_change
297300
} else if (historyItem) {
298301
promise = instance.resumeTaskFromHistory()
299302
} else {
@@ -409,6 +412,7 @@ export class Task extends EventEmitter<ClineEvents> {
409412
partial?: boolean,
410413
progressStatus?: ToolProgressStatus,
411414
): Promise<{ response: ClineAskResponse; text?: string; images?: string[]; files?: string[] }> {
415+
// kilocode_change
412416
// If this Cline instance was aborted by the provider, then the only
413417
// thing keeping us alive is a promise still running in the background,
414418
// in which case we don't want to send its result to the webview as it
@@ -456,7 +460,7 @@ export class Task extends EventEmitter<ClineEvents> {
456460
this.askResponse = undefined
457461
this.askResponseText = undefined
458462
this.askResponseImages = undefined
459-
this.askResponseFiles = undefined
463+
this.askResponseFiles = undefined // kilocode_change
460464

461465
// Bug for the history books:
462466
// In the webview we use the ts as the chatrow key for the
@@ -481,7 +485,7 @@ export class Task extends EventEmitter<ClineEvents> {
481485
this.askResponse = undefined
482486
this.askResponseText = undefined
483487
this.askResponseImages = undefined
484-
this.askResponseFiles = undefined
488+
this.askResponseFiles = undefined // kilocode_change
485489
askTs = Date.now()
486490
this.lastMessageTs = askTs
487491
await this.addToClineMessages({ ts: askTs, type: "ask", ask: type, text })
@@ -511,7 +515,7 @@ export class Task extends EventEmitter<ClineEvents> {
511515
response: this.askResponse!,
512516
text: this.askResponseText,
513517
images: this.askResponseImages,
514-
files: this.askResponseFiles,
518+
files: this.askResponseFiles, // kilocode_change
515519
}
516520
this.askResponse = undefined
517521
this.askResponseText = undefined
@@ -522,10 +526,11 @@ export class Task extends EventEmitter<ClineEvents> {
522526
}
523527

524528
async handleWebviewAskResponse(askResponse: ClineAskResponse, text?: string, images?: string[], files?: string[]) {
529+
// kilocode_change
525530
this.askResponse = askResponse
526531
this.askResponseText = text
527532
this.askResponseImages = images
528-
this.askResponseFiles = files
533+
this.askResponseFiles = files // kilocode_change
529534
}
530535

531536
async handleTerminalOperation(terminalOperation: "continue" | "abort") {
@@ -598,7 +603,7 @@ export class Task extends EventEmitter<ClineEvents> {
598603
"condense_context",
599604
undefined /* text */,
600605
undefined /* images */,
601-
undefined /* files */,
606+
undefined /* files */, // kilocode_change
602607
false /* partial */,
603608
undefined /* checkpoint */,
604609
undefined /* progressStatus */,
@@ -635,7 +640,7 @@ export class Task extends EventEmitter<ClineEvents> {
635640
// Existing partial message, so update it.
636641
lastMessage.text = text
637642
lastMessage.images = images
638-
lastMessage.files = files
643+
lastMessage.files = files // kilocode_change
639644
lastMessage.partial = partial
640645
lastMessage.progressStatus = progressStatus
641646
this.updateClineMessage(lastMessage)
@@ -653,7 +658,7 @@ export class Task extends EventEmitter<ClineEvents> {
653658
say: type,
654659
text,
655660
images,
656-
files,
661+
files, // kilocode_change
657662
partial,
658663
contextCondense,
659664
})
@@ -669,7 +674,7 @@ export class Task extends EventEmitter<ClineEvents> {
669674

670675
lastMessage.text = text
671676
lastMessage.images = images
672-
lastMessage.files = files
677+
lastMessage.files = files // kilocode_change
673678
lastMessage.partial = false
674679
lastMessage.progressStatus = progressStatus
675680

@@ -708,7 +713,7 @@ export class Task extends EventEmitter<ClineEvents> {
708713
say: type,
709714
text,
710715
images,
711-
files,
716+
files, // kilocode_change
712717
checkpoint,
713718
contextCondense,
714719
})
@@ -738,7 +743,7 @@ export class Task extends EventEmitter<ClineEvents> {
738743
this.apiConversationHistory = []
739744
await this.providerRef.deref()?.postStateToWebview()
740745

741-
await this.say("text", task, images, files)
746+
await this.say("text", task, images, files) // kilocode_change
742747
this.isInitialized = true
743748

744749
let imageBlocks: Anthropic.ImageBlockParam[] = formatResponse.imageBlocks(images)
@@ -751,7 +756,7 @@ export class Task extends EventEmitter<ClineEvents> {
751756
},
752757
...imageBlocks,
753758
]
754-
759+
// kilocode_change start
755760
if (files && files.length > 0) {
756761
const fileContentString = await processFilesIntoText(files)
757762
if (fileContentString) {
@@ -761,7 +766,7 @@ export class Task extends EventEmitter<ClineEvents> {
761766
})
762767
}
763768
}
764-
769+
// kilocode_change end
765770
await this.initiateTaskLoop(userContent)
766771
}
767772

@@ -844,12 +849,12 @@ export class Task extends EventEmitter<ClineEvents> {
844849
const { response, text, images, files } = await this.ask(askType) // calls poststatetowebview
845850
let responseText: string | undefined
846851
let responseImages: string[] | undefined
847-
let responseFiles: string[] | undefined
852+
let responseFiles: string[] | undefined // kilocode_change
848853
if (response === "messageResponse") {
849-
await this.say("user_feedback", text, images, files)
854+
await this.say("user_feedback", text, images, files) // kilocode_change
850855
responseText = text
851856
responseImages = images
852-
responseFiles = files
857+
responseFiles = files // kilocode_change
853858
}
854859

855860
// Make sure that the api conversation history can be resumed by the API,
@@ -1020,7 +1025,7 @@ export class Task extends EventEmitter<ClineEvents> {
10201025
if (responseImages && responseImages.length > 0) {
10211026
newUserContent.push(...formatResponse.imageBlocks(responseImages))
10221027
}
1023-
1028+
// kilocode_change start
10241029
if (responseFiles && responseFiles.length > 0) {
10251030
const fileContentString = await processFilesIntoText(responseFiles)
10261031
if (fileContentString) {
@@ -1030,7 +1035,7 @@ export class Task extends EventEmitter<ClineEvents> {
10301035
})
10311036
}
10321037
}
1033-
1038+
// kilocode_change end
10341039
await this.overwriteApiConversationHistory(modifiedApiConversationHistory)
10351040

10361041
console.log(`[subtasks] task ${this.taskId}.${this.instanceId} resuming from history item`)
@@ -1180,6 +1185,7 @@ export class Task extends EventEmitter<ClineEvents> {
11801185

11811186
if (this.consecutiveMistakeCount >= this.consecutiveMistakeLimit) {
11821187
const { response, text, images, files } = await this.ask(
1188+
// kilocode_change
11831189
"mistake_limit_reached",
11841190
t("common:errors.mistake_limit_guidance"),
11851191
)
@@ -1191,7 +1197,7 @@ export class Task extends EventEmitter<ClineEvents> {
11911197
...formatResponse.imageBlocks(images),
11921198
],
11931199
)
1194-
1200+
// kilocode_change start
11951201
if (files && files.length > 0) {
11961202
const fileContentString = await processFilesIntoText(files)
11971203
if (fileContentString) {
@@ -1201,8 +1207,8 @@ export class Task extends EventEmitter<ClineEvents> {
12011207
})
12021208
}
12031209
}
1204-
1205-
await this.say("user_feedback", text, images, files)
1210+
// kilocode_change end
1211+
await this.say("user_feedback", text, images, files) // kilocode_change
12061212

12071213
// Track consecutive mistake errors in telemetry.
12081214
// TelemetryService.instance.captureConsecutiveMistakeError(this.taskId)
@@ -1835,7 +1841,7 @@ export class Task extends EventEmitter<ClineEvents> {
18351841
"condense_context",
18361842
undefined /* text */,
18371843
undefined /* images */,
1838-
undefined /* files */,
1844+
undefined /* files */, // kilocode_change
18391845
false /* partial */,
18401846
undefined /* checkpoint */,
18411847
undefined /* progressStatus */,

src/core/webview/webviewMessageHandler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { checkExistKey } from "../../shared/checkExistApiConfig"
1818
import { experimentDefault } from "../../shared/experiments"
1919
import { Terminal } from "../../integrations/terminal/Terminal"
2020
import { openFile, openImage } from "../../integrations/misc/open-file"
21-
// import { selectImage } from "../../integrations/misc/select-image" // kilocode_change unused
21+
import { selectImages } from "../../integrations/misc/process-images"
2222
import { selectFiles } from "../../integrations/misc/process-files"
2323
import { getTheme } from "../../integrations/theme/getTheme"
2424
import { discoverChromeHostUrl, tryChromeHostUrl } from "../../services/browser/browserDiscovery"
@@ -205,8 +205,9 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
205205
await provider.postStateToWebview()
206206
break
207207
case "selectImages":
208-
const { images, files } = await selectFiles()
209-
await provider.postMessageToWebview({ type: "selectedImages", images, filePaths: files })
208+
const images = await selectImages()
209+
const { files } = await selectFiles() // kilocode_change
210+
await provider.postMessageToWebview({ type: "selectedImages", images, filePaths: files }) // kilocode_change
210211
break
211212
case "exportCurrentTask":
212213
const currentTaskId = provider.getCurrentCline()?.taskId

src/integrations/misc/process-files.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function selectFiles(): Promise<{ images: string[]; files: string[]
3030

3131
const options: vscode.OpenDialogOptions = {
3232
canSelectMany: true,
33-
openLabel: "Import Images & Files",
33+
openLabel: "Upload Images & Files",
3434
filters: {
3535
"All Files": [...IMAGE_EXTENSIONS, ...OTHER_FILE_EXTENSIONS],
3636
Images: IMAGE_EXTENSIONS,
@@ -92,7 +92,6 @@ export async function selectFiles(): Promise<{ images: string[]; files: string[]
9292
return { images, files }
9393
}
9494

95-
// kilocode_change start
9695
/**
9796
* Helper function used to load file(s) and format them into a string
9897
*/
@@ -122,4 +121,3 @@ export async function processFilesIntoText(files: string[]): Promise<string> {
122121
// the user text saying that the file wasn't able to be read
123122
return ""
124123
}
125-
// kilocode_change end

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,10 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
752752
handleChatReset()
753753
break
754754
case "sendMessage":
755-
handleSendMessage(message.text ?? "", message.images ?? [], message.filePaths ?? [])
755+
handleSendMessage(message.text ?? "", message.images ?? [], message.filePaths ?? []) // kilocode_change
756756
break
757757
case "setChatBoxMessage":
758-
handleSetChatBoxMessage(message.text ?? "", message.images ?? [], message.filePaths ?? [])
758+
handleSetChatBoxMessage(message.text ?? "", message.images ?? [], message.filePaths ?? []) // kilocode_change
759759
break
760760
case "primaryButtonClick":
761761
handlePrimaryButtonClick(

webview-ui/src/components/chat/ContextMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
9797
return <span>No results found</span>
9898
// kilocode_change start
9999
case ContextMenuOptionType.Image:
100-
return <span>Import Images & Files</span>
100+
return <span>Upload Images & Files</span>
101101
// kilocode_change end
102102
case ContextMenuOptionType.Git:
103103
if (option.value) {
@@ -158,7 +158,7 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
158158
</div>
159159
)
160160
} else {
161-
return <span>Add {option.type === ContextMenuOptionType.File ? "File" : "Folder"}</span>
161+
return <span>Reference {option.type === ContextMenuOptionType.File ? "File" : "Folder"}</span> // kilocode_change
162162
}
163163
}
164164
}

0 commit comments

Comments
 (0)