File tree Expand file tree Collapse file tree 9 files changed +17
-20
lines changed
workspaces/WorkspaceBuildLogs Expand file tree Collapse file tree 9 files changed +17
-20
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { MONOSPACE_FONT_FAMILY } from "theme/constants";
6
6
export const DEFAULT_LOG_LINE_SIDE_PADDING = 24 ;
7
7
8
8
export interface Line {
9
+ id : number ;
9
10
time : string ;
10
11
output : string ;
11
12
level : LogLevel ;
Original file line number Diff line number Diff line change 1
1
import type { Meta , StoryObj } from "@storybook/react" ;
2
2
import { chromatic } from "testHelpers/chromatic" ;
3
3
import { MockWorkspaceBuildLogs } from "testHelpers/entities" ;
4
+ import type { Line } from "./LogLine" ;
4
5
import { Logs } from "./Logs" ;
5
6
6
7
const meta : Meta < typeof Logs > = {
7
8
title : "components/Logs" ,
8
9
parameters : { chromatic } ,
9
10
component : Logs ,
10
11
args : {
11
- lines : MockWorkspaceBuildLogs . map ( ( log ) => ( {
12
+ lines : MockWorkspaceBuildLogs . map < Line > ( ( log ) => ( {
13
+ id : log . id ,
12
14
level : log . log_level ,
13
15
time : log . created_at ,
14
16
output : log . output ,
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export const Logs: FC<LogsProps> = ({
20
20
< div css = { styles . root } className = { `${ className } logs-container` } >
21
21
< div css = { { minWidth : "fit-content" } } >
22
22
{ lines . map ( ( line ) => (
23
- < LogLine key = { line . output } level = { line . level } >
23
+ < LogLine key = { line . id } level = { line . level } >
24
24
{ ! hideTimestamps && (
25
25
< LogLinePrefix >
26
26
{ dayjs ( line . time ) . format ( "HH:mm:ss.SSS" ) }
Original file line number Diff line number Diff line change @@ -3,13 +3,6 @@ import AnsiToHTML from "ansi-to-html";
3
3
import { type Line , LogLine , LogLinePrefix } from "components/Logs/LogLine" ;
4
4
import { type FC , type ReactNode , useMemo } from "react" ;
5
5
6
- // Logs are stored as the Line interface to make rendering
7
- // much more efficient. Instead of mapping objects each time, we're
8
- // able to just pass the array of logs to the component.
9
- export interface LineWithID extends Line {
10
- id : number ;
11
- }
12
-
13
6
// Approximate height of a log line. Used to control virtualized list height.
14
7
export const AGENT_LOG_LINE_HEIGHT = 20 ;
15
8
Original file line number Diff line number Diff line change 1
1
import type { Interpolation , Theme } from "@emotion/react" ;
2
2
import Tooltip from "@mui/material/Tooltip" ;
3
3
import type { WorkspaceAgentLogSource } from "api/typesGenerated" ;
4
+ import type { Line } from "components/Logs/LogLine" ;
4
5
import { type ComponentProps , forwardRef , useMemo } from "react" ;
5
6
import { FixedSizeList as List } from "react-window" ;
6
- import {
7
- AGENT_LOG_LINE_HEIGHT ,
8
- AgentLogLine ,
9
- type LineWithID ,
10
- } from "./AgentLogLine" ;
7
+ import { AGENT_LOG_LINE_HEIGHT , AgentLogLine } from "./AgentLogLine" ;
11
8
12
9
type AgentLogsProps = Omit <
13
10
ComponentProps < typeof List > ,
14
11
"children" | "itemSize" | "itemCount"
15
12
> & {
16
- logs : readonly LineWithID [ ] ;
13
+ logs : readonly Line [ ] ;
17
14
sources : readonly WorkspaceAgentLogSource [ ] ;
18
15
} ;
19
16
Original file line number Diff line number Diff line change 1
1
// Those mocks are fetched from the Coder API in dev.coder.com
2
2
3
- import type { LineWithID } from "./AgentLogLine " ;
3
+ import type { Line } from "components/Logs/LogLine " ;
4
4
5
5
export const MockSources = [
6
6
{
@@ -1128,4 +1128,4 @@ export const MockLogs = [
1128
1128
time : "2024-03-14T11:31:10.859531Z" ,
1129
1129
sourceId : "d9475581-8a42-4bce-b4d0-e4d2791d5c98" ,
1130
1130
} ,
1131
- ] satisfies LineWithID [ ] ;
1131
+ ] satisfies Line [ ] ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import type {
12
12
WorkspaceAgentMetadata ,
13
13
} from "api/typesGenerated" ;
14
14
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow" ;
15
+ import type { Line } from "components/Logs/LogLine" ;
15
16
import { Stack } from "components/Stack/Stack" ;
16
17
import { useProxy } from "contexts/ProxyContext" ;
17
18
import {
@@ -318,7 +319,7 @@ export const AgentRow: FC<AgentRowProps> = ({
318
319
width = { width }
319
320
css = { styles . startupLogs }
320
321
onScroll = { handleLogScroll }
321
- logs = { startupLogs . map ( ( l ) => ( {
322
+ logs = { startupLogs . map < Line > ( ( l ) => ( {
322
323
id : l . id ,
323
324
level : l . level ,
324
325
output : l . output ,
Original file line number Diff line number Diff line change 1
1
import { type Interpolation , type Theme , useTheme } from "@emotion/react" ;
2
2
import type { ProvisionerJobLog } from "api/typesGenerated" ;
3
+ import type { Line } from "components/Logs/LogLine" ;
3
4
import { DEFAULT_LOG_LINE_SIDE_PADDING , Logs } from "components/Logs/Logs" ;
4
5
import dayjs from "dayjs" ;
5
6
import { type FC , Fragment , type HTMLAttributes } from "react" ;
@@ -63,7 +64,8 @@ export const WorkspaceBuildLogs: FC<WorkspaceBuildLogsProps> = ({
63
64
>
64
65
{ Object . entries ( groupedLogsByStage ) . map ( ( [ stage , logs ] ) => {
65
66
const isEmpty = logs . every ( ( log ) => log . output === "" ) ;
66
- const lines = logs . map ( ( log ) => ( {
67
+ const lines = logs . map < Line > ( ( log ) => ( {
68
+ id : log . id ,
67
69
time : log . created_at ,
68
70
output : log . output ,
69
71
level : log . log_level ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import type {
7
7
import { Alert } from "components/Alert/Alert" ;
8
8
import { ErrorAlert } from "components/Alert/ErrorAlert" ;
9
9
import { Loader } from "components/Loader/Loader" ;
10
+ import type { Line } from "components/Logs/LogLine" ;
10
11
import { Margins } from "components/Margins/Margins" ;
11
12
import {
12
13
FullWidthPageHeader ,
@@ -302,7 +303,7 @@ const AgentLogsContent: FC<{ workspaceId: string; agent: WorkspaceAgent }> = ({
302
303
return (
303
304
< AgentLogs
304
305
sources = { agent . log_sources }
305
- logs = { logs . map ( ( l ) => ( {
306
+ logs = { logs . map < Line > ( ( l ) => ( {
306
307
id : l . id ,
307
308
output : l . output ,
308
309
time : l . created_at ,
You can’t perform that action at this time.
0 commit comments