Przeglądaj źródła

fix: messages layout instability

adamdotdevin 6 miesięcy temu
rodzic
commit
66d99ba527

+ 2 - 0
packages/tui/internal/components/chat/message.go

@@ -183,6 +183,8 @@ func renderContentBlock(
 		if renderer.borderRight {
 			style = style.BorderRightForeground(borderColor)
 		}
+	} else {
+		style = style.PaddingLeft(renderer.paddingLeft + 1).PaddingRight(renderer.paddingRight + 1)
 	}
 
 	content = style.Render(content)

+ 0 - 60
packages/tui/internal/components/chat/messages.go

@@ -386,12 +386,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
 								fileParts,
 								agentParts,
 							)
-							content = lipgloss.PlaceHorizontal(
-								m.width,
-								lipgloss.Center,
-								content,
-								styles.WhitespaceStyle(t.Background()),
-							)
 							m.cache.Set(key, content)
 						}
 						if content != "" {
@@ -468,12 +462,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
 									[]opencode.AgentPart{},
 									toolCallParts...,
 								)
-								content = lipgloss.PlaceHorizontal(
-									m.width,
-									lipgloss.Center,
-									content,
-									styles.WhitespaceStyle(t.Background()),
-								)
 								m.cache.Set(key, content)
 							}
 						} else {
@@ -490,12 +478,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
 								[]opencode.AgentPart{},
 								toolCallParts...,
 							)
-							content = lipgloss.PlaceHorizontal(
-								m.width,
-								lipgloss.Center,
-								content,
-								styles.WhitespaceStyle(t.Background()),
-							)
 						}
 						if content != "" {
 							partCount++
@@ -536,12 +518,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
 									permission,
 									width,
 								)
-								content = lipgloss.PlaceHorizontal(
-									m.width,
-									lipgloss.Center,
-									content,
-									styles.WhitespaceStyle(t.Background()),
-								)
 								m.cache.Set(key, content)
 							}
 						} else {
@@ -552,12 +528,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
 								permission,
 								width,
 							)
-							content = lipgloss.PlaceHorizontal(
-								m.width,
-								lipgloss.Center,
-								content,
-								styles.WhitespaceStyle(t.Background()),
-							)
 						}
 						if content != "" {
 							partCount++
@@ -586,12 +556,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
 								[]opencode.FilePart{},
 								[]opencode.AgentPart{},
 							)
-							content = lipgloss.PlaceHorizontal(
-								m.width,
-								lipgloss.Center,
-								content,
-								styles.WhitespaceStyle(t.Background()),
-							)
 							partCount++
 							lineCount += lipgloss.Height(content) + 1
 							blocks = append(blocks, content)
@@ -625,12 +589,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
 						[]opencode.FilePart{},
 						[]opencode.AgentPart{},
 					)
-					content = lipgloss.PlaceHorizontal(
-						m.width,
-						lipgloss.Center,
-						content,
-						styles.WhitespaceStyle(t.Background()),
-					)
 					partCount++
 					lineCount += lipgloss.Height(content) + 1
 					blocks = append(blocks, content)
@@ -645,12 +603,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
 					width,
 					WithBorderColor(t.Error()),
 				)
-				error = lipgloss.PlaceHorizontal(
-					m.width,
-					lipgloss.Center,
-					error,
-					styles.WhitespaceStyle(t.Background()),
-				)
 				blocks = append(blocks, error)
 				lineCount += lipgloss.Height(error) + 1
 			}
@@ -742,12 +694,6 @@ func (m *messagesComponent) renderView() tea.Cmd {
 							m.app.CurrentPermission,
 							width,
 						)
-						content = lipgloss.PlaceHorizontal(
-							m.width,
-							lipgloss.Center,
-							content,
-							styles.WhitespaceStyle(t.Background()),
-						)
 						if content != "" {
 							partCount++
 							lineCount += lipgloss.Height(content) + 1
@@ -916,12 +862,6 @@ func (m *messagesComponent) renderHeader() string {
 		BorderForeground(t.BackgroundElement()).
 		BorderStyle(lipgloss.ThickBorder()).
 		Render(header)
-	header = lipgloss.PlaceHorizontal(
-		m.width,
-		lipgloss.Center,
-		header,
-		styles.WhitespaceStyle(t.Background()),
-	)
 
 	return "\n" + header + "\n"
 }