Skip to content

Commit 6127443

Browse files
[ENG-417] Add command to focus chat input (RooCodeInc#2910)
* Make command to focus on chat input * Allow cmd to focus from anywhere * changeset * fix unit test * Jump to chat input from anywhere * fix focusChatInput call after opening ext
1 parent 01a4873 commit 6127443

File tree

8 files changed

+45
-1
lines changed

8 files changed

+45
-1
lines changed

.changeset/nasty-months-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": patch
3+
---
4+
5+
Add command to focus chat input

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@
116116
"command": "cline.fixWithCline",
117117
"title": "Fix with Cline",
118118
"category": "Cline"
119+
},
120+
{
121+
"command": "cline.focusChatInput",
122+
"title": "Jump to Chat Input",
123+
"category": "Cline"
119124
}
120125
],
121126
"keybindings": [

src/api/providers/xai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ApiHandler } from "../"
44
import { ApiHandlerOptions, XAIModelId, ModelInfo, xaiDefaultModelId, xaiModels } from "../../shared/api"
55
import { convertToOpenAiMessages } from "../transform/openai-format"
66
import { ApiStream } from "../transform/stream"
7-
import { ChatCompletionReasoningEffort } from "openai/resources/chat/completions.mjs"
7+
import { ChatCompletionReasoningEffort } from "openai/resources/chat/completions"
88

99
export class XAIHandler implements ApiHandler {
1010
private options: ApiHandlerOptions

src/core/controller/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ export class Controller {
255255
telemetryService.updateTelemetryState(isOptedIn)
256256
})
257257
break
258+
case "showChatView": {
259+
this.postMessageToWebview({
260+
type: "action",
261+
action: "chatButtonClicked",
262+
})
263+
break
264+
}
258265
case "newTask":
259266
// Code that should run in response to the hello message command
260267
//vscode.window.showInformationMessage(message.text!)

src/extension.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,24 @@ export function activate(context: vscode.ExtensionContext) {
397397
}),
398398
)
399399

400+
// Register the focusChatInput command handler
401+
context.subscriptions.push(
402+
vscode.commands.registerCommand("cline.focusChatInput", () => {
403+
let visibleWebview = WebviewProvider.getVisibleInstance()
404+
if (!visibleWebview) {
405+
vscode.commands.executeCommand("claude-dev.SidebarProvider.focus")
406+
visibleWebview = WebviewProvider.getSidebarInstance()
407+
// showing the extension will call didBecomeVisible which focuses it already
408+
// but it doesn't focus if a tab is selected which focusChatInput accounts for
409+
}
410+
411+
visibleWebview?.controller.postMessageToWebview({
412+
type: "action",
413+
action: "focusChatInput",
414+
})
415+
}),
416+
)
417+
400418
// Set up test server if in test mode
401419
if (IS_TEST === "true") {
402420
createTestServer(sidebarWebview)

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export interface ExtensionMessage {
6060
| "accountLoginClicked"
6161
| "accountLogoutClicked"
6262
| "accountButtonClicked"
63+
| "focusChatInput"
6364
invoke?: Invoke
6465
state?: ExtensionState
6566
images?: string[]

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface WebviewMessage {
2929
| "openFile"
3030
| "openMention"
3131
| "cancelTask"
32+
| "showChatView"
3233
| "refreshOpenRouterModels"
3334
| "refreshRequestyModels"
3435
| "refreshOpenAiModels"

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,13 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
461461
textAreaRef.current?.focus()
462462
}
463463
break
464+
case "focusChatInput":
465+
textAreaRef.current?.focus()
466+
if (isHidden) {
467+
// Send message back to extension to show chat view
468+
vscode.postMessage({ type: "showChatView" })
469+
}
470+
break
464471
}
465472
break
466473
case "selectedImages":

0 commit comments

Comments
 (0)