Skip to content
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
await visibleProvider.removeClineFromStack()
await visibleProvider.postStateToWebview()
await visibleProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })

// Focus the input after a short delay to ensure the view has switched
setTimeout(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this 100ms delay intentional? While it works in most cases, slower machines or heavy load could cause the ChatView to take longer than 100ms to render, making the focus attempt fail silently. Could we consider using a more robust approach like a callback or event-based mechanism to ensure the view is ready?

visibleProvider.postMessageToWebview({ type: "action", action: "focusInput" })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice there's already a command (lines 198-209) that handles focus differently for sidebar vs tab panels. Could we consider reusing that existing command for consistency? It already has error handling and panel-specific logic.

}, 100)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting this magic number to a named constant with a comment explaining why 100ms was chosen. Something like:

},
mcpButtonClicked: () => {
const visibleProvider = getVisibleProviderOrLog(outputChannel)
Expand Down
Loading