mirror of
https://github.com/cline/cline.git
synced 2026-09-24 23:20:16 +08:00
fix: Clear the input only after creating a message (#4288)
* Return if the message was sent when toggling plan act mode to properly clear the input * Add changeset * Use a common value instead of a unique response
This commit is contained in:
@@ -268,7 +268,7 @@ export class Controller {
|
||||
telemetryService.updateTelemetryState(isOptedIn)
|
||||
}
|
||||
|
||||
async togglePlanActModeWithChatSettings(chatSettings: ChatSettings, chatContent?: ChatContent) {
|
||||
async togglePlanActModeWithChatSettings(chatSettings: ChatSettings, chatContent?: ChatContent): Promise<boolean> {
|
||||
const didSwitchToActMode = chatSettings.mode === "act"
|
||||
|
||||
// Capture mode switch telemetry | Capture regardless of if we know the taskId
|
||||
@@ -454,10 +454,15 @@ export class Controller {
|
||||
chatContent?.images || [],
|
||||
chatContent?.files || [],
|
||||
)
|
||||
|
||||
return true
|
||||
} else {
|
||||
this.cancelTask()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
async cancelTask() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Controller } from ".."
|
||||
import { Empty } from "../../../shared/proto/common"
|
||||
import { Boolean } from "../../../shared/proto/common"
|
||||
import { TogglePlanActModeRequest } from "../../../shared/proto/state"
|
||||
import {
|
||||
convertProtoChatContentToChatContent,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
* @param request The request containing the chat settings and optional chat content
|
||||
* @returns An empty response
|
||||
*/
|
||||
export async function togglePlanActMode(controller: Controller, request: TogglePlanActModeRequest): Promise<Empty> {
|
||||
export async function togglePlanActMode(controller: Controller, request: TogglePlanActModeRequest): Promise<Boolean> {
|
||||
try {
|
||||
if (!request.chatSettings) {
|
||||
throw new Error("Chat settings are required")
|
||||
@@ -22,9 +22,11 @@ export async function togglePlanActMode(controller: Controller, request: ToggleP
|
||||
const chatContent = request.chatContent ? convertProtoChatContentToChatContent(request.chatContent) : undefined
|
||||
|
||||
// Call the existing controller implementation
|
||||
await controller.togglePlanActModeWithChatSettings(chatSettings, chatContent)
|
||||
const sentMessage = await controller.togglePlanActModeWithChatSettings(chatSettings, chatContent)
|
||||
|
||||
return Empty.create()
|
||||
return Boolean.create({
|
||||
value: sentMessage,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("Failed to toggle Plan/Act mode:", error)
|
||||
throw error
|
||||
|
||||
Reference in New Issue
Block a user