feat: make subagent acp config options dynamic
Some checks failed
Build / Build (push) Failing after 3s
Build / Verify Plugin (push) Has been skipped

This commit is contained in:
Carl-Robert Linnupuu 2026-03-18 15:32:22 +00:00
parent 96c1a05748
commit e7208b5e79
3 changed files with 15 additions and 13 deletions

View file

@ -114,11 +114,15 @@ class ExternalAcpAgentService(private val project: Project) {
ensureSessionReady(session, preset, NO_OP_EVENTS)
}
suspend fun loadConfigOptions(externalAgentId: String): List<AcpConfigOption> {
suspend fun loadConfigOptions(
externalAgentId: String,
existingSelections: Map<String, String> = emptyMap()
): List<AcpConfigOption> {
val session = AgentSession(
sessionId = "subagent-settings:$externalAgentId:${UUID.randomUUID()}",
conversation = Conversation(),
externalAgentId = externalAgentId
externalAgentId = externalAgentId,
externalAgentConfigSelections = existingSelections
)
return try {
warmUpSession(session)

View file

@ -4,7 +4,6 @@ import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.ui.DocumentAdapter
import com.intellij.ui.SearchTextField
import com.intellij.ui.components.JBLabel
import com.intellij.ui.components.JBScrollPane
import com.intellij.ui.table.JBTable
import com.intellij.util.ui.JBFont
@ -29,7 +28,7 @@ class AcpAgentSettingsForm(project: Project) {
private val presets = ExternalAcpAgents.all()
private val root = BorderLayoutPanel()
private val searchField = SearchTextField().apply {
textEditor.emptyText.text = "Search ACP runtimes..."
textEditor.emptyText.text = "Search external agents..."
border = JBUI.Borders.compound(
JBUI.Borders.customLine(UIUtil.getTooltipSeparatorColor(), 1),
JBUI.Borders.empty(3, 8)
@ -38,13 +37,6 @@ class AcpAgentSettingsForm(project: Project) {
}
private val tableModel = AcpAgentTableModel()
private val rowSorter = TableRowSorter(tableModel)
private val helperLabel = JBLabel(
"ACP runtimes are external agents that can appear in the Agent runtime dropdown."
).apply {
font = JBFont.small()
foreground = UIUtil.getContextHelpForeground()
border = JBUI.Borders.emptyTop(6)
}
private val table = JBTable(tableModel).apply {
rowSorter = this@AcpAgentSettingsForm.rowSorter
emptyText.text = "No ACP runtimes match your search."
@ -94,7 +86,6 @@ class AcpAgentSettingsForm(project: Project) {
BorderLayoutPanel().apply {
border = JBUI.Borders.emptyBottom(8)
addToTop(searchField)
addToCenter(helperLabel)
}
)
root.addToCenter(scrollPane)

View file

@ -295,8 +295,11 @@ class SubagentDetailsPanel(
rebuildExternalOptionsPanel()
val requestId = ++loadSequence
val selectionsSnapshot = current?.externalAgentOptions?.toMap().orEmpty()
loadJob = backgroundScope.launch {
val result = runCatching { externalAgentService.loadConfigOptions(externalAgentId) }
val result = runCatching {
externalAgentService.loadConfigOptions(externalAgentId, selectionsSnapshot)
}
runInEdt(ModalityState.any()) {
if (requestId != loadSequence || current?.externalAgentId != externalAgentId) {
@ -405,6 +408,10 @@ class SubagentDetailsPanel(
combo.addActionListener {
val selected = combo.selectedItem as? AcpConfigOptionChoice ?: return@addActionListener
current?.externalAgentOptions?.set(option.id, selected.value)
if (option.category == "model") {
current?.externalAgentId?.let { externalOptionsCache.remove(it) }
refreshExternalOptions()
}
}
val comboPanel = JPanel(BorderLayout())