Merge pull request '261015_02_ENH: 컨택 진행 화면 발송 현황 모바일 UI 개선' (#52) from develop into master

Reviewed-on: #52
This commit is contained in:
2026-10-15 08:37:09 +09:00
3 changed files with 49 additions and 3 deletions

View File

@@ -23,10 +23,11 @@ const CollapsibleHistorySection = ({
return (
<div className={`space-y-2 ${showDivider ? 'border-t pt-3' : ''}`}>
<div className="flex w-full items-center justify-between gap-2">
{/* 제목과 headerExtra가 한 줄에 들어가지 않으면 headerExtra를 다음 줄 오른쪽으로 내린다. */}
<div className="flex w-full flex-wrap items-center justify-between gap-2">
<button
type="button"
className="flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-semibold cursor-pointer"
className="flex min-w-0 flex-auto items-center gap-2 whitespace-nowrap text-left text-sm font-semibold cursor-pointer"
aria-expanded={open}
aria-controls={contentId}
onClick={() => setOpen((prev) => !prev)}
@@ -34,7 +35,7 @@ const CollapsibleHistorySection = ({
{open ? <ChevronDown className="h-4 w-4" /> : <ChevronRight className="h-4 w-4" />}
{title}
</button>
{headerExtra}
{headerExtra ? <div className="ml-auto">{headerExtra}</div> : null}
</div>
{open ? <div id={contentId}>{children}</div> : null}
</div>

View File

@@ -20,3 +20,9 @@ export const CTI_DIALING_TIMEOUT_MS = 30 * 1000;
// 처리하지 않는 오류(ZCommand에 Error 포함) alert를 같은 ZCommand에 대해 다시 띄우기까지의 최소 간격
export const CTI_ERROR_ALERT_THROTTLE_MS = 10 * 1000;
// 예상치 못한 소켓 끊김(onclose) 시 자동 재연결 간격. 1초부터 2배씩 늘려 최대 15초까지 무제한 재시도하며,
// 서버 재시작 시 동시 접속이 몰리지 않도록 매번 0~1초 jitter를 더한다.
export const CTI_AUTO_RECONNECT_BASE_MS = 1000;
export const CTI_AUTO_RECONNECT_MAX_MS = 15 * 1000;
export const CTI_AUTO_RECONNECT_JITTER_MS = 1000;

View File

@@ -3,6 +3,9 @@ import { nextApi } from "@/lib/http-client";
import { HttpError } from "@kri/common/http";
import {
CTI_AGENT_GROUP,
CTI_AUTO_RECONNECT_BASE_MS,
CTI_AUTO_RECONNECT_JITTER_MS,
CTI_AUTO_RECONNECT_MAX_MS,
CTI_DIALING_TIMEOUT_MS,
CTI_ERROR_ALERT_THROTTLE_MS,
CTI_ON_CALL_STATUSES,
@@ -96,6 +99,8 @@ let lastCallHistId: number | null = null;
let hangupRequested = false;
let callClosedReceived = false;
let reconnectIntervalId: ReturnType<typeof setInterval> | null = null;
let autoReconnectTimeoutId: ReturnType<typeof setTimeout> | null = null;
let autoReconnectAttempt = 0;
let dialingTimeoutId: ReturnType<typeof setTimeout> | null = null;
const lastErrorAlertAt = new Map<string, number>();
@@ -395,6 +400,32 @@ const stopReconnectLoop = () => {
console.log("[CTI][TEMP_LOG] reconnect loop stopped, agentStatus =", agentStatus); // TEMP_CTI_LOG
};
const clearAutoReconnect = () => {
if (autoReconnectTimeoutId === null) return;
clearTimeout(autoReconnectTimeoutId);
autoReconnectTimeoutId = null;
};
// 예상치 못한 소켓 끊김(onclose) 시 새로고침과 같은 connectAndLogin 경로로 다시 연결한다.
// 상태 복원과 통화 이력 복구(recoverLastCallHistId)도 함께 수행된다.
// HangUp 재연결 루프가 돌고 있으면 그 루프에 맡긴다.
const scheduleAutoReconnect = () => {
if (!currentLoginParams || reconnectIntervalId !== null || autoReconnectTimeoutId !== null) return;
const delay =
Math.min(CTI_AUTO_RECONNECT_BASE_MS * 2 ** autoReconnectAttempt, CTI_AUTO_RECONNECT_MAX_MS) +
Math.random() * CTI_AUTO_RECONNECT_JITTER_MS;
autoReconnectAttempt += 1;
console.log("[CTI][TEMP_LOG] auto reconnect scheduled, attempt =", autoReconnectAttempt, "delay =", Math.round(delay)); // TEMP_CTI_LOG
autoReconnectTimeoutId = setTimeout(() => {
autoReconnectTimeoutId = null;
const params = currentLoginParams;
if (!params || reconnectIntervalId !== null) return;
connectAndLogin(params);
}, delay);
};
const setAgentStatus = (next: string | null) => {
agentStatus = next;
if (next !== null && next !== "0") {
@@ -668,6 +699,8 @@ const logout = () => {
hangupRequested = false;
callClosedReceived = false;
stopReconnectLoop();
clearAutoReconnect();
autoReconnectAttempt = 0;
clearDialingTimeout();
setAgentStatus(null);
setLastCallHistId(null);
@@ -682,6 +715,7 @@ const openSocketAndLogin = (params: CtiLoginParams) => {
socket = ws;
ws.onopen = () => {
autoReconnectAttempt = 0;
setConnectionState("open");
sendLogin(params);
};
@@ -698,6 +732,8 @@ const openSocketAndLogin = (params: CtiLoginParams) => {
ws.onclose = (event) => {
setConnectionState("closed");
console.log("[CTI][TEMP_LOG] websocket closed, code =", event.code, "reason =", event.reason, "wasClean =", event.wasClean); // TEMP_CTI_LOG
// 의도적인 종료(teardownSocket)는 핸들러를 먼저 떼므로 여기에 오지 않는다.
scheduleAutoReconnect();
};
};
@@ -747,6 +783,8 @@ const connectAndLogin = (params: CtiLoginParams) => {
return;
}
clearAutoReconnect();
if (currentAgentLoginId && currentAgentLoginId !== params.agentLoginId) {
console.log("[CTI][TEMP_LOG] switching agent from", currentAgentLoginId, "to", params.agentLoginId); // TEMP_CTI_LOG
logout();
@@ -769,6 +807,7 @@ const connectAndLogin = (params: CtiLoginParams) => {
const suspendForPageHide = () => {
if (!currentLoginParams) return;
stopReconnectLoop();
clearAutoReconnect();
if (currentAgentLoginId && connectionState === "open" && !isCallInProgress()) {
send({ ZCommand: "Logout", AgentLoginID: currentAgentLoginId });
}