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:
Tomás Barreiro
2025-06-19 14:01:22 -06:00
committed by GitHub
parent 8aa6935cbb
commit 288f1bf7f8
6 changed files with 21 additions and 12 deletions
+6 -1
View File
@@ -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