Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ee.carlrobert.codegpt.actions

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.wm.ToolWindowManager
import ee.carlrobert.codegpt.toolwindow.agent.AgentToolWindowPanel

class FocusAgentInputAction : AnAction() {

override fun update(e: AnActionEvent) {
e.presentation.isEnabled = e.project != null
}

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val toolWindow = ToolWindowManager.getInstance(project).getToolWindow("ProxyAI") ?: return
toolWindow.show {
val contentManager = toolWindow.contentManager
val agentContent = contentManager.contents.firstOrNull { it.tabName == "Agent" }
?: contentManager.getContent(0)
?: return@show
contentManager.setSelectedContent(agentContent)
(agentContent.component as? AgentToolWindowPanel)?.focusActiveInput()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ee.carlrobert.codegpt.actions

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.wm.ToolWindowManager
import ee.carlrobert.codegpt.toolwindow.chat.ChatToolWindowPanel

class FocusChatInputAction : AnAction() {

override fun update(e: AnActionEvent) {
e.presentation.isEnabled = e.project != null
}

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val toolWindow = ToolWindowManager.getInstance(project).getToolWindow("ProxyAI") ?: return
toolWindow.show {
val contentManager = toolWindow.contentManager
val chatContent = contentManager.contents.firstOrNull { it.tabName == "Chat" }
?: return@show
contentManager.setSelectedContent(chatContent)
(chatContent.component as? ChatToolWindowPanel)?.requestFocusForInput()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ class AgentToolWindowPanel(

fun getTabbedPane(): AgentToolWindowTabbedPane = tabbedPane

fun focusActiveInput() {
landingPanel?.let {
it.requestFocusForTextArea()
return
}
contentManager.getActiveTabPanel()?.requestFocusForTextArea()
}

private fun showTabsView() {
disposeLandingPanel()
centerLayout.show(centerPanel, TABS_CARD)
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,17 @@
<override-text place="MainMenu" text="Open Settings"/>
<override-text place="popup" use-text-of-place="MainMenu"/>
</action>

<action
id="ProxyAI.FocusAgentInput"
text="ProxyAI: Focus Agent Input"
description="Open the ProxyAI tool window, switch to the Agent tab and focus its input"
class="ee.carlrobert.codegpt.actions.FocusAgentInputAction"/>
<action
id="ProxyAI.FocusChatInput"
text="ProxyAI: Focus Chat Input"
description="Open the ProxyAI tool window, switch to the Chat tab and focus its input"
class="ee.carlrobert.codegpt.actions.FocusChatInputAction"/>
<action
id="statusbar.enableCompletions"
class="ee.carlrobert.codegpt.actions.EnableCompletionsAction">
Expand Down