fix: summary newline logic
This commit is contained in:
@ -5,9 +5,7 @@ import { Text } from "../text";
|
|||||||
export function StreamSummary({ text }: { text: string }) {
|
export function StreamSummary({ text }: { text: string }) {
|
||||||
const [expand, setExpand] = useState(false);
|
const [expand, setExpand] = useState(false);
|
||||||
|
|
||||||
const cutOff = Math.min(
|
const line3 = [...text].reduce(
|
||||||
100,
|
|
||||||
[...text].reduce(
|
|
||||||
(acc, v, i) => {
|
(acc, v, i) => {
|
||||||
if (v === "\n" && acc[0] < 3) {
|
if (v === "\n" && acc[0] < 3) {
|
||||||
acc[0] += 1;
|
acc[0] += 1;
|
||||||
@ -16,8 +14,9 @@ export function StreamSummary({ text }: { text: string }) {
|
|||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
[0, 0],
|
[0, 0],
|
||||||
)[1],
|
)[1];
|
||||||
);
|
|
||||||
|
const cutOff = Math.min(100, line3 > 0 ? line3 : text.length);
|
||||||
const shouldExpand = text.length > cutOff;
|
const shouldExpand = text.length > cutOff;
|
||||||
return (
|
return (
|
||||||
<div className="whitespace-pre text-pretty">
|
<div className="whitespace-pre text-pretty">
|
||||||
|
Reference in New Issue
Block a user