fix(jetbrains): open created worktree editor

This commit is contained in:
kirillk
2026-07-28 15:52:40 -04:00
parent 8254e9c525
commit a0dcab0c6a
2 changed files with 18 additions and 0 deletions
@@ -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) }
@@ -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) }