Skip to content

Commit

Permalink
refactor(gui): initialize AIAssistantFoldLabel and hide chatRole in S…
Browse files Browse the repository at this point in the history
…impleMessage

Updated the `AIAssistantFoldLabel` class to use property initialization for the `side` parameter. This change removes the need for a separate init block for the variable. Additionally, the `chatRole` property in the `SimpleMessage` class has been made private to encapsulate the field.

The commit adheres to the Conventional Commits specification, providing a clear and concise description of the changes made.
  • Loading branch information
phodal committed Nov 25, 2024
1 parent a8b11fa commit 4b0234f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ import javax.swing.Box
import javax.swing.JComponent


class AIAssistantFoldLabel(side: ChatRole) : JBLabel("", 0) {
private val side: ChatRole

class AIAssistantFoldLabel(private val side: ChatRole) : JBLabel("", 0) {
init {
this.side = side
setOpaque(true)
isVisible = false
}
Expand Down Expand Up @@ -57,12 +54,11 @@ class EditorPadding(private val editor: Editor, pad: Int) :

class EditorFragment(private val project: Project, private val editor: EditorEx, message: CompletableMessage) {
private val editorLineThreshold = 6
private val expandCollapseTextLabel: AIAssistantFoldLabel
private val expandCollapseTextLabel: AIAssistantFoldLabel = AIAssistantFoldLabel(message.getRole())
private val content: BorderLayoutPanel
private var collapsed = false

init {
expandCollapseTextLabel = AIAssistantFoldLabel(message.getRole())
content = object : BorderLayoutPanel() {
override fun getPreferredSize(): Dimension {
val preferredSize = super.getPreferredSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cc.unitmesh.devti.gui.chat.message.ChatMessageRating
class SimpleMessage(
override val displayText: String,
override val text: String,
val chatRole: ChatRole,
private val chatRole: ChatRole,
override var rating: ChatMessageRating = ChatMessageRating.None
) : CompletableMessage {
private val textListeners: MutableList<MessageBlockTextListener> = mutableListOf()
Expand Down

0 comments on commit 4b0234f

Please sign in to comment.