Trim dictation toasts to failures
This commit is contained in:
@@ -144,7 +144,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) {
|
|||||||
const [connectionStatus, setConnectionStatus] = useState(() =>
|
const [connectionStatus, setConnectionStatus] = useState(() =>
|
||||||
wsOrInert.getConnectionState ? wsOrInert.getConnectionState() : { isConnected: wsOrInert.isConnected, isConnecting: wsOrInert.isConnecting }
|
wsOrInert.getConnectionState ? wsOrInert.getConnectionState() : { isConnected: wsOrInert.isConnected, isConnecting: wsOrInert.isConnecting }
|
||||||
);
|
);
|
||||||
const [lastSuccessToastAt, setLastSuccessToastAt] = useState<number | null>(null);
|
|
||||||
|
|
||||||
const textInputRef = useRef<TextInput | (TextInput & { getNativeRef?: () => unknown }) | null>(null);
|
const textInputRef = useRef<TextInput | (TextInput & { getNativeRef?: () => unknown }) | null>(null);
|
||||||
const inputHeightRef = useRef(MIN_INPUT_HEIGHT);
|
const inputHeightRef = useRef(MIN_INPUT_HEIGHT);
|
||||||
@@ -228,7 +227,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) {
|
|||||||
retryAttempt: dictationRetryAttempt,
|
retryAttempt: dictationRetryAttempt,
|
||||||
maxRetryAttempts: dictationMaxRetryAttempts,
|
maxRetryAttempts: dictationMaxRetryAttempts,
|
||||||
retryInfo: dictationRetryInfo,
|
retryInfo: dictationRetryInfo,
|
||||||
lastOutcome: dictationLastOutcome,
|
|
||||||
startDictation,
|
startDictation,
|
||||||
cancelDictation,
|
cancelDictation,
|
||||||
confirmDictation,
|
confirmDictation,
|
||||||
@@ -260,26 +258,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) {
|
|||||||
});
|
});
|
||||||
}, [wsOrInert]);
|
}, [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(() => {
|
const handleRetryFailedRecording = useCallback(() => {
|
||||||
void retryFailedDictation();
|
void retryFailedDictation();
|
||||||
}, [retryFailedDictation]);
|
}, [retryFailedDictation]);
|
||||||
@@ -296,31 +274,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) {
|
|||||||
hasWs: !!ws,
|
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") {
|
if (dictationStatus === "retrying") {
|
||||||
const attempt = dictationRetryInfo?.attempt ?? Math.max(1, dictationRetryAttempt || 1);
|
const attempt = dictationRetryInfo?.attempt ?? Math.max(1, dictationRetryAttempt || 1);
|
||||||
const maxAttempts = dictationRetryInfo?.maxAttempts ?? dictationMaxRetryAttempts;
|
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;
|
return null;
|
||||||
}, [
|
}, [
|
||||||
connectionStatus.isConnected,
|
|
||||||
dictationError,
|
dictationError,
|
||||||
dictationMaxRetryAttempts,
|
dictationMaxRetryAttempts,
|
||||||
dictationRetryAttempt,
|
dictationRetryAttempt,
|
||||||
@@ -365,7 +309,6 @@ export function AgentInputArea({ agentId, serverId }: AgentInputAreaProps) {
|
|||||||
dictationStatus,
|
dictationStatus,
|
||||||
handleDiscardFailedRecording,
|
handleDiscardFailedRecording,
|
||||||
handleRetryFailedRecording,
|
handleRetryFailedRecording,
|
||||||
successToastVisible,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -458,12 +458,6 @@ function AgentFlowModal({
|
|||||||
const [openDropdown, setOpenDropdown] = useState<DropdownKey | null>(null);
|
const [openDropdown, setOpenDropdown] = useState<DropdownKey | null>(null);
|
||||||
const pendingRequestIdRef = useRef<string | null>(null);
|
const pendingRequestIdRef = useRef<string | null>(null);
|
||||||
const shouldSyncBaseBranchRef = useRef(true);
|
const shouldSyncBaseBranchRef = useRef(true);
|
||||||
const [connectionStatus, setConnectionStatus] = useState(() =>
|
|
||||||
effectiveWs.getConnectionState
|
|
||||||
? effectiveWs.getConnectionState()
|
|
||||||
: { isConnected: effectiveWs.isConnected, isConnecting: effectiveWs.isConnecting }
|
|
||||||
);
|
|
||||||
const [dictationSuccessToastAt, setDictationSuccessToastAt] = useState<number | null>(null);
|
|
||||||
const promptInputRef = useRef<
|
const promptInputRef = useRef<
|
||||||
TextInput | (TextInput & { getNativeRef?: () => unknown }) | null
|
TextInput | (TextInput & { getNativeRef?: () => unknown }) | null
|
||||||
>(null);
|
>(null);
|
||||||
@@ -537,7 +531,6 @@ function AgentFlowModal({
|
|||||||
maxRetryAttempts: dictationMaxRetryAttempts,
|
maxRetryAttempts: dictationMaxRetryAttempts,
|
||||||
retryInfo: dictationRetryInfo,
|
retryInfo: dictationRetryInfo,
|
||||||
failedRecording: dictationFailedRecording,
|
failedRecording: dictationFailedRecording,
|
||||||
lastOutcome: dictationLastOutcome,
|
|
||||||
startDictation,
|
startDictation,
|
||||||
cancelDictation,
|
cancelDictation,
|
||||||
confirmDictation,
|
confirmDictation,
|
||||||
@@ -561,35 +554,6 @@ function AgentFlowModal({
|
|||||||
dictationRequestIdRef.current = dictationPendingRequestId;
|
dictationRequestIdRef.current = dictationPendingRequestId;
|
||||||
}, [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 hasPendingCreateOrResume = pendingRequestIdRef.current !== null;
|
||||||
const hasPendingDictation = dictationPendingRequestId !== null;
|
const hasPendingDictation = dictationPendingRequestId !== null;
|
||||||
const shouldListenForStatus = isVisible || hasPendingCreateOrResume;
|
const shouldListenForStatus = isVisible || hasPendingCreateOrResume;
|
||||||
@@ -1228,31 +1192,6 @@ function AgentFlowModal({
|
|||||||
}, [discardFailedDictation]);
|
}, [discardFailedDictation]);
|
||||||
|
|
||||||
const promptDictationToast = useMemo<DictationToastConfig | null>(() => {
|
const promptDictationToast = useMemo<DictationToastConfig | null>(() => {
|
||||||
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") {
|
if (dictationStatus === "retrying") {
|
||||||
const attempt = dictationRetryInfo?.attempt ?? Math.max(1, dictationRetryAttempt || 1);
|
const attempt = dictationRetryInfo?.attempt ?? Math.max(1, dictationRetryAttempt || 1);
|
||||||
const maxAttempts = dictationRetryInfo?.maxAttempts ?? dictationMaxRetryAttempts;
|
const maxAttempts = dictationRetryInfo?.maxAttempts ?? dictationMaxRetryAttempts;
|
||||||
@@ -1279,23 +1218,13 @@ function AgentFlowModal({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dictationSuccessToastVisible) {
|
|
||||||
return {
|
|
||||||
variant: "success",
|
|
||||||
title: "Transcribed",
|
|
||||||
subtitle: "Inserted into prompt",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}, [
|
}, [
|
||||||
connectionStatus.isConnected,
|
|
||||||
dictationError,
|
dictationError,
|
||||||
dictationMaxRetryAttempts,
|
dictationMaxRetryAttempts,
|
||||||
dictationRetryAttempt,
|
dictationRetryAttempt,
|
||||||
dictationRetryInfo,
|
dictationRetryInfo,
|
||||||
dictationStatus,
|
dictationStatus,
|
||||||
dictationSuccessToastVisible,
|
|
||||||
handlePromptDictationDiscard,
|
handlePromptDictationDiscard,
|
||||||
handlePromptDictationRetry,
|
handlePromptDictationRetry,
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user