@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
tsx 37 lines 1.04 KB
Raw
1 /** @jsxRuntime automatic */
2 /** @jsxImportSource @alchemy.run/sigil */
3 import { inspect } from "node:util";
4 import { AnsiText } from "@alchemy.run/sigil";
5 import type { ReactNode } from "react";
6 import { Box, useCliEnvironment } from "../ui/index.ts";
7
8 export interface StackOutputsProps {
9 readonly value: unknown;
10 readonly offset?: number;
11 readonly limit?: number;
12 }
13
14 export function StackOutputs({
15 value,
16 offset = 0,
17 limit = Number.POSITIVE_INFINITY,
18 }: StackOutputsProps) {
19 const { colors } = useCliEnvironment();
20 const output = inspect(value, { colors });
21 const lines = output.split("\n").slice(offset, offset + limit);
22
23 return (
24 <Box flexDirection="column">
25 {lines.map((line, index) => (
26 <AnsiText key={offset + index} wrap="none">
27 {line || " "}
28 </AnsiText>
29 ))}
30 </Box>
31 );
32 }
33
34 export const stackOutputLineCount = (value: unknown): number =>
35 inspect(value, { colors: false }).split("\n").length;
36
37 export const stackOutputsView = (value: unknown): ReactNode => <StackOutputs value={value} />;