260812_03_ENH: cti관련 수정 및 리스트 배정 페이지에서 목록에 대한 필터와 건수 위치 뒤집음

This commit is contained in:
2026-08-12 16:38:20 +09:00
parent e9bb02820c
commit 8cd0f5bd53
2 changed files with 53 additions and 10 deletions

View File

@@ -124,6 +124,12 @@ export function AssignTargetList({
return (
<div className="flex h-[78vh] flex-col border border-gray-200 rounded-lg overflow-hidden bg-white shadow-sm">
{summary ? (
<div className="shrink-0 border-b border-gray-200 bg-gray-50 px-3 py-1 text-lg font-semibold text-gray-700">
전체 {summary.totalCount}건 · 미배정 {summary.unassignedCount}건
</div>
) : null}
{canFilterByCmpn ? (
<div className="shrink-0 border-b border-gray-200 p-2">
<KriMultiSelect
@@ -139,12 +145,6 @@ export function AssignTargetList({
</div>
) : null}
{summary ? (
<div className="shrink-0 border-b border-gray-200 bg-gray-50 px-3 py-1 text-lg font-semibold text-gray-700">
전체 {summary.totalCount}건 · 미배정 {summary.unassignedCount}건
</div>
) : null}
<div className="flex-1 overflow-y-auto">
<table className="w-full table-fixed">
<colgroup>

View File

@@ -1,5 +1,6 @@
import { clientEnv } from "@/lib/env.client";
import { nextApi } from "@/lib/http-client";
import { HttpError } from "@kri/common/http";
import { CTI_AGENT_GROUP, CTI_ON_CALL_STATUSES } from "@/const/ctiConst";
import type {
ListCallCloseRequest,
@@ -250,6 +251,9 @@ const restoreCtiState = (agentLoginId: string) => {
return true;
};
const fetchCallHistBySession = (agentSessionId: string) =>
nextApi.get<ListCallHist>(`/list-call-hist/session/${encodeURIComponent(agentSessionId)}`);
const recoverLastCallHistId = async (agentLoginId: string) => {
const targetCall =
activeCall?.agentSessionId ? activeCall :
@@ -259,11 +263,40 @@ const recoverLastCallHistId = async (agentLoginId: string) => {
const agentSessionId = targetCall.agentSessionId;
const callContext = targetCall.context;
let result: ListCallHist;
try {
const result = await nextApi.get<ListCallHist>(
`/list-call-hist/session/${encodeURIComponent(agentSessionId)}`,
);
result = await fetchCallHistBySession(agentSessionId);
} catch (firstError) {
// call-start 저장(PUT)이 아직 커밋되기 전에 재연결 복구용 조회가 먼저 도착하는 레이스가 있을 수 있어,
// 바로 포기하지 않고 짧게 대기 후 한 번 더 시도한다.
await new Promise((resolve) => setTimeout(resolve, 1000));
try {
result = await fetchCallHistBySession(agentSessionId);
} catch (secondError) {
console.warn("[CTI][TEMP_LOG] failed to recover call history after retry", {
agentSessionId,
firstError,
secondError,
}); // TEMP_CTI_LOG
// 재시도까지 404(진짜로 존재하지 않는 세션)로 확인된 경우에만 phantom 상태를 정리한다.
// 다른 오류(네트워크 문제 등)는 통화가 실제로 살아있을 수 있으니 그대로 둔다.
const isConfirmedNotFound = secondError instanceof HttpError && secondError.status === 404;
if (isConfirmedNotFound && currentAgentLoginId === agentLoginId) {
if (closingCall?.agentSessionId === agentSessionId) {
closingCall = null;
} else if (activeCall?.agentSessionId === agentSessionId) {
activeCall = null;
agentStatus = null;
}
persistCtiState();
notify();
}
return;
}
}
try {
const isSameCall =
currentAgentLoginId === agentLoginId &&
(activeCall?.agentSessionId === agentSessionId ||
@@ -484,11 +517,21 @@ const handleIncomingMessage = (raw: unknown) => {
const eventAgentSessionId = String(parsed.AgntSessionID ?? "");
const isClosingCall =
eventAgentSessionId !== "" && eventAgentSessionId === closingCall?.agentSessionId;
// saveCallHistory가 activeCall/closingCall에서 컨텍스트를 동기적으로 먼저 읽어가므로,
// 아래에서 activeCall을 비우기 전에 반드시 먼저 호출해야 한다(순서 변경 금지).
saveCallHistory(parsed, "close");
if (!isClosingCall) {
callClosedReceived = true;
setAgentStatus(null);
// CallClosed는 통화가 끝났다는 CTI 서버의 확정 신호이므로, 이력 저장(백엔드 API) 성공 여부와
// 무관하게 로컬 상태는 즉시 비운다. 저장이 실패해도 이 처리를 기다리다 UI가 "통화 중"에
// 멈춰있으면 안 된다. 세션ID가 일치할 때만 비워서, 그 사이 새 통화가 시작된 경우를 보호한다.
if (eventAgentSessionId !== "" && activeCall?.agentSessionId === eventAgentSessionId) {
activeCall = null;
persistCtiState();
notify();
}
}
saveCallHistory(parsed, "close");
break;
}
default: