[fix] agent·negodata/front: 중간값 멘트 모순 수정(갑 포지션 갱신을 치환 뒤로·원값 인용가 반올림 제외·1% 카드 역행 금지) + 계정 전환 쿼리캐시 초기화·ChatTab 카드 렌더 정리 + font-mono 한글 폴백(Windows 한글깨짐)

This commit is contained in:
minaChoi committed 2026-08-07 15:48:48 +09:00
1 parent 7dc925bcd4
commit a405e00bf9
10 files changed
+72 -90

No files matched your search

+3 -14
View File
@@ -1,21 +1,10 @@
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
import {useState, type ReactNode} from 'react';
import {QueryClientProvider} from '@tanstack/react-query';
import {type ReactNode} from 'react';
import {Toaster} from 'sonner';
import {ConfirmHost} from '@/lib/confirm';
import {queryClient} from '@/lib/query-client';
export function Providers({children}: {children: ReactNode}) {
const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
retry: 1,
refetchOnWindowFocus: false,
},
},
}),
);
return (
<QueryClientProvider client={queryClient}>
{children}
@@ -49,14 +49,11 @@ export function ActionBanner() {
const queryClient = useQueryClient();
const readOne = useReadOne();
const { data: notif } = useListNotifications(
{ size: 20 },
{ query: { refetchInterval: 30_000, staleTime: 10_000 } },
);
const { data: notif } = useListNotifications({ size: 20 }, { query: { refetchInterval: 30_000 } });
// 재협상 요청 토스트는 '아직 완료 안 된(대기중)' 것만 — 내가 처리 가능한(can_act) 대기 세션 집합.
const { data: renego } = useListRequests(
{ status: 1, page: 1, size: 50 },
{ query: { refetchInterval: 30_000, staleTime: 10_000 } },
{ query: { refetchInterval: 30_000 } },
);
const pendingSessions = new Set(
(renego?.requests ?? []).filter((r) => r.can_act !== false).map((r) => r.session_id),
@@ -10,6 +10,7 @@ import {useAuthStore, type AuthUser, type UserRole} from '../../stores/auth';
import {UserRole as UserRoleCode} from '../../api/generated/model';
import {USER_ROLE_LABEL} from '../../lib/enumLabels';
import {toMessage, resultMessage} from '../../lib/apiError';
import {queryClient} from '../../lib/query-client';
const ACCESS_KEY = 'negodata.accessToken';
const REFRESH_KEY = 'negodata.refreshToken';
@@ -69,6 +70,8 @@ export function initAuth(): Promise<void> {
export async function login(loginId: string, password: string): Promise<ResMe> {
const tokens = ensureOk(await loginRequest({id: loginId, password}));
// 직전 계정(다른 회사)의 캐시가 남아 브랜딩·목록이 그대로 보이는 것 방지
queryClient.clear();
localStorage.setItem(ACCESS_KEY, tokens.access_token ?? '');
localStorage.setItem(REFRESH_KEY, tokens.refresh_token ?? '');
setAccessToken(tokens.access_token ?? null);
@@ -105,4 +108,5 @@ export async function logout(): Promise<void> {
localStorage.removeItem(REFRESH_KEY);
setAccessToken(null);
useAuthStore.getState().setUser(null);
queryClient.clear();
}
@@ -4,13 +4,11 @@ import type { SessionData } from '@/api/generated/model/sessionData';
import type { QuotationCardData } from '@/api/generated/model/quotationCardData';
import type { ChatMessageData } from '@/api/generated/model/chatMessageData';
import { ChatSender, CardType } from '@/api/generated/model';
import SlateRenderer from '@/components/SlateRenderer';
import { Typography } from '@/components/ui/typography';
import { StatusPill, sessionStatusTone } from './StatusPill';
import { type Product, type Partner, sessionStatusLabel } from '../../types';
import { useCompanySettings } from '@/features/settings/useCompanySettings';
import { renderEmphasis } from '@/lib/emphasis';
import { renderCardScriptPreview } from '@/features/cards/editor';
// 협상로그 JSON 다운로드(IMK #9). 가격·인하율은 실값 그대로 내보낸다 — 이 탭을 열 수 있는 사람이
// 이미 공개 대상(해당 견적 담당자∪최고관리자, 조회 게이팅)뿐이라 마스킹이 하던 차단 역할이 없다.
@@ -186,19 +184,12 @@ export function ChatTab({
) : (
chatMessages.map((m) =>
m.sender === ChatSender.BOT ? (
<BotBubble
key={m.chat_id}
message={m}
currentSupplierName={currentSupplierName}
currentProduct={currentProduct}
serverCards={serverCards}
/>
<BotBubble key={m.chat_id} message={m} serverCards={serverCards} />
) : (
<PartnerBubble
key={m.chat_id}
message={m}
currentSupplierName={currentSupplierName}
currentProduct={currentProduct}
serverCards={serverCards}
/>
),
@@ -211,22 +202,16 @@ export function ChatTab({
);
}
// 봇(좌측) 말풍선. 진행 단계·협상 스크립트(가격 마스킹)·사용 협상카드를 보여준다.
// 봇(좌측) 말풍선. 진행 단계·협상 스크립트·사용 협상카드를 보여준다.
// 간격은 부모(flex flex-col gap)에서 주고, 말풍선 박스는 block 으로 둬 긴 텍스트 줄바꿈이 깨지지 않게 한다.
function BotBubble({
message,
currentSupplierName,
currentProduct,
serverCards,
}: {
message: ChatMessageData;
currentSupplierName: string;
currentProduct: Product | undefined;
serverCards: QuotationCardData[];
}) {
const m = message;
// 카드 사용 메시지는 같은 멘트가 아래 카드 박스에 그대로 나오므로 본문 script 는 중복 → 카드 없을 때만 노출.
const usedCard = findUsedCard(m, serverCards);
return (
<div className="flex justify-start">
<div className="flex flex-col gap-1.5 max-w-[85%]">
@@ -241,18 +226,13 @@ function BotBubble({
{m.step}
</Typography>
)}
{m.script && !usedCard && (
{/* 본문은 실제 발화(chats.meta.script) — 카드 멘트도 변수 치환·자연화가 끝난 최종본이 여기 담긴다. */}
{m.script && (
<Typography as="p" variant="small" className="text-xs whitespace-pre-line leading-relaxed text-inherit">
{renderEmphasis(m.script)}
</Typography>
)}
<UsedCardBox
message={m}
isBot
currentSupplierName={currentSupplierName}
currentProduct={currentProduct}
serverCards={serverCards}
/>
<UsedCardBox message={m} isBot serverCards={serverCards} />
</div>
</div>
</div>
@@ -263,12 +243,10 @@ function BotBubble({
function PartnerBubble({
message,
currentSupplierName,
currentProduct,
serverCards,
}: {
message: ChatMessageData;
currentSupplierName: string;
currentProduct: Product | undefined;
serverCards: QuotationCardData[];
}) {
const m = message;
@@ -291,13 +269,7 @@ function PartnerBubble({
{m.script}
</Typography>
)}
<UsedCardBox
message={m}
isBot={false}
currentSupplierName={currentSupplierName}
currentProduct={currentProduct}
serverCards={serverCards}
/>
<UsedCardBox message={m} isBot={false} serverCards={serverCards} />
</div>
</div>
</div>
@@ -305,24 +277,20 @@ function PartnerBubble({
}
// 말풍선에 붙는 협상카드 박스(봇/협력사 공용). 카드 미사용 메시지면 아무것도 렌더하지 않는다.
// 톤(amber/primary)만 isBot 으로 가르고, 멘트/조건/메모 렌더 로직은 공유한다.
// 멘트 본문은 위 말풍선(실발화 m.script)이 담당 — 여기선 카드 메타(번호·이름·종류·와일드 조건/메모)만.
// 톤은 카드 종류(와일드=amber, 협상=primary)로 가른다.
function UsedCardBox({
message,
isBot,
currentSupplierName,
currentProduct,
serverCards,
}: {
message: ChatMessageData;
isBot: boolean;
currentSupplierName: string;
currentProduct: Product | undefined;
serverCards: QuotationCardData[];
}) {
const m = message;
const usedCard = findUsedCard(m, serverCards);
if (!usedCard) return null;
const cardNodes = Array.isArray(usedCard.edit_script) ? (usedCard.edit_script as unknown[]) : null;
const isWildCard = usedCard.type === CardType.WILD;
const cardDetailId = usedCard.nego_card_id ?? usedCard.wild_card_id ?? null; // 협상카드 상세(/cards?detail=) 링크용
@@ -330,12 +298,20 @@ function UsedCardBox({
<div
className={`rounded border p-2 ${
isBot
? 'bg-amber-50/70 border-amber-200 dark:bg-amber-950/20 dark:border-amber-900/40'
: 'bg-white/10 border-white/20'
? isWildCard
? 'bg-amber-50/70 border-amber-200 dark:bg-amber-950/20 dark:border-amber-900/40'
: 'bg-primary/5 border-primary/25 dark:bg-primary/10 dark:border-primary/30'
: isWildCard
? 'bg-amber-300/15 border-amber-200/40'
: 'bg-white/10 border-white/20'
}`}
>
{/* 헤더: 어떤 카드인지(번호·이름·종류) */}
<div className={`flex items-center gap-1 ${isBot ? 'text-amber-800 dark:text-amber-300' : 'text-primary-foreground'}`}>
<div
className={`flex items-center gap-1 ${
isBot ? (isWildCard ? 'text-amber-800 dark:text-amber-300' : 'text-primary') : 'text-primary-foreground'
}`}
>
<Sparkles size={10} />
<Typography as="span" variant="small" className="text-[10px] font-semibold text-inherit">협상카드</Typography>
{cardDetailId ? (
@@ -374,23 +350,6 @@ function UsedCardBox({
</Typography>
</div>
{/* 멘트 본문: 서식본(edit_script) 우선, 없으면 평문 script. 가격 변수는 매핑하지 않아(값 미주입) 실가격이 노출되지 않는다. */}
{cardNodes ? (
<div className="mt-1.5">
<SlateRenderer
nodes={cardNodes}
variables={{
partner_name: currentSupplierName,
product_name: currentProduct?.name ?? '',
}}
/>
</div>
) : usedCard.script ? (
<Typography as="p" variant="small" className="mt-1.5 text-xs leading-relaxed whitespace-pre-line text-foreground/85">
{renderCardScriptPreview(usedCard.script)}
</Typography>
) : null}
{/* 와일드카드 부가 정보: 사용 조건 / 메모 */}
{isWildCard && (usedCard.condition || usedCard.memo) && (
<div className="mt-1.5 pt-1.5 border-t border-amber-200/60 dark:border-amber-900/40 space-y-0.5 text-muted-foreground">
@@ -6,7 +6,7 @@ import { LABEL_DEFAULTS, DEFAULT_VAT_MODE, type CompanySettings, type VatMode }
// 조회는 전 유저(브랜딩/라벨 렌더용), 저장은 백엔드가 OWNER 로 게이트한다.
export function useCompanySettings() {
const queryClient = useQueryClient();
const query = useGetSettings({ query: { staleTime: 5 * 60 * 1000 } });
const query = useGetSettings();
const settings: CompanySettings = (query.data?.settings as CompanySettings) ?? {};
const save = async (next: CompanySettings) => {
+16
View File
@@ -0,0 +1,16 @@
import {QueryClient} from '@tanstack/react-query';
// negodata 는 서버 응답을 캐시하지 않는다 — 화면에 뜨는 값은 항상 그 시점의 서버 값이다.
// (캐시를 두면 계정을 갈아탔을 때 앞 회사 CI·라벨·목록이 그대로 그려진다.)
// staleTime 0 = 받는 즉시 stale 로 보고 다시 읽는다, gcTime 0 = 화면에서 내려가면 바로 버린다.
// 페이지네이션 깜빡임은 각 훅의 placeholderData(keepPreviousData)가 막는다 — 캐시가 아니라 직전 렌더값이다.
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 0,
gcTime: 0,
retry: 1,
refetchOnWindowFocus: false,
},
},
});
+2 -1
View File
@@ -36,7 +36,8 @@
--color-ring: var(--ring);
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
--font-mono: "JetBrains Mono", Consolas, "Segoe UI Mono", ui-monospace, SFMono-Regular, "Menlo", monospace;
/* 모노 폰트엔 한글 글리프가 없다 — Pretendard 를 넣어야 한글이 OS 기본(Windows 굴림)으로 떨어지지 않는다 */
--font-mono: "JetBrains Mono", Consolas, "Segoe UI Mono", ui-monospace, SFMono-Regular, "Menlo", "Pretendard Variable", monospace;
}
:root {