Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
await visibleProvider.removeClineFromStack()
await visibleProvider.refreshWorkspace()
await visibleProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
// Send focusInput action immediately after chatButtonClicked
// This ensures the focus happens after the view has switched
await visibleProvider.postMessageToWebview({ type: "action", action: "focusInput" })
},
mcpButtonClicked: () => {
const visibleProvider = getVisibleProviderOrLog(outputChannel)
Expand Down Expand Up @@ -197,9 +194,13 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
try {
await focusPanel(tabPanel, sidebarPanel)

// Send focus input message only for sidebar panels
if (sidebarPanel && getPanel() === sidebarPanel) {
provider.postMessageToWebview({ type: "action", action: "focusInput" })
// Send focus input message to webview after panel becomes focusable
// Use setTimeout to defer until after the panel reveal/focus completes
const activePanel = getPanel()
if (activePanel) {
setTimeout(() => {
provider.postMessageToWebview({ type: "action", action: "focusInput" })
}, 0)
}
} catch (error) {
outputChannel.appendLine(`Error focusing input: ${error}`)
Expand Down
8 changes: 6 additions & 2 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,15 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
switch (message.action!) {
case "didBecomeVisible":
if (!isHidden && !sendingDisabled && !enableButtons) {
textAreaRef.current?.focus()
requestAnimationFrame(() => {
textAreaRef.current?.focus()
})
}
break
case "focusInput":
textAreaRef.current?.focus()
requestAnimationFrame(() => {
textAreaRef.current?.focus()
})
break
}
break
Expand Down