fix(jetbrains): align prompt attachment chips

Remove the rounded outline from compact prompt attachment chips and let the prompt attachment container own left, right, and bottom padding so attached selections align with the prompt text.
This commit is contained in:
kirillk
2026-08-10 09:21:40 -04:00
parent f66b7efc6c
commit 9ebe1f6bd4
4 changed files with 38 additions and 19 deletions
@@ -65,7 +65,6 @@ class AttachmentChip(
init {
isOpaque = false
border = JBUI.Borders.empty(0, JBUI.scale(SessionUiStyle.View.Attachment.CHIP_HORIZONTAL_PADDING))
cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
toolTipText = tip
accessibleContext?.accessibleName = KiloBundle.message("prompt.attachment.open", item.name)
@@ -85,21 +84,6 @@ class AttachmentChip(
override fun getMinimumSize(): Dimension = preferredSize
override fun paintComponent(g: Graphics) {
val g2 = g.create() as Graphics2D
try {
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
val arc = JBUI.scale(SessionUiStyle.View.Attachment.CORNER_ARC)
g2.color = SessionUiStyle.View.Surface.bgColor()
g2.fillRoundRect(0, 0, width, height, arc, arc)
g2.color = SessionUiStyle.View.Outline.color()
g2.drawRoundRect(0, 0, width - 1, height - 1, arc, arc)
} finally {
g2.dispose()
}
super.paintComponent(g)
}
private fun label(): String {
val start = startLine
val end = endLine
@@ -122,7 +122,6 @@ object SessionUiStyle {
const val CLOSE_SIZE = 18
const val CORNER_ARC = 8
const val CHIP_HEIGHT = 28
const val CHIP_HORIZONTAL_PADDING = 8
const val CHIP_ICON_GAP = 6
}
@@ -36,11 +36,12 @@ class PromptAttachmentView(
init {
isOpaque = false
// Align the attachment chips with the prompt text: same left/right/bottom padding as PromptView.
border = JBUI.Borders.empty(
0,
0,
JBUI.scale(SessionUiStyle.View.Prompt.SHELL_HORIZONTAL_PADDING),
JBUI.scale(SessionUiStyle.View.Prompt.SHELL_VERTICAL_PADDING),
0,
JBUI.scale(SessionUiStyle.View.Prompt.SHELL_HORIZONTAL_PADDING),
)
add(scroll)
}
@@ -0,0 +1,35 @@
package ai.kilocode.client.session.views
import ai.kilocode.client.session.model.Text
import ai.kilocode.client.session.ui.attachment.AttachmentCardItem
import ai.kilocode.client.session.ui.attachment.AttachmentChip
import com.intellij.testFramework.fixtures.BasePlatformTestCase
class PromptAttachmentViewTest : BasePlatformTestCase() {
// The attachment strip should line up with the prompt text: same left, right, and bottom
// padding as PromptView so the selection reference reads as part of the prompt.
fun `test attachment padding matches prompt text`() {
val prompt = PromptView(Text("p1")).insets
val attach = PromptAttachmentView("m1") {}.insets
assertEquals(prompt.left, attach.left)
assertEquals(prompt.right, attach.right)
assertEquals(prompt.bottom, attach.bottom)
}
// With the outline removed, the chip owns no internal padding; alignment comes from the
// container so the chip content sits flush against the prompt-matching insets.
fun `test attachment chip has no outline padding`() {
val chip = AttachmentChip(
AttachmentCardItem("HvJwtFilter.java", "text/plain", "file:///HvJwtFilter.java"),
file = true,
startLine = 40,
endLine = 42,
).insets
assertEquals(0, chip.left)
assertEquals(0, chip.right)
assertEquals(0, chip.top)
assertEquals(0, chip.bottom)
}
}