mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
feat: auto-focus chatbox when task is opened or created
- Focus textarea after starting new task in ChatView - Send focusInput action after showing task from history - Send focusInput action after creating new task via webview message This improves user experience by automatically placing cursor in the chat input when a task is opened or created.
This commit is contained in:
parent
2170c61e3c
commit
d915dd4a5d
4 changed files with 40 additions and 1 deletions
|
|
@ -1167,6 +1167,8 @@ export class ClineProvider
|
|||
}
|
||||
|
||||
await this.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
|
||||
// Focus the input after loading the task
|
||||
await this.postMessageToWebview({ type: "action", action: "focusInput" })
|
||||
}
|
||||
|
||||
async exportTaskWithId(id: string) {
|
||||
|
|
|
|||
|
|
@ -288,6 +288,8 @@ export const webviewMessageHandler = async (
|
|||
// agentically running promises in old instance don't affect our new
|
||||
// task. This essentially creates a fresh slate for the new task.
|
||||
await provider.initClineWithTask(message.text, message.images)
|
||||
// Focus the input after creating a new task
|
||||
await provider.postMessageToWebview({ type: "action", action: "focusInput" })
|
||||
break
|
||||
case "customInstructions":
|
||||
await provider.updateCustomInstructions(message.text)
|
||||
|
|
|
|||
29
test-focus-implementation.md
Normal file
29
test-focus-implementation.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Test Plan for Auto-Focus Chat Input Feature
|
||||
|
||||
## Changes Made:
|
||||
|
||||
1. **ChatView.tsx** - Modified `startNewTask` function to focus textarea after clearing task
|
||||
2. **ClineProvider.ts** - Added focus action after showing task with ID
|
||||
3. **webviewMessageHandler.ts** - Added focus action after creating new task
|
||||
|
||||
## Test Scenarios:
|
||||
|
||||
### 1. New Task Creation
|
||||
|
||||
- Click "Start New Task" button
|
||||
- Expected: Chat input should automatically receive focus
|
||||
|
||||
### 2. Opening Past Task from History
|
||||
|
||||
- Click on a task from history
|
||||
- Expected: Chat input should automatically receive focus after task loads
|
||||
|
||||
### 3. Focus Action Handler
|
||||
|
||||
- The existing `focusInput` action handler in ChatView.tsx (line 720) will handle the focus request
|
||||
|
||||
## Implementation Details:
|
||||
|
||||
- Used `setTimeout` with 100ms delay in `startNewTask` to ensure DOM is ready
|
||||
- Used `postMessageToWebview` with `focusInput` action for consistent focus handling
|
||||
- Leveraged existing focus infrastructure in the codebase
|
||||
|
|
@ -594,7 +594,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
[inputValue, selectedImages],
|
||||
)
|
||||
|
||||
const startNewTask = useCallback(() => vscode.postMessage({ type: "clearTask" }), [])
|
||||
const startNewTask = useCallback(() => {
|
||||
vscode.postMessage({ type: "clearTask" })
|
||||
// Focus the textarea after starting a new task
|
||||
setTimeout(() => {
|
||||
textAreaRef.current?.focus()
|
||||
}, 100)
|
||||
}, [])
|
||||
|
||||
// This logic depends on the useEffect[messages] above to set clineAsk,
|
||||
// after which buttons are shown and we then send an askResponse to the
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue