ChatCodeDiff

Data Display

파일 변경 내용을 줄 단위로 보여주는 뷰어.

Usage

이미 계산된 diff 줄과 변경량을 그대로 보여줄 때 사용한다.

import

import

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

API Reference

ChatCodeDiff Props

Prop

Type

Default

additions
필수

number

지정 안 함

deletions
필수

number

지정 안 함

filename
필수

ReactNode

지정 안 함

lines
필수

readonly ChatDiffLine[]

지정 안 함

labels

Partial<ChatDiffStatLabels>

지정 안 함

같은 패밀리

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

예제

기본

import type { ComponentProps } from 'react';
import { ChatCodeDiff } from '@mildang/design-system/unofficial/Chat';
import type { ChatDiffLine } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatCodeDiff>;
const DEFAULT_ARGS: Props = { filename: 'src/chat/Tool/resolveToolStatus.ts', additions: 3, deletions: 1, lines: [{ kind: 'context', text: 'export function resolveToolStatus(part: ToolCallPart) {' }, { kind: 'context', text: '  const { status } = part;' }, { kind: 'removed', text: '  if (status.type === "requires-action") return "running";' }, { kind: 'added', text: '  if (status.type === "requires-action") {' }, { kind: 'added', text: '    return status.reason === "interrupt" ? "interrupt" : "awaiting";' }, { kind: 'added', text: '  }' }, { kind: 'context', text: '  return status.type;' }, { kind: 'context', text: '}' }] as ChatDiffLine[], className: undefined };
export default function CodeDiffDefaultExample(props: Partial<Props> = {}) { return <ChatCodeDiff {...DEFAULT_ARGS} {...props} />; }

가로 오버플로

import type { ComponentProps } from 'react';
import { ChatCodeDiff } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatCodeDiff>;
const DEFAULT_ARGS: Props = { filename: 'packages/design-system/src/ui/unofficial/chat/CodeDiff/CodeDiff.tsx', additions: 1, deletions: 1, lines: [{ kind: 'context', text: 'const classes = chatCodeSurface();' }, { kind: 'removed', text: '  const className = cx(surface.paper, classes.root, css(styleProps, cssStyleProps, sx), className);' }, { kind: 'added', text: '  const className = cx(surface.paper, classes.root, classes.scroll, css(styleProps, cssStyleProps, sx), className, "그리고 더 긴 한 줄");' }, { kind: 'context', text: '}' }] };
export default function CodeDiffHorizontalOverflowExample(props: Partial<Props> = {}) { return <ChatCodeDiff {...DEFAULT_ARGS} {...props} />; }

요약만

import type { ComponentProps } from 'react';
import { ChatCodeDiff } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatCodeDiff>;
const DEFAULT_ARGS: Props = { filename: 'pnpm-lock.yaml', additions: 412, deletions: 96, lines: [{ kind: 'context', text: '@@ 생략된 hunk 508줄 @@' }] };
export default function CodeDiffSummaryOnlyExample(props: Partial<Props> = {}) { return <ChatCodeDiff {...DEFAULT_ARGS} {...props} />; }