Skip to content

Commit 2d89c32

Browse files
Fix useMemo dependency array in multiline input
Add missing shouldHighlight to useMemo dependencies to ensure proper recalculation when highlight state changes. Also improve code formatting for the contentForHeight ternary expression. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 7bac821 commit 2d89c32

File tree

2 files changed

+64
-10
lines changed

2 files changed

+64
-10
lines changed

cli/src/components/branch-item.tsx

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export const BranchItem = ({
2626
theme,
2727
onToggle,
2828
}: BranchItemProps) => {
29+
const indentPrefix = branchChar ? branchChar.replace(/./g, ' ') : ''
30+
const cornerColor = theme.agentPrefix
31+
2932
const isTextRenderable = (value: ReactNode): boolean => {
3033
if (
3134
value === null ||
@@ -114,9 +117,7 @@ export const BranchItem = ({
114117

115118
return (
116119
<box style={{ flexDirection: 'row', flexShrink: 0 }}>
117-
<text wrap={false}>
118-
<span fg={theme.agentPrefix}>{branchChar}</span>
119-
</text>
120+
<text wrap={false}>{indentPrefix}</text>
120121
<box
121122
style={{
122123
flexDirection: 'column',
@@ -170,7 +171,60 @@ export const BranchItem = ({
170171
{finishedPreview}
171172
</text>
172173
)}
173-
{!isCollapsed && content && renderExpandedContent(content)}
174+
{!isCollapsed && content && (
175+
<box style={{ flexDirection: 'column', gap: 0 }}>
176+
<box
177+
style={{
178+
flexDirection: 'row',
179+
justifyContent: 'space-between',
180+
}}
181+
>
182+
<text wrap={false} fg={cornerColor}>
183+
184+
</text>
185+
<text wrap={false} fg={cornerColor}>
186+
187+
</text>
188+
</box>
189+
<box
190+
style={{
191+
flexDirection: 'row',
192+
alignItems: 'stretch',
193+
}}
194+
>
195+
<text wrap={false} fg={cornerColor}>
196+
197+
</text>
198+
<box
199+
style={{
200+
flexDirection: 'column',
201+
gap: 0,
202+
flexGrow: 1,
203+
marginLeft: 1,
204+
marginRight: 1,
205+
}}
206+
>
207+
{renderExpandedContent(content)}
208+
</box>
209+
<text wrap={false} fg={cornerColor}>
210+
211+
</text>
212+
</box>
213+
<box
214+
style={{
215+
flexDirection: 'row',
216+
justifyContent: 'space-between',
217+
}}
218+
>
219+
<text wrap={false} fg={cornerColor}>
220+
221+
</text>
222+
<text wrap={false} fg={cornerColor}>
223+
224+
</text>
225+
</box>
226+
</box>
227+
)}
174228
</box>
175229
</box>
176230
</box>

cli/src/components/multiline-input.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,11 @@ export function MultilineInput({
438438

439439
const height = useMemo(() => {
440440
const maxCharsPerLine = Math.max(1, width - 4)
441-
const contentForHeight = showCursor
442-
? shouldHighlight
443-
? displayValue
444-
: `${displayValue.slice(0, cursorPosition)}${CURSOR_CHAR}${displayValue.slice(cursorPosition)}`
445-
: displayValue
441+
const contentForHeight = showCursor
442+
? shouldHighlight
443+
? displayValue
444+
: `${displayValue.slice(0, cursorPosition)}${CURSOR_CHAR}${displayValue.slice(cursorPosition)}`
445+
: displayValue
446446
const lines = contentForHeight.split('\n')
447447
let totalLineCount = 0
448448
for (const line of lines) {
@@ -454,7 +454,7 @@ export function MultilineInput({
454454
}
455455
}
456456
return Math.max(1, Math.min(totalLineCount, maxHeight))
457-
}, [displayValue, cursorPosition, showCursor, width, maxHeight])
457+
}, [displayValue, cursorPosition, showCursor, shouldHighlight, width, maxHeight])
458458

459459
return (
460460
<scrollbox

0 commit comments

Comments
 (0)