Code review fixes for show question mark pr. (#18480)

This commit is contained in:
Jacob Richman
2026-02-06 22:35:14 -08:00
committed by GitHub
parent 6f1a5bf81d
commit a37844e5a1
11 changed files with 298 additions and 235 deletions

View File

@@ -5,27 +5,25 @@
*/
import type React from 'react';
import { Text } from 'ink';
import stringWidth from 'string-width';
import { useTerminalSize } from '../../hooks/useTerminalSize.js';
import { Box, Text } from 'ink';
import { theme } from '../../semantic-colors.js';
const buildHeaderLine = (title: string, width: number) => {
const prefix = `── ${title} `;
const prefixWidth = stringWidth(prefix);
if (width <= prefixWidth) {
return prefix.slice(0, Math.max(0, width));
}
return prefix + '─'.repeat(Math.max(0, width - prefixWidth));
};
export const SectionHeader: React.FC<{ title: string; width?: number }> = ({
title,
width,
}) => {
const { columns: terminalWidth } = useTerminalSize();
const resolvedWidth = Math.max(10, width ?? terminalWidth);
const text = buildHeaderLine(title, resolvedWidth);
return <Text color={theme.text.secondary}>{text}</Text>;
};
export const SectionHeader: React.FC<{ title: string }> = ({ title }) => (
<Box width="100%" flexDirection="row" overflow="hidden">
<Text color={theme.text.secondary} wrap="truncate-end">
{`── ${title}`}
</Text>
<Box
flexGrow={1}
flexShrink={0}
minWidth={2}
marginLeft={1}
borderStyle="single"
borderTop
borderBottom={false}
borderLeft={false}
borderRight={false}
borderColor={theme.text.secondary}
/>
</Box>
);