Remove hard timeouts and fallback paths in chat flow
This commit is contained in:
@@ -361,7 +361,6 @@ let pilotWaveRecordPlugin: any = null;
|
||||
let pilotWaveMicSession: { onDestroy: () => void; onEnd: () => void } | null = null;
|
||||
const commCallWaveHosts = new Map<string, HTMLDivElement>();
|
||||
const commCallWaveSurfers = new Map<string, any>();
|
||||
const FALLBACK_CALL_AUDIO_URL = "/audio-samples/national-road-9.m4a";
|
||||
const callTranscriptOpen = ref<Record<string, boolean>>({});
|
||||
const callTranscriptLoading = ref<Record<string, boolean>>({});
|
||||
const callTranscriptText = ref<Record<string, string>>({});
|
||||
@@ -731,23 +730,15 @@ async function sendPilotText(rawText: string) {
|
||||
const text = rawText.trim();
|
||||
if (!text || pilotSending.value) return;
|
||||
|
||||
const sendTimeoutMs = 45000;
|
||||
pilotSending.value = true;
|
||||
pilotInput.value = "";
|
||||
livePilotUserText.value = text;
|
||||
livePilotAssistantText.value = "";
|
||||
pilotLiveLogs.value = [];
|
||||
try {
|
||||
await Promise.race([
|
||||
pilotChat.sendMessage({ text }),
|
||||
new Promise((_, reject) => {
|
||||
setTimeout(() => reject(new Error("pilot_send_timeout")), sendTimeoutMs);
|
||||
}),
|
||||
]);
|
||||
} catch (error: any) {
|
||||
if (error?.message !== "pilot_send_timeout") {
|
||||
pilotInput.value = text;
|
||||
}
|
||||
await pilotChat.sendMessage({ text });
|
||||
} catch {
|
||||
pilotInput.value = text;
|
||||
} finally {
|
||||
const latestAssistant = [...pilotChat.messages]
|
||||
.reverse()
|
||||
@@ -840,8 +831,7 @@ function buildCallWavePeaks(item: CommItem, size = 320) {
|
||||
}
|
||||
|
||||
function getCallAudioUrl(item?: CommItem) {
|
||||
const direct = String(item?.audioUrl ?? "").trim();
|
||||
return direct || FALLBACK_CALL_AUDIO_URL;
|
||||
return String(item?.audioUrl ?? "").trim();
|
||||
}
|
||||
|
||||
async function ensureCommCallWave(itemId: string) {
|
||||
@@ -1688,7 +1678,7 @@ const selectedCommThread = computed(() =>
|
||||
commThreads.value.find((thread) => thread.id === selectedCommThreadId.value),
|
||||
);
|
||||
|
||||
const commSendChannel = ref<CommItem["channel"]>("Telegram");
|
||||
const commSendChannel = ref<CommItem["channel"] | "">("");
|
||||
const commPinnedOnly = ref(false);
|
||||
const commDraft = ref("");
|
||||
const commSending = ref(false);
|
||||
@@ -1735,14 +1725,14 @@ watch(selectedCommThreadId, () => {
|
||||
eventArchiveRecordingById.value = {};
|
||||
eventArchiveTranscribingById.value = {};
|
||||
eventArchiveMicErrorById.value = {};
|
||||
const fallback = selectedCommThread.value?.channels.find((channel) => channel !== "Phone") ?? "Telegram";
|
||||
commSendChannel.value = fallback;
|
||||
const preferred = selectedCommThread.value?.channels.find((channel) => channel !== "Phone") ?? "";
|
||||
commSendChannel.value = preferred;
|
||||
});
|
||||
|
||||
const commSendChannelOptions = computed<CommItem["channel"][]>(() => {
|
||||
if (!selectedCommThread.value) return ["Telegram"];
|
||||
if (!selectedCommThread.value) return [];
|
||||
const items = selectedCommThread.value.channels.filter((channel) => channel !== "Phone");
|
||||
return items.length ? items : ["Telegram"];
|
||||
return items;
|
||||
});
|
||||
|
||||
const visibleThreadItems = computed(() => {
|
||||
@@ -2468,8 +2458,8 @@ async function sendCommMessage() {
|
||||
|
||||
commSending.value = true;
|
||||
try {
|
||||
const fallback = selectedCommThread.value.channels.find((channel) => channel !== "Phone") ?? "Telegram";
|
||||
const channel = commSendChannel.value || fallback;
|
||||
const channel = commSendChannel.value;
|
||||
if (!channel) return;
|
||||
|
||||
await gqlFetch<{ createCommunication: { ok: boolean; id: string } }>(createCommunicationMutation, {
|
||||
input: {
|
||||
@@ -3758,7 +3748,7 @@ async function decideFeedCard(card: FeedCard, decision: "accepted" | "rejected")
|
||||
:disabled="commSending"
|
||||
:title="`Channel: ${commSendChannel}`"
|
||||
>
|
||||
<span class="mr-1">{{ commSendChannel }}</span>
|
||||
<span class="mr-1">{{ commSendChannel || "Channel" }}</span>
|
||||
<svg viewBox="0 0 20 20" class="h-3.5 w-3.5 fill-current">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" />
|
||||
</svg>
|
||||
@@ -3799,7 +3789,7 @@ async function decideFeedCard(card: FeedCard, decision: "accepted" | "rejected")
|
||||
|
||||
<button
|
||||
class="btn btn-sm btn-circle border-0 bg-[#5865f2] text-white hover:bg-[#4752c4]"
|
||||
:disabled="commSending || commEventSaving || !commDraft.trim()"
|
||||
:disabled="commSending || commEventSaving || !commDraft.trim() || (commComposerMode === 'message' && !commSendChannel)"
|
||||
:title="commComposerMode === 'message' ? `Send via ${commSendChannel}` : (commComposerMode === 'logged' ? 'Save log event' : 'Create event')"
|
||||
@click="commComposerMode === 'message' ? sendCommMessage() : createCommEvent()"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user