ChatTerminalBlock

Data Display

명령과 실행 결과를 보여주는 읽기 전용 터미널 블록.

Usage

이미 끝난 명령의 출력만 보여줄 때 사용한다.

import

import

import { ChatTerminalBlock } from '@mildang/design-system/unofficial/Chat';

API Reference

ChatTerminalBlock Props

Prop

Type

Default

command
필수

ReactNode

지정 안 함

lines
필수

readonly string[]

지정 안 함

exitCode

number

지정 안 함

labels

Partial<ChatTerminalBlockLabels>

지정 안 함

prompt

ReactNode

$

visibleCount

number

지정 안 함

같은 패밀리

@mildang/design-system/unofficial/Chat 에서 같이 내보내는 컴포넌트다.

예제

성공

코드

import type { ComponentProps } from 'react';
import { ChatTerminalBlock } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatTerminalBlock>;
const LINES = [
  'Scope: 3 of 42 workspace projects',
  'packages/design-system test$ vitest run',
  '  ✓ src/ui/unofficial/chat/range.test.ts (12)',
  '  ✓ src/ui/unofficial/chat/CodeRunner/CodeRunner.test.tsx (3)',
  'Test Files  2 passed (2)',
];
const DEFAULT_ARGS: Props = {
  command: 'pnpm --filter @mildang/design-system test',
  lines: LINES,
  exitCode: 0,
};
export default function TerminalBlockSuccessExample(props: Partial<Props> = {}) {
  return <ChatTerminalBlock {...DEFAULT_ARGS} {...props} />;
}

실행 중

코드

// TerminalBlockSuccess.example.tsx
import { ChatTerminalBlock } from "@mildang/design-system/unofficial/Chat";
var LINES = [
  "Scope: 3 of 42 workspace projects",
  "packages/design-system test$ vitest run",
  "  ✓ src/ui/unofficial/chat/range.test.ts (12)",
  "  ✓ src/ui/unofficial/chat/CodeRunner/CodeRunner.test.tsx (3)",
  "Test Files  2 passed (2)"
];
var DEFAULT_ARGS = {
  command: "pnpm --filter @mildang/design-system test",
  lines: LINES,
  exitCode: 0
};
function TerminalBlockSuccessExample(props = {}) {
  return <ChatTerminalBlock {...DEFAULT_ARGS} {...props} />;
}

// TerminalBlockRunning.example.tsx
var DEFAULT_ARGS2 = {
  lines: [
    "Scope: 3 of 42 workspace projects",
    "packages/design-system test$ vitest run",
    "  ✓ src/ui/unofficial/chat/range.test.ts (12)"
  ],
  exitCode: void 0
};
function TerminalBlockRunningExample(props = {}) {
  return <TerminalBlockSuccessExample {...DEFAULT_ARGS2} {...props} />;
}
export {
  TerminalBlockRunningExample as default
};

실패

코드

import type { ComponentProps } from 'react';
import { ChatTerminalBlock } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatTerminalBlock>;
const DEFAULT_ARGS: Props = {
  command: 'pnpm --filter @mildang/design-system check-types',
  lines: [
    'src/ui/unofficial/chat/Thread/Thread.tsx(41,7): error TS2322:',
    "  Type 'string' is not assignable to type 'number'.",
    'Found 1 error.',
  ],
  exitCode: 1,
};
export default function TerminalBlockFailedExample(props: Partial<Props> = {}) {
  return <ChatTerminalBlock {...DEFAULT_ARGS} {...props} />;
}

스트리밍

코드

// TerminalBlockSuccess.example.tsx
import { ChatTerminalBlock } from "@mildang/design-system/unofficial/Chat";
var LINES = [
  "Scope: 3 of 42 workspace projects",
  "packages/design-system test$ vitest run",
  "  ✓ src/ui/unofficial/chat/range.test.ts (12)",
  "  ✓ src/ui/unofficial/chat/CodeRunner/CodeRunner.test.tsx (3)",
  "Test Files  2 passed (2)"
];
var DEFAULT_ARGS = {
  command: "pnpm --filter @mildang/design-system test",
  lines: LINES,
  exitCode: 0
};
function TerminalBlockSuccessExample(props = {}) {
  return <ChatTerminalBlock {...DEFAULT_ARGS} {...props} />;
}

// TerminalBlockStreaming.example.tsx
var DEFAULT_ARGS2 = { command: "git log --oneline -n 5", visibleCount: 2 };
function TerminalBlockStreamingExample(props = {}) {
  return <TerminalBlockSuccessExample {...DEFAULT_ARGS2} {...props} />;
}
export {
  TerminalBlockStreamingExample as default
};

긴 줄

코드

import type { ComponentProps } from 'react';
import { ChatTerminalBlock } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatTerminalBlock>;
const DEFAULT_ARGS: Props = {
  command: 'npx dotenv-vault@latest pull development .env',
  lines: [
    'remote: Pulling environment variables from the vault for the development environment of this project…',
    'ok',
  ],
  exitCode: 0,
};
export default function TerminalBlockLongLinesExample(props: Partial<Props> = {}) {
  return <ChatTerminalBlock {...DEFAULT_ARGS} {...props} />;
}