ChatAgentPlan

Data Display

진행 단계를 순서대로 보여주는 체크리스트.

Usage

data part로 전달된 단계 목록의 진행 상황을 순서대로 보여줄 때 사용한다.

import

import

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

예제를 복사해 쓸 때 필요한 준비

@mildang/styled-system 은 이 저장소에서 Panda 가 생성하는 산출물이다. 저장소 안에서는 turbo run ship 이후 쓸 수 있고, 패키지 소비자는 자기 Panda 산출물이나 다른 레이아웃 수단으로 바꿔야 한다.

외부 패키지를 따로 설치한다. DS 의 전이 의존성에 기대지 않는다.

API Reference

ChatAgentPlan Props

Prop

Type

Default

activeIndex
필수

number

지정 안 함

steps
필수

readonly string[]

지정 안 함

labels

Partial<ChatAgentPlanLabels>

지정 안 함

같은 패밀리

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

예제

진행 중

진행 중인 계획이다.

import type { ComponentProps } from 'react';
import { ChatAgentPlan } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatAgentPlan>;
const DEFAULT_ARGS: Props = { steps: ['저장소 구조 파악','실패하는 테스트 재현','원인 지점 좁히기','수정 적용','전체 테스트 재실행'], activeIndex: 2, maxWidth: '360px' };
export default function AgentPlanInProgressExample(props: Partial<Props> = {}) { return <ChatAgentPlan {...DEFAULT_ARGS} {...props} />; }

시작 전

시작 전 계획이다.

import type { ComponentProps } from 'react';
import { ChatAgentPlan } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatAgentPlan>;
const DEFAULT_ARGS: Props = { steps: ['저장소 구조 파악','실패하는 테스트 재현','원인 지점 좁히기','수정 적용','전체 테스트 재실행'], activeIndex: 0, maxWidth: '360px' };
export default function AgentPlanNotStartedExample(props: Partial<Props> = {}) { return <ChatAgentPlan {...DEFAULT_ARGS} {...props} />; }

전부 완료

완료된 계획이다.

import type { ComponentProps } from 'react';
import { ChatAgentPlan } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatAgentPlan>;
const DEFAULT_ARGS: Props = { steps: ['저장소 구조 파악','실패하는 테스트 재현','원인 지점 좁히기','수정 적용','전체 테스트 재실행'], activeIndex: 5, maxWidth: '360px' };
export default function AgentPlanCompletedExample(props: Partial<Props> = {}) { return <ChatAgentPlan {...DEFAULT_ARGS} {...props} />; }

문구 교체

문구를 교체한 계획이다.

import type { ComponentProps } from 'react';
import { ChatAgentPlan } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatAgentPlan>;
const DEFAULT_ARGS: Props = { steps: ['저장소 구조 파악','실패하는 테스트 재현','원인 지점 좁히기','수정 적용','전체 테스트 재실행'], activeIndex: 3, maxWidth: '360px', labels: { title: 'Plan', count: (completed, total) => `${completed} of ${total}`, progress: 'progress' } };
export default function AgentPlanCustomLabelsExample(props: Partial<Props> = {}) { return <ChatAgentPlan {...DEFAULT_ARGS} {...props} />; }

범위 밖 입력

음수·초과·NaN이 들어와도 0~steps.length 범위로 갇히는 예시다.

import { css } from '@mildang/styled-system/css';
import { ChatAgentPlan } from '@mildang/design-system/unofficial/Chat';

const STEPS = [
  '저장소 구조 파악',
  '실패하는 테스트 재현',
  '원인 지점 좁히기',
  '수정 적용',
  '전체 테스트 재실행',
];

const AgentPlanOutOfRangeExample = () => (
    <div className={css({ display: 'flex', flexDirection: 'column', gap: '24', maxWidth: '360px' })}>
      <ChatAgentPlan steps={STEPS} activeIndex={-3} labels={{ title: '음수' }} />
      <ChatAgentPlan steps={STEPS} activeIndex={99} labels={{ title: '초과' }} />
      <ChatAgentPlan steps={STEPS} activeIndex={Number.NaN} labels={{ title: 'NaN' }} />
    </div>
  );

export default AgentPlanOutOfRangeExample;

data part 등록

AgentPlanData가 그대로 data part 페이로드 스키마가 되는 등록 코드 예시다.

코드

import { css } from '@mildang/styled-system/css';

const REGISTRATION = `// 앱 소유 — DS 는 등록하지 않고 등록 가능한 부품만 export 한다(AD-1).
import { makeAssistantDataUI } from '@assistant-ui/react';
import { ChatAgentPlan, ChatTodoList } from '@mildang/design-system/unofficial/Chat';
import type { AgentPlanData, TodoListData } from '@mildang/design-system/unofficial/Chat';

// 서버가 흘려보내는 data part 의 페이로드가 곧 컴포넌트 prop 이다(AD-3).
export const PlanUI = makeAssistantDataUI<AgentPlanData>({
  type: 'plan',
  render: ({ data }) => <ChatAgentPlan {...data} />,
});

export const TodoUI = makeAssistantDataUI<TodoListData>({
  type: 'todos',
  render: ({ data }) => <ChatTodoList {...data} />,
});

// <AssistantRuntimeProvider> 아래 어디든 한 번 마운트해 두면 된다.
function Registry() {
  return (
    <>
      <PlanUI />
      <TodoUI />
    </>
  );
}`;

const AgentPlanMakeAssistantDataExample = () => (
    <pre
      className={css({
        margin: '0',
        overflowX: 'auto',
        borderRadius: 'lg',
        backgroundColor: 'neutral.ghostBg.base',
        padding: '16',
        textStyle: 'chat-small-text-R',
        fontFamily: 'monospace',
        color: 'neutral.text.base',
      })}
    >
      {REGISTRATION}
    </pre>
  );

export default AgentPlanMakeAssistantDataExample;