From 0196d332d534f704f2d9fc45fe4aa6c403092368 Mon Sep 17 00:00:00 2001 From: Hoan HL Date: Fri, 3 Apr 2026 14:01:54 +0700 Subject: [PATCH] allow configuration for noise isolation and fix UI layout issue --- src/common/types.ts | 4 ++ src/window/app.tsx | 12 ++-- src/window/history/recent.tsx | 2 - src/window/phone/index.tsx | 93 +++++++++++++++-------------- src/window/settings/accountForm.tsx | 50 ++++++++++++++++ 5 files changed, 110 insertions(+), 51 deletions(-) diff --git a/src/common/types.ts b/src/common/types.ts index e2561d2..49c02a5 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -62,6 +62,10 @@ export interface AppSettings { accountSid?: string; apiKey?: string; apiServer?: string; + + noiseIsolationVendor?: string; + noiseIsolationLevel?: number; + noiseIsolationModel?: string; } export interface IAppSettings { diff --git a/src/window/app.tsx b/src/window/app.tsx index 78a7800..0aca0cf 100644 --- a/src/window/app.tsx +++ b/src/window/app.tsx @@ -110,16 +110,20 @@ export const WindowApp = () => { setCallHistories(getCallHistories(sipUsername)); }; return ( - - + + - + {tabsSettings.map((s, i) => ( { ))} - + {tabsSettings.map((s, i) => ( {s.content} ))} diff --git a/src/window/history/recent.tsx b/src/window/history/recent.tsx index 36ecae8..c067bc0 100644 --- a/src/window/history/recent.tsx +++ b/src/window/history/recent.tsx @@ -41,8 +41,6 @@ export const Recents = ({ {callHistories.length > 0 ? ( diff --git a/src/window/phone/index.tsx b/src/window/phone/index.tsx index f39ba12..259c7dd 100644 --- a/src/window/phone/index.tsx +++ b/src/window/phone/index.tsx @@ -528,7 +528,14 @@ export const Phone = ({ activeCall.disableNoiseIsolation(); setIsNoiseIsolation(false); } else { - activeCall.enableNoiseIsolation(); + const settings = advancedSettings?.decoded; + activeCall.enableNoiseIsolation({ + vendor: settings?.noiseIsolationVendor || "krisp", + level: settings?.noiseIsolationLevel ?? 0.3, + ...(settings?.noiseIsolationModel + ? { model: settings.noiseIsolationModel } + : {}), + }); setIsNoiseIsolation(true); } } @@ -817,51 +824,20 @@ export const Phone = ({ Call ) : ( - - - - - } - w="33%" - variant="unstyled" - display="flex" - alignItems="center" - justifyContent="center" - onClick={handleCallOnHold} - /> - - - + + } - w="70px" - h="70px" - borderRadius="100%" - colorScheme="jambonz" - onClick={handleHangup} + aria-label="Place call onhold" + icon={ + + } + variant="unstyled" + display="flex" + alignItems="center" + justifyContent="center" + onClick={handleCallOnHold} /> - - - - } - w="33%" - variant="unstyled" - display="flex" - alignItems="center" - justifyContent="center" - onClick={handleCallMute} - /> - - + {isSipClientAnswered(callState) && ( )} - + + + } + w="70px" + h="70px" + borderRadius="100%" + colorScheme="jambonz" + onClick={handleHangup} + /> + + + + } + variant="unstyled" + display="flex" + alignItems="center" + justifyContent="center" + onClick={handleCallMute} + /> + + )} )} diff --git a/src/window/settings/accountForm.tsx b/src/window/settings/accountForm.tsx index ff9ffb2..6f69671 100644 --- a/src/window/settings/accountForm.tsx +++ b/src/window/settings/accountForm.tsx @@ -48,6 +48,9 @@ function AccountForm({ const [accountSid, setAccountSid] = useState(""); const [isCredentialOk, setIsCredentialOk] = useState(false); const [isAdvancedMode, setIsAdvancedMode] = useState(false); + const [noiseIsolationVendor, setNoiseIsolationVendor] = useState("krisp"); + const [noiseIsolationLevel, setNoiseIsolationLevel] = useState("0.3"); + const [noiseIsolationModel, setNoiseIsolationModel] = useState(""); const toast = useToast(); useEffect( @@ -62,6 +65,13 @@ function AccountForm({ setAccountSid(formData.decoded.accountSid); setApiKey(formData.decoded.apiKey || ""); setApiServer(formData.decoded.apiServer); + setNoiseIsolationVendor(formData.decoded.noiseIsolationVendor || "krisp"); + setNoiseIsolationLevel( + formData.decoded.noiseIsolationLevel !== undefined + ? String(formData.decoded.noiseIsolationLevel) + : "0.3" + ); + setNoiseIsolationModel(formData.decoded.noiseIsolationModel || ""); if ( formData.decoded.accountSid || @@ -101,6 +111,9 @@ function AccountForm({ accountSid, apiKey, apiServer: apiServer ? normalizeUrl(apiServer) : "", + noiseIsolationVendor: noiseIsolationVendor || "krisp", + noiseIsolationLevel: parseFloat(noiseIsolationLevel) || 0.3, + noiseIsolationModel: noiseIsolationModel || undefined, }; formData ? editSettings(settings, formData.id) : saveSettings(settings); @@ -146,6 +159,9 @@ function AccountForm({ setApiServer(""); setAccountSid(""); setIsAdvancedMode(false); + setNoiseIsolationVendor("krisp"); + setNoiseIsolationLevel("0.3"); + setNoiseIsolationModel(""); if (formData) { handleClose && handleClose(); @@ -282,6 +298,40 @@ function AccountForm({ )} )} + + + Noise Isolation + + + Vendor + setNoiseIsolationVendor(e.target.value)} + /> + + + Level + setNoiseIsolationLevel(e.target.value)} + /> + + + Model (Optional) + setNoiseIsolationModel(e.target.value)} + /> + )}