mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(jetbrains): polish question response editor
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@kilocode/kilo-jetbrains": patch
|
||||
---
|
||||
|
||||
Improve JetBrains question response editing and answer spacing.
|
||||
+1
@@ -216,6 +216,7 @@ class QuestionResultView(tool: Tool, private val selection: SessionSelection? =
|
||||
|
||||
val qText = makeText(q, UiStyle.Colors.weak(), false)
|
||||
qText.alignmentX = Component.LEFT_ALIGNMENT
|
||||
qText.border = JBUI.Borders.emptyBottom(UiStyle.Gap.xs())
|
||||
row.add(qText)
|
||||
|
||||
val joined = result.answers.getOrNull(i)?.joinToString(", ").orEmpty()
|
||||
|
||||
+2
@@ -490,6 +490,7 @@ class QuestionView(
|
||||
private fun buildCustomEditor(): SessionEditorTextField {
|
||||
val ed = SessionEditorTextField(project, selection = selection)
|
||||
ed.border = JBUI.Borders.empty()
|
||||
ed.setFontInheritedFromLAF(false)
|
||||
ed.setPlaceholder(KiloBundle.message("session.question.custom.placeholder"))
|
||||
ed.setShowPlaceholderWhenFocused(true)
|
||||
ed.setOneLineMode(false)
|
||||
@@ -502,6 +503,7 @@ class QuestionView(
|
||||
ex.scrollPane.background = style.editorScheme.defaultBackground
|
||||
ex.scrollPane.viewport.background = style.editorScheme.defaultBackground
|
||||
ex.settings.isUseSoftWraps = true
|
||||
ex.settings.isPaintSoftWraps = false
|
||||
ex.settings.isAdditionalPageAtBottom = false
|
||||
ex.scrollPane.horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
|
||||
}
|
||||
|
||||
+18
@@ -7,7 +7,9 @@ import ai.kilocode.client.session.ui.style.SessionEditorStyle
|
||||
import ai.kilocode.client.session.ui.style.SessionUiStyle
|
||||
import ai.kilocode.client.session.views.question.QuestionResultView
|
||||
import ai.kilocode.client.session.views.tool.ToolView
|
||||
import ai.kilocode.client.ui.UiStyle
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||
import com.intellij.ui.components.JBTextArea
|
||||
import java.awt.Color
|
||||
import java.awt.Component
|
||||
import java.awt.Container
|
||||
@@ -104,6 +106,22 @@ class QuestionResultViewTest : BasePlatformTestCase() {
|
||||
assertTrue(view.bodyText().contains("Manual verification, Unit tests"))
|
||||
}
|
||||
|
||||
fun `test answer rows keep standard gap after question text`() {
|
||||
val view = QuestionResultView(completedTool(
|
||||
input = mapOf("questions" to """[{"question":"Q1"}]"""),
|
||||
metadata = mapOf("answers" to """[["A1"]]"""),
|
||||
))
|
||||
|
||||
view.toggle()
|
||||
val root = view.node(0)
|
||||
val body = root.node(1)
|
||||
val row = body.node(0)
|
||||
val text = row.components[0] as JBTextArea
|
||||
val ins = text.border.getBorderInsets(text)
|
||||
|
||||
assertEquals(UiStyle.Gap.xs(), ins.bottom)
|
||||
}
|
||||
|
||||
fun `test label shows count of non-empty answers`() {
|
||||
val tool = completedTool(
|
||||
input = mapOf("questions" to """[{"question":"Q1"},{"question":"Q2"}]"""),
|
||||
|
||||
+26
@@ -17,6 +17,7 @@ import com.intellij.ui.components.JBCheckBox
|
||||
import com.intellij.ui.components.JBLabel
|
||||
import com.intellij.ui.components.JBRadioButton
|
||||
import com.intellij.ui.components.JBTextArea
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Component
|
||||
import java.awt.Container
|
||||
@@ -24,6 +25,7 @@ import kotlin.math.abs
|
||||
import javax.swing.AbstractButton
|
||||
import javax.swing.JButton
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.ScrollPaneConstants
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
@@ -269,6 +271,30 @@ class QuestionViewTest : BasePlatformTestCase() {
|
||||
assertEquals("hint should use hintFont", style.hintFont, hint.font)
|
||||
}
|
||||
|
||||
fun `test custom answer editor uses prompt text styling`() {
|
||||
view.show(customSingleQuestion("q_custom_style"))
|
||||
|
||||
findAll<JBRadioButton>(view).first { it.actionCommand == "" }.doClick()
|
||||
val field = findAll<EditorTextField>(view).first()
|
||||
view.addNotify()
|
||||
try {
|
||||
layout(view)
|
||||
UIUtil.dispatchAllInvocationEvents()
|
||||
val editor = field.getEditor(true) ?: error("missing editor")
|
||||
val style = SessionEditorStyle.current()
|
||||
|
||||
assertEquals(style.transcriptFont, field.font)
|
||||
assertEquals(style.transcriptFont.fontName, editor.colorsScheme.editorFontName)
|
||||
assertEquals(style.transcriptFont.size, editor.colorsScheme.editorFontSize)
|
||||
assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, editor.scrollPane.horizontalScrollBarPolicy)
|
||||
assertTrue(editor.settings.isUseSoftWraps)
|
||||
assertFalse(editor.settings.isPaintSoftWraps)
|
||||
} finally {
|
||||
view.hideView()
|
||||
view.removeNotify()
|
||||
}
|
||||
}
|
||||
|
||||
// ------ multi-question navigation ------
|
||||
|
||||
fun `test multi question shows one question at a time and navigates`() {
|
||||
|
||||
Reference in New Issue
Block a user