fix(jetbrains): move settings into tool window gear

This commit is contained in:
kirillk
2026-08-11 10:32:46 -04:00
parent bf1ebd6861
commit ac23a8e2cb
3 changed files with 25 additions and 6 deletions
@@ -13,9 +13,9 @@ import ai.kilocode.client.agentManager.worktree.WorktreeController
import ai.kilocode.client.agentManager.AgentManagerPanel
import ai.kilocode.client.plugin.KiloBundle
import ai.kilocode.log.KiloLog
import com.intellij.openapi.actionSystem.ActionGroup
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.DataProvider
import com.intellij.openapi.actionSystem.Separator
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.DumbAware
@@ -108,6 +108,8 @@ internal class KiloToolWindowSetupService(
chat.add(manager.component, BorderLayout.CENTER)
val agent = object : JPanel(BorderLayout()), DataProvider {
override fun getData(dataId: String): Any? {
// Expose the shared manager here too so History works from the Agent Manager tab.
if (SessionManager.KEY.`is`(dataId)) return manager
if (SessionManager.WORKSPACE_KEY.`is`(dataId)) return workspace
if (SidePanelKeys.MODE.`is`(dataId)) return SidePanelMode.AGENT_MANAGER
if (SidePanelKeys.WORKTREE_PANEL.`is`(dataId)) return agentManagerPanel
@@ -143,10 +145,13 @@ internal class KiloToolWindowSetupService(
ActionManager.getInstance().getAction("Kilo.NewSession"),
ActionManager.getInstance().getAction("Kilo.NewWorktree"),
ActionManager.getInstance().getAction("Kilo.History"),
Separator.getInstance(),
ActionManager.getInstance().getAction("Kilo.Settings"),
)
toolWindow.setTitleActions(actions)
// Settings moves off the toolbar into the header gear (options) menu: Open Settings…,
// Config Files, and Core, inlined from the declarative Kilo.SettingsGroup.
(ActionManager.getInstance().getAction("Kilo.SettingsGroup") as? ActionGroup)?.let {
toolWindow.setAdditionalGearActions(it)
}
} catch (e: Exception) {
Telemetry.send("Tool Window Setup Failed", mapOf("stage" to "setup", "errorClass" to e::class.java.name))
LOG.error("Failed to set up Kilo tool window content", e)
@@ -8,6 +8,8 @@ import ai.kilocode.client.agentManager.SidePanelMode
import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DataProvider
import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.project.DumbAware
class HistoryAction : AnAction(
@@ -16,12 +18,23 @@ class HistoryAction : AnAction(
AllIcons.Vcs.History,
), DumbAware {
override fun actionPerformed(e: AnActionEvent) {
val manager = e.getData(SessionManager.KEY) ?: return
Telemetry.send("History Opened", mapOf("surface" to "tool_window"))
e.getData(SessionManager.KEY)?.showHistory()
// History renders inside the chat content, which only lives on the AI Chat tab, so bring
// that tab forward first when invoked from the Agent Manager tab.
if (e.getData(SidePanelKeys.MODE) == SidePanelMode.AGENT_MANAGER) selectChat(e)
manager.showHistory()
}
override fun update(e: AnActionEvent) {
e.presentation.isVisible = e.getData(SidePanelKeys.MODE) != SidePanelMode.AGENT_MANAGER
e.presentation.isEnabled = e.getData(SessionManager.KEY) != null
}
private fun selectChat(e: AnActionEvent) {
val manager = e.getData(PlatformDataKeys.TOOL_WINDOW)?.contentManager ?: return
val chat = manager.contents.firstOrNull {
(it.component as? DataProvider)?.getData(SidePanelKeys.MODE.name) == SidePanelMode.CHAT
} ?: return
manager.setSelectedContent(chat, true)
}
}
@@ -147,7 +147,8 @@
class="ai.kilocode.client.actions.CoreInfoAction"/>
<action id="Kilo.OpenSettings"
class="ai.kilocode.client.actions.OpenSettingsAction"/>
class="ai.kilocode.client.actions.OpenSettingsAction"
icon="AllIcons.General.GearPlain"/>
<action id="Kilo.OpenLocalConfig"
class="ai.kilocode.client.actions.OpenLocalConfigAction"/>