From 957decc1f7a2a9df54325737a819551286a859fe Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Tue, 23 Dec 2025 14:02:55 +0700 Subject: [PATCH] Trim dictation toasts to failures --- .../app/src/components/agent-input-area.tsx | 57 --------------- .../app/src/components/create-agent-modal.tsx | 71 ------------------- 2 files changed, 128 deletions(-) diff --git a/packages/app/src/components/agent-input-area.tsx b/packages/app/src/components/agent-input-area.tsx index 2c6651e32..47784fb4f 100644 --- a/packages/app/src/components/agent-input-area.tsx +++ b/packages/app/src/components/agent-input-area.tsx @@ -144,7 +144,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) { const [connectionStatus, setConnectionStatus] = useState(() => wsOrInert.getConnectionState ? wsOrInert.getConnectionState() : { isConnected: wsOrInert.isConnected, isConnecting: wsOrInert.isConnecting } ); - const [lastSuccessToastAt, setLastSuccessToastAt] = useState(null); const textInputRef = useRef unknown }) | null>(null); const inputHeightRef = useRef(MIN_INPUT_HEIGHT); @@ -228,7 +227,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) { retryAttempt: dictationRetryAttempt, maxRetryAttempts: dictationMaxRetryAttempts, retryInfo: dictationRetryInfo, - lastOutcome: dictationLastOutcome, startDictation, cancelDictation, confirmDictation, @@ -260,26 +258,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) { }); }, [wsOrInert]); - useEffect(() => { - if (dictationLastOutcome?.type === "success") { - setLastSuccessToastAt(dictationLastOutcome.timestamp); - } - }, [dictationLastOutcome]); - - useEffect(() => { - if (lastSuccessToastAt === null) { - return; - } - const timeout = setTimeout(() => { - setLastSuccessToastAt(null); - }, 4000); - return () => { - clearTimeout(timeout); - }; - }, [lastSuccessToastAt]); - - const successToastVisible = lastSuccessToastAt !== null; - const handleRetryFailedRecording = useCallback(() => { void retryFailedDictation(); }, [retryFailedDictation]); @@ -296,31 +274,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) { hasWs: !!ws, }); - if (!connectionStatus.isConnected) { - return { - variant: "warning", - title: "Offline", - subtitle: "Waiting for connection…", - }; - } - - if (dictationStatus === "recording") { - return { - variant: "info", - title: "Recording voice note…", - subtitle: "Release to transcribe", - }; - } - - if (dictationStatus === "uploading") { - const attemptLabel = `Attempt ${Math.max(1, dictationRetryAttempt || 1)}/${dictationMaxRetryAttempts}`; - return { - variant: "info", - title: "Transcribing…", - meta: attemptLabel, - }; - } - if (dictationStatus === "retrying") { const attempt = dictationRetryInfo?.attempt ?? Math.max(1, dictationRetryAttempt || 1); const maxAttempts = dictationRetryInfo?.maxAttempts ?? dictationMaxRetryAttempts; @@ -347,17 +300,8 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) { }; } - if (successToastVisible) { - return { - variant: "success", - title: "Transcribed", - subtitle: "Added to chat", - }; - } - return null; }, [ - connectionStatus.isConnected, dictationError, dictationMaxRetryAttempts, dictationRetryAttempt, @@ -365,7 +309,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) { dictationStatus, handleDiscardFailedRecording, handleRetryFailedRecording, - successToastVisible, ]); useEffect(() => { diff --git a/packages/app/src/components/create-agent-modal.tsx b/packages/app/src/components/create-agent-modal.tsx index 29b05db02..19d799628 100644 --- a/packages/app/src/components/create-agent-modal.tsx +++ b/packages/app/src/components/create-agent-modal.tsx @@ -458,12 +458,6 @@ function AgentFlowModal({ const [openDropdown, setOpenDropdown] = useState(null); const pendingRequestIdRef = useRef(null); const shouldSyncBaseBranchRef = useRef(true); - const [connectionStatus, setConnectionStatus] = useState(() => - effectiveWs.getConnectionState - ? effectiveWs.getConnectionState() - : { isConnected: effectiveWs.isConnected, isConnecting: effectiveWs.isConnecting } - ); - const [dictationSuccessToastAt, setDictationSuccessToastAt] = useState(null); const promptInputRef = useRef< TextInput | (TextInput & { getNativeRef?: () => unknown }) | null >(null); @@ -537,7 +531,6 @@ function AgentFlowModal({ maxRetryAttempts: dictationMaxRetryAttempts, retryInfo: dictationRetryInfo, failedRecording: dictationFailedRecording, - lastOutcome: dictationLastOutcome, startDictation, cancelDictation, confirmDictation, @@ -561,35 +554,6 @@ function AgentFlowModal({ dictationRequestIdRef.current = dictationPendingRequestId; }, [dictationPendingRequestId]); - useEffect(() => { - if (!effectiveWs.subscribeConnectionStatus) { - return; - } - return effectiveWs.subscribeConnectionStatus((status) => { - setConnectionStatus(status); - }); - }, [effectiveWs]); - - useEffect(() => { - if (dictationLastOutcome?.type === "success") { - setDictationSuccessToastAt(dictationLastOutcome.timestamp); - } - }, [dictationLastOutcome]); - - useEffect(() => { - if (dictationSuccessToastAt === null) { - return; - } - const timeout = setTimeout(() => { - setDictationSuccessToastAt(null); - }, 4000); - return () => { - clearTimeout(timeout); - }; - }, [dictationSuccessToastAt]); - - const dictationSuccessToastVisible = dictationSuccessToastAt !== null; - const hasPendingCreateOrResume = pendingRequestIdRef.current !== null; const hasPendingDictation = dictationPendingRequestId !== null; const shouldListenForStatus = isVisible || hasPendingCreateOrResume; @@ -1228,31 +1192,6 @@ function AgentFlowModal({ }, [discardFailedDictation]); const promptDictationToast = useMemo(() => { - if (!connectionStatus.isConnected) { - return { - variant: "warning", - title: "Offline", - subtitle: "Waiting for connection…", - }; - } - - if (dictationStatus === "recording") { - return { - variant: "info", - title: "Recording prompt…", - subtitle: "Release to insert transcription", - }; - } - - if (dictationStatus === "uploading") { - const attemptLabel = `Attempt ${Math.max(1, dictationRetryAttempt || 1)}/${dictationMaxRetryAttempts}`; - return { - variant: "info", - title: "Transcribing prompt…", - meta: attemptLabel, - }; - } - if (dictationStatus === "retrying") { const attempt = dictationRetryInfo?.attempt ?? Math.max(1, dictationRetryAttempt || 1); const maxAttempts = dictationRetryInfo?.maxAttempts ?? dictationMaxRetryAttempts; @@ -1279,23 +1218,13 @@ function AgentFlowModal({ }; } - if (dictationSuccessToastVisible) { - return { - variant: "success", - title: "Transcribed", - subtitle: "Inserted into prompt", - }; - } - return null; }, [ - connectionStatus.isConnected, dictationError, dictationMaxRetryAttempts, dictationRetryAttempt, dictationRetryInfo, dictationStatus, - dictationSuccessToastVisible, handlePromptDictationDiscard, handlePromptDictationRetry, ]);