Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,27 @@ async function startApp() {
}
}

const translationHotkeyCallback = () => {
windowManager.sendToggleTranslation();
};
windowManager._translationHotkeyCallback = translationHotkeyCallback;

const savedTranslationKey = environmentManager.getTranslationKey?.() || "";
if (savedTranslationKey) {
const result = await hotkeyManager.registerSlot(
"translation",
savedTranslationKey,
translationHotkeyCallback
);
if (!result.success) {
debugLogger.warn(
"Failed to restore translation hotkey",
{ hotkey: savedTranslationKey },
"hotkey"
);
}
}

// Set up meeting mode hotkey
const meetingHotkeyCallback = () => {
if (hotkeyManager.isInListeningMode()) return;
Expand Down Expand Up @@ -1105,13 +1126,19 @@ async function startApp() {
const voiceAgentUsesGlobe = hotkeyManager
.getSlotHotkeys("voiceAgent")
.some(isGlobeLikeHotkey);
const translationUsesGlobe = hotkeyManager
.getSlotHotkeys("translation")
.some(isGlobeLikeHotkey);
if (agentUsesGlobe) {
windowManager.toggleAgentOverlay();
}
if (voiceAgentUsesGlobe) {
windowManager.sendToggleVoiceAgent();
}
if (!agentUsesGlobe && !voiceAgentUsesGlobe && !dictationUsesGlobe) {
if (translationUsesGlobe) {
windowManager.sendToggleTranslation();
}
if (!agentUsesGlobe && !voiceAgentUsesGlobe && !translationUsesGlobe && !dictationUsesGlobe) {
debugLogger?.debug("[Globe] Ignored — hotkey is not GLOBE", { currentHotkey });
}
});
Expand Down Expand Up @@ -1161,6 +1188,9 @@ async function startApp() {
if (hotkeyManager.slotHasHotkey("voiceAgent", modifier)) {
windowManager.sendToggleVoiceAgent();
}
if (hotkeyManager.slotHasHotkey("translation", modifier)) {
windowManager.sendToggleTranslation();
}

if (!hotkeyManager.slotHasHotkey("dictation", modifier)) return;
if (!isLiveWindow(windowManager.mainWindow)) return;
Expand Down Expand Up @@ -1219,7 +1249,7 @@ async function startApp() {

const syncSuppressedMouseButtons = () => {
const buttons = [];
for (const slotName of ["dictation", "agent", "voiceAgent"]) {
for (const slotName of ["dictation", "agent", "voiceAgent", "translation"]) {
for (const hotkey of hotkeyManager.getSlotHotkeys(slotName)) {
if (isMouseButtonHotkey(hotkey)) buttons.push(hotkey);
}
Expand All @@ -1243,6 +1273,9 @@ async function startApp() {
if (hotkeyManager.slotHasHotkey("voiceAgent", button)) {
windowManager.sendToggleVoiceAgent();
}
if (hotkeyManager.slotHasHotkey("translation", button)) {
windowManager.sendToggleTranslation();
}

if (!hotkeyManager.slotHasHotkey("dictation", button)) return;
if (!isLiveWindow(windowManager.mainWindow)) return;
Expand Down Expand Up @@ -1368,6 +1401,8 @@ async function startApp() {
}
if (hotkeyManager.slotHasHotkey("voiceAgent", key)) {
windowManager.sendToggleVoiceAgent();
} else if (hotkeyManager.slotHasHotkey("translation", key)) {
windowManager.sendToggleTranslation();
} else if (hotkeyManager.slotHasHotkey("agent", key)) {
if (!hotkeyManager.isInListeningMode()) windowManager.toggleAgentOverlay();
} else if (hotkeyManager.slotHasHotkey("meeting", key)) {
Expand Down
9 changes: 7 additions & 2 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ contextBridge.exposeInMainWorld("electronAPI", {
showDictationPanel: () => ipcRenderer.invoke("show-dictation-panel"),
onToggleDictation: registerListener("toggle-dictation", (callback) => () => callback()),
onToggleVoiceAgent: registerListener("toggle-voice-agent", (callback) => () => callback()),
onToggleTranslation: registerListener("toggle-translation", (callback) => () => callback()),
onStartDictation: registerListener("start-dictation", (callback) => () => callback()),
onStopDictation: registerListener("stop-dictation", (callback) => () => callback()),

Expand All @@ -70,8 +71,10 @@ contextBridge.exposeInMainWorld("electronAPI", {
getAudioStorageUsage: () => ipcRenderer.invoke("get-audio-storage-usage"),
deleteAllAudio: () => ipcRenderer.invoke("delete-all-audio"),
retryTranscription: (id, settings) => ipcRenderer.invoke("retry-transcription", id, settings),
updateTranscriptionText: (id, text, rawText) =>
ipcRenderer.invoke("update-transcription-text", id, text, rawText),
updateTranscriptionText: (id, text, rawText, cleanupLevel) =>
ipcRenderer.invoke("update-transcription-text", id, text, rawText, cleanupLevel),
setTranscriptionAiEditApplied: (id, applied) =>
ipcRenderer.invoke("set-transcription-ai-edit-applied", id, applied),
getTranscriptionById: (id) => ipcRenderer.invoke("get-transcription-by-id", id),

// Dictionary functions
Expand Down Expand Up @@ -737,7 +740,9 @@ contextBridge.exposeInMainWorld("electronAPI", {
// Agent mode
updateAgentHotkey: (hotkey) => ipcRenderer.invoke("update-agent-hotkey", hotkey),
updateVoiceAgentHotkey: (hotkey) => ipcRenderer.invoke("update-voice-agent-hotkey", hotkey),
updateTranslationHotkey: (hotkey) => ipcRenderer.invoke("update-translation-hotkey", hotkey),
getVoiceAgentKey: () => ipcRenderer.invoke("get-voice-agent-key"),
getTranslationKey: () => ipcRenderer.invoke("get-translation-key"),
getAgentKey: () => ipcRenderer.invoke("get-agent-key"),
saveAgentKey: (key) => ipcRenderer.invoke("save-agent-key", key),
onAgentStartRecording: registerListener("agent-start-recording", (callback) => () => callback()),
Expand Down
69 changes: 68 additions & 1 deletion src/components/ControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
clearPendingInvitationToken,
} from "../utils/pendingInvitationToken";
import { WORKSPACES_ENABLED } from "../lib/features";
import { reprocessTranscript } from "../utils/reprocessTranscript";

const platform = getCachedPlatform();

Expand Down Expand Up @@ -533,7 +534,8 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
const updated = await window.electronAPI.updateTranscriptionText(
id,
reasonedText,
rawText
rawText,
s.cleanupLevel === "none" ? null : s.cleanupLevel
);
if (updated.success && updated.transcription) {
finalTranscription = updated.transcription;
Expand Down Expand Up @@ -570,6 +572,69 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
[toast, t, useCleanupModel]
);

const setTranscriptionAiEditApplied = useCallback(
async (id: number, applied: boolean) => {
try {
const result = await window.electronAPI.setTranscriptionAiEditApplied(id, applied);
if (result.success && result.transcription) {
updateInStore(result.transcription);
return;
}
throw new Error(result.error || "AI edit state was not updated");
} catch {
toast({
title: t("controlPanel.history.aiEditToggleErrorTitle"),
description: t("controlPanel.history.aiEditToggleErrorDescription"),
variant: "destructive",
});
}
},
[toast, t]
);

const reprocessTranscription = useCallback(
async (id: number, rawText: string) => {
try {
const [{ default: ReasoningService }, settingsModule] = await Promise.all([
import("../services/ReasoningService"),
import("../stores/settingsStore"),
]);
const settings = settingsModule.getSettings();
const model = settingsModule.getEffectiveCleanupModel();
const isCloud = settingsModule.isCloudCleanupMode();

if (!settings.useCleanupModel || (!model && !isCloud)) {
throw new Error(t("controlPanel.history.reprocessUnavailable"));
}

const transcription = await reprocessTranscript({
rawText,
process: (text) =>
ReasoningService.processText(text, model, localStorage.getItem("agentName"), {
disableThinking: settings.cleanupDisableThinking,
}),
persist: (processedText, sourceText) =>
window.electronAPI.updateTranscriptionText(
id,
processedText,
sourceText,
settings.cleanupLevel === "none" ? null : settings.cleanupLevel
),
});

updateInStore(transcription);
toast({ title: t("controlPanel.history.reprocessSuccess") });
} catch (error) {
toast({
title: t("controlPanel.history.reprocessError"),
description: error instanceof Error ? error.message : undefined,
variant: "destructive",
});
}
},
[t, toast]
);

const toggleShowDiscarded = useCallback(() => {
loadTranscriptions(!showDiscarded);
}, [loadTranscriptions, showDiscarded]);
Expand Down Expand Up @@ -896,6 +961,8 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
clearAllTranscriptions={clearAllTranscriptions}
onShowAudioInFolder={showAudioInFolder}
onRetryTranscription={retryTranscription}
onSetAiEditApplied={setTranscriptionAiEditApplied}
onReprocessTranscription={useCleanupModel ? reprocessTranscription : undefined}
showDiscarded={showDiscarded}
onToggleDiscarded={toggleShowDiscarded}
onOpenSettings={(section) => {
Expand Down
6 changes: 6 additions & 0 deletions src/components/HistoryView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ interface HistoryViewProps {
onOpenSettings: (section?: string) => void;
onShowAudioInFolder: (id: number) => void;
onRetryTranscription: (id: number, options?: { isRecover?: boolean }) => Promise<void>;
onSetAiEditApplied: (id: number, applied: boolean) => Promise<void>;
onReprocessTranscription?: (id: number, rawText: string) => Promise<void>;
showDiscarded: boolean;
onToggleDiscarded: () => void;
}
Expand All @@ -45,6 +47,8 @@ export default function HistoryView({
onOpenSettings,
onShowAudioInFolder,
onRetryTranscription,
onSetAiEditApplied,
onReprocessTranscription,
showDiscarded,
onToggleDiscarded,
}: HistoryViewProps) {
Expand Down Expand Up @@ -325,6 +329,8 @@ export default function HistoryView({
onDelete={deleteTranscription}
onShowAudioInFolder={onShowAudioInFolder}
onRetryTranscription={onRetryTranscription}
onSetAiEditApplied={onSetAiEditApplied}
onReprocessTranscription={onReprocessTranscription}
onOpenSettings={() => onOpenSettings("transcription")}
/>
))}
Expand Down
Loading
Loading