Skip to content

Commit 6ce157d

Browse files
authored
Skip enhance for short meeting (#707)
1 parent bacdcf0 commit 6ce157d

File tree

1 file changed

+25
-11
lines changed
  • apps/desktop/src/components/editor-area

1 file changed

+25
-11
lines changed

apps/desktop/src/components/editor-area/index.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { toast } from "@hypr/ui/components/ui/toast";
12
import { useMutation } from "@tanstack/react-query";
23
import usePreviousValue from "beautiful-react-hooks/usePreviousValue";
34
import { motion } from "motion/react";
@@ -163,16 +164,29 @@ export function useEnhanceMutation({
163164
const enhance = useMutation({
164165
mutationKey: ["enhance", sessionId],
165166
mutationFn: async () => {
166-
const { type } = await connectorCommands.getLlmConnection();
167-
168-
const config = await dbCommands.getConfig();
169-
const participants = await dbCommands.sessionListParticipants(sessionId);
170-
171167
const fn = sessionId === onboardingSessionId
172168
? dbCommands.getTimelineViewOnboarding
173169
: dbCommands.getTimelineView;
170+
174171
const timeline = await fn(sessionId);
175172

173+
if (!timeline?.items.length) {
174+
toast({
175+
id: "short-timeline",
176+
title: "Enhancing Skipped",
177+
content: "The conversation is too short to enhance",
178+
dismissible: true,
179+
duration: 15000,
180+
});
181+
182+
return;
183+
}
184+
185+
const { type } = await connectorCommands.getLlmConnection();
186+
187+
const config = await dbCommands.getConfig();
188+
const participants = await dbCommands.sessionListParticipants(sessionId);
189+
176190
const systemMessage = await templateCommands.render(
177191
"enhance.system",
178192
{ config, type },
@@ -189,17 +203,17 @@ export function useEnhanceMutation({
189203
);
190204

191205
const abortController = new AbortController();
192-
const timeoutSignal = AbortSignal.timeout(60 * 1000);
193-
const combinedSignal = AbortSignal.any([abortController.signal, timeoutSignal]);
206+
const abortSignal = AbortSignal.any([abortController.signal, AbortSignal.timeout(60 * 1000)]);
194207
setEnhanceController(abortController);
195208

196209
const provider = await modelProvider();
210+
const model = sessionId === onboardingSessionId
211+
? provider.languageModel("onboardingModel")
212+
: provider.languageModel("defaultModel");
197213

198214
const { text, textStream } = streamText({
199-
abortSignal: combinedSignal,
200-
model: sessionId === onboardingSessionId
201-
? provider.languageModel("onboardingModel")
202-
: provider.languageModel("defaultModel"),
215+
abortSignal,
216+
model,
203217
messages: [
204218
{ role: "system", content: systemMessage },
205219
{ role: "user", content: userMessage },

0 commit comments

Comments
 (0)