From a0dcab0c6a3e35313efcf3f5e6de0d2831826f10 Mon Sep 17 00:00:00 2001 From: kirillk Date: Tue, 28 Jul 2026 15:52:40 -0400 Subject: [PATCH] fix(jetbrains): open created worktree editor --- .../client/agentManager/AgentManagerPanel.kt | 1 + .../agentManager/AgentManagerPanelTest.kt | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/AgentManagerPanel.kt b/packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/AgentManagerPanel.kt index c6042351731..800a7150ce6 100644 --- a/packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/AgentManagerPanel.kt +++ b/packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/AgentManagerPanel.kt @@ -72,6 +72,7 @@ class AgentManagerPanel( // Focus the list so the freshly created worktree renders as an active selection rather // than the inactive highlight it would get while focus stays on the toolbar. if (list.select(key)) list.focusList() + item(key)?.takeIf { !controller.isPending(it.id) }?.let { open(it, focus = false) } } controller.onCreateFailure = { err -> notifyCreateFailed(err) } controller.onRemoveSuccess = { item -> close(item) } diff --git a/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentManagerPanelTest.kt b/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentManagerPanelTest.kt index 277a689ef0d..7fc0d702cd2 100644 --- a/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentManagerPanelTest.kt +++ b/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentManagerPanelTest.kt @@ -68,6 +68,23 @@ class AgentManagerPanelTest : BasePlatformTestCase() { assertEquals(created.id, edt { (list.selectedValue as ActiveListItem).key }) } + fun `test creating a worktree opens the created worktree session editor`() { + val controller = WorktreeController(service, "/test", coroutines.scope) + val panel = edt { AgentManagerPanel(testRootDisposable, controller, project) } + + edt { controller.create("feature/y", null) } + flush() + + val list = edt { UIUtil.findComponentOfType(panel, JBList::class.java)!! } + val created = edt { controller.model.getElementAt(0) } + assertEquals(created.id, edt { (list.selectedValue as ActiveListItem).key }) + val file = edt { FileEditorManager.getInstance(project).openFiles.single() as KiloVirtualFile } + assertEquals(WorktreeSessionEditorKind.ID, file.path.kind) + assertEquals(created.path, file.path.params["path"]) + assertSame(WorktreeSessionEditorKind.fileType(file.path.params), file.fileType) + assertEquals(false, file.getUserData(KiloVfsManager.FOCUS)) + } + fun `test panel hides worktree search field`() { val controller = WorktreeController(service, "/test", coroutines.scope) val panel = edt { AgentManagerPanel(testRootDisposable, controller) }