@@ -2,8 +2,7 @@ import { TextAttributes, type BorderCharacters } from '@opentui/core'
22import React , { type ReactNode } from 'react'
33
44import { RaisedPill } from './raised-pill'
5-
6- import type { ChatTheme } from '../utils/theme-system'
5+ import { useTheme } from '../hooks/use-theme'
76
87interface AgentBranchItemProps {
98 name : string
@@ -18,10 +17,7 @@ interface AgentBranchItemProps {
1817 statusLabel ?: string
1918 statusColor ?: string
2019 statusIndicator ?: string
21- theme : ChatTheme
2220 onToggle ?: ( ) => void
23- showBorder ?: boolean
24- toggleEnabled ?: boolean
2521 titleSuffix ?: string
2622}
2723
@@ -52,24 +48,10 @@ export const AgentBranchItem = ({
5248 statusLabel,
5349 statusColor,
5450 statusIndicator = '●' ,
55- theme,
5651 onToggle,
57- showBorder = true ,
58- toggleEnabled = true ,
5952 titleSuffix,
6053} : AgentBranchItemProps ) => {
61- const resolveFg = (
62- color ?: string | null ,
63- fallback ?: string | null ,
64- ) : string | undefined => {
65- if ( color && color !== 'default' ) return color
66- if ( fallback && fallback !== 'default' ) return fallback
67- return undefined
68- }
69- const fallbackTextColor =
70- resolveFg ( theme . agentContentText ) ??
71- resolveFg ( theme . chromeText ) ??
72- '#d1d5e5'
54+ const theme = useTheme ( )
7355
7456 const baseTextAttributes = theme . messageTextAttributes ?? 0
7557 const getAttributes = ( extra : number = 0 ) : number | undefined => {
@@ -80,19 +62,12 @@ export const AgentBranchItem = ({
8062 const isExpanded = ! isCollapsed
8163 const toggleFrameColor = isExpanded
8264 ? theme . agentToggleExpandedBg
83- : theme . agentResponseCount ?? theme . agentToggleHeaderBg
84- const toggleIconColor = isStreaming
85- ? theme . statusAccent
86- : theme . chromeText ?? toggleFrameColor
87- const toggleLabelColor = theme . chromeText ?? toggleFrameColor
88- const toggleIndicator = toggleEnabled ? ( isCollapsed ? '▸ ' : '▾ ' ) : ''
65+ : theme . agentResponseCount
66+ const toggleIconColor = isStreaming ? theme . statusAccent : theme . chromeText
67+ const toggleIndicator = onToggle ? ( isCollapsed ? '▸ ' : '▾ ' ) : ''
8968 const toggleLabel = `${ branchChar } ${ toggleIndicator } `
9069 const collapseButtonFrame = theme . agentToggleExpandedBg
9170 const collapseButtonText = collapseButtonFrame
92- const toggleFrameFg = resolveFg ( toggleFrameColor , fallbackTextColor )
93- const toggleIconFg = resolveFg ( toggleIconColor , fallbackTextColor )
94- const toggleLabelFg = resolveFg ( toggleLabelColor , fallbackTextColor )
95- const headerFg = resolveFg ( theme . agentToggleHeaderText , fallbackTextColor )
9671 const statusText =
9772 statusLabel && statusLabel . length > 0
9873 ? statusIndicator === '✓'
@@ -149,7 +124,7 @@ export const AgentBranchItem = ({
149124 if ( isTextRenderable ( value ) ) {
150125 return (
151126 < text
152- fg = { resolveFg ( theme . agentText ) }
127+ fg = { theme . agentText }
153128 key = "expanded-text"
154129 attributes = { getAttributes ( ) }
155130 >
@@ -204,10 +179,10 @@ export const AgentBranchItem = ({
204179 } }
205180 >
206181 < box
207- border = { showBorder }
208- borderStyle = { showBorder ? ' single' : undefined }
209- borderColor = { showBorder ? toggleFrameFg ?? undefined : undefined }
210- customBorderChars = { showBorder ? containerBorderChars : undefined }
182+ border
183+ borderStyle = " single"
184+ borderColor = { toggleFrameColor }
185+ customBorderChars = { containerBorderChars }
211186 style = { {
212187 flexDirection : 'column' ,
213188 gap : 0 ,
@@ -230,9 +205,9 @@ export const AgentBranchItem = ({
230205 width : '100%' ,
231206 } }
232207 >
233- < text { ... ( headerFg ? { fg : headerFg } : undefined ) } > Prompt</ text >
208+ < text fg = { theme . agentToggleHeaderText } > Prompt</ text >
234209 < text
235- fg = { resolveFg ( theme . agentText ) }
210+ fg = { theme . agentText }
236211 style = { { wrapMode : 'word' } }
237212 attributes = { getAttributes ( ) }
238213 >
@@ -244,27 +219,27 @@ export const AgentBranchItem = ({
244219 style = { {
245220 flexDirection : 'row' ,
246221 alignItems : 'center' ,
247- paddingLeft : showBorder ? 1 : 0 ,
248- paddingRight : showBorder ? 1 : 0 ,
222+ paddingLeft : 1 ,
223+ paddingRight : 1 ,
249224 paddingTop : 0 ,
250225 paddingBottom : isCollapsed ? 0 : 1 ,
251226 width : '100%' ,
252227 } }
253- onMouseDown = { toggleEnabled && onToggle ? onToggle : undefined }
228+ onMouseDown = { onToggle }
254229 >
255230 < text style = { { wrapMode : 'none' } } >
256- < span { ... ( toggleIconFg ? { fg : toggleIconFg } : undefined ) } >
231+ < span fg = { toggleIconColor } >
257232 { toggleLabel }
258233 </ span >
259234 < span
260- { ... ( toggleLabelFg ? { fg : toggleLabelFg } : undefined ) }
235+ fg = { theme . chromeText }
261236 attributes = { isExpanded ? TextAttributes . BOLD : undefined }
262237 >
263238 { name }
264239 </ span >
265240 { titleSuffix ? (
266241 < span
267- { ... ( toggleLabelFg ? { fg : toggleLabelFg } : undefined ) }
242+ fg = { theme . chromeText }
268243 attributes = { TextAttributes . BOLD }
269244 >
270245 { ` ${ titleSuffix } ` }
@@ -292,10 +267,7 @@ export const AgentBranchItem = ({
292267 } }
293268 >
294269 < text
295- fg = { resolveFg (
296- isStreaming ? theme . agentText : theme . agentResponseCount ,
297- fallbackTextColor ,
298- ) }
270+ fg = { isStreaming ? theme . agentText : theme . agentResponseCount }
299271 attributes = { getAttributes ( TextAttributes . ITALIC ) }
300272 >
301273 { isStreaming ? streamingPreview : finishedPreview }
@@ -321,19 +293,19 @@ export const AgentBranchItem = ({
321293 marginBottom : content ? 1 : 0 ,
322294 } }
323295 >
324- < text { ... ( headerFg ? { fg : headerFg } : undefined ) } >
296+ < text fg = { theme . agentToggleHeaderText } >
325297 Prompt
326298 </ text >
327299 < text
328- fg = { resolveFg ( theme . agentText ) }
300+ fg = { theme . agentText }
329301 style = { { wrapMode : 'word' } }
330302 attributes = { getAttributes ( ) }
331303 >
332304 { prompt }
333305 </ text >
334306 { content && (
335307 < text
336- { ... ( headerFg ? { fg : headerFg } : undefined ) }
308+ fg = { theme . agentToggleHeaderText }
337309 style = { { marginTop : 1 } }
338310 >
339311 Response
@@ -342,12 +314,12 @@ export const AgentBranchItem = ({
342314 </ box >
343315 ) }
344316 { renderExpandedContent ( content ) }
345- { toggleEnabled && onToggle && (
317+ { onToggle && (
346318 < box
347319 style = { {
348320 alignSelf : 'flex-end' ,
349321 marginTop : content ? 0 : 1 ,
350- paddingRight : showBorder ? 1 : 0 ,
322+ paddingRight : 1 ,
351323 paddingBottom : 0 ,
352324 marginBottom : 0 ,
353325 } }
0 commit comments