From 4c2f36606e951c906cfd6f03bfe7f105c6f47fd9 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 16 Feb 2026 08:38:16 +0100 Subject: [PATCH] IJPL-233558 hide structure window GitOrigin-RevId: cb41f8014f9119580bb033e4040fd16c4a08fd51 --- .../src/AgentSessionsTreeUiStateService.kt | 4 ++-- .../src/AgentWorkbenchFrameConstants.kt | 3 ++- ...rkbenchProjectFrameCapabilitiesProvider.kt | 2 -- ...orkbenchToolWindowLayoutProfileProvider.kt | 19 ++++++++++++++- ...enchToolWindowLayoutProfileProviderTest.kt | 24 +++++++++++++++++++ 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/plugins/agent-workbench/sessions/src/AgentSessionsTreeUiStateService.kt b/plugins/agent-workbench/sessions/src/AgentSessionsTreeUiStateService.kt index 4b663ce029b7..a79b6481db8d 100644 --- a/plugins/agent-workbench/sessions/src/AgentSessionsTreeUiStateService.kt +++ b/plugins/agent-workbench/sessions/src/AgentSessionsTreeUiStateService.kt @@ -3,9 +3,9 @@ package com.intellij.agent.workbench.sessions import com.intellij.openapi.components.SerializablePersistentStateComponent import com.intellij.openapi.components.Service -import com.intellij.openapi.components.SettingsCategory import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage +import com.intellij.openapi.components.StoragePathMacros import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow @@ -107,7 +107,7 @@ internal class InMemorySessionsTreeUiState : SessionsTreeUiState { } @Service(Service.Level.APP) -@State(name = "CodexSessionsTreeUiState", storages = [Storage("other.xml")], category = SettingsCategory.TOOLS) +@State(name = "CodexSessionsTreeUiState", storages = [Storage(StoragePathMacros.CACHE_FILE)]) internal class AgentSessionsTreeUiStateService : SerializablePersistentStateComponent(SessionsTreeUiStateState()), SessionsTreeUiState { diff --git a/plugins/agent-workbench/sessions/src/AgentWorkbenchFrameConstants.kt b/plugins/agent-workbench/sessions/src/AgentWorkbenchFrameConstants.kt index 4eb371c0d9ca..91b4d11a1390 100644 --- a/plugins/agent-workbench/sessions/src/AgentWorkbenchFrameConstants.kt +++ b/plugins/agent-workbench/sessions/src/AgentWorkbenchFrameConstants.kt @@ -3,4 +3,5 @@ package com.intellij.agent.workbench.sessions internal const val AGENT_SESSIONS_TOOL_WINDOW_ID: String = "agent.workbench.sessions" internal const val AGENT_WORKBENCH_DEDICATED_LAYOUT_PROFILE_ID: String = "agent.workbench.dedicated" -internal const val AGENT_WORKBENCH_LAYOUT_MIGRATION_VERSION: Int = 1 +internal const val TERMINAL_TOOL_WINDOW_ID: String = "Terminal" +internal const val AGENT_WORKBENCH_LAYOUT_MIGRATION_VERSION: Int = 2 diff --git a/plugins/agent-workbench/sessions/src/AgentWorkbenchProjectFrameCapabilitiesProvider.kt b/plugins/agent-workbench/sessions/src/AgentWorkbenchProjectFrameCapabilitiesProvider.kt index eb7c6ad3b340..f374024f45de 100644 --- a/plugins/agent-workbench/sessions/src/AgentWorkbenchProjectFrameCapabilitiesProvider.kt +++ b/plugins/agent-workbench/sessions/src/AgentWorkbenchProjectFrameCapabilitiesProvider.kt @@ -2,7 +2,6 @@ package com.intellij.agent.workbench.sessions import com.intellij.openapi.project.Project -import com.intellij.openapi.wm.ToolWindowId import com.intellij.openapi.wm.ex.ProjectFrameCapabilitiesProvider import com.intellij.openapi.wm.ex.ProjectFrameCapability import com.intellij.openapi.wm.ex.ProjectFrameUiPolicy @@ -41,6 +40,5 @@ private val AGENT_WORKBENCH_FRAME_CAPABILITIES = EnumSet.of( private val AGENT_WORKBENCH_FRAME_UI_POLICY = ProjectFrameUiPolicy( startupToolWindowIdToActivate = AGENT_SESSIONS_TOOL_WINDOW_ID, - toolWindowIdsToHideOnStartup = setOf(ToolWindowId.PROJECT_VIEW), toolWindowLayoutProfileId = AGENT_WORKBENCH_DEDICATED_LAYOUT_PROFILE_ID, ) diff --git a/plugins/agent-workbench/sessions/src/AgentWorkbenchToolWindowLayoutProfileProvider.kt b/plugins/agent-workbench/sessions/src/AgentWorkbenchToolWindowLayoutProfileProvider.kt index 5d7d20ff63ef..97287766c5b3 100644 --- a/plugins/agent-workbench/sessions/src/AgentWorkbenchToolWindowLayoutProfileProvider.kt +++ b/plugins/agent-workbench/sessions/src/AgentWorkbenchToolWindowLayoutProfileProvider.kt @@ -25,7 +25,7 @@ internal class AgentWorkbenchToolWindowLayoutProfileProvider : ToolWindowLayoutP val baseLayout = ToolWindowDefaultLayoutManager.getInstance().getLayoutCopy() val infos = baseLayout.getInfos() .asSequence() - .filter { (id, _) -> id != ToolWindowId.PROJECT_VIEW } + .filterNot { (id, _) -> id == ToolWindowId.PROJECT_VIEW || id == ToolWindowId.STRUCTURE_VIEW } .associateTo(LinkedHashMap()) { (id, info) -> id to info.copy() } val sessionsInfo = infos.get(AGENT_SESSIONS_TOOL_WINDOW_ID) ?: WindowInfoImpl() @@ -43,6 +43,23 @@ internal class AgentWorkbenchToolWindowLayoutProfileProvider : ToolWindowLayoutP sessionsInfo.weight = 0.25f infos.put(AGENT_SESSIONS_TOOL_WINDOW_ID, sessionsInfo) + val nextOrderOnBottom = infos.values.asSequence() + .filter { it.toolWindowPaneId == paneId && it.anchor == ToolWindowAnchor.BOTTOM && it.order >= 0 } + .maxOfOrNull { it.order + 1 } ?: 0 + val terminalInfo = infos.get(TERMINAL_TOOL_WINDOW_ID) ?: WindowInfoImpl() + val needsBottomPlacement = terminalInfo.toolWindowPaneId != paneId || + terminalInfo.anchor != ToolWindowAnchor.BOTTOM || + terminalInfo.order < 0 + terminalInfo.id = TERMINAL_TOOL_WINDOW_ID + terminalInfo.toolWindowPaneId = paneId + terminalInfo.anchor = ToolWindowAnchor.BOTTOM + if (needsBottomPlacement) { + terminalInfo.order = nextOrderOnBottom + } + terminalInfo.isVisible = false + terminalInfo.isShowStripeButton = true + infos.put(TERMINAL_TOOL_WINDOW_ID, terminalInfo) + return DesktopLayout(infos, baseLayout.unifiedWeights.copy()) } diff --git a/plugins/agent-workbench/sessions/testSrc/AgentWorkbenchToolWindowLayoutProfileProviderTest.kt b/plugins/agent-workbench/sessions/testSrc/AgentWorkbenchToolWindowLayoutProfileProviderTest.kt index 1486376f9314..56cb71a3507d 100644 --- a/plugins/agent-workbench/sessions/testSrc/AgentWorkbenchToolWindowLayoutProfileProviderTest.kt +++ b/plugins/agent-workbench/sessions/testSrc/AgentWorkbenchToolWindowLayoutProfileProviderTest.kt @@ -2,12 +2,19 @@ package com.intellij.agent.workbench.sessions import com.intellij.openapi.project.Project +import com.intellij.openapi.wm.ToolWindowAnchor +import com.intellij.openapi.wm.ToolWindowId +import com.intellij.testFramework.ApplicationRule import com.intellij.toolWindow.ToolWindowLayoutApplyMode import org.assertj.core.api.Assertions.assertThat +import org.junit.Rule import org.junit.Test import java.lang.reflect.Proxy class AgentWorkbenchToolWindowLayoutProfileProviderTest { + @get:Rule + val applicationRule = ApplicationRule() + private val provider = AgentWorkbenchToolWindowLayoutProfileProvider() @Test @@ -20,6 +27,23 @@ class AgentWorkbenchToolWindowLayoutProfileProviderTest { .isEqualTo(AGENT_WORKBENCH_LAYOUT_MIGRATION_VERSION) } + @Test + fun dedicatedLayoutHidesStructureAndKeepsTerminalInStripeWithoutOpeningIt() { + val project = testProject() + + val layout = provider.getLayout(project, AGENT_WORKBENCH_DEDICATED_LAYOUT_PROFILE_ID, isNewUi = true) + + assertThat(layout).isNotNull + assertThat(layout!!.getInfo(ToolWindowId.PROJECT_VIEW)).isNull() + assertThat(layout.getInfo(ToolWindowId.STRUCTURE_VIEW)).isNull() + + val terminalInfo = layout.getInfo(TERMINAL_TOOL_WINDOW_ID) + assertThat(terminalInfo).isNotNull + assertThat(terminalInfo!!.anchor).isEqualTo(ToolWindowAnchor.BOTTOM) + assertThat(terminalInfo.isShowStripeButton).isTrue() + assertThat(terminalInfo.isVisible).isFalse() + } + @Test fun nonDedicatedProfileKeepsSeedOnlyPolicy() { val project = testProject()