@@ -5,10 +5,9 @@ import com.intellij.openapi.actionSystem.ActionPlaces
55import com.intellij.openapi.application.invokeLater
66import com.intellij.openapi.components.service
77import com.intellij.openapi.diagnostic.logger
8+ import com.intellij.openapi.observable.util.whenTextChanged
89import com.intellij.openapi.wm.ToolWindow
910import com.intellij.ui.dsl.builder.*
10- import com.intellij.ui.util.minimumWidth
11- import com.intellij.ui.util.preferredWidth
1211import com.intellij.util.application
1312import com.intellij.util.ui.UIUtil
1413import org.openasr.idiolect.actions.LlmCompletionAction
@@ -18,6 +17,7 @@ import org.openasr.idiolect.nlp.ai.OpenAiClient
1817import org.openasr.idiolect.presentation.components.FocusableTextArea
1918import org.openasr.idiolect.presentation.components.IdiolectHtmlEditorKit
2019import org.openasr.idiolect.settings.openai.OpenAiConfig
20+ import java.awt.Dimension
2121import java.awt.Rectangle
2222import java.util.*
2323import javax.swing.JComponent
@@ -26,6 +26,8 @@ import javax.swing.JLabel
2626import javax.swing.JSlider
2727import javax.swing.event.AncestorEvent
2828import javax.swing.event.AncestorListener
29+ import javax.swing.event.DocumentEvent
30+ import javax.swing.event.DocumentListener
2931import kotlin.reflect.KFunction1
3032import kotlin.reflect.KMutableProperty0
3133
@@ -48,7 +50,7 @@ class ChatTab(private val toolWindow: ToolWindow) : Disposable, AncestorListener
4850
4951 initialiseLogPane()
5052
51- userInput.minimumWidth = 500
53+ userInput.minimumSize = Dimension ( 500 , userInput.minimumSize.height)
5254 userInput.emptyText.text = " Enter prompt here..."
5355
5456 updateModels()
@@ -71,15 +73,15 @@ class ChatTab(private val toolWindow: ToolWindow) : Disposable, AncestorListener
7173 intTextField(IntRange (1 ,4096 ), 16 ).columns(COLUMNS_TINY ).label(" Max tokens" )
7274 .applyToComponent {
7375 toolTipText = " The maximum number of tokens the LLM will generate"
74- }
75- .onChanged {
76- if (it.text.isNotEmpty()) {
77- try {
78- val value = it.text.toInt()
79- OpenAiConfig .settings.maxTokens = value
80- aiService.setMaxTokens(value)
81- } catch (e : Exception ) {
82- log.info( " Invalid max token. Must be an integer value <= 4096 " )
76+ document.whenTextChanged {
77+ if (text.isNotEmpty()) {
78+ try {
79+ val value = text.toInt()
80+ OpenAiConfig .settings.maxTokens = value
81+ aiService.setMaxTokens( value)
82+ } catch (e : Exception ) {
83+ log.info( " Invalid max token. Must be an integer value <= 4096 " )
84+ }
8385 }
8486 }
8587 }
@@ -170,7 +172,7 @@ class ChatTab(private val toolWindow: ToolWindow) : Disposable, AncestorListener
170172
171173 return slider(0 , scale, 1 , scale / 2 )
172174 .applyToComponent {
173- preferredWidth = 100
175+ preferredSize = Dimension ( 100 , 20 )
174176// labelTable = sliderLabels
175177// paintTicks = false
176178 paintLabels = false
0 commit comments