From 4801e43127bf42d338251c9f44f6a9c0409159b3 Mon Sep 17 00:00:00 2001 From: kirillk Date: Thu, 27 Aug 2026 14:18:00 -0400 Subject: [PATCH] fix(jetbrains): use standard diagram toolbar icons --- .../ai/kilocode/client/ui/diagram/ui/DiagramViewer.kt | 9 ++------- .../kilocode/client/ui/diagram/ui/DiagramViewerTest.kt | 7 ++++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/diagram/ui/DiagramViewer.kt b/packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/diagram/ui/DiagramViewer.kt index 535da9bdac..191fbc488b 100644 --- a/packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/diagram/ui/DiagramViewer.kt +++ b/packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/diagram/ui/DiagramViewer.kt @@ -11,7 +11,6 @@ import ai.kilocode.client.ui.toolbarButton import com.intellij.icons.AllIcons import com.intellij.ui.components.JBLayeredPane import com.intellij.ui.components.JBScrollPane -import com.intellij.util.IconUtil import com.intellij.util.concurrency.annotations.RequiresEdt import com.intellij.util.ui.JBUI import java.awt.Color @@ -43,7 +42,7 @@ internal class DiagramViewer(palette: Palette) : JBLayeredPane() { } private val copy = SessionCopyButton( tooltip = KiloBundle.message("diagram.copy"), - icon = big(AllIcons.Actions.Copy), + icon = AllIcons.Actions.Copy, image = { canvas.image() }, ) { null } // Built by chaining rather than `apply`, so these lambdas cannot bind to Stack's own fit(). @@ -177,12 +176,8 @@ internal class DiagramViewer(palette: Palette) : JBLayeredPane() { private companion object { const val STEP = 1.25 - const val SIZE = 2f fun control(icon: Icon, key: String, handler: () -> Unit) = - toolbarButton(ToolbarButtonAction(big(icon), KiloBundle.message(key), handler)) - - /** Overlay icons are drawn over the diagram, so they are sized up to stay readable. */ - fun big(icon: Icon): Icon = IconUtil.scale(icon, null, SIZE) + toolbarButton(ToolbarButtonAction(icon, KiloBundle.message(key), handler)) } } diff --git a/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/diagram/ui/DiagramViewerTest.kt b/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/diagram/ui/DiagramViewerTest.kt index 3822a99b24..2d0d5ac47c 100644 --- a/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/diagram/ui/DiagramViewerTest.kt +++ b/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/diagram/ui/DiagramViewerTest.kt @@ -177,14 +177,15 @@ class DiagramViewerTest : BasePlatformTestCase() { ) } - fun `test overlay icons are twice the platform size and size their buttons`() = edtWait { + fun `test overlay icons keep the standard platform action size`() = edtWait { val viewer = viewer(400, 300) val zoom = buttons(viewer).first() - assertEquals(AllIcons.General.ZoomIn.iconWidth * 2, zoom.icon.iconWidth) - assertTrue("the hit target grows with the icon", zoom.preferredSize.width > zoom.icon.iconWidth) + assertEquals(AllIcons.General.ZoomIn.iconWidth, zoom.icon.iconWidth) + assertEquals(AllIcons.General.ZoomIn.iconHeight, zoom.icon.iconHeight) assertTrue("icon-only controls stay square", zoom.preferredSize.width == zoom.preferredSize.height) + assertTrue("the hit target is larger than the glyph", zoom.preferredSize.width > zoom.icon.iconWidth) } fun `test copy puts the whole diagram on the clipboard as a picture`() = edtWait {