Color enhancements (#680)

This commit is contained in:
Miguel Solorio 2025-06-02 11:20:58 -07:00 committed by GitHub
parent c5869db080
commit 33052018a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 49 additions and 15 deletions

View File

@ -27,7 +27,7 @@ export const ConsoleSummaryDisplay: React.FC<ConsoleSummaryDisplayProps> = ({
{errorCount > 0 && ( {errorCount > 0 && (
<Text color={Colors.AccentRed}> <Text color={Colors.AccentRed}>
{errorIcon} {errorCount} error{errorCount > 1 ? 's' : ''}{' '} {errorIcon} {errorCount} error{errorCount > 1 ? 's' : ''}{' '}
<Text color={Colors.SubtleComment}>(CTRL-O for details)</Text> <Text color={Colors.SubtleComment}>(ctrl+O for details)</Text>
</Text> </Text>
)} )}
</Box> </Box>

View File

@ -33,7 +33,7 @@ export const DetailedMessagesDisplay: React.FC<
<Box marginBottom={1}> <Box marginBottom={1}>
<Text bold color={Colors.Foreground}> <Text bold color={Colors.Foreground}>
Debug Console{' '} Debug Console{' '}
<Text color={Colors.SubtleComment}>(CTRL-O to close)</Text> <Text color={Colors.SubtleComment}>(ctrl+O to close)</Text>
</Text> </Text>
</Box> </Box>
{messages.map((msg, index) => { {messages.map((msg, index) => {

View File

@ -64,10 +64,15 @@ export const Footer: React.FC<FooterProps> = ({
</Text> </Text>
) : process.env.SANDBOX === 'sandbox-exec' ? ( ) : process.env.SANDBOX === 'sandbox-exec' ? (
<Text color={Colors.AccentYellow}> <Text color={Colors.AccentYellow}>
sandbox-exec ({process.env.SEATBELT_PROFILE}) sandbox-exec{' '}
<Text color={Colors.SubtleComment}>
({process.env.SEATBELT_PROFILE})
</Text>
</Text> </Text>
) : ( ) : (
<Text color={Colors.AccentRed}>no sandbox (see README)</Text> <Text color={Colors.AccentRed}>
no sandbox <Text color={Colors.SubtleComment}>(see README)</Text>
</Text>
)} )}
</Box> </Box>

View File

@ -37,8 +37,8 @@ export const LoadingIndicator: React.FC<LoadingIndicatorProps> = ({
} }
/> />
</Box> </Box>
<Text color={Colors.AccentPurple}> <Text color={Colors.AccentPurple}>{currentLoadingPhrase}</Text>
{currentLoadingPhrase} <Text color={Colors.SubtleComment}>
{streamingState === StreamingState.WaitingForConfirmation {streamingState === StreamingState.WaitingForConfirmation
? '' ? ''
: ` (esc to cancel, ${elapsedTime}s)`} : ` (esc to cancel, ${elapsedTime}s)`}

View File

@ -260,7 +260,7 @@ const renderDiffContent = (
acc.push( acc.push(
<Box key={lineKey} flexDirection="row"> <Box key={lineKey} flexDirection="row">
<Text color={Colors.Foreground}>{gutterNumStr.padEnd(4)} </Text> <Text color={Colors.SubtleComment}>{gutterNumStr.padEnd(4)} </Text>
<Text color={color} dimColor={dim}> <Text color={color} dimColor={dim}>
{prefixSymbol}{' '} {prefixSymbol}{' '}
</Text> </Text>

View File

@ -94,16 +94,31 @@ export function colorizeCode(
const activeTheme = themeManager.getActiveTheme(); const activeTheme = themeManager.getActiveTheme();
try { try {
const hastTree =
!language || !lowlight.registered(language)
? lowlight.highlightAuto(codeToHighlight)
: lowlight.highlight(language, codeToHighlight);
// Render the HAST tree using the adapted theme // Render the HAST tree using the adapted theme
// Apply the theme's default foreground color to the top-level Text element // Apply the theme's default foreground color to the top-level Text element
const lines = codeToHighlight.split('\n');
const getHighlightedLines = (line: string) =>
!language || !lowlight.registered(language)
? lowlight.highlightAuto(line)
: lowlight.highlight(language, line);
return ( return (
<Text color={activeTheme.defaultColor}> <Text>
{renderHastNode(hastTree, activeTheme, undefined)} {lines.map((line, index) => (
<Text key={index}>
<Text color={activeTheme.colors.SubtleComment}>
{`${String(index + 1).padStart(3, ' ')} `}
</Text>
<Text color={activeTheme.defaultColor}>
{renderHastNode(
getHighlightedLines(line),
activeTheme,
undefined,
)}
</Text>
{index < lines.length - 1 && '\n'}
</Text>
))}
</Text> </Text>
); );
} catch (error) { } catch (error) {
@ -112,6 +127,20 @@ export function colorizeCode(
error, error,
); );
// Fallback to plain text with default color on error // Fallback to plain text with default color on error
return <Text color={activeTheme.defaultColor}>{codeToHighlight}</Text>; // Also display line numbers in fallback
const lines = codeToHighlight.split('\n');
return (
<Text>
{lines.map((line, index) => (
<Text key={index}>
<Text color={activeTheme.colors.SubtleComment}>
{`${String(index + 1).padStart(3, ' ')} `}
</Text>
<Text color={activeTheme.defaultColor}>{line}</Text>
{index < lines.length - 1 && '\n'}
</Text>
))}
</Text>
);
} }
} }