diff --git a/apps/desktop/src/components/editor-area/index.tsx b/apps/desktop/src/components/editor-area/index.tsx index b02238dc82..e10265a69f 100644 --- a/apps/desktop/src/components/editor-area/index.tsx +++ b/apps/desktop/src/components/editor-area/index.tsx @@ -199,11 +199,11 @@ export default function EditorArea({ const handleEnhanceWithTemplate = useCallback((templateId: string) => { const targetTemplateId = templateId === "auto" ? null : templateId; - enhance.mutate({ templateId: targetTemplateId, triggerType: "template" }); + enhance.mutate({ templateId: targetTemplateId }); }, [enhance]); const handleClickEnhance = useCallback(() => { - enhance.mutate({ triggerType: "manual" }); + enhance.mutate({}); }, [enhance]); const safelyFocusEditor = useCallback(() => { @@ -403,12 +403,10 @@ export function useEnhanceMutation({ const enhance = useMutation({ mutationKey: ["enhance", sessionId], mutationFn: async ({ - triggerType, templateId, }: { - triggerType: "manual" | "template" | "auto"; templateId?: string | null; - } = { triggerType: "manual" }) => { + }) => { setIsCancelled(false); originalContentRef.current = getCurrentEnhancedContent; const abortController = new AbortController(); diff --git a/apps/desktop/src/components/editor-area/note-header/listen-button.tsx b/apps/desktop/src/components/editor-area/note-header/listen-button.tsx index fa00962100..e6785acb47 100644 --- a/apps/desktop/src/components/editor-area/note-header/listen-button.tsx +++ b/apps/desktop/src/components/editor-area/note-header/listen-button.tsx @@ -1,12 +1,11 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { Trans } from "@lingui/react/macro"; -import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import { useMutation, useQuery } from "@tanstack/react-query"; import { CheckIcon, ChevronDownIcon, MicIcon, MicOffIcon, - PauseIcon, PlayIcon, StopCircleIcon, Volume2Icon, @@ -19,18 +18,12 @@ import { z } from "zod"; import SoundIndicator from "@/components/sound-indicator"; import { useHypr } from "@/contexts"; import { useEnhancePendingState } from "@/hooks/enhance-pending"; -import { TemplateService } from "@/utils/template-service"; -import { commands as analyticsCommands } from "@hypr/plugin-analytics"; import { commands as dbCommands } from "@hypr/plugin-db"; import { commands as listenerCommands } from "@hypr/plugin-listener"; import { commands as localSttCommands } from "@hypr/plugin-local-stt"; -import { commands as miscCommands } from "@hypr/plugin-misc"; import { Button } from "@hypr/ui/components/ui/button"; -import { Form, FormControl, FormField, FormItem, FormLabel } from "@hypr/ui/components/ui/form"; import { Popover, PopoverContent, PopoverTrigger } from "@hypr/ui/components/ui/popover"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@hypr/ui/components/ui/select"; import { Spinner } from "@hypr/ui/components/ui/spinner"; -import { Switch } from "@hypr/ui/components/ui/switch"; import { sonnerToast, toast } from "@hypr/ui/components/ui/toast"; import { Tooltip, TooltipContent, TooltipTrigger } from "@hypr/ui/components/ui/tooltip"; import { cn } from "@hypr/ui/lib/utils"; @@ -63,8 +56,6 @@ export default function ListenButton({ sessionId, isCompact = false }: { session const ongoingSessionId = useOngoingSession((s) => s.sessionId); const ongoingSessionStore = useOngoingSession((s) => ({ start: s.start, - resume: s.resume, - pause: s.pause, stop: s.stop, loading: s.loading, })); @@ -112,10 +103,6 @@ export default function ListenButton({ sessionId, isCompact = false }: { session } }; - const handleResumeSession = () => { - ongoingSessionStore.resume(); - }; - if (ongoingSessionStore.loading) { return (
@@ -124,24 +111,6 @@ export default function ListenButton({ sessionId, isCompact = false }: { session ); } - if (ongoingSessionStatus === "running_paused" && sessionId === ongoingSessionId) { - return ( - - ); - } - if (ongoingSessionStatus === "inactive") { const buttonProps = { disabled: isOnboarding @@ -267,23 +236,13 @@ function WhenInactiveAndMeetingEndedOnboarding({ disabled, onClick }: { disabled function WhenActive({ sessionId }: { sessionId: string }) { const ongoingSessionId = useOngoingSession((s) => s.sessionId); const ongoingSessionStore = useOngoingSession((s) => ({ - pause: s.pause, stop: s.stop, setAutoEnhanceTemplate: s.setAutoEnhanceTemplate, })); const sessionWords = useSession(ongoingSessionId!, (s) => s.session.words); const [isPopoverOpen, setIsPopoverOpen] = useState(false); - const handlePauseSession = () => { - ongoingSessionStore.pause(); - setIsPopoverOpen(false); - }; - - const handleStopSession = (templateId?: string | null) => { - if (templateId !== undefined) { - ongoingSessionStore.setAutoEnhanceTemplate(templateId); - } - + const handleStopSession = () => { ongoingSessionStore.stop(); setIsPopoverOpen(false); @@ -308,7 +267,6 @@ function WhenActive({ sessionId }: { sessionId: string }) { @@ -318,12 +276,10 @@ function WhenActive({ sessionId }: { sessionId: string }) { function RecordingControls({ sessionId, - onPause, onStop, }: { sessionId: string; - onPause: () => void; - onStop: (templateId?: string | null) => void; + onStop: () => void; }) { const { onboardingSessionId } = useHypr(); const ongoingSessionMuted = useOngoingSession((s) => ({ @@ -353,20 +309,7 @@ function RecordingControls({ />
-
- - -
+ ); } @@ -378,22 +321,7 @@ const stopButtonSchema = z.object({ type StopButtonFormData = z.infer; -function StopButton({ sessionId, onStop }: { sessionId: string; onStop: (templateId: string | null) => void }) { - const [isOpen, setIsOpen] = useState(false); - const { userId } = useHypr(); - - useEffect(() => { - if (isOpen) { - analyticsCommands.event({ - event: "stop_button_dropdown_opened", - distinct_id: userId, - session_id: sessionId, - }); - } - }, [isOpen]); - - const queryClient = useQueryClient(); - +function StopButton({ onStop }: { onStop: (templateId: string | null) => void }) { const defaultTemplateQuery = useQuery({ queryKey: ["config"], queryFn: () => dbCommands.getConfig().then((config) => config.general.selected_template_id), @@ -406,19 +334,6 @@ function StopButton({ sessionId, onStop }: { sessionId: string; onStop: (templat refetchOnWindowFocus: true, }); - const templatesQuery = useQuery({ - queryKey: ["templates"], - queryFn: () => - TemplateService.getAllTemplates().then((templates) => - templates.map((template) => { - const title = template.title || "Untitled"; - const truncatedTitle = title.length > 20 ? title.substring(0, 20) + "..." : title; - return { id: template.id, title: truncatedTitle }; - }) - ), - refetchOnWindowFocus: true, - }); - const form = useForm({ resolver: zodResolver(stopButtonSchema), defaultValues: { @@ -439,98 +354,18 @@ function StopButton({ sessionId, onStop }: { sessionId: string; onStop: (templat } }, [saveRecordingsQuery.data, form]); - const handleSubmit = (data: StopButtonFormData) => { - const actualTemplateId = data.selectedTemplate === "auto" ? null : data.selectedTemplate; - if (!data.saveAudio) { - miscCommands.audioDelete(sessionId); - } - onStop(actualTemplateId); - queryClient.invalidateQueries({ predicate: (query) => query.queryKey[0] === "audio" }); - }; - return ( - -
- - - - - -
- - - -
-
- ( - - - Save current recording - - - - - - )} - /> - -
- - ( - - - Template - - - - - - )} - /> -
- - - + ); } diff --git a/apps/desktop/src/components/left-sidebar/index.tsx b/apps/desktop/src/components/left-sidebar/index.tsx index a220525ea1..6cf332b771 100644 --- a/apps/desktop/src/components/left-sidebar/index.tsx +++ b/apps/desktop/src/components/left-sidebar/index.tsx @@ -34,7 +34,7 @@ export default function LeftSidebar() { const isInOngoingNoteMain = activeSessionId === ongoingSessionId; const isInOngoingNoteSub = activeSessionId === ongoingSessionId; const isInOngoingNote = isInOngoingNoteMain || isInOngoingNoteSub; - const isMeetingRunning = status === "running_active" || status === "running_paused"; + const isMeetingRunning = status === "running_active"; const inMeetingAndNotInNote = isMeetingRunning && ongoingSessionId !== null && !isInOngoingNote; diff --git a/apps/desktop/src/components/toast/ota.tsx b/apps/desktop/src/components/toast/ota.tsx index 5c1a0c620f..f08cd136d6 100644 --- a/apps/desktop/src/components/toast/ota.tsx +++ b/apps/desktop/src/components/toast/ota.tsx @@ -127,7 +127,7 @@ export default function OtaNotification() { } // Don't show update notifications during active meetings - if (ongoingSession.status === "running_active" || ongoingSession.status === "running_paused") { + if (ongoingSession.status === "running_active") { return; } diff --git a/apps/desktop/src/locales/en/messages.po b/apps/desktop/src/locales/en/messages.po index 667d50cc52..730deff57d 100644 --- a/apps/desktop/src/locales/en/messages.po +++ b/apps/desktop/src/locales/en/messages.po @@ -267,10 +267,9 @@ msgstr "(Optional)" #. placeholder {0}: disabled ? "Wait..." : "Play again" #. placeholder {0}: disabled ? "Wait..." : "Play video" #. placeholder {0}: disabled ? "Wait..." : isHovered ? (isCompact ? "Resume" : "Resume") : (isCompact ? "Ended" : "Ended") -#: src/components/editor-area/note-header/listen-button.tsx:140 -#: src/components/editor-area/note-header/listen-button.tsx:218 -#: src/components/editor-area/note-header/listen-button.tsx:242 -#: src/components/editor-area/note-header/listen-button.tsx:262 +#: src/components/editor-area/note-header/listen-button.tsx:187 +#: src/components/editor-area/note-header/listen-button.tsx:211 +#: src/components/editor-area/note-header/listen-button.tsx:231 #: src/components/settings/views/templates.tsx:252 msgid "{0}" msgstr "{0}" @@ -1231,9 +1230,9 @@ msgstr "No recent notes with this organization" #~ msgid "No Template" #~ msgstr "No Template" -#: src/components/editor-area/note-header/listen-button.tsx:517 -msgid "No Template (Default)" -msgstr "No Template (Default)" +#: src/components/editor-area/note-header/listen-button.tsx:473 +#~ msgid "No Template (Default)" +#~ msgstr "No Template (Default)" #: src/components/settings/views/templates.tsx:342 msgid "No templates yet" @@ -1321,8 +1320,8 @@ msgid "Owner" msgstr "Owner" #: src/components/editor-area/note-header/listen-button.tsx:363 -msgid "Pause" -msgstr "Pause" +#~ msgid "Pause" +#~ msgstr "Pause" #: src/components/share-and-permission/participants-selector.tsx:35 msgid "people" @@ -1428,9 +1427,9 @@ msgstr "Role" msgid "Save audio recording locally alongside the transcript." msgstr "Save audio recording locally alongside the transcript." -#: src/components/editor-area/note-header/listen-button.tsx:487 -msgid "Save current recording" -msgstr "Save current recording" +#: src/components/editor-area/note-header/listen-button.tsx:443 +#~ msgid "Save current recording" +#~ msgstr "Save current recording" #: src/components/editor-area/note-header/chips/event-chip.tsx:595 msgid "Save Date" @@ -1578,11 +1577,11 @@ msgstr "Start automatically at login" #~ msgid "Start Monthly Plan" #~ msgstr "Start Monthly Plan" -#: src/components/editor-area/note-header/listen-button.tsx:189 +#: src/components/editor-area/note-header/listen-button.tsx:158 msgid "Start recording" msgstr "Start recording" -#: src/components/editor-area/note-header/listen-button.tsx:464 +#: src/components/editor-area/note-header/listen-button.tsx:367 msgid "Stop" msgstr "Stop" @@ -1635,9 +1634,9 @@ msgstr "Team management features are currently under development and will be ava msgid "Teamspace" msgstr "Teamspace" -#: src/components/editor-area/note-header/listen-button.tsx:508 -msgid "Template" -msgstr "Template" +#: src/components/editor-area/note-header/listen-button.tsx:464 +#~ msgid "Template" +#~ msgstr "Template" #: src/routes/app.settings.tsx:52 #: src/routes/app.settings.tsx:106 diff --git a/apps/desktop/src/locales/ko/messages.po b/apps/desktop/src/locales/ko/messages.po index 9094c2ad03..85751234c0 100644 --- a/apps/desktop/src/locales/ko/messages.po +++ b/apps/desktop/src/locales/ko/messages.po @@ -267,10 +267,9 @@ msgstr "" #. placeholder {0}: disabled ? "Wait..." : "Play again" #. placeholder {0}: disabled ? "Wait..." : "Play video" #. placeholder {0}: disabled ? "Wait..." : isHovered ? (isCompact ? "Resume" : "Resume") : (isCompact ? "Ended" : "Ended") -#: src/components/editor-area/note-header/listen-button.tsx:140 -#: src/components/editor-area/note-header/listen-button.tsx:218 -#: src/components/editor-area/note-header/listen-button.tsx:242 -#: src/components/editor-area/note-header/listen-button.tsx:262 +#: src/components/editor-area/note-header/listen-button.tsx:187 +#: src/components/editor-area/note-header/listen-button.tsx:211 +#: src/components/editor-area/note-header/listen-button.tsx:231 #: src/components/settings/views/templates.tsx:252 msgid "{0}" msgstr "" @@ -1235,9 +1234,9 @@ msgstr "" #~ msgid "No Template" #~ msgstr "" -#: src/components/editor-area/note-header/listen-button.tsx:517 -msgid "No Template (Default)" -msgstr "" +#: src/components/editor-area/note-header/listen-button.tsx:473 +#~ msgid "No Template (Default)" +#~ msgstr "" #: src/components/settings/views/templates.tsx:342 msgid "No templates yet" @@ -1325,8 +1324,8 @@ msgid "Owner" msgstr "" #: src/components/editor-area/note-header/listen-button.tsx:363 -msgid "Pause" -msgstr "" +#~ msgid "Pause" +#~ msgstr "" #: src/components/share-and-permission/participants-selector.tsx:35 msgid "people" @@ -1432,9 +1431,9 @@ msgstr "" msgid "Save audio recording locally alongside the transcript." msgstr "" -#: src/components/editor-area/note-header/listen-button.tsx:487 -msgid "Save current recording" -msgstr "" +#: src/components/editor-area/note-header/listen-button.tsx:443 +#~ msgid "Save current recording" +#~ msgstr "" #: src/components/editor-area/note-header/chips/event-chip.tsx:595 msgid "Save Date" @@ -1582,11 +1581,11 @@ msgstr "" #~ msgid "Start Monthly Plan" #~ msgstr "" -#: src/components/editor-area/note-header/listen-button.tsx:189 +#: src/components/editor-area/note-header/listen-button.tsx:158 msgid "Start recording" msgstr "" -#: src/components/editor-area/note-header/listen-button.tsx:464 +#: src/components/editor-area/note-header/listen-button.tsx:367 msgid "Stop" msgstr "" @@ -1639,9 +1638,9 @@ msgstr "" msgid "Teamspace" msgstr "" -#: src/components/editor-area/note-header/listen-button.tsx:508 -msgid "Template" -msgstr "" +#: src/components/editor-area/note-header/listen-button.tsx:464 +#~ msgid "Template" +#~ msgstr "" #: src/routes/app.settings.tsx:52 #: src/routes/app.settings.tsx:106 diff --git a/apps/desktop/src/routes/app.control.tsx b/apps/desktop/src/routes/app.control.tsx index 1b0dbc4c67..3f412491cb 100644 --- a/apps/desktop/src/routes/app.control.tsx +++ b/apps/desktop/src/routes/app.control.tsx @@ -28,9 +28,7 @@ function Component() { micMuted, speakerMuted, isRecording, - isRecordingActive, toggleRecording, - pauseRecording, toggleMic, toggleSpeaker, } = useRecordingState(); @@ -97,10 +95,8 @@ function Component() { @@ -147,32 +143,15 @@ function AudioControls({ function RecordingControls({ isRecording, - isRecordingActive, recordingLoading, onToggleRecording, - onPauseRecording, }: { isRecording: boolean; - isRecordingActive: boolean; recordingLoading: boolean; onToggleRecording: () => void; - onPauseRecording: () => void; }) { return (
- {isRecording && ( - - {recordingLoading ? : isRecordingActive ? : } - - )} - ; } -function PauseIcon() { - return ( -
-
-
-
- ); -} - function IconButton({ onClick, children, @@ -466,14 +436,12 @@ function useFloatingPosition(toolbarRef: React.RefObject) { } function useRecordingState() { - const [recordingStatus, setRecordingStatus] = useState<"inactive" | "running_active" | "running_paused">("inactive"); + const [recordingStatus, setRecordingStatus] = useState<"inactive" | "running_active">("inactive"); const [recordingLoading, setRecordingLoading] = useState(false); const [micMuted, setMicMuted] = useState(false); const [speakerMuted, setSpeakerMuted] = useState(false); const isRecording = recordingStatus !== "inactive"; - const isRecordingActive = recordingStatus === "running_active"; - const isRecordingPaused = recordingStatus === "running_paused"; useEffect(() => { const initializeState = async () => { @@ -484,7 +452,7 @@ function useRecordingState() { listenerCommands.getSpeakerMuted(), ]); - if (["running_active", "running_paused", "inactive"].includes(currentState)) { + if (["running_active", "inactive"].includes(currentState)) { setRecordingStatus(currentState as any); } @@ -498,7 +466,7 @@ function useRecordingState() { initializeState(); const unsubscribeSession = listenerEvents.sessionEvent.listen(({ payload }) => { - if (["inactive", "running_active", "running_paused"].includes(payload.type)) { + if (["inactive", "running_active"].includes(payload.type)) { setRecordingStatus(payload.type as any); setRecordingLoading(false); } @@ -522,11 +490,7 @@ function useRecordingState() { setRecordingLoading(true); if (isRecording) { - if (isRecordingActive) { - await listenerCommands.stopSession(); - } else if (isRecordingPaused) { - await listenerCommands.resumeSession(); - } + await listenerCommands.stopSession(); } else { const newSessionId = `control-session-${Date.now()}`; await listenerCommands.startSession(newSessionId); @@ -538,19 +502,6 @@ function useRecordingState() { } }; - const pauseRecording = async () => { - try { - setRecordingLoading(true); - if (isRecordingActive) { - await listenerCommands.pauseSession(); - } - } catch (error) { - console.error("[Control Bar] Pause error:", error); - } finally { - setRecordingLoading(false); - } - }; - const toggleMic = async () => { try { const newMuted = !micMuted; @@ -579,10 +530,7 @@ function useRecordingState() { micMuted, speakerMuted, isRecording, - isRecordingActive, - isRecordingPaused, toggleRecording, - pauseRecording, toggleMic, toggleSpeaker, }; diff --git a/apps/desktop/src/routes/video.tsx b/apps/desktop/src/routes/video.tsx index e3374fb81d..8bed950e52 100644 --- a/apps/desktop/src/routes/video.tsx +++ b/apps/desktop/src/routes/video.tsx @@ -34,10 +34,6 @@ function Component() { let unlisten: () => void; listenerEvents.sessionEvent.listen(({ payload }) => { - if (payload.type === "running_paused") { - player.current?.pause(); - } - if (payload.type === "running_active") { player.current?.play(); diff --git a/packages/utils/src/stores/ongoing-session.ts b/packages/utils/src/stores/ongoing-session.ts index 1aadd6af2a..9fec7cb16f 100644 --- a/packages/utils/src/stores/ongoing-session.ts +++ b/packages/utils/src/stores/ongoing-session.ts @@ -8,7 +8,7 @@ type State = { sessionId: string | null; sessionEventUnlisten?: () => void; loading: boolean; - status: "inactive" | "running_active" | "running_paused"; + status: "inactive" | "running_active"; amplitude: { mic: number; speaker: number }; enhanceController: AbortController | null; micMuted: boolean; @@ -23,8 +23,6 @@ type Actions = { setAutoEnhanceTemplate: (templateId: string | null) => void; start: (sessionId: string) => void; stop: () => void; - pause: () => void; - resume: () => void; }; const initialState: State = { @@ -72,7 +70,6 @@ export const createOngoingSessionStore = ( ); }, start: (sessionId: string) => { - console.log("start", sessionId); set((state) => mutate(state, (draft) => { draft.sessionId = sessionId; @@ -83,8 +80,6 @@ export const createOngoingSessionStore = ( const sessionStore = sessionsStore.getState().sessions[sessionId]; const currentSession = sessionStore.getState().session; - sessionStore.getState().persistSession(undefined, true); - if (currentSession.raw_memo_html && currentSession.raw_memo_html != "

") { const preMeetingNote = currentSession.raw_memo_html; sessionStore.getState().updatePreMeetingNote(preMeetingNote); @@ -107,13 +102,6 @@ export const createOngoingSessionStore = ( draft.loading = false; }) ); - } else if (payload.type === "running_paused") { - set((state) => - mutate(state, (draft) => { - draft.status = "running_paused"; - draft.loading = false; - }) - ); } else if (payload.type === "inactive") { set((state) => mutate(state, (draft) => { @@ -183,62 +171,5 @@ export const createOngoingSessionStore = ( ); }); }, - pause: () => { - const { sessionId } = get(); - - set((state) => - mutate(state, (draft) => { - draft.loading = true; - }) - ); - - listenerCommands.pauseSession().then(() => { - set((state) => - mutate(state, (draft) => { - draft.status = "running_paused"; - draft.loading = false; - }) - ); - - // We need refresh since session in store is now stale. - // setTimeout is needed because of debounce. - setTimeout(() => { - if (sessionId) { - const sessionStore = sessionsStore.getState().sessions[sessionId]; - sessionStore.getState().refresh(); - } - }, 1500); - }).catch((error) => { - console.error("Failed to pause session:", error); - set((state) => - mutate(state, (draft) => { - draft.loading = false; - }) - ); - }); - }, - resume: () => { - set((state) => - mutate(state, (draft) => { - draft.loading = true; - }) - ); - - listenerCommands.resumeSession().then(() => { - set((state) => - mutate(state, (draft) => { - draft.status = "running_active"; - draft.loading = false; - }) - ); - }).catch((error) => { - console.error("Failed to resume session:", error); - set((state) => - mutate(state, (draft) => { - draft.loading = false; - }) - ); - }); - }, })); }; diff --git a/plugins/listener/build.rs b/plugins/listener/build.rs index d4b0b38521..810b6416f1 100644 --- a/plugins/listener/build.rs +++ b/plugins/listener/build.rs @@ -14,8 +14,6 @@ const COMMANDS: &[&str] = &[ "set_speaker_muted", "start_session", "stop_session", - "pause_session", - "resume_session", "get_state", ]; diff --git a/plugins/listener/js/bindings.gen.ts b/plugins/listener/js/bindings.gen.ts index 4eec90a85d..93a59f00b3 100644 --- a/plugins/listener/js/bindings.gen.ts +++ b/plugins/listener/js/bindings.gen.ts @@ -52,12 +52,6 @@ async startSession(sessionId: string) : Promise { async stopSession() : Promise { return await TAURI_INVOKE("plugin:listener|stop_session"); }, -async pauseSession() : Promise { - return await TAURI_INVOKE("plugin:listener|pause_session"); -}, -async resumeSession() : Promise { - return await TAURI_INVOKE("plugin:listener|resume_session"); -}, async getState() : Promise { return await TAURI_INVOKE("plugin:listener|get_state"); } @@ -78,7 +72,7 @@ sessionEvent: "plugin:listener:session-event" /** user-defined types **/ -export type SessionEvent = { type: "inactive" } | { type: "running_active" } | { type: "running_paused" } | { type: "finalWords"; words: Partial<{ [key in number]: Word2[] }> } | { type: "partialWords"; words: Partial<{ [key in number]: Word2[] }> } | { type: "audioAmplitude"; mic: number; speaker: number } | { type: "micMuted"; value: boolean } | { type: "speakerMuted"; value: boolean } +export type SessionEvent = { type: "inactive" } | { type: "running_active" } | { type: "finalWords"; words: Partial<{ [key in number]: Word2[] }> } | { type: "partialWords"; words: Partial<{ [key in number]: Word2[] }> } | { type: "audioAmplitude"; mic: number; speaker: number } | { type: "micMuted"; value: boolean } | { type: "speakerMuted"; value: boolean } export type SpeakerIdentity = { type: "unassigned"; value: { index: number } } | { type: "assigned"; value: { id: string; label: string } } export type Word2 = { text: string; speaker: SpeakerIdentity | null; confidence: number | null; start_ms: number | null; end_ms: number | null } diff --git a/plugins/listener/permissions/autogenerated/commands/pause_session.toml b/plugins/listener/permissions/autogenerated/commands/pause_session.toml deleted file mode 100644 index c5319eb0e6..0000000000 --- a/plugins/listener/permissions/autogenerated/commands/pause_session.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-pause-session" -description = "Enables the pause_session command without any pre-configured scope." -commands.allow = ["pause_session"] - -[[permission]] -identifier = "deny-pause-session" -description = "Denies the pause_session command without any pre-configured scope." -commands.deny = ["pause_session"] diff --git a/plugins/listener/permissions/autogenerated/commands/resume_session.toml b/plugins/listener/permissions/autogenerated/commands/resume_session.toml deleted file mode 100644 index d8bdb55327..0000000000 --- a/plugins/listener/permissions/autogenerated/commands/resume_session.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-resume-session" -description = "Enables the resume_session command without any pre-configured scope." -commands.allow = ["resume_session"] - -[[permission]] -identifier = "deny-resume-session" -description = "Denies the resume_session command without any pre-configured scope." -commands.deny = ["resume_session"] diff --git a/plugins/listener/permissions/autogenerated/reference.md b/plugins/listener/permissions/autogenerated/reference.md index a44206bf14..38d9579e61 100644 --- a/plugins/listener/permissions/autogenerated/reference.md +++ b/plugins/listener/permissions/autogenerated/reference.md @@ -15,8 +15,6 @@ Default permissions for the plugin - `allow-open-system-audio-access-settings` - `allow-start-session` - `allow-stop-session` -- `allow-pause-session` -- `allow-resume-session` - `allow-get-mic-muted` - `allow-set-mic-muted` - `allow-get-speaker-muted` @@ -295,32 +293,6 @@ Denies the open_system_audio_access_settings command without any pre-configured -`listener:allow-pause-session` - - - - -Enables the pause_session command without any pre-configured scope. - - - - - - - -`listener:deny-pause-session` - - - - -Denies the pause_session command without any pre-configured scope. - - - - - - - `listener:allow-request-microphone-access` @@ -373,32 +345,6 @@ Denies the request_system_audio_access command without any pre-configured scope. -`listener:allow-resume-session` - - - - -Enables the resume_session command without any pre-configured scope. - - - - - - - -`listener:deny-resume-session` - - - - -Denies the resume_session command without any pre-configured scope. - - - - - - - `listener:allow-set-mic-muted` diff --git a/plugins/listener/permissions/default.toml b/plugins/listener/permissions/default.toml index 010548327b..e46470fa04 100644 --- a/plugins/listener/permissions/default.toml +++ b/plugins/listener/permissions/default.toml @@ -12,8 +12,6 @@ permissions = [ "allow-open-system-audio-access-settings", "allow-start-session", "allow-stop-session", - "allow-pause-session", - "allow-resume-session", "allow-get-mic-muted", "allow-set-mic-muted", "allow-get-speaker-muted", diff --git a/plugins/listener/permissions/schemas/schema.json b/plugins/listener/permissions/schemas/schema.json index 4b10ef8e55..41fe9c5043 100644 --- a/plugins/listener/permissions/schemas/schema.json +++ b/plugins/listener/permissions/schemas/schema.json @@ -414,18 +414,6 @@ "const": "deny-open-system-audio-access-settings", "markdownDescription": "Denies the open_system_audio_access_settings command without any pre-configured scope." }, - { - "description": "Enables the pause_session command without any pre-configured scope.", - "type": "string", - "const": "allow-pause-session", - "markdownDescription": "Enables the pause_session command without any pre-configured scope." - }, - { - "description": "Denies the pause_session command without any pre-configured scope.", - "type": "string", - "const": "deny-pause-session", - "markdownDescription": "Denies the pause_session command without any pre-configured scope." - }, { "description": "Enables the request_microphone_access command without any pre-configured scope.", "type": "string", @@ -450,18 +438,6 @@ "const": "deny-request-system-audio-access", "markdownDescription": "Denies the request_system_audio_access command without any pre-configured scope." }, - { - "description": "Enables the resume_session command without any pre-configured scope.", - "type": "string", - "const": "allow-resume-session", - "markdownDescription": "Enables the resume_session command without any pre-configured scope." - }, - { - "description": "Denies the resume_session command without any pre-configured scope.", - "type": "string", - "const": "deny-resume-session", - "markdownDescription": "Denies the resume_session command without any pre-configured scope." - }, { "description": "Enables the set_mic_muted command without any pre-configured scope.", "type": "string", @@ -523,10 +499,10 @@ "markdownDescription": "Denies the stop_session command without any pre-configured scope." }, { - "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-list-microphone-devices`\n- `allow-get-current-microphone-device`\n- `allow-set-microphone-device`\n- `allow-check-microphone-access`\n- `allow-check-system-audio-access`\n- `allow-request-microphone-access`\n- `allow-request-system-audio-access`\n- `allow-open-microphone-access-settings`\n- `allow-open-system-audio-access-settings`\n- `allow-start-session`\n- `allow-stop-session`\n- `allow-pause-session`\n- `allow-resume-session`\n- `allow-get-mic-muted`\n- `allow-set-mic-muted`\n- `allow-get-speaker-muted`\n- `allow-set-speaker-muted`\n- `allow-get-state`", + "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-list-microphone-devices`\n- `allow-get-current-microphone-device`\n- `allow-set-microphone-device`\n- `allow-check-microphone-access`\n- `allow-check-system-audio-access`\n- `allow-request-microphone-access`\n- `allow-request-system-audio-access`\n- `allow-open-microphone-access-settings`\n- `allow-open-system-audio-access-settings`\n- `allow-start-session`\n- `allow-stop-session`\n- `allow-get-mic-muted`\n- `allow-set-mic-muted`\n- `allow-get-speaker-muted`\n- `allow-set-speaker-muted`\n- `allow-get-state`", "type": "string", "const": "default", - "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-list-microphone-devices`\n- `allow-get-current-microphone-device`\n- `allow-set-microphone-device`\n- `allow-check-microphone-access`\n- `allow-check-system-audio-access`\n- `allow-request-microphone-access`\n- `allow-request-system-audio-access`\n- `allow-open-microphone-access-settings`\n- `allow-open-system-audio-access-settings`\n- `allow-start-session`\n- `allow-stop-session`\n- `allow-pause-session`\n- `allow-resume-session`\n- `allow-get-mic-muted`\n- `allow-set-mic-muted`\n- `allow-get-speaker-muted`\n- `allow-set-speaker-muted`\n- `allow-get-state`" + "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-list-microphone-devices`\n- `allow-get-current-microphone-device`\n- `allow-set-microphone-device`\n- `allow-check-microphone-access`\n- `allow-check-system-audio-access`\n- `allow-request-microphone-access`\n- `allow-request-system-audio-access`\n- `allow-open-microphone-access-settings`\n- `allow-open-system-audio-access-settings`\n- `allow-start-session`\n- `allow-stop-session`\n- `allow-get-mic-muted`\n- `allow-set-mic-muted`\n- `allow-get-speaker-muted`\n- `allow-set-speaker-muted`\n- `allow-get-state`" } ] } diff --git a/plugins/listener/src/commands.rs b/plugins/listener/src/commands.rs index f6d4811dab..99435c4ad0 100644 --- a/plugins/listener/src/commands.rs +++ b/plugins/listener/src/commands.rs @@ -148,26 +148,6 @@ pub async fn stop_session(app: tauri::AppHandle) -> Result } } -#[tauri::command] -#[specta::specta] -pub async fn pause_session(app: tauri::AppHandle) -> Result<(), String> { - app.pause_session().await; - match app.get_state().await { - crate::fsm::State::RunningPaused { .. } => Ok(()), - _ => Err(crate::Error::PauseSessionFailed.to_string()), - } -} - -#[tauri::command] -#[specta::specta] -pub async fn resume_session(app: tauri::AppHandle) -> Result<(), String> { - app.resume_session().await; - match app.get_state().await { - crate::fsm::State::RunningActive { .. } => Ok(()), - _ => Err(crate::Error::ResumeSessionFailed.to_string()), - } -} - #[tauri::command] #[specta::specta] pub async fn get_state( diff --git a/plugins/listener/src/error.rs b/plugins/listener/src/error.rs index a8b77527f1..ec7c403970 100644 --- a/plugins/listener/src/error.rs +++ b/plugins/listener/src/error.rs @@ -22,10 +22,6 @@ pub enum Error { StartSessionFailed, #[error("stop session failed")] StopSessionFailed, - #[error("pause session failed")] - PauseSessionFailed, - #[error("resume session failed")] - ResumeSessionFailed, } impl Serialize for Error { diff --git a/plugins/listener/src/events.rs b/plugins/listener/src/events.rs index 005cad3b4d..30e8b436ac 100644 --- a/plugins/listener/src/events.rs +++ b/plugins/listener/src/events.rs @@ -15,8 +15,6 @@ common_event_derives! { Inactive {}, #[serde(rename = "running_active")] RunningActive {}, - #[serde(rename = "running_paused")] - RunningPaused {}, #[serde(rename = "finalWords")] FinalWords { words: HashMap>}, #[serde(rename = "partialWords")] diff --git a/plugins/listener/src/ext.rs b/plugins/listener/src/ext.rs index aaf6ab688b..6cfc3f74d7 100644 --- a/plugins/listener/src/ext.rs +++ b/plugins/listener/src/ext.rs @@ -33,8 +33,6 @@ pub trait ListenerPluginExt { fn get_state(&self) -> impl Future; fn stop_session(&self) -> impl Future; fn start_session(&self, id: impl Into) -> impl Future; - fn pause_session(&self) -> impl Future; - fn resume_session(&self) -> impl Future; } impl> ListenerPluginExt for T { @@ -246,26 +244,4 @@ impl> ListenerPluginExt for T { guard.fsm.handle(&event).await; } } - - #[tracing::instrument(skip_all)] - async fn pause_session(&self) { - let state = self.state::(); - - { - let mut guard = state.lock().await; - let event = crate::fsm::StateEvent::Pause; - guard.fsm.handle(&event).await; - } - } - - #[tracing::instrument(skip_all)] - async fn resume_session(&self) { - let state = self.state::(); - - { - let mut guard = state.lock().await; - let event = crate::fsm::StateEvent::Resume; - guard.fsm.handle(&event).await; - } - } } diff --git a/plugins/listener/src/fsm.rs b/plugins/listener/src/fsm.rs index b40f1eaa20..9998773010 100644 --- a/plugins/listener/src/fsm.rs +++ b/plugins/listener/src/fsm.rs @@ -241,8 +241,6 @@ impl Session { let (mic_muted_tx, mic_muted_rx_main) = tokio::sync::watch::channel(false); let (speaker_muted_tx, speaker_muted_rx_main) = tokio::sync::watch::channel(false); - let (session_state_tx, session_state_rx) = - tokio::sync::watch::channel(State::RunningActive {}); let (stop_tx, mut stop_rx) = tokio::sync::mpsc::channel::<()>(1); @@ -250,7 +248,6 @@ impl Session { self.mic_muted_rx = Some(mic_muted_rx_main.clone()); self.speaker_muted_tx = Some(speaker_muted_tx); self.speaker_muted_rx = Some(speaker_muted_rx_main.clone()); - self.session_state_tx = Some(session_state_tx); let listen_client = setup_listen_client(&self.app, languages, session_id == onboarding_session_id).await?; @@ -324,12 +321,6 @@ impl Session { } }; - if matches!(*session_state_rx.borrow(), State::RunningPaused {}) { - let mut rx = session_state_rx.clone(); - let _ = rx.changed().await; - continue; - } - let processed_mic = mic_chunk.clone(); let processed_speaker = speaker_chunk.clone(); @@ -546,7 +537,7 @@ impl Session { if let Some(state) = app.try_state::() { let mut guard = state.lock().await; - guard.fsm.handle(&crate::fsm::StateEvent::Pause).await; + guard.fsm.handle(&crate::fsm::StateEvent::Stop).await; } } } @@ -653,8 +644,6 @@ async fn update_session( pub enum StateEvent { Start(String), Stop, - Pause, - Resume, MicMuted(bool), SpeakerMuted(bool), MicChange(Option), @@ -709,24 +698,6 @@ impl Session { _ => Handled, }, StateEvent::Stop => Transition(State::inactive()), - StateEvent::Pause => Transition(State::running_paused()), - StateEvent::Resume => Handled, - _ => Super, - } - } - - #[state(superstate = "common")] - async fn running_paused(&mut self, event: &StateEvent) -> Response { - match event { - StateEvent::Start(incoming_session_id) => match &self.session_id { - Some(current_id) if current_id != incoming_session_id => { - Transition(State::inactive()) - } - _ => Handled, - }, - StateEvent::Stop => Transition(State::inactive()), - StateEvent::Pause => Handled, - StateEvent::Resume => Transition(State::running_active()), _ => Super, } } @@ -747,8 +718,6 @@ impl Session { } }, StateEvent::Stop => Handled, - StateEvent::Pause => Handled, - StateEvent::Resume => Handled, _ => Super, } } @@ -808,7 +777,6 @@ impl Session { match target { State::RunningActive {} => SessionEvent::RunningActive {}.emit(&self.app).unwrap(), - State::RunningPaused {} => SessionEvent::RunningPaused {}.emit(&self.app).unwrap(), State::Inactive {} => SessionEvent::Inactive {}.emit(&self.app).unwrap(), } @@ -826,7 +794,6 @@ impl serde::Serialize for State { match self { State::Inactive {} => serializer.serialize_str("inactive"), State::RunningActive {} => serializer.serialize_str("running_active"), - State::RunningPaused {} => serializer.serialize_str("running_paused"), } } } diff --git a/plugins/listener/src/lib.rs b/plugins/listener/src/lib.rs index fafd0d62ec..7cf5ae4d20 100644 --- a/plugins/listener/src/lib.rs +++ b/plugins/listener/src/lib.rs @@ -47,8 +47,6 @@ fn make_specta_builder() -> tauri_specta::Builder { commands::set_speaker_muted::, commands::start_session::, commands::stop_session::, - commands::pause_session::, - commands::resume_session::, commands::get_state::, ]) .events(tauri_specta::collect_events![SessionEvent]) diff --git a/plugins/notification/src/handler.rs b/plugins/notification/src/handler.rs index 869f5e2aaa..5afaa296c8 100644 --- a/plugins/notification/src/handler.rs +++ b/plugins/notification/src/handler.rs @@ -121,7 +121,7 @@ impl NotificationHandler { let app_handle = app_handle.clone(); tauri::async_runtime::spawn(async move { - app_handle.pause_session().await; + app_handle.stop_session().await; }); } _ => {}