Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: prevent invalid render output for build logs#17233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Parkreiner merged 2 commits intomainfrommes/owws-tweaks
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionssite/src/components/Logs/LogLine.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ import { MONOSPACE_FONT_FAMILY } from "theme/constants";
export const DEFAULT_LOG_LINE_SIDE_PADDING = 24;

export interface Line {
id: number;
time: string;
output: string;
level: LogLevel;
Expand Down
4 changes: 3 additions & 1 deletionsite/src/components/Logs/Logs.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
import type { Meta, StoryObj } from "@storybook/react";
import { chromatic } from "testHelpers/chromatic";
import { MockWorkspaceBuildLogs } from "testHelpers/entities";
import type { Line } from "./LogLine";
import { Logs } from "./Logs";

const meta: Meta<typeof Logs> = {
title: "components/Logs",
parameters: { chromatic },
component: Logs,
args: {
lines: MockWorkspaceBuildLogs.map((log) => ({
lines: MockWorkspaceBuildLogs.map<Line>((log) => ({
id: log.id,
level: log.log_level,
time: log.created_at,
output: log.output,
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/Logs/Logs.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ export const Logs: FC<LogsProps> = ({
<div css={styles.root} className={`${className} logs-container`}>
<div css={{ minWidth: "fit-content" }}>
{lines.map((line) => (
<LogLine key={line.output} level={line.level}>
<LogLine key={line.id} level={line.level}>
{!hideTimestamps && (
<LogLinePrefix>
{dayjs(line.time).format("HH:mm:ss.SSS")}
Expand Down
7 changes: 0 additions & 7 deletionssite/src/modules/resources/AgentLogs/AgentLogLine.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,13 +3,6 @@ import AnsiToHTML from "ansi-to-html";
import { type Line, LogLine, LogLinePrefix } from "components/Logs/LogLine";
import { type FC, type ReactNode, useMemo } from "react";

// Logs are stored as the Line interface to make rendering
// much more efficient. Instead of mapping objects each time, we're
// able to just pass the array of logs to the component.
export interface LineWithID extends Line {
id: number;
}

// Approximate height of a log line. Used to control virtualized list height.
export const AGENT_LOG_LINE_HEIGHT = 20;

Expand Down
9 changes: 3 additions & 6 deletionssite/src/modules/resources/AgentLogs/AgentLogs.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
import type { Interpolation, Theme } from "@emotion/react";
import Tooltip from "@mui/material/Tooltip";
import type { WorkspaceAgentLogSource } from "api/typesGenerated";
import type { Line } from "components/Logs/LogLine";
import { type ComponentProps, forwardRef, useMemo } from "react";
import { FixedSizeList as List } from "react-window";
import {
AGENT_LOG_LINE_HEIGHT,
AgentLogLine,
type LineWithID,
} from "./AgentLogLine";
import { AGENT_LOG_LINE_HEIGHT, AgentLogLine } from "./AgentLogLine";

type AgentLogsProps = Omit<
ComponentProps<typeof List>,
"children" | "itemSize" | "itemCount"
> & {
logs: readonlyLineWithID[];
logs: readonlyLine[];
sources: readonly WorkspaceAgentLogSource[];
};

Expand Down
4 changes: 2 additions & 2 deletionssite/src/modules/resources/AgentLogs/mocks.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Those mocks are fetched from the Coder API in dev.coder.com

import type {LineWithID } from "./AgentLogLine";
import type {Line } from "components/Logs/LogLine";

export const MockSources = [
{
Expand DownExpand Up@@ -1128,4 +1128,4 @@ export const MockLogs = [
time: "2024-03-14T11:31:10.859531Z",
sourceId: "d9475581-8a42-4bce-b4d0-e4d2791d5c98",
},
] satisfiesLineWithID[];
] satisfiesLine[];
3 changes: 2 additions & 1 deletionsite/src/modules/resources/AgentRow.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ import type {
WorkspaceAgentMetadata,
} from "api/typesGenerated";
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow";
import type { Line } from "components/Logs/LogLine";
import { Stack } from "components/Stack/Stack";
import { useProxy } from "contexts/ProxyContext";
import {
Expand DownExpand Up@@ -318,7 +319,7 @@ export const AgentRow: FC<AgentRowProps> = ({
width={width}
css={styles.startupLogs}
onScroll={handleLogScroll}
logs={startupLogs.map((l) => ({
logs={startupLogs.map<Line>((l) => ({
id: l.id,
level: l.level,
output: l.output,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
import { type Interpolation, type Theme, useTheme } from "@emotion/react";
import type { ProvisionerJobLog } from "api/typesGenerated";
import type { Line } from "components/Logs/LogLine";
import { DEFAULT_LOG_LINE_SIDE_PADDING, Logs } from "components/Logs/Logs";
import dayjs from "dayjs";
import { type FC, Fragment, type HTMLAttributes } from "react";
Expand DownExpand Up@@ -63,7 +64,8 @@ export const WorkspaceBuildLogs: FC<WorkspaceBuildLogsProps> = ({
>
{Object.entries(groupedLogsByStage).map(([stage, logs]) => {
const isEmpty = logs.every((log) => log.output === "");
const lines = logs.map((log) => ({
const lines = logs.map<Line>((log) => ({
id: log.id,
time: log.created_at,
output: log.output,
level: log.log_level,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ import type {
import { Alert } from "components/Alert/Alert";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { Loader } from "components/Loader/Loader";
import type { Line } from "components/Logs/LogLine";
import { Margins } from "components/Margins/Margins";
import {
FullWidthPageHeader,
Expand DownExpand Up@@ -302,7 +303,7 @@ const AgentLogsContent: FC<{ workspaceId: string; agent: WorkspaceAgent }> = ({
return (
<AgentLogs
sources={agent.log_sources}
logs={logs.map((l) => ({
logs={logs.map<Line>((l) => ({
id: l.id,
output: l.output,
time: l.created_at,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp