MCPcopy
hub / github.com/srcbookdev/srcbook / CellOutput

Function CellOutput

packages/components/src/components/cell-output.tsx:21–177  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

19};
20
21export function CellOutput(props: Props) {
22 const { cell, show, setShow } = props;
23 const { getOutput, clearOutput, getTsServerDiagnostics, getTsServerSuggestions } = useCells();
24
25 const [activeTab, setActiveTab] = useState<'stdout' | 'stderr' | 'problems' | 'warnings'>(
26 'stdout',
27 );
28
29 const fullscreen = props.fullscreen;
30 const stdout = getOutput(cell.id, 'stdout') as StdoutOutputType[];
31 const stderr = getOutput(cell.id, 'stderr') as StderrOutputType[];
32 const diagnostics = getTsServerDiagnostics(cell.id);
33 const suggestions = getTsServerSuggestions(cell.id);
34
35 return (
36 <div className={cn('font-mono text-sm', fullscreen && !show && 'border-b')}>
37 <Tabs
38 value={activeTab}
39 onValueChange={(value) =>
40 setActiveTab(value as 'stdout' | 'stderr' | 'problems' | 'warnings')
41 }
42 defaultValue="stdout"
43 >
44 <div
45 className={cn(
46 'border-t px-3 flex items-center justify-between bg-muted text-tertiary-foreground rounded-b-md',
47 show && 'border-b rounded-none',
48 fullscreen && 'sticky top-0 border-t',
49 )}
50 >
51 <TabsList className={cn('h-full', !show && '')}>
52 <TabsTrigger
53 onClick={() => setShow(true)}
54 value="stdout"
55 className={cn(
56 !show &&
57 'border-transparent data-[state=active]:border-transparent data-[state=active]:text-tertiary-foreground mb-0',
58 )}
59 >
60 stdout
61 </TabsTrigger>
62 <TabsTrigger
63 onClick={() => setShow(true)}
64 value="stderr"
65 className={cn(
66 !show &&
67 'border-transparent data-[state=active]:border-transparent data-[state=active]:text-tertiary-foreground mb-0',
68 )}
69 >
70 {stderr.length > 0 ? (
71 <>
72 stderr <span className="text-sb-red-30">({stderr.length})</span>
73 </>
74 ) : (
75 'stderr'
76 )}
77 </TabsTrigger>
78 {cell.type === 'code' && cell.language === 'typescript' && (

Callers

nothing calls this directly

Calls 2

useCellsFunction · 0.85
cnFunction · 0.50

Tested by

no test coverage detected