Skip to content

Commit 95e1555

Browse files
authored
Merge pull request RooCodeInc#1748 from dcbartlett/feature/ENG-107_send_input_on_mode_switch
Feature/ENG_107 Send input on mode switch
2 parents a996488 + 2a894d8 commit 95e1555

File tree

7 files changed

+47
-5
lines changed

7 files changed

+47
-5
lines changed

.changeset/silly-cats-appear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
Add new ability to send message that is in Input field during Plan/Act Mode Change to Act.

src/core/Cline.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,14 +2716,15 @@ export class Cline {
27162716
this.isAwaitingPlanResponse = false
27172717

27182718
if (this.didRespondToPlanAskBySwitchingMode) {
2719-
// await this.say("user_feedback", text ?? "", images)
27202719
pushToolResult(
27212720
formatResponse.toolResult(
27222721
`[The user has switched to ACT MODE, so you may now proceed with the task.]`,
27232722
images,
27242723
),
27252724
)
2726-
} else {
2725+
}
2726+
2727+
if (text) {
27272728
await this.say("user_feedback", text ?? "", images)
27282729
pushToolResult(formatResponse.toolResult(`<user_message>\n${text}\n</user_message>`, images))
27292730
}

src/core/webview/ClineProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
626626
await this.postMessageToWebview({
627627
type: "invoke",
628628
invoke: "sendMessage",
629-
text: "[Proceeding with the task...]",
629+
text: message.chatContent?.message || "[Proceeding with the task...]",
630+
images: message.chatContent?.images,
630631
})
631632
} else {
632633
this.cancelTask()

src/shared/ChatContent.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface ChatContent {
2+
message?: string
3+
images?: string[]
4+
}

src/shared/WebviewMessage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ApiConfiguration } from "./api"
22
import { AutoApprovalSettings } from "./AutoApprovalSettings"
33
import { BrowserSettings } from "./BrowserSettings"
44
import { ChatSettings } from "./ChatSettings"
5+
import { ChatContent } from "./ChatContent"
56

67
export interface WebviewMessage {
78
type:
@@ -53,6 +54,7 @@ export interface WebviewMessage {
5354
autoApprovalSettings?: AutoApprovalSettings
5455
browserSettings?: BrowserSettings
5556
chatSettings?: ChatSettings
57+
chatContent?: ChatContent
5658

5759
// For toggleToolAutoApprove
5860
serverName?: string

src/test/webview/chat-native.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ describe("Chat Integration Tests", () => {
2828
vscode.postMessage({ type: 'newTask', text: message.text });
2929
break;
3030
case 'toggleMode':
31-
vscode.postMessage({ type: 'chatSettings', chatSettings: { mode: 'act' } });
31+
vscode.postMessage({
32+
type: 'chatSettings',
33+
chatSettings: { mode: 'act' },
34+
chatContent: {
35+
message: "message test",
36+
}
37+
});
3238
break;
3339
case 'invoke':
3440
if (message.invoke === 'primaryButtonClick') {
@@ -92,6 +98,25 @@ describe("Chat Integration Tests", () => {
9298
assert.equal(stateChange.chatSettings.mode, "act")
9399
})
94100

101+
it("should toggle between plan and act modes with messages", async () => {
102+
// Set up state change listener
103+
const stateChangePromise = new Promise<any>((resolve) => {
104+
panel.webview.onDidReceiveMessage((message) => {
105+
if (message.type === "chatSettings") {
106+
resolve(message)
107+
}
108+
})
109+
})
110+
111+
// Trigger mode toggle
112+
await panel.webview.postMessage({ type: "toggleMode" })
113+
114+
// Verify mode changed
115+
const stateChange = await stateChangePromise
116+
assert.equal(stateChange.chatSettings.mode, "act")
117+
assert.equal(stateChange.chatContent.message, "message test")
118+
})
119+
95120
it("should handle tool approval flow", async () => {
96121
// Set up approval listener
97122
const approvalPromise = new Promise<any>((resolve) => {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,13 +616,17 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
616616
chatSettings: {
617617
mode: newMode,
618618
},
619+
chatContent: {
620+
message: inputValue.trim() ? inputValue : undefined,
621+
images: selectedImages.length > 0 ? selectedImages : undefined,
622+
},
619623
})
620624
// Focus the textarea after mode toggle with slight delay
621625
setTimeout(() => {
622626
textAreaRef.current?.focus()
623627
}, 100)
624628
}, changeModeDelay)
625-
}, [chatSettings.mode, showModelSelector, submitApiConfig])
629+
}, [chatSettings.mode, showModelSelector, submitApiConfig, inputValue, selectedImages])
626630

627631
useShortcut("Meta+Shift+a", onModeToggle, { disableTextInputs: false }) // important that we don't disable the text input here
628632

0 commit comments

Comments
 (0)