Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/simulation/workbench/components/output.tsx
13399 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as mobxlite from 'mobx-react-lite';
7
import * as React from 'react';
8
import { TestRun } from '../stores/testRun';
9
import { Editor } from './editor';
10
11
type Props = {
12
readonly run: TestRun;
13
readonly baseline: TestRun | undefined;
14
readonly expand: boolean;
15
};
16
17
export const OutputView = mobxlite.observer(({ run, baseline, expand }: Props) => {
18
19
const [expanded, setExpanded] = React.useState(expand);
20
21
function ensureOutputValue(value: string | undefined): string {
22
if (value) {
23
return value;
24
}
25
26
return '';
27
}
28
29
return (
30
<div className='request-container'>
31
<div className='title' onClick={() => setExpanded(!expanded)}>
32
{expanded ? '▼' : '▶'} Output
33
</div>
34
{
35
!expanded
36
? null
37
: (
38
<div className='request-details' style={{ borderLeft: '1px solid #ccc', marginLeft: '7px', paddingLeft: '5px' }}>
39
{
40
!(run.stdout || (baseline && baseline.stdout))
41
? null
42
: (
43
<>
44
<h3>stdout</h3>
45
{
46
baseline
47
? (
48
<>
49
<h4>stdout from "Compare against" run</h4>
50
<div style={{ marginLeft: '-10px' }}>
51
<Editor lineNumbers={false} languageId='markdown' contents={ensureOutputValue(baseline.stdout)} />
52
</div>
53
</>
54
)
55
: null
56
}
57
<h4>stdout from "Current" run</h4>
58
<div style={{ marginLeft: '-10px' }}>
59
<Editor lineNumbers={false} languageId='markdown' contents={ensureOutputValue(run.stdout)} />
60
</div>
61
62
</>
63
)
64
}
65
{
66
!(run.stderr || (baseline && baseline.stderr))
67
? null
68
: (
69
<>
70
<h3>stderr</h3>
71
{
72
baseline
73
? (
74
<>
75
<h4>stderr from "Compare against" run</h4>
76
<div style={{ marginLeft: '-10px' }}>
77
<Editor lineNumbers={false} languageId='markdown' contents={ensureOutputValue(baseline.stderr)} />
78
</div>
79
</>
80
)
81
: null
82
}
83
<h4>stderr from "Current" run</h4>
84
<div style={{ marginLeft: '-10px' }}>
85
<Editor lineNumbers={false} languageId='markdown' contents={ensureOutputValue(run.stderr)} />
86
</div>
87
</>
88
)
89
}
90
</div>
91
)
92
}
93
</div>
94
);
95
});
96
97