Skip to content

Commit 427cde8

Browse files
authored
Merge pull request #66 from hqwlkj/main
feat(ui): 优化消息视图的布局和宽度自适应
2 parents c92e429 + 6bee73e commit 427cde8

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/ui/MessageView.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Box, Text } from "ink";
2+
import { Box, Text, useWindowSize } from "ink";
33
import { renderMarkdown } from "./markdown";
44
import type { SessionMessage } from "../session";
55

@@ -9,6 +9,7 @@ type Props = {
99
};
1010

1111
export function MessageView({ message, collapsed }: Props): React.ReactElement | null {
12+
const { columns } = useWindowSize();
1213
if (!message.visible) {
1314
return null;
1415
}
@@ -46,20 +47,20 @@ export function MessageView({ message, collapsed }: Props): React.ReactElement |
4647
return (
4748
<Box marginLeft={1} flexDirection="column" marginY={0}>
4849
<StatusLine bulletColor="gray" name="Thinking" params={summary} />
49-
<Box flexDirection="column" marginLeft={2}>
50+
<Box flexDirection="column" marginLeft={4}>
5051
{content ? <Text dimColor>{renderMarkdown(content)}</Text> : null}
5152
</Box>
5253
</Box>
5354
);
5455
}
5556

5657
return (
57-
<Box marginLeft={1} marginBottom={1} flexGrow={1} gap={1} marginY={0}>
58-
<Box>
58+
<Box marginLeft={1} marginBottom={1} width={columns - 2} gap={1} marginY={0} flexDirection="row">
59+
<Box alignSelf="stretch">
5960
<Text color="#229ac3"></Text>
6061
</Box>
61-
<Box flexDirection="column" flexGrow={1}>
62-
{content ? <Text>{renderMarkdown(content)}</Text> : null}
62+
<Box flexGrow={1} width={columns - 4}>
63+
{content ? <Text wrap="wrap">{renderMarkdown(content)}</Text> : null}
6364
</Box>
6465
</Box>
6566
);

0 commit comments

Comments
 (0)