Skip to content

chore(site): add AgentLogs storybook #12601

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import AnsiToHTML from "ansi-to-html";
import { type FC, type ReactNode, useMemo } from "react";
import { type Line, LogLine, LogLinePrefix } from "components/Logs/LogLine";

// 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;

const convert = new AnsiToHTML();

interface AgentLogLineProps {
Expand Down
24 changes: 24 additions & 0 deletions site/src/modules/resources/AgentLogs/AgentLogs.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Meta, StoryObj } from "@storybook/react";
import { AGENT_LOG_LINE_HEIGHT } from "./AgentLogLine";
import { AgentLogs } from "./AgentLogs";
import { MockLogs, MockSources } from "./mocks";

const meta: Meta<typeof AgentLogs> = {
title: "modules/resources/AgentLogs",
component: AgentLogs,
args: {
sources: MockSources,
logs: MockLogs,
height: MockLogs.length * AGENT_LOG_LINE_HEIGHT,
},
parameters: {
layout: "fullscreen",
},
};

export default meta;
type Story = StoryObj<typeof AgentLogs>;

const Default: Story = {};

export { Default as AgentLogs };
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import {
import { FixedSizeList as List } from "react-window";
import * as API from "api/api";
import type { WorkspaceAgentLogSource } from "api/typesGenerated";
import { AgentLogLine } from "./AgentLogLine";
import { AGENT_LOG_LINE_HEIGHT, type LineWithID } from "./AgentRow";
import {
AGENT_LOG_LINE_HEIGHT,
AgentLogLine,
type LineWithID,
} from "./AgentLogLine";

type AgentLogsProps = Omit<
ComponentProps<typeof List>,
Expand Down
Loading