Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

feat(freeflow): rework (B) to hold-Option-to-talk per human decision

Chaitanya Giribf9ca890d5d4
diff --git a/src/main/config.ts b/src/main/config.ts
index f2142958..5b12a8a4 100644
--- a/src/main/config.ts
+++ b/src/main/config.ts
@@ -164,9 +164,6 @@ export interface HarnessConfig {
groqApiKey?: string;
/** Groq Whisper model id. Default 'whisper-large-v3-turbo' (fast, multilingual). */
freeflowModel?: string;
- /** Electron accelerator for the global push-to-talk TOGGLE hotkey (entry point
- * B). Registered only while Free Flow is enabled. Default 'Control+Alt+D'. */
- freeflowHotkey?: string;
// ─── Generic inbound webhook + status API ──────────────────────────────────
/** Master toggle for the generic webhook HTTP API (POST → work, GET → status). */
@@ -212,7 +209,6 @@ const DEFAULTS: HarnessConfig = {
freeflowEnabled: false,
groqApiKey: undefined,
freeflowModel: 'whisper-large-v3-turbo',
- freeflowHotkey: 'Control+Alt+D',
webhookEnabled: false,
webhookSecret: undefined,
webhookPort: undefined,
diff --git a/src/main/index.ts b/src/main/index.ts
index 06e675b7..dcf01d26 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -1,4 +1,4 @@
-import { app, BrowserWindow, clipboard, dialog, globalShortcut, ipcMain, powerSaveBlocker, screen, shell, Notification } from 'electron';
+import { app, BrowserWindow, clipboard, dialog, ipcMain, powerSaveBlocker, screen, shell, Notification } from 'electron';
import { spawn } from 'node:child_process';
import { rmSync, existsSync, readFileSync, readdirSync, statSync, cpSync, writeFileSync, unlinkSync } from 'node:fs';
import { randomBytes, createHash, timingSafeEqual } from 'node:crypto';
@@ -1620,49 +1620,19 @@ ipcMain.handle('webhook:setConfig', (_evt, patch: unknown) => {
});
// ─── IPC: Free Flow (voice dictation → message queue) ────────────────────────
-/** The global push-to-talk hotkey currently registered with the OS, or null when
- * Free Flow is disabled / has no hotkey. Tracked so we unregister exactly ours. */
-let freeflowHotkey: string | null = null;
-
-/** Register (or re-register) the global push-to-talk TOGGLE hotkey from config.
- * Only registers while Free Flow is enabled and a hotkey is set; on trigger it
- * pushes `freeflow:hotkey` to the renderer, which toggles recording for the
- * focused agent. NOTE: Electron globalShortcut can't capture the macOS Fn key
- * (electron#16714) nor a bare modifier, so this is a real accelerator toggle —
- * the documented v1 fallback for the native-Fn gesture. Best-effort: a failed or
- * already-taken accelerator is logged, never fatal. */
-function reconcileFreeflowHotkey(): void {
- // Tear down whatever we previously held.
- if (freeflowHotkey) {
- try { globalShortcut.unregister(freeflowHotkey); } catch { /* noop */ }
- freeflowHotkey = null;
- }
- const cfg = readConfig();
- if (!cfg.freeflowEnabled) return;
- const accel = (cfg.freeflowHotkey ?? '').trim();
- if (!accel) return;
- try {
- const ok = globalShortcut.register(accel, () => {
- try { liveWebContents()?.send('freeflow:hotkey'); } catch { /* window gone */ }
- });
- if (ok) freeflowHotkey = accel;
- else console.error('[freeflow] hotkey already in use or invalid:', accel);
- } catch (e) {
- console.error('[freeflow] could not register hotkey', accel, '-', e instanceof Error ? e.message : e);
- }
-}
+// Entry point B is hold-Option-to-talk, handled entirely in the renderer
+// (capture-phase key listeners) — no globalShortcut here. macOS doesn't deliver
+// the Fn key to Electron (electron#16714) and a faithful native Fn helper
+// (CGEventTap) is deferred; hold-Option is the human-chosen v1 activation.
ipcMain.handle('freeflow:setConfig', (_evt, patch: unknown) => {
- const p = (patch ?? {}) as { enabled?: unknown; apiKey?: unknown; model?: unknown; hotkey?: unknown };
+ const p = (patch ?? {}) as { enabled?: unknown; apiKey?: unknown; model?: unknown };
const next: Partial<HarnessConfig> = {};
if (typeof p.enabled === 'boolean') next.freeflowEnabled = p.enabled;
- // Trim string fields; an emptied key/hotkey clears back to undefined.
+ // Trim string fields; an emptied key clears back to undefined.
if (typeof p.apiKey === 'string') next.groqApiKey = p.apiKey.trim() || undefined;
if (typeof p.model === 'string') next.freeflowModel = p.model.trim() || DEFAULT_GROQ_MODEL;
- if (typeof p.hotkey === 'string') next.freeflowHotkey = p.hotkey.trim() || undefined;
writeConfig(next);
- // Re-arm (or tear down) the global hotkey to match the new state.
- reconcileFreeflowHotkey();
return { ok: true };
});
@@ -1749,8 +1719,6 @@ app.whenReady().then(() => {
else console.log('[webhook] listening', r.url ? `(tunnel: ${r.url})` : '(no tunnel)');
});
}
- // Arm the Free Flow global push-to-talk hotkey when enabled (entry point B).
- reconcileFreeflowHotkey();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
@@ -1775,9 +1743,3 @@ app.on('window-all-closed', () => {
app.quit();
}
});
-
-// Release the Free Flow global hotkey on quit so it never lingers past the app.
-app.on('will-quit', () => {
- try { globalShortcut.unregisterAll(); } catch { /* noop */ }
- freeflowHotkey = null;
-});
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 16409e79..bd2c3e90 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -162,12 +162,11 @@ export interface HarnessConfig {
webhookEnabled?: boolean;
webhookSecret?: string;
webhookPort?: number;
- /** Free Flow voice dictation — master flag (default off), user Groq key, model,
- * and the global push-to-talk hotkey accelerator. */
+ /** Free Flow voice dictation — master flag (default off), user Groq key, model.
+ * Entry point B (hold-Option-to-talk) is handled in the renderer, no hotkey. */
freeflowEnabled?: boolean;
groqApiKey?: string;
freeflowModel?: string;
- freeflowHotkey?: string;
costCapUsd?: number;
costCapTokens?: number;
agentTokenCaps?: Record<string, number>;
@@ -661,10 +660,10 @@ const api = {
ipcRenderer.invoke('webhook:setConfig', patch),
// ─── Free Flow (voice dictation → message queue) ─────────────────────────────
- /** Persist Free Flow settings (flag / Groq key / model / hotkey) and re-arm the
- * global push-to-talk hotkey to match. The Groq key is stored in main config. */
+ /** Persist Free Flow settings (flag / Groq key / model). The Groq key is stored
+ * in main config; entry point B (hold-Option) is renderer-side, no hotkey here. */
freeflowSetConfig: (patch: {
- enabled?: boolean; apiKey?: string; model?: string; hotkey?: string;
+ enabled?: boolean; apiKey?: string; model?: string;
}): Promise<{ ok: boolean }> =>
ipcRenderer.invoke('freeflow:setConfig', patch),
/** Transcribe one captured audio clip via Groq (the key stays in main; only the
@@ -672,14 +671,7 @@ const api = {
freeflowTranscribe: (arg: {
audio: ArrayBuffer | Uint8Array; mimeType?: string; filename?: string; language?: string;
}): Promise<{ ok: boolean; text?: string; error?: string }> =>
- ipcRenderer.invoke('freeflow:transcribe', arg),
- /** Subscribe to the global push-to-talk hotkey (entry point B); returns an
- * unsubscribe fn. Fires each time the user presses the configured accelerator. */
- onFreeflowHotkey: (cb: () => void): (() => void) => {
- const listener = (): void => cb();
- ipcRenderer.on('freeflow:hotkey', listener);
- return () => ipcRenderer.removeListener('freeflow:hotkey', listener);
- }
+ ipcRenderer.invoke('freeflow:transcribe', arg)
};
contextBridge.exposeInMainWorld('cth', api);
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index ad18e759..0ae262ca 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -20,7 +20,7 @@ import { acquireTerminal } from '@/components/terminalPool';
import { FullscreenTerminal } from '@/components/FullscreenTerminal';
import { TaskDetailOverlay } from '@/components/TaskDetailOverlay';
import { FullscreenFileEditor } from '@/components/FullscreenFileEditor';
-import { freeflowRecorder } from '@/freeflow/recorder';
+import { useHoldOptionToTalk } from '@/freeflow/holdOption';
import brandLogo from '@brand/logo.png?url';
// Injected at build time from package.json (see electron.vite.config.ts).
@@ -57,14 +57,10 @@ export function App() {
return () => { cancelled = true; };
}, []);
- // Free Flow entry point B — the global push-to-talk hotkey. Main fires this
- // (only while Free Flow is enabled); toggle dictation for whichever agent the
- // user is currently viewing (fullscreen tab wins, else the selected agent).
- useEffect(() => window.cth.onFreeflowHotkey(() => {
- const s = useStore.getState();
- const target = s.fullscreenAgentId ?? s.selectedId;
- if (target) freeflowRecorder.toggle(target);
- }), []);
+ // Free Flow entry point B — hold-Option (⌥) to talk. In-renderer push-to-talk
+ // for whichever agent the user is viewing; gated on the flag, terminal-safe
+ // (solo-hold threshold, aborts on any other key). See freeflow/holdOption.ts.
+ useHoldOptionToTalk();
// Quit warning subscription
useEffect(() => window.cth.onCloseRequested((info) => setQuitWarn(info)), []);
diff --git a/src/renderer/src/components/SettingsModal.tsx b/src/renderer/src/components/SettingsModal.tsx
index ce5e3f19..bd35e8b1 100644
--- a/src/renderer/src/components/SettingsModal.tsx
+++ b/src/renderer/src/components/SettingsModal.tsx
@@ -199,7 +199,6 @@ export function SettingsModal({ config, onClose }: SettingsModalProps) {
const [freeflowEnabled, setFreeflowEnabled] = useState(slackCfg.freeflowEnabled ?? false);
const [groqKey, setGroqKey] = useState(slackCfg.groqApiKey ?? '');
const [freeflowModel, setFreeflowModel] = useState(slackCfg.freeflowModel ?? 'whisper-large-v3-turbo');
- const [freeflowHotkey, setFreeflowHotkey] = useState(slackCfg.freeflowHotkey ?? 'Control+Alt+D');
const [showGroqKey, setShowGroqKey] = useState(false);
const [freeflowBusy, setFreeflowBusy] = useState(false);
const [freeflowNote, setFreeflowNote] = useState('');
@@ -226,7 +225,6 @@ export function SettingsModal({ config, onClose }: SettingsModalProps) {
setFreeflowEnabled(cc.freeflowEnabled ?? false);
setGroqKey(cc.groqApiKey ?? '');
setFreeflowModel(cc.freeflowModel ?? 'whisper-large-v3-turbo');
- setFreeflowHotkey(cc.freeflowHotkey ?? 'Control+Alt+D');
}).catch(() => { /* keep prop-seeded values */ });
// Hydrate live connection state + the persisted Request URL: the
// tunnel URL lives in main, so reopening Settings while connected re-shows it.
@@ -358,8 +356,7 @@ export function SettingsModal({ config, onClose }: SettingsModalProps) {
await window.cth.freeflowSetConfig({
enabled,
apiKey: groqKey,
- model: freeflowModel.trim() || 'whisper-large-v3-turbo',
- hotkey: freeflowHotkey
+ model: freeflowModel.trim() || 'whisper-large-v3-turbo'
});
setFreeflowEnabledStore(enabled);
setFreeflowNote('saved');
@@ -1047,30 +1044,18 @@ export function SettingsModal({ config, onClose }: SettingsModalProps) {
</div>
</label>
- <div style={{ display: 'flex', gap: 16 }}>
- {/* Model picker */}
- <label style={{ display: 'flex', flexDirection: 'column', gap: 4, flex: 1 }}>
- <span style={slackLabelStyle}>Model</span>
- <select
- value={freeflowModel}
- onChange={(e) => setFreeflowModel(e.target.value)}
- style={{ ...slackInputStyle, fontFamily: 'var(--cth-font-mono)' }}
- >
- <option value="whisper-large-v3-turbo">whisper-large-v3-turbo (fast)</option>
- <option value="whisper-large-v3">whisper-large-v3 (accurate)</option>
- </select>
- </label>
- {/* Global push-to-talk hotkey (entry point B). */}
- <label style={{ display: 'flex', flexDirection: 'column', gap: 4, flex: 1 }}>
- <span style={slackLabelStyle}>Global hotkey (toggle)</span>
- <input
- value={freeflowHotkey}
- onChange={(e) => setFreeflowHotkey(e.target.value)}
- placeholder="Control+Alt+D"
- style={{ ...slackInputStyle, fontFamily: 'var(--cth-font-mono)' }}
- />
- </label>
- </div>
+ {/* Model picker */}
+ <label style={{ display: 'flex', flexDirection: 'column', gap: 4, width: 280 }}>
+ <span style={slackLabelStyle}>Model</span>
+ <select
+ value={freeflowModel}
+ onChange={(e) => setFreeflowModel(e.target.value)}
+ style={{ ...slackInputStyle, fontFamily: 'var(--cth-font-mono)' }}
+ >
+ <option value="whisper-large-v3-turbo">whisper-large-v3-turbo (fast)</option>
+ <option value="whisper-large-v3">whisper-large-v3 (accurate)</option>
+ </select>
+ </label>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<PixelButton variant="ghost" size="sm" onClick={() => saveFreeflow()} disabled={freeflowBusy}>
@@ -1082,11 +1067,11 @@ export function SettingsModal({ config, onClose }: SettingsModalProps) {
</div>
<span style={{ fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-500)' }}>
- A mic button appears above Send in the queue composer — click to record, click again to
- transcribe into the draft (review before sending). The global hotkey toggles dictation for
- the agent you're viewing from anywhere. macOS doesn't expose the <code>Fn</code> key to the
- app, so the global gesture is a key-combo toggle rather than Fn hold-to-talk. macOS will ask
- for microphone permission the first time you record.
+ Two ways to dictate: click the mic button above Send in the queue composer (click to record,
+ click again to transcribe), or — while viewing any agent's terminal — <strong>hold Option
+ (⌥)</strong> to talk and release to transcribe. Either way the text lands in the composer
+ draft for you to review before sending. macOS will ask for microphone permission the first
+ time you record.
</span>
</div>
)}
diff --git a/src/renderer/src/freeflow/holdOption.ts b/src/renderer/src/freeflow/holdOption.ts
new file mode 100644
index 00000000..891669c8
--- /dev/null
+++ b/src/renderer/src/freeflow/holdOption.ts
@@ -0,0 +1,116 @@
+/**
+ * Free Flow entry point B — hold-Option-to-talk (the human's chosen activation).
+ *
+ * Hold the Option (⌥) key ALONE for a short threshold to ARM recording; release
+ * to stop and transcribe into the focused agent's composer draft (same path as
+ * the mic button — review before send). Active only while Free Flow is enabled.
+ *
+ * The hard part is the TERMINAL Alt/Meta conflict: in a terminal Option is Meta
+ * (Alt+key combos, special chars), so a naive "Option is down → record" would
+ * clobber normal input. Disambiguation:
+ * - A solo-hold THRESHOLD (~320ms): Option must be held alone, with no other
+ * key, before recording arms. A quick Alt+key combo never reaches it.
+ * - ABORT the instant any other key joins while Option is down (and before
+ * recording armed) — it's a real Alt combo; we never call preventDefault, so
+ * the terminal/composer sees the keystroke untouched.
+ * - Auto-repeat keydowns (e.repeat) are ignored so a held Option doesn't re-arm.
+ * - Listeners are CAPTURE-phase on window, so the gesture still fires while
+ * xterm (or the composer textarea) holds DOM focus.
+ * - We never preventDefault, so when not recording, Option behaves exactly as
+ * before for terminals and text fields.
+ *
+ * Scope: works app-wide while the window is focused (covers any agent's terminal
+ * screen per the requirement). Target = the fullscreen agent, else the selected
+ * agent. A window blur resets state so a release missed off-window can't strand a
+ * recording.
+ */
+import { useEffect } from 'react';
+import { useStore } from '@/store/store';
+import { freeflowRecorder } from './recorder';
+
+/** How long Option must be held ALONE before recording arms. Long enough that a
+ * normal Alt+key combo (which disqualifies immediately) never trips it. */
+const ARM_MS = 320;
+
+function isOptionKey(e: KeyboardEvent): boolean {
+ return e.code === 'AltLeft' || e.code === 'AltRight' || e.key === 'Alt' || e.key === 'AltGraph';
+}
+
+/** Install the hold-Option-to-talk gesture for as long as the component is
+ * mounted. Reads enablement + the focused agent from the store live. */
+export function useHoldOptionToTalk(): void {
+ useEffect(() => {
+ let optionDown = false; // Option physically held right now
+ let armTimer: ReturnType<typeof setTimeout> | null = null;
+ let recording = false; // THIS gesture started a recording
+ let disqualified = false; // another key joined → treat as a normal Alt combo
+
+ const focusedAgentId = (): string | null => {
+ const s = useStore.getState();
+ return s.fullscreenAgentId ?? s.selectedId;
+ };
+
+ const clearArm = (): void => {
+ if (armTimer) { clearTimeout(armTimer); armTimer = null; }
+ };
+
+ const reset = (): void => {
+ clearArm();
+ if (recording) freeflowRecorder.stop();
+ optionDown = false;
+ recording = false;
+ disqualified = false;
+ };
+
+ const onKeyDown = (e: KeyboardEvent): void => {
+ // Only active when Free Flow is on.
+ if (!useStore.getState().freeflowEnabled) return;
+
+ if (isOptionKey(e)) {
+ if (e.repeat || optionDown) return; // ignore auto-repeat / already tracking
+ optionDown = true;
+ disqualified = false;
+ // Don't start a second capture if one is already running/uploading.
+ if (freeflowRecorder.isBusy()) { disqualified = true; return; }
+ const target = focusedAgentId();
+ if (!target) { disqualified = true; return; }
+ clearArm();
+ armTimer = setTimeout(() => {
+ armTimer = null;
+ if (optionDown && !disqualified) {
+ recording = true;
+ void freeflowRecorder.start(target);
+ }
+ }, ARM_MS);
+ return;
+ }
+
+ // Any non-Option key while Option is held, BEFORE recording armed, means a
+ // real Alt combo (or plain typing) — disqualify and let it pass untouched.
+ if (optionDown && !recording) {
+ disqualified = true;
+ clearArm();
+ }
+ };
+
+ const onKeyUp = (e: KeyboardEvent): void => {
+ if (!isOptionKey(e)) return;
+ clearArm();
+ if (recording) freeflowRecorder.stop(); // release → transcribe
+ optionDown = false;
+ recording = false;
+ disqualified = false;
+ };
+
+ // Capture phase so xterm/textarea focus can't swallow the events first.
+ window.addEventListener('keydown', onKeyDown, true);
+ window.addEventListener('keyup', onKeyUp, true);
+ window.addEventListener('blur', reset);
+ return () => {
+ window.removeEventListener('keydown', onKeyDown, true);
+ window.removeEventListener('keyup', onKeyUp, true);
+ window.removeEventListener('blur', reset);
+ reset();
+ };
+ }, []);
+}
diff --git a/src/renderer/src/freeflow/recorder.ts b/src/renderer/src/freeflow/recorder.ts
index aad7e5c9..ff450a1c 100644
--- a/src/renderer/src/freeflow/recorder.ts
+++ b/src/renderer/src/freeflow/recorder.ts
@@ -1,8 +1,9 @@
/**
* Free Flow recorder — a single shared push-to-talk capture engine for the whole
* renderer. Both entry points use it, so only ONE recording can run at a time:
- * (A) the "Free Flow" button in MessageQueueComposer, and
- * (B) the global push-to-talk hotkey (main pushes `freeflow:hotkey`).
+ * (A) the "Free Flow" button in MessageQueueComposer (click to start/stop), and
+ * (B) hold-Option-to-talk (see freeflow/holdOption.ts) — start on arm, stop on
+ * Option release.
*
* Flow: getUserMedia(audio) → MediaRecorder (webm/opus) → on stop, the blob's
* bytes go to main over IPC (`freeflowTranscribe`), which calls Groq Whisper and
@@ -10,8 +11,11 @@
* composer draft (store.drafts) — never auto-sent — faithful to freeflow: the
* user reviews, then presses Send/Enter.
*
- * Exposed as a module singleton + a `useFreeflow()` hook (useSyncExternalStore)
- * so the button can reflect recording/transcribing state without prop-drilling.
+ * Hold-to-talk makes the start/stop race real: a user can release Option before
+ * getUserMedia resolves. `wantActive` tracks the user's intent so a stop that
+ * lands mid-open discards the about-to-start recording instead of stranding it.
+ *
+ * Exposed as a module singleton + a `useFreeflow()` hook (useSyncExternalStore).
*/
import { useSyncExternalStore } from 'react';
import { useStore } from '@/store/store';
@@ -47,6 +51,12 @@ function getSnapshot(): FreeflowState {
let recorder: MediaRecorder | null = null;
let stream: MediaStream | null = null;
let chunks: Blob[] = [];
+/** True between start() and the next stop(): the user wants a recording. A stop
+ * that arrives while getUserMedia is still opening flips this so the open path
+ * discards instead of recording. */
+let wantActive = false;
+/** True while getUserMedia is in flight, to ignore re-entrant start() calls. */
+let opening = false;
/** Prefer webm/opus (Groq-supported, Chromium default); fall back to whatever the
* platform offers. Returns '' to let MediaRecorder pick its default. */
@@ -75,19 +85,24 @@ function deliverTranscript(agentId: string, text: string): void {
st.setDraft(agentId, cur + sep + text);
}
-/** Begin capturing for `agentId`. No-op (besides surfacing an error) if the mic
- * can't be opened. Safe to call only from the idle state. */
+/** Begin capturing for `agentId`. Safe to call only from the idle state; surfaces
+ * a friendly error if the mic can't be opened. */
async function start(agentId: string): Promise<void> {
- if (state.status !== 'idle') return;
+ if (state.status !== 'idle' || opening) return;
if (!agentId) { setState({ error: 'no agent selected' }); return; }
if (typeof navigator === 'undefined' || !navigator.mediaDevices?.getUserMedia) {
setState({ error: 'microphone not available' });
return;
}
+ wantActive = true;
+ opening = true;
+ setState({ error: null });
+ let opened: MediaStream;
try {
- stream = await navigator.mediaDevices.getUserMedia({ audio: true });
+ opened = await navigator.mediaDevices.getUserMedia({ audio: true });
} catch (e) {
- // Permission denied / no device — surface a short, friendly message.
+ opening = false;
+ wantActive = false;
const name = e instanceof DOMException ? e.name : '';
setState({
status: 'idle',
@@ -95,12 +110,20 @@ async function start(agentId: string): Promise<void> {
});
return;
}
+ opening = false;
+ // Released before the mic finished opening (a quick tap) — discard cleanly.
+ if (!wantActive) {
+ try { opened.getTracks().forEach((t) => t.stop()); } catch { /* noop */ }
+ return;
+ }
+ stream = opened;
chunks = [];
const mimeType = pickMimeType();
try {
recorder = mimeType ? new MediaRecorder(stream, { mimeType }) : new MediaRecorder(stream);
} catch {
teardownStream();
+ wantActive = false;
setState({ status: 'idle', error: 'recording not supported' });
return;
}
@@ -110,8 +133,11 @@ async function start(agentId: string): Promise<void> {
setState({ status: 'recording', targetAgentId: agentId, error: null });
}
-/** Stop the active recording (triggers transcription via `onstop`). */
+/** Stop the active recording (triggers transcription via `onstop`). If a start is
+ * still opening the mic, this cancels it (the open path discards). */
function stop(): void {
+ wantActive = false;
+ if (opening) return; // the in-flight start() will see !wantActive and discard
if (state.status !== 'recording' || !recorder) return;
try { recorder.stop(); } catch { /* already stopped */ }
}
@@ -147,14 +173,20 @@ async function finish(agentId: string): Promise<void> {
}
}
-/** Toggle capture for `agentId`: start if idle, stop if recording. During
- * transcription it's a no-op (the upload is in flight). */
+/** Toggle capture for `agentId` (used by the composer button): start if idle,
+ * stop if recording. During transcription it's a no-op (the upload is in flight). */
function toggle(agentId: string): void {
if (state.status === 'recording') stop();
else if (state.status === 'idle') void start(agentId);
}
-export const freeflowRecorder = { start, stop, toggle, subscribe, getSnapshot };
+/** True while a clip is recording or uploading — the hold gesture uses this to
+ * avoid starting a second capture. */
+function isBusy(): boolean {
+ return state.status !== 'idle' || opening;
+}
+
+export const freeflowRecorder = { start, stop, toggle, isBusy, subscribe, getSnapshot };
/** React hook: subscribe to the shared recorder state. */
export function useFreeflow(): FreeflowState {
diff --git a/src/renderer/src/store/config.ts b/src/renderer/src/store/config.ts
index f8923c46..3639efdb 100644
--- a/src/renderer/src/store/config.ts
+++ b/src/renderer/src/store/config.ts
@@ -62,7 +62,6 @@ export interface HarnessConfig {
freeflowEnabled?: boolean;
groqApiKey?: string;
freeflowModel?: string;
- freeflowHotkey?: string;
costCapUsd?: number;
/** Hard total-token ceiling across active agents (the user-facing budget). */
costCapTokens?: number;