From 044579c27fd8107c18c18cdc10d48c1352080934 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Thu, 15 Oct 2026 08:34:49 +0900 Subject: [PATCH 1/2] =?UTF-8?q?261015=5F02=5FENH:=20=EC=BB=A8=ED=83=9D=20?= =?UTF-8?q?=EC=A7=84=ED=96=89=20=ED=99=94=EB=A9=B4=20=EB=B0=9C=EC=86=A1=20?= =?UTF-8?q?=ED=98=84=ED=99=A9=20=EB=AA=A8=EB=B0=94=EC=9D=BC=20UI=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 (1M context) --- src/components/list-contact/CollapsibleHistorySection.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/list-contact/CollapsibleHistorySection.tsx b/src/components/list-contact/CollapsibleHistorySection.tsx index a3ad587..719c984 100644 --- a/src/components/list-contact/CollapsibleHistorySection.tsx +++ b/src/components/list-contact/CollapsibleHistorySection.tsx @@ -23,10 +23,11 @@ const CollapsibleHistorySection = ({ return (
-
+ {/* 제목과 headerExtra가 한 줄에 들어가지 않으면 headerExtra를 다음 줄 오른쪽으로 내린다. */} +
- {headerExtra} + {headerExtra ?
{headerExtra}
: null}
{open ?
{children}
: null}
-- 2.49.0.windows.1 From 4e51530922ee4eabe3e816807ee00f638f74c2d7 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Thu, 15 Oct 2026 08:36:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?261015=5F03=5FENH:=20CTI=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0=20=EB=81=8A=EA=B9=80=20=EC=9E=90=EB=8F=99=20=EB=B3=B5?= =?UTF-8?q?=EA=B5=AC(=EC=B5=9C=EB=8C=80=2015=EC=B4=88=20=EA=B0=84=EA=B2=A9?= =?UTF-8?q?=20=EC=9E=AC=EC=8B=9C=EB=8F=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 (1M context) --- src/const/ctiConst.ts | 6 ++++++ src/lib/cti/ctiClient.ts | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/const/ctiConst.ts b/src/const/ctiConst.ts index 19dda20..d2d05d8 100644 --- a/src/const/ctiConst.ts +++ b/src/const/ctiConst.ts @@ -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; + diff --git a/src/lib/cti/ctiClient.ts b/src/lib/cti/ctiClient.ts index 9fbf4bc..059a51b 100644 --- a/src/lib/cti/ctiClient.ts +++ b/src/lib/cti/ctiClient.ts @@ -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 | null = null; +let autoReconnectTimeoutId: ReturnType | null = null; +let autoReconnectAttempt = 0; let dialingTimeoutId: ReturnType | null = null; const lastErrorAlertAt = new Map(); @@ -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 }); } -- 2.49.0.windows.1