2025-05-18 01:18:32 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-26 00:04:53 +02:00
|
|
|
import type React from 'react';
|
2025-05-18 01:18:32 -07:00
|
|
|
import { Box, Text } from 'ink';
|
2025-09-10 10:57:07 -07:00
|
|
|
import { theme } from '../../semantic-colors.js';
|
2026-01-26 15:23:54 -08:00
|
|
|
import { HalfLinePaddedBox } from '../shared/HalfLinePaddedBox.js';
|
|
|
|
|
import { useConfig } from '../../contexts/ConfigContext.js';
|
2025-05-18 01:18:32 -07:00
|
|
|
|
|
|
|
|
interface UserShellMessageProps {
|
|
|
|
|
text: string;
|
2026-01-26 15:23:54 -08:00
|
|
|
width: number;
|
2025-05-18 01:18:32 -07:00
|
|
|
}
|
|
|
|
|
|
2026-01-26 15:23:54 -08:00
|
|
|
export const UserShellMessage: React.FC<UserShellMessageProps> = ({
|
|
|
|
|
text,
|
|
|
|
|
width,
|
|
|
|
|
}) => {
|
|
|
|
|
const config = useConfig();
|
|
|
|
|
const useBackgroundColor = config.getUseBackgroundColor();
|
|
|
|
|
|
2025-05-18 01:18:32 -07:00
|
|
|
// Remove leading '!' if present, as App.tsx adds it for the processor.
|
|
|
|
|
const commandToDisplay = text.startsWith('!') ? text.substring(1) : text;
|
|
|
|
|
|
|
|
|
|
return (
|
2026-01-26 15:23:54 -08:00
|
|
|
<HalfLinePaddedBox
|
2026-02-24 01:21:10 -08:00
|
|
|
backgroundBaseColor={theme.background.message}
|
|
|
|
|
backgroundOpacity={1}
|
2026-01-26 15:23:54 -08:00
|
|
|
useBackgroundColor={useBackgroundColor}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
paddingY={0}
|
|
|
|
|
marginY={useBackgroundColor ? 0 : 1}
|
|
|
|
|
paddingX={useBackgroundColor ? 1 : 0}
|
|
|
|
|
width={width}
|
|
|
|
|
>
|
|
|
|
|
<Text color={theme.ui.symbol}>$ </Text>
|
|
|
|
|
<Text color={theme.text.primary}>{commandToDisplay}</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
</HalfLinePaddedBox>
|
2025-05-18 01:18:32 -07:00
|
|
|
);
|
|
|
|
|
};
|