From cf23ca264ac52781f2208d030910d562129ba8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AF=BC=ED=97=8C?= Date: Mon, 31 Aug 2026 14:43:28 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=B0=EC=B9=98=20+=20=EB=AF=B8=EB=8B=88=20?= =?UTF-8?q?=EC=82=AC=EB=B6=84=EB=A9=B4=20=EC=A6=89=EC=8B=9C=20=EC=A0=84?= =?UTF-8?q?=ED=99=98=20+=20=EA=B0=80=EA=B2=A9=20=EB=9D=BC=EC=9A=B4?= =?UTF-8?q?=EB=93=9C=20=EC=84=B9=EC=85=98=20=EC=8B=A0=EC=84=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 좌측: 협상 케이스(상시 미니 4분면 — 클릭 시 해당 케이스로 즉시 재시작)·상품 정보·가격/차트 - 우측: 협상 진행(스텝 전용)·가격 라운드·엔진 판단 - 가격 라운드: 라운드별 제안가·기존가 대비 %·응수 협상 카드 기록 (카드는 확인 뒤 응답에 실려오므로 비어 있는 마지막 라운드에 지연 채움) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01UFZ7JWdwCaQAwNYJErL8pP --- frontend/src/App.tsx | 52 +++++++++---- frontend/src/components/CasePanel.tsx | 68 +++++++++++------ frontend/src/components/Dashboard.tsx | 101 +++++++++++++------------ frontend/src/components/PricePanel.tsx | 52 +++++++++++++ 4 files changed, 186 insertions(+), 87 deletions(-) create mode 100644 frontend/src/components/PricePanel.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index c0683ae..c0d568b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react' import { DEMO_CASES, type DemoCase } from './content/cases' import { buildCardData, chat, invalidateSession, serverAlive, type ChatMetadata } from './lib/api' import { CasePanel } from './components/CasePanel' +import { PricePanel } from './components/PricePanel' import { ChatPanel, type Msg } from './components/ChatPanel' import { Dashboard } from './components/Dashboard' @@ -16,6 +17,12 @@ export interface NegoState { done: boolean } +// 가격 라운드 기록 — 제안가와 그에 응수한 협상 카드 +export interface Round { + price: number + card: string | null +} + const IDLE: NegoState = { step: '시작', index: 0, iteration: 0, price: null, initial: null, mode: 'null', options: [], done: false, @@ -28,6 +35,7 @@ export default function App() { const [meta, setMeta] = useState(null) const [finalPrice, setFinalPrice] = useState(null) const [priceTrail, setPriceTrail] = useState([]) + const [rounds, setRounds] = useState([]) const [busy, setBusy] = useState(false) const [started, setStarted] = useState(false) const [runId, setRunId] = useState(0) @@ -42,7 +50,7 @@ export default function App() { }, []) const send = useCallback( - async (userInput: string | null, state: NegoState, userLabel?: string) => { + async (userInput: string | null, state: NegoState, userLabel?: string, isOffer = false) => { if (!demoCase) return setBusy(true) setError(null) @@ -71,6 +79,20 @@ export default function App() { setMessages((m) => [...m, { role: 'bot', text: res.script, step: res.step, meta: res.chat_metadata }]) if (res.chat_metadata?.card_id || res.chat_metadata?.tension != null) setMeta(res.chat_metadata) if (res.step === '협상완료' && res.chat_metadata?.price != null) setFinalPrice(res.chat_metadata.price) + // 제안 시 라운드 추가 — 카드는 제안 직후가 아니라 [예] 확인 뒤 응답에 실려오므로, + // 카드가 비어 있는 마지막 라운드를 뒤따르는 응답의 카드로 채운다 + const cardId = res.chat_metadata?.card_id ?? null + if (isOffer && state.price != null) { + const offered = state.price + setRounds((r) => [...r, { price: offered, card: cardId }]) + } else if (cardId) { + setRounds((r) => { + if (!r.length || r[r.length - 1].card != null) return r + const next = [...r] + next[next.length - 1] = { ...next[next.length - 1], card: cardId } + return next + }) + } setNego({ ...state, step: res.step, @@ -96,6 +118,7 @@ export default function App() { setMeta(null) setFinalPrice(null) setPriceTrail([]) + setRounds([]) setStarted(true) setNego(IDLE) setRunId((r) => r + 1) @@ -115,6 +138,7 @@ export default function App() { setMeta(null) setFinalPrice(null) setPriceTrail([]) + setRounds([]) setStarted(false) setNego(IDLE) }, []) @@ -126,14 +150,14 @@ export default function App() { if (next.initial == null) next.initial = v else next.iteration = nego.iteration + 1 setPriceTrail((t) => [...t, v]) - send(null, next, `${v.toLocaleString()}원 제안`) + send(null, next, `${v.toLocaleString()}원 제안`, true) } return (
-

NEGO 협상 콘솔

+

NEGO 협상 콘솔

구매 협상 에이전트 시연 — 당신은 공급사입니다 @@ -151,8 +175,17 @@ export default function App() {
-
- +
+ demoCase && start(demoCase)} onSelect={start} /> - +
) diff --git a/frontend/src/components/CasePanel.tsx b/frontend/src/components/CasePanel.tsx index 03e3729..02a6d18 100644 --- a/frontend/src/components/CasePanel.tsx +++ b/frontend/src/components/CasePanel.tsx @@ -1,30 +1,30 @@ import { DIST_LABEL, PARTNER_LABEL, SCENARIO_QUADRANTS, type DemoCase } from '../content/cases' export function CasePanel({ - selected, busy, onChange, + cases, selected, busy, onSelect, onChange, }: { + cases: DemoCase[] selected: DemoCase | null busy: boolean + onSelect: (c: DemoCase) => void onChange: () => void }) { if (!selected) { return ( - +
+

협상 케이스

+

+ 가운데 화면에서 시나리오를 선택하면 진행 중인 케이스와 상품 정보가 + 여기에 표시됩니다. +

+
) } - const q = SCENARIO_QUADRANTS.find((x) => x.scenario === selected.scenario) + const selectedQ = SCENARIO_QUADRANTS.find((x) => x.scenario === selected.scenario) return ( - + ) } diff --git a/frontend/src/components/Dashboard.tsx b/frontend/src/components/Dashboard.tsx index 8ceba1c..af6c1b5 100644 --- a/frontend/src/components/Dashboard.tsx +++ b/frontend/src/components/Dashboard.tsx @@ -1,9 +1,9 @@ import type { ChatMetadata } from '../lib/api' import type { DemoCase } from '../content/cases' -import type { NegoState } from '../App' -import { PriceChart } from './PriceChart' +import type { NegoState, Round } from '../App' const FLOW = ['서비스안내', '담당자확인', '협상품목안내', '가격협상', '협상종료'] +const MAX_ROUNDS = 5 // 긴장도 구간 → 응대 페르소나 (엔진 프리셋과 동일한 3구간) const PERSONA_ZONE: Record = { @@ -20,10 +20,13 @@ function flowIndex(step: string): number { return i >= 0 ? i : 0 } -function Panel({ title, children }: { title: string; children: React.ReactNode }) { +function Panel({ title, right, children }: { title: string; right?: React.ReactNode; children: React.ReactNode }) { return (
-

{title}

+
+

{title}

+ {right} +
{children}
) @@ -49,65 +52,27 @@ function StepCircle({ state }: { state: 'done' | 'current' | 'todo' }) { } export function Dashboard({ - demoCase, nego, meta, priceTrail, started, finalPrice, + demoCase, nego, meta, rounds, started, }: { demoCase: DemoCase | null nego: NegoState meta: ChatMetadata | null - priceTrail: number[] + rounds: Round[] started: boolean - finalPrice: number | null }) { const fi = started ? flowIndex(nego.step) : -1 const tension = meta?.tension ?? null const indicator = meta?.indicator_value ?? null const zone = meta?.persona != null ? PERSONA_ZONE[meta.persona] ?? null : null - // 합의가가 마지막 제안가와 다르면(1% 추가 네고 등) 차트 종점으로 잇는다 - const series = finalPrice != null && priceTrail[priceTrail.length - 1] !== finalPrice - ? [...priceTrail, finalPrice] - : priceTrail - - const current = finalPrice ?? (priceTrail.length ? priceTrail[priceTrail.length - 1] : null) - const priceLabel = finalPrice != null ? '최종 합의가' : current != null ? '현재 제안가' : '기존 공급가' - const priceValue = current ?? demoCase?.item_price ?? 0 - const savedPct = demoCase && current != null && current < demoCase.item_price - ? Math.round(((demoCase.item_price - current) / demoCase.item_price) * 1000) / 10 - : null - return (