refactor(jetbrains): rename ChatPanel to SessionUi, move UI components to chat.ui

- Rename ChatPanel → SessionUi to match its role as session view layer
- Move LabelPicker, MessageListPanel, PromptPanel, StatusPanel into
  client.chat.ui subpackage
- Clean up qualified references (Component.LEFT_ALIGNMENT → LEFT_ALIGNMENT,
  java.awt.Font → Font, javax.swing.ScrollPaneConstants → import)
This commit is contained in:
kirillk
2026-04-15 16:17:58 -04:00
parent 73e92ad136
commit b02e8daa48
6 changed files with 24 additions and 19 deletions
@@ -1,6 +1,6 @@
package ai.kilocode.client
import ai.kilocode.client.chat.ChatPanel
import ai.kilocode.client.chat.SessionUi
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.Logger
@@ -13,7 +13,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
/**
* Creates the Kilo Code tool window with a single [ChatPanel].
* Creates the Kilo Code tool window with a single [SessionUi].
*
* The chat panel shows a welcome/status view in the center until the
* first prompt is sent, then switches to a scrollable message list.
@@ -32,7 +32,7 @@ class KiloToolWindowFactory : ToolWindowFactory, DumbAware {
val sessions = project.service<KiloSessionService>()
val scope = CoroutineScope(SupervisorJob())
val chat = ChatPanel(project, app, workspace, sessions, scope)
val chat = SessionUi(project, app, workspace, sessions, scope)
val content = ContentFactory.getInstance()
.createContent(chat, "", false)
content.setDisposer(chat)
@@ -5,6 +5,10 @@ import ai.kilocode.client.KiloProjectService
import ai.kilocode.client.KiloSessionService
import ai.kilocode.client.chat.model.SessionEvent
import ai.kilocode.client.chat.model.SessionModel
import ai.kilocode.client.chat.ui.LabelPicker
import ai.kilocode.client.chat.ui.MessageListPanel
import ai.kilocode.client.chat.ui.PromptPanel
import ai.kilocode.client.chat.ui.StatusPanel
import com.intellij.openapi.Disposable
import com.intellij.openapi.project.Project
import com.intellij.ui.components.JBScrollPane
@@ -22,11 +26,11 @@ import javax.swing.JPanel
*
* All business logic (app/workspace watching, session lifecycle, event
* handling, status computation) lives in [SessionModel]. Welcome
* rendering lives in [StatusPanel]. This class handles layout, prompt
* rendering lives in [ai.kilocode.client.chat.ui.StatusPanel]. This class handles layout, prompt
* wiring, message list updates, card switching, picker population,
* busy state, and scrolling.
*/
class ChatPanel(
class SessionUi(
project: Project,
app: KiloAppService,
workspace: KiloProjectService,
@@ -53,9 +57,9 @@ class ChatPanel(
}
private val prompt = PromptPanel(
project = project,
onSend = { text -> send(text) },
onAbort = { model.abort() },
project = project,
onSend = { text -> send(text) },
onAbort = { model.abort() },
)
init {
@@ -1,4 +1,4 @@
package ai.kilocode.client.chat
package ai.kilocode.client.chat.ui
import com.intellij.icons.AllIcons
import com.intellij.openapi.ui.popup.JBPopupFactory
@@ -1,4 +1,4 @@
package ai.kilocode.client.chat
package ai.kilocode.client.chat.ui
import ai.kilocode.rpc.dto.MessageDto
import com.intellij.ui.AnimatedIcon
@@ -7,7 +7,6 @@ import com.intellij.ui.components.JBLabel
import com.intellij.util.ui.JBUI
import com.intellij.util.ui.UIUtil
import java.awt.BorderLayout
import java.awt.Component
import java.awt.FlowLayout
import javax.swing.BoxLayout
import javax.swing.JPanel
@@ -40,7 +39,7 @@ class MessageListPanel : JPanel(BorderLayout()) {
isOpaque = false
isVisible = false
border = JBUI.Borders.empty(6, 0)
alignmentX = Component.LEFT_ALIGNMENT
alignmentX = LEFT_ALIGNMENT
add(JBLabel(AnimatedIcon.Default()))
add(statusLabel)
}
@@ -86,7 +85,7 @@ class MessageListPanel : JPanel(BorderLayout()) {
foreground = JBColor.RED
font = JBUI.Fonts.label()
border = JBUI.Borders.empty(4, 0)
alignmentX = Component.LEFT_ALIGNMENT
alignmentX = LEFT_ALIGNMENT
}
inner.add(label, inner.componentCount - 1)
revalidate()
@@ -129,7 +128,7 @@ private class MessageBlock(info: MessageDto) : JPanel() {
init {
layout = BoxLayout(this, BoxLayout.Y_AXIS)
isOpaque = false
alignmentX = Component.LEFT_ALIGNMENT
alignmentX = LEFT_ALIGNMENT
border = if (info.role == "user") {
JBUI.Borders.compound(
@@ -161,6 +160,6 @@ private class MessageBlock(info: MessageDto) : JPanel() {
font = JBUI.Fonts.label()
foreground = UIUtil.getLabelForeground()
border = JBUI.Borders.empty()
alignmentX = Component.LEFT_ALIGNMENT
alignmentX = LEFT_ALIGNMENT
}
}
@@ -1,4 +1,4 @@
package ai.kilocode.client.chat
package ai.kilocode.client.chat.ui
import com.intellij.openapi.fileTypes.PlainTextFileType
import com.intellij.openapi.project.Project
@@ -14,6 +14,7 @@ import javax.swing.BoxLayout
import javax.swing.Icon
import javax.swing.JButton
import javax.swing.JPanel
import javax.swing.ScrollPaneConstants
/**
* Prompt input panel with an IntelliJ editor text field and a bottom
@@ -52,7 +53,7 @@ class PromptPanel(
ed.settings.isUseSoftWraps = true
ed.settings.isAdditionalPageAtBottom = false
ed.scrollPane.horizontalScrollBarPolicy =
javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
ed.contentComponent.addKeyListener(object : KeyAdapter() {
override fun keyPressed(e: KeyEvent) {
if (e.keyCode == KeyEvent.VK_ENTER && !e.isShiftDown) {
@@ -1,4 +1,4 @@
package ai.kilocode.client.chat
package ai.kilocode.client.chat.ui
import ai.kilocode.client.chat.model.SessionEvent
import ai.kilocode.client.chat.model.SessionModel
@@ -17,6 +17,7 @@ import com.intellij.ui.AnimatedIcon
import com.intellij.ui.components.JBLabel
import com.intellij.util.ui.JBUI
import com.intellij.util.ui.UIUtil
import java.awt.Font
import java.awt.GridBagConstraints
import java.awt.GridBagLayout
import javax.swing.Box
@@ -270,7 +271,7 @@ class StatusPanel(
private fun header(text: String): JBLabel = JBLabel(text).apply {
alignmentX = LEFT_ALIGNMENT
font = JBUI.Fonts.label().deriveFont(JBUI.Fonts.label().style or java.awt.Font.BOLD)
font = JBUI.Fonts.label().deriveFont(JBUI.Fonts.label().style or Font.BOLD)
foreground = UIUtil.getLabelForeground()
border = JBUI.Borders.empty(0, 0, 4, 0)
}