-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRuntimeLogPanel.js
More file actions
155 lines (145 loc) · 4.36 KB
/
RuntimeLogPanel.js
File metadata and controls
155 lines (145 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import React from "react";
import { Alert, Button, Space, Tag, Typography, message } from "antd";
const phaseColors = {
idle: "default",
starting: "processing",
running: "processing",
finished: "success",
failed: "error",
stopped: "warning",
};
function formatValue(value) {
if (value === null || value === undefined || value === "") {
return "—";
}
return String(value);
}
function RuntimeLogPanel({ title, runtime, onRefresh }) {
const text = runtime?.text || "";
const phase = runtime?.phase || "idle";
const metadata = runtime?.metadata || {};
const handleCopy = async () => {
try {
await navigator.clipboard.writeText(text || "");
message.success(`${title} log copied.`);
} catch (error) {
message.error(`Failed to copy ${title.toLowerCase()} log.`);
}
};
return (
<div
style={{
marginTop: 16,
border: "1px solid #d9d9d9",
borderRadius: 8,
overflow: "hidden",
background: "#fafafa",
}}
>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
padding: "12px 16px",
borderBottom: "1px solid #f0f0f0",
background: "#fff",
gap: 12,
flexWrap: "wrap",
}}
>
<Space wrap size={8}>
<Typography.Text strong>{title}</Typography.Text>
<Tag color={phaseColors[phase] || "default"}>{phase}</Tag>
<Typography.Text type="secondary">
PID {formatValue(runtime?.pid)}
</Typography.Text>
<Typography.Text type="secondary">
Exit {formatValue(runtime?.exitCode)}
</Typography.Text>
<Typography.Text type="secondary">
Lines {formatValue(runtime?.lineCount)}
</Typography.Text>
</Space>
<Space wrap size={8}>
<Button size="small" onClick={onRefresh}>
Refresh
</Button>
<Button size="small" onClick={handleCopy} disabled={!text}>
Copy Log
</Button>
</Space>
</div>
{runtime?.lastError && (
<div style={{ padding: "12px 16px 0 16px" }}>
<Alert
type="error"
showIcon
message={runtime.lastError}
style={{ marginBottom: 12 }}
/>
</div>
)}
<div style={{ padding: "0 16px 12px 16px" }}>
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(240px, 1fr))",
gap: 8,
marginBottom: 12,
fontSize: 12,
color: "#595959",
}}
>
<div>Started: {formatValue(runtime?.startedAt)}</div>
<div>Ended: {formatValue(runtime?.endedAt)}</div>
<div>Updated: {formatValue(runtime?.lastUpdatedAt)}</div>
<div>Config path: {formatValue(runtime?.configPath)}</div>
<div>Config origin: {formatValue(runtime?.configOriginPath)}</div>
<div>Output path: {formatValue(metadata.outputPath)}</div>
<div>Checkpoint: {formatValue(metadata.checkpointPath)}</div>
<div>Log path: {formatValue(metadata.logPath)}</div>
</div>
{runtime?.command && (
<div
style={{
marginBottom: 12,
padding: "8px 10px",
borderRadius: 6,
background: "#fff",
border: "1px solid #f0f0f0",
fontFamily:
"ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace",
fontSize: 12,
color: "#262626",
wordBreak: "break-word",
}}
>
{runtime.command}
</div>
)}
<pre
style={{
margin: 0,
minHeight: 220,
maxHeight: 420,
overflow: "auto",
padding: 12,
borderRadius: 6,
background: "#111827",
color: "#f3f4f6",
fontSize: 12,
lineHeight: 1.5,
whiteSpace: "pre-wrap",
wordBreak: "break-word",
fontFamily:
"ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace",
}}
>
{text || "No runtime logs captured yet."}
</pre>
</div>
</div>
);
}
export default RuntimeLogPanel;