Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(voice): streamline Live Voice controls
vastsa7c7fc624fc19
diff --git a/apps/desktop/src/components/Composer.tsx b/apps/desktop/src/components/Composer.tsxindex 5da4c2699..71cb2a252 100644--- a/apps/desktop/src/components/Composer.tsx+++ b/apps/desktop/src/components/Composer.tsx@@ -59,8 +59,6 @@ import { ComposerInput } from "../features/chat/composer/ComposerInput";import { useComposerModelMenu } from "../features/chat/composer/hooks/useComposerModelMenu";import { ComposerToolbar } from "../features/chat/composer/ComposerToolbar";import { useVoiceInput } from "../features/voice/useVoiceInput";-import { VoiceOverlay } from "../features/voice/VoiceOverlay";-import "../styles/voice.css";import { ComposerStatus } from "../features/chat/composer/ComposerStatus";const EMPTY_QUEUED_PROMPTS: QueuedPrompt[] = [];@@ -458,11 +456,11 @@ export function Composer({return submit(steering);};- const voiceEnabled = import.meta.env.DEV && !!settings?.voice?.enabled;- const voice = useVoiceInput({- enabled: voiceEnabled,+ // Keep the legacy listener for already-started or IPC-owned Dictation, but+ // the Composer no longer exposes a Dictation control or overlay.+ useVoiceInput({+ enabled: import.meta.env.DEV && !!settings?.voice?.enabled,onTranscriptionComplete: (text) => {- // Insert transcribed text into Composerconst current = readLiveDraft();if (!current.trim()) {applyEditorDraft(text, fileReferencesRef.current, text.length);@@ -472,6 +470,7 @@ export function Composer({}},});+const composerAc = useComposerAutocomplete({value,cursor,@@ -618,9 +617,6 @@ export function Composer({persistDraft();}}/>- {import.meta.env.DEV && (- <VoiceOverlay t={t} state={voice.state} onCancel={voice.cancel} />- )}<ComposerToolbart={t}mode={mode}@@ -652,10 +648,6 @@ export function Composer({hasDraftContent={hasDraftContent}abort={abort}submit={submitFromComposer}- voicePhase={voice.state.phase}- voiceEnabled={voiceEnabled}- onVoiceToggle={voice.toggle}- onVoiceCancel={voice.cancel}/></div></div>diff --git a/apps/desktop/src/features/app/useAppShellRuntime.tsx b/apps/desktop/src/features/app/useAppShellRuntime.tsxindex ad7bff035..51b60e076 100644--- a/apps/desktop/src/features/app/useAppShellRuntime.tsx+++ b/apps/desktop/src/features/app/useAppShellRuntime.tsx@@ -32,6 +32,7 @@ import { useAppStore } from "../../stores/app-store";import { useSidebarTransition } from "./useSidebarTransition";import { useStartupWatchdog } from "./useStartupWatchdog";import { useTraySessions } from "./useTraySessions";+import { runLiveVoiceShortcut } from "../voice/live/live-voice-shortcuts";const MODIFIER_ONLY_KEYS = new Set(["Alt",@@ -736,10 +737,17 @@ export function useAppShellRuntime() {}if (e.repeat &&- (shortcut.id === "navigateBack" || shortcut.id === "navigateForward")+ (shortcut.id === "navigateBack" ||+ shortcut.id === "navigateForward" ||+ shortcut.id === "voiceToggle" ||+ shortcut.id === "voiceCancel")) {return;}+ if (shortcut.id === "voiceToggle" || shortcut.id === "voiceCancel") {+ if (runLiveVoiceShortcut(shortcut.id)) e.preventDefault();+ return;+ }e.preventDefault();const runShortcut = (id: KeyboardShortcutId) => {diff --git a/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx b/apps/desktop/src/features/chat/composer/ComposerToolbar.tsxindex 9633efa96..b78477d17 100644--- a/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx+++ b/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx@@ -1,16 +1,13 @@-import type { Dispatch, SetStateAction } from "react";-import type { TFunction } from "i18next";import {keybindingDisplayParts,type Mode,type PermissionMode,- type ShortcutPlatform,type SessionThinkingLevel,+ type ShortcutPlatform,} from "@pi-desktop/shared";-import type { AppState } from "../../../stores/app-store";-import { ComposerPermissionPicker } from "./ComposerPermissionPicker";+import type { TFunction } from "i18next";+import type { Dispatch, SetStateAction } from "react";import { ContextUsageInspector } from "../../../components/ContextUsageInspector";-import { TooltipButton } from "../../../components/ui";import {IconArrowUp,IconPlus,@@ -18,16 +15,17 @@ import {IconStop,IconUndo2,} from "../../../components/icons";-import { ModeIcon } from "./ComposerModeIcon";-import { VoiceMicButton } from "../../voice/VoiceMicButton";+import { TooltipButton } from "../../../components/ui";+import type { AppState } from "../../../stores/app-store";import { LiveVoiceControls } from "../../voice/live/LiveVoiceControls";+import { ModeIcon } from "./ComposerModeIcon";import { ComposerModelPicker } from "./ComposerModelPicker";+import { ComposerPermissionPicker } from "./ComposerPermissionPicker";+import type { useComposerModelMenu } from "./hooks/useComposerModelMenu";import {MODE_LABEL_KEYS,nextMode,} from "./model";-import type { useComposerModelMenu } from "./hooks/useComposerModelMenu";-import type { VoicePhase } from "../../voice/useVoiceInput";type ModelMenuController = ReturnType<typeof useComposerModelMenu>;type ContextUsage = Parameters<typeof ContextUsageInspector>[0];@@ -63,10 +61,6 @@ export type ComposerToolbarProps = {hasDraftContent: boolean;abort: AppState["abort"];submit: () => Promise<void>;- voicePhase: VoicePhase;- voiceEnabled: boolean;- onVoiceToggle: () => void;- onVoiceCancel: () => void;};/** Composer controls: mode, permission, model, enhancement, and send/stop. */@@ -101,10 +95,6 @@ export function ComposerToolbar({hasDraftContent,abort,submit,- voicePhase,- voiceEnabled,- onVoiceToggle,- onVoiceCancel,}: ComposerToolbarProps) {const platform = (window.piDesktop?.platform ?? "darwin") as ShortcutPlatform;const steeringShortcut = keybindingDisplayParts("Alt+Enter", platform).join("+");@@ -126,15 +116,6 @@ export function ComposerToolbar({<IconPlus size={15} aria-hidden="true" /></TooltipButton></div>- {voiceEnabled && (- <VoiceMicButton- t={t}- phase={voicePhase}- disabled={controlsBlocked}- onToggle={onVoiceToggle}- onCancel={onVoiceCancel}- />- )}<LiveVoiceControls t={t} /><TooltipButtontype="button"diff --git a/apps/desktop/src/features/settings/voice/VoiceSettingsSection.tsx b/apps/desktop/src/features/settings/voice/VoiceSettingsSection.tsxindex 0dd399625..8dd493720 100644--- a/apps/desktop/src/features/settings/voice/VoiceSettingsSection.tsx+++ b/apps/desktop/src/features/settings/voice/VoiceSettingsSection.tsx@@ -1,302 +1 @@-/**- * Voice settings panel — uses project-standard SettingsRow, SettingsCard,- * SettingsToggle, Select (field-select), and Button components.- */--import { useCallback, useEffect, useState } from "react";-import type { TFunction } from "i18next";-import type { AppSettings, VoiceInputSettings } from "@pi-desktop/shared";-import { Button, Badge, CheckboxGroup, SettingsToggle } from "../../../components/ui";-import { SettingsMenuSelect } from "../../../components/settings/SettingsMenuSelect";-import { SettingsRow, SettingsCard } from "../primitives";-import { voiceIpc } from "../../voice/voice-ipc";-import { LiveVoiceSettings } from "./LiveVoiceSettings";--interface AudioInputDevice {- deviceId: string;- label: string;- isDefault: boolean;-}--interface ModelInfo {- id: string;- name: string;- description: string;- sizeBytes: number;- recommended: boolean;-}--interface ModelState {- info: ModelInfo;- status: string;- downloadProgress?: number;- error?: string;-}--export function VoiceSettingsSection({- t,- settings,- saveSettings,-}: {- t: TFunction;- settings: AppSettings;- saveSettings: (patch: Partial<AppSettings>) => Promise<void>;-}) {- const voice: VoiceInputSettings = settings.voice ?? {- enabled: false,- deviceId: null,- languages: ["zh", "en"],- chineseVariant: "simplified" as const,- modelId: "",- };-- const [devices, setDevices] = useState<AudioInputDevice[]>([]);- const [models, setModels] = useState<ModelState[]>([]);- const [permission, setPermission] = useState<string>("undetermined");- const [deviceLoadError, setDeviceLoadError] = useState(false);-- useEffect(() => {- if (!voice.enabled) {- setDevices([]);- setDeviceLoadError(false);- return;- }-- let cancelled = false;- setDeviceLoadError(false);- void voiceIpc- .getDevices()- .then((d) => {- if (cancelled) return;- setDevices(Array.isArray(d) ? (d as AudioInputDevice[]) : []);- })- .catch(() => {- if (cancelled) return;- setDevices([]);- setDeviceLoadError(true);- });- return () => {- cancelled = true;- };- }, [voice.enabled]);-- useEffect(() => {- voiceIpc- .getModels()- .then((m) => setModels(Array.isArray(m) ? m as ModelState[] : []))- .catch(() => {});- voiceIpc- .checkPermission()- .then((p) => setPermission(typeof p === "string" ? p : "undetermined"))- .catch(() => {});- }, []);-- useEffect(() => {- return voiceIpc.onModelProgress(({ modelId, progress }) => {- setModels((prev) =>- prev.map((m) =>- m.info.id === modelId- ? {- ...m,- status: progress >= 1 ? "downloaded" : "downloading",- downloadProgress: progress,- }- : m,- ),- );- });- }, []);-- const save = useCallback(- (patch: Partial<VoiceInputSettings>) => {- const next = { ...voice, ...patch };- void saveSettings({ voice: next });- void voiceIpc.updateSettings(next);- },- [voice, saveSettings],- );-- const formatSize = (bytes: number) => {- if (bytes >= 1e9) return `${(bytes / 1e9).toFixed(1)} GB`;- return `${(bytes / 1e6).toFixed(0)} MB`;- };-- return (- <div className="settings-stack voice-settings">- <LiveVoiceSettings t={t} settings={settings} saveSettings={saveSettings} />- {/* ---- Enable ---- */}- <SettingsCard title={t("settings.voice")}>- <SettingsRow title={t("settings.voiceEnable")}>- <SettingsToggle- checked={voice.enabled}- label={t("settings.voiceEnable")}- onChange={() => save({ enabled: !voice.enabled })}- />- </SettingsRow>- </SettingsCard>-- {/* ---- Permission warning ---- */}- {permission === "denied" && (- <SettingsCard title={t("settings.voiceMicDenied")}>- <SettingsRow title={t("settings.voiceMicDeniedDesc")}>- <Button- size="sm"- variant="secondary"- onClick={() => voiceIpc.requestPermission()}- >- {t("settings.voiceOpenSystemSettings")}- </Button>- </SettingsRow>- </SettingsCard>- )}-- {/* ---- Input ---- */}- <SettingsCard title={t("settings.voiceMicrophone")}>- <SettingsRow- title={t("settings.voiceMicrophone")}- detail={deviceLoadError ? t("settings.voiceMicUnavailable") : undefined}- >- <SettingsMenuSelect- value={voice.deviceId ?? ""}- label={t("settings.voiceMicrophone")}- disabled={!voice.enabled}- options={[- { id: "", label: t("settings.voiceSystemDefault") },- ...devices.map((d) => ({ id: d.deviceId, label: d.label })),- ]}- onChange={(id) => save({ deviceId: id || null })}- />- </SettingsRow>-- <SettingsRow title={t("settings.voiceLanguages")}>- <CheckboxGroup- values={voice.languages}- onChange={(langs) => save({ languages: langs })}- options={[- { value: "zh", label: "中文" },- { value: "en", label: "English" },- { value: "ja", label: "日本語" },- { value: "ko", label: "한국어" },- ]}- label={t("settings.voiceLanguages")}- disabled={!voice.enabled}- minSelected={1}- />- </SettingsRow>-- <SettingsRow title={t("settings.voiceChineseVariant")}>- <SettingsMenuSelect- value={voice.chineseVariant}- label={t("settings.voiceChineseVariant")}- disabled={!voice.enabled}- options={[- { id: "simplified", label: t("settings.voiceSimplified") },- { id: "traditional-taiwan", label: t("settings.voiceTraditionalTaiwan") },- { id: "traditional-hong-kong", label: t("settings.voiceTraditionalHK") },- ]}- onChange={(id) => {- if (- id === "simplified" ||- id === "traditional-taiwan" ||- id === "traditional-hong-kong"- ) {- save({ chineseVariant: id });- }- }}- />- </SettingsRow>- </SettingsCard>-- {/* ---- Model ---- */}- <SettingsCard title={t("settings.voiceModel")}>- <SettingsRow title={t("settings.voiceModel")}>- <SettingsMenuSelect- value={voice.modelId}- label={t("settings.voiceModel")}- disabled={!voice.enabled}- options={[- { id: "", label: t("settings.voiceNoModelSelected") },- ...models.map((m) => ({- id: m.info.id,- label: `${m.info.name}${m.info.recommended ? " ★" : ""}${m.status === "downloaded" || m.status === "loaded" ? " ✓" : ""}`,- })),- ]}- onChange={(id) => save({ modelId: id })}- />- </SettingsRow>-- {models.map((m) => (- <SettingsRow- key={m.info.id}- title={m.info.name}- detail={- <>- {formatSize(m.info.sizeBytes)}- {m.info.recommended ? (- <Badge tone="success" style={{ marginLeft: 6 }}>- Recommended- </Badge>- ) : null}- </>- }- >- {m.status === "downloaded" || m.status === "loaded" ? (- <div className="voice-model-actions">- <Badge tone="success">- {t("settings.voiceModelDownloaded")}- </Badge>- <Button- size="sm"- variant="ghost"- onClick={() => {- void voiceIpc.deleteModel(m.info.id);- setModels((prev) =>- prev.map((x) =>- x.info.id === m.info.id- ? { ...x, status: "not-downloaded" }- : x,- ),- );- }}- >- {t("settings.voiceModelDelete")}- </Button>- </div>- ) : m.status === "downloading" ? (- <div className="voice-model-actions">- <div className="voice-progress-track">- <div- className="voice-progress-fill"- style={{- width: `${(m.downloadProgress ?? 0) * 100}%`,- }}- />- </div>- <span className="voice-progress-label">- {Math.round((m.downloadProgress ?? 0) * 100)}%- </span>- </div>- ) : (- <Button- size="sm"- variant="secondary"- onClick={() => {- void voiceIpc.downloadModel(m.info.id);- setModels((prev) =>- prev.map((x) =>- x.info.id === m.info.id- ? { ...x, status: "downloading", downloadProgress: 0 }- : x,- ),- );- }}- >- {t("settings.voiceModelDownload")}- </Button>- )}- </SettingsRow>- ))}- </SettingsCard>- </div>- );-}+export { LiveVoiceSettings as VoiceSettingsSection } from "./LiveVoiceSettings";diff --git a/apps/desktop/src/features/voice/live/LiveVoiceControls.tsx b/apps/desktop/src/features/voice/live/LiveVoiceControls.tsxindex e955550ad..2002477d6 100644--- a/apps/desktop/src/features/voice/live/LiveVoiceControls.tsx+++ b/apps/desktop/src/features/voice/live/LiveVoiceControls.tsx@@ -31,6 +31,10 @@ export function LiveVoiceControls({ t }: { t: TFunction }) {return () => window.removeEventListener("keydown", onKeyDown);}, [open]);+ useEffect(() => {+ if (snapshot.starting) setOpen(true);+ }, [snapshot.starting]);+const closePanel = () => {setOpen(false);triggerRef.current?.focus();diff --git a/apps/desktop/src/features/voice/live/live-voice-shortcuts.ts b/apps/desktop/src/features/voice/live/live-voice-shortcuts.tsnew file mode 100644index 000000000..d59569ca3--- /dev/null+++ b/apps/desktop/src/features/voice/live/live-voice-shortcuts.ts@@ -0,0 +1,37 @@+import { getLiveCallController, type LiveCallController } from "./live-call-controller";++type LiveVoiceShortcutController = Pick<+ LiveCallController,+ "getSnapshot" | "start" | "end" | "cancelStart"+>;++const TERMINAL_PHASES = new Set(["ended", "failed", "idle"]);++/** Run the existing configurable Live Voice shortcut actions. */+export function runLiveVoiceShortcut(+ shortcutId: "voiceToggle" | "voiceCancel",+ controller: LiveVoiceShortcutController = getLiveCallController(),+): boolean {+ const snapshot = controller.getSnapshot();++ if (shortcutId === "voiceCancel") {+ if (!snapshot.starting) return false;+ void controller.cancelStart().catch(() => undefined);+ return true;+ }++ if (snapshot.starting) return false;+ if (snapshot.call && !TERMINAL_PHASES.has(snapshot.call.phase)) {+ void controller.end().catch(() => undefined);+ return true;+ }+ if (+ snapshot.status?.enabled !== true ||+ !snapshot.status.bindings.some((binding) => binding.selectable)+ ) {+ return false;+ }++ void controller.start().catch(() => undefined);+ return true;+}diff --git a/apps/desktop/src/lib/settings-search.ts b/apps/desktop/src/lib/settings-search.tsindex cc5f7d513..1de86bd1e 100644--- a/apps/desktop/src/lib/settings-search.ts+++ b/apps/desktop/src/lib/settings-search.ts@@ -128,19 +128,19 @@ export const SETTINGS_NAV: SettingsNavEntry[] = [},{id: "voice",- labelKey: "settings.nav.voice",- titleKey: "settings.voice",+ labelKey: "liveVoice.title",+ titleKey: "liveVoice.title",group: "preferences",developerOnly: true,developmentOnly: true,experimentalBadgeKey: "settings.voiceExperimental",keywordKeys: [- "settings.voiceEnable",- "settings.voiceMicrophone",- "settings.voiceLanguages",- "settings.voiceChineseVariant",- "settings.voiceModel",- "settings.voiceLocalModels",+ "liveVoice.title",+ "liveVoice.description",+ "liveVoice.enable",+ "liveVoice.provider",+ "liveVoice.model",+ "liveVoice.voice",],},{diff --git a/apps/desktop/src/styles/voice.css b/apps/desktop/src/styles/voice.cssindex 631e61ba1..b5a672103 100644--- a/apps/desktop/src/styles/voice.css+++ b/apps/desktop/src/styles/voice.css@@ -122,28 +122,49 @@left: 0;bottom: calc(100% + 8px);z-index: 20;- display: grid;width: min(360px, calc(100vw - 32px));- gap: 10px;- padding: 12px;+}++.live-voice-panel .live-voice-panel-surface {+ display: grid;+ gap: 12px;+ padding: 14px 16px;+ border: 1px solid var(--ds-border-subtle);+ border-radius: var(--radius-sm);+ background: var(--ds-bg-elevated-opaque);+ box-shadow: var(--ds-shadow-dialog);+ color: var(--ds-text-primary);}.live-voice-panel-heading,.live-voice-actions {display: flex;align-items: center;- justify-content: space-between;gap: 8px;}+.live-voice-panel-heading {+ justify-content: space-between;+}++.live-voice-actions {+ justify-content: flex-end;+}++.live-voice-panel-heading strong {+ color: var(--ds-text-primary);+ font-size: var(--text-md);+}+.live-voice-provider,.live-voice-hint {- color: var(--color-text-secondary, #999);+ color: var(--ds-text-secondary);font-size: var(--text-sm);+ overflow-wrap: anywhere;}.live-voice-error {- color: var(--color-danger, #ef4444);+ color: var(--ds-error);font-size: var(--text-sm);}@@ -153,8 +174,9 @@max-height: 180px;overflow: auto;padding: 8px;- border-radius: var(--radius-xs);- background: var(--color-surface, #171717);+ border-radius: var(--radius-sm);+ background: var(--ds-tile);+ color: var(--ds-text-primary);font-size: var(--text-sm);white-space: pre-wrap;}@@ -164,6 +186,6 @@}.live-voice-transcripts p[data-role="user"] {- color: var(--color-text-secondary, #999);+ color: var(--ds-text-secondary);}diff --git a/apps/desktop/test/live-voice-shortcuts.test.mjs b/apps/desktop/test/live-voice-shortcuts.test.mjsnew file mode 100644index 000000000..d30647ea2--- /dev/null+++ b/apps/desktop/test/live-voice-shortcuts.test.mjs@@ -0,0 +1,118 @@+import assert from "node:assert/strict";+import test from "node:test";+import { fileURLToPath } from "node:url";+import { createServer } from "vite";+import {+ KEYBOARD_SHORTCUTS,+ keybindingMatchesEvent,+ resolveKeybinding,+} from "@pi-desktop/shared";++const originalWindow = Object.getOwnPropertyDescriptor(globalThis, "window");+Object.defineProperty(globalThis, "window", {+ configurable: true,+ value: {+ location: { origin: "http://localhost" },+ addEventListener() {},+ removeEventListener() {},+ piDesktop: {+ channels: {},+ on: () => () => undefined,+ onLiveVoicePort: () => () => undefined,+ invoke: async () => ({ ok: true, data: {} }),+ },+ },+});++const server = await createServer({+ root: fileURLToPath(new URL("..", import.meta.url)),+ configFile: false,+ server: { middlewareMode: true, hmr: false, ws: false },+ appType: "custom",+ optimizeDeps: { noDiscovery: true, include: [] },+});+const { runLiveVoiceShortcut } = await server.ssrLoadModule(+ "/src/features/voice/live/live-voice-shortcuts.ts",+);++test.after(async () => {+ await server.close();+ if (originalWindow) Object.defineProperty(globalThis, "window", originalWindow);+ else delete globalThis.window;+});++function shortcutController(snapshot) {+ const actions = [];+ return {+ actions,+ controller: {+ getSnapshot: () => snapshot,+ start: async () => { actions.push("start"); },+ end: async () => { actions.push("end"); },+ cancelStart: async () => { actions.push("cancel"); },+ },+ };+}++const voiceStatus = {+ enabled: true,+ bindings: [{ selectable: true }],+};++test("configured voiceToggle binding starts and ends Live Voice", () => {+ const definition = KEYBOARD_SHORTCUTS.find(({ id }) => id === "voiceToggle");+ assert.ok(definition);+ const binding = resolveKeybinding(definition, undefined, "darwin");+ assert.equal(binding, "Mod+Shift+V");+ assert.equal(+ keybindingMatchesEvent(binding, { key: "v", metaKey: true, shiftKey: true }, "darwin"),+ true,+ );++ const starting = shortcutController({ status: voiceStatus, call: null, starting: false });+ assert.equal(runLiveVoiceShortcut("voiceToggle", starting.controller), true);+ assert.deepEqual(starting.actions, ["start"]);++ const connected = shortcutController({+ status: voiceStatus,+ call: { phase: "connected" },+ starting: false,+ });+ assert.equal(runLiveVoiceShortcut("voiceToggle", connected.controller), true);+ assert.deepEqual(connected.actions, ["end"]);+});++test("voiceToggle does not duplicate startup or start without a selectable binding", () => {+ const pending = shortcutController({ status: voiceStatus, call: null, starting: true });+ assert.equal(runLiveVoiceShortcut("voiceToggle", pending.controller), false);+ assert.deepEqual(pending.actions, []);++ for (const status of [+ { enabled: false, bindings: [{ selectable: true }] },+ { enabled: true, bindings: [{ selectable: false }] },+ null,+ ]) {+ const unavailable = shortcutController({ status, call: null, starting: false });+ assert.equal(runLiveVoiceShortcut("voiceToggle", unavailable.controller), false);+ assert.deepEqual(unavailable.actions, []);+ }+});++test("voiceCancel cancels startup only and never ends an active call", () => {+ const cancelDefinition = KEYBOARD_SHORTCUTS.find(({ id }) => id === "voiceCancel");+ assert.ok(cancelDefinition);+ const cancelBinding = resolveKeybinding(cancelDefinition, undefined, "darwin");+ assert.equal(cancelBinding, "Escape");+ assert.equal(keybindingMatchesEvent(cancelBinding, { key: "Escape" }, "darwin"), true);+ const pending = shortcutController({ status: voiceStatus, call: null, starting: true });+ assert.equal(runLiveVoiceShortcut("voiceCancel", pending.controller), true);+ assert.deepEqual(pending.actions, ["cancel"]);++ const connected = shortcutController({+ status: voiceStatus,+ call: { phase: "connected" },+ starting: false,+ });+ assert.equal(runLiveVoiceShortcut("voiceCancel", connected.controller), false);+ assert.deepEqual(connected.actions, []);+});diff --git a/apps/desktop/test/settings-developer-only-destinations.test.mjs b/apps/desktop/test/settings-developer-only-destinations.test.mjsindex 8d3486dfc..b7c0e2903 100644--- a/apps/desktop/test/settings-developer-only-destinations.test.mjs+++ b/apps/desktop/test/settings-developer-only-destinations.test.mjs@@ -25,6 +25,10 @@ const composer = readFileSync(new URL("../src/components/Composer.tsx", import.meta.url),"utf8",);+const composerToolbar = readFileSync(+ new URL("../src/features/chat/composer/ComposerToolbar.tsx", import.meta.url),+ "utf8",+);const identity = (key) => key;const experimentalIds = ["voice", "sync", "remoteHosts"];@@ -67,7 +71,7 @@ test("settings search mirrors developer and packaged visibility", () => {.some((hit) => hit.tab === "sync"),);- for (const query of ["voiceEnable", "configSync.connectionTitle", "remotehosts"]) {+ for (const query of ["liveVoice.enable", "configSync.connectionTitle", "remotehosts"]) {assert.ok(searchSettings(query, identity, { developerMode: true }).some((hit) => experimentalIds.includes(hit.tab)),@@ -91,6 +95,8 @@ test("settings routes, global search, and composer use build visibility", () =>assert.match(settingsPage, /tab === "sync" && !tabHidden && <ConfigSyncPage \/>/);assert.match(settingsPage, /tab === "remoteHosts" && !tabHidden && <RemoteHostsPage \/>/);assert.match(searchDialog, /includeDevelopmentOnly: import\.meta\.env\.DEV/);- assert.match(composer, /const voiceEnabled = import\.meta\.env\.DEV && !!settings\?\.voice\?\.enabled/);- assert.match(composer, /\{import\.meta\.env\.DEV && \([\s\S]*<VoiceOverlay/);+ assert.match(composer, /useVoiceInput/);+ assert.doesNotMatch(composer, /VoiceOverlay|voiceEnabled/);+ assert.match(composerToolbar, /<LiveVoiceControls t=\{t\} \/>/);+ assert.doesNotMatch(composerToolbar, /VoiceMicButton|voicePhase|onVoiceToggle|onVoiceCancel/);});diff --git a/apps/desktop/test/settings-general.test.mjs b/apps/desktop/test/settings-general.test.mjsindex 26552c91e..0baecd97f 100644--- a/apps/desktop/test/settings-general.test.mjs+++ b/apps/desktop/test/settings-general.test.mjs@@ -179,8 +179,10 @@ test("Basics and AI tabs expose their respective app and AI controls", () => {// Voice owns a separate destination; the AI tab does not duplicate it.assert.doesNotMatch(aiSource, /VoiceSettingsCard|VoiceSettingsSection|voice-settings/);assert.match(settingsPageSource, /tab === "voice" && !tabHidden && settings && [\s\S]*?<VoiceSettingsSection/);- assert.match(voiceSettingsSource, /if \(!voice\.enabled\) \{/);- assert.match(voiceSettingsSource, /voiceMicUnavailable/);+ assert.match(voiceSettingsSource, /LiveVoiceSettings as VoiceSettingsSection/);+ assert.doesNotMatch(voiceSettingsSource, /voiceIpc|voiceEnable|voiceMicrophone|voiceModel/);+ assert.doesNotMatch(settingsSearchSource, /settings\.voiceEnable|settings\.voiceMicrophone|settings\.voiceModel/);+ assert.match(settingsSearchSource, /liveVoice\.enable/);assert.doesNotMatch(settingsSearchSource, /settings\.speech/);assert.doesNotMatch(stylesSource, /\.settings-speech/);assert.doesNotMatch(enLocaleSource, /speechTitle:|speechVoicePlaceholder:/);diff --git a/apps/desktop/test/settings-keyboard-shortcuts.test.mjs b/apps/desktop/test/settings-keyboard-shortcuts.test.mjsindex cc7b04feb..d8eb0c4b0 100644--- a/apps/desktop/test/settings-keyboard-shortcuts.test.mjs+++ b/apps/desktop/test/settings-keyboard-shortcuts.test.mjs@@ -49,6 +49,8 @@ test("shared shortcut map drives renderer dispatch and native menu accelerators""zoomIn","zoomOut","toggleFullScreen",+ "voiceToggle",+ "voiceCancel",]) {assert.match(shortcutSource, new RegExp(`"${id}"`));}@@ -56,6 +58,7 @@ test("shared shortcut map drives renderer dispatch and native menu accelerators"assert.match(appSource, /settings\?\.keybindings/);assert.match(appSource, /keybindingMatchesEvent/);assert.match(appSource, /keybindingDisplayParts/);+ assert.match(appSource, /runLiveVoiceShortcut\(shortcut\.id\)/);assert.match(appSource, /case "openWorkPanel"/);assert.match(appSource, /useAppStore\.getState\(\)\.toggleWorkPanel\(\)/);assert.match(menuSource, /resolveKeybinding\(shortcut, keybindings/);@@ -81,6 +84,7 @@ test("global shortcut dispatch ignores incomplete keyboard events", () => {appSource,/e\.repeat[\s\S]*shortcut\.id === "navigateBack"[\s\S]*shortcut\.id === "navigateForward"/,);+ assert.match(appSource, /e\.repeat[\s\S]*shortcut\.id === "voiceToggle"[\s\S]*shortcut\.id === "voiceCancel"/);});test("Basics exposes editable, conflict-safe, resettable shortcut mappings", () => {diff --git a/apps/desktop/test/voice-settings-surface.test.mjs b/apps/desktop/test/voice-settings-surface.test.mjsnew file mode 100644index 000000000..19ddf949e--- /dev/null+++ b/apps/desktop/test/voice-settings-surface.test.mjs@@ -0,0 +1,90 @@+import assert from "node:assert/strict";+import { readFile } from "node:fs/promises";+import test from "node:test";+import { fileURLToPath } from "node:url";+import { createServer } from "vite";++test("Voice settings render Live Voice only and preserve legacy settings", async (t) => {+ const originalWindow = Object.getOwnPropertyDescriptor(globalThis, "window");+ Object.defineProperty(globalThis, "window", {+ configurable: true,+ value: {+ location: { origin: "http://localhost" },+ addEventListener() {},+ removeEventListener() {},+ piDesktop: {+ on: () => () => undefined,+ invoke: async () => ({ ok: true, data: { voice: { enabled: true } } }),+ },+ },+ });+ t.after(() => {+ if (originalWindow) Object.defineProperty(globalThis, "window", originalWindow);+ else delete globalThis.window;+ });++ const server = await createServer({+ root: fileURLToPath(new URL("..", import.meta.url)),+ configFile: false,+ server: { middlewareMode: true, hmr: false, ws: false },+ appType: "custom",+ optimizeDeps: { noDiscovery: true, include: [] },+ });+ t.after(() => server.close());++ const React = await import("react");+ const { renderToStaticMarkup } = await import("react-dom/server");+ const { VoiceSettingsSection } = await server.ssrLoadModule(+ "/src/features/settings/voice/VoiceSettingsSection.tsx",+ );+ let savedPatch;+ const html = renderToStaticMarkup(+ React.createElement(VoiceSettingsSection, {+ t: (key) => key,+ settings: {+ voice: {+ enabled: true,+ deviceId: "legacy-microphone",+ languages: ["zh"],+ chineseVariant: "simplified",+ modelId: "legacy-transcription-model",+ },+ liveVoice: { enabled: false, bindings: [] },+ },+ saveSettings: async (patch) => {+ savedPatch = patch;+ },+ }),+ );++ assert.match(html, /liveVoice\.title/);+ assert.match(html, /liveVoice\.enable/);+ for (const legacyLabel of [+ "settings.voiceEnable",+ "settings.voiceMicrophone",+ "settings.voiceLanguages",+ "settings.voiceChineseVariant",+ "settings.voiceModel",+ "legacy-microphone",+ "legacy-transcription-model",+ ]) {+ assert.equal(html.includes(legacyLabel), false, `legacy UI leaked: ${legacyLabel}`);+ }+ assert.equal(savedPatch, undefined);+});++test("Composer keeps Live Voice and no longer mounts local Dictation controls", async () => {+ const composer = await readFile(+ new URL("../src/components/Composer.tsx", import.meta.url),+ "utf8",+ );+ const toolbar = await readFile(+ new URL("../src/features/chat/composer/ComposerToolbar.tsx", import.meta.url),+ "utf8",+ );++ assert.match(composer, /useVoiceInput/);+ assert.doesNotMatch(composer, /VoiceOverlay|voiceEnabled/);+ assert.match(toolbar, /<LiveVoiceControls t=\{t\} \/>/);+ assert.doesNotMatch(toolbar, /VoiceMicButton|voicePhase|onVoiceToggle|onVoiceCancel/);+});diff --git a/docs/spec/03-runtime/live-voice.md b/docs/spec/03-runtime/live-voice.mdindex b9d2a38c3..6c84946cf 100644--- a/docs/spec/03-runtime/live-voice.md+++ b/docs/spec/03-runtime/live-voice.md@@ -79,13 +79,15 @@ stops all local tracks, playback and ports before releasing the lease.## Settings and compatibility-The Voice settings page lets the user bind an existing compatible Provider,-choose the next-call binding, and set model, voice and Realtime profile. A-currently active binding cannot be rewritten while its call is running. Turning-Live Voice off ends the call. Provider credentials stay in the existing-Provider/secret or VendorOAuth systems. Old settings with no `liveVoice` value-read as disabled with no bindings; Dictation settings are preserved on every-write and read.+The Voice settings destination exposes only Live Voice: users can bind an+existing compatible Provider, choose the next-call binding, and set model, voice+and Realtime profile. A currently active binding cannot be rewritten while its+call is running. Turning Live Voice off ends the call. Provider credentials stay+in the existing Provider/secret or VendorOAuth systems. Legacy local Dictation+settings and its Composer entry are hidden; existing `voice` values and the+underlying Dictation capability remain unchanged and are not deleted or rewritten+by the UI. Old settings with no `liveVoice` value read as disabled with no+bindings.Live DTOs and IPC contracts live in `packages/shared`. Pure wire parsing andPCM math are exported only from `@pi-desktop/voice-runtime/live`; they do notdiff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex 1275fbab6..cd2594fac 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -23,6 +23,8 @@| `Cmd/Ctrl + ]` | Next destination | Global || `Cmd/Ctrl + .` | Abort active turn | Global (same as abort button) || `Cmd/Ctrl + K` | Open command palette | Global |+| `Cmd/Ctrl + Shift + V` | Start Live Voice when idle; end an active call | Application focused; Live Voice enabled with a selectable binding |+| `Escape` | Cancel Live Voice startup; never end a connected call | Application focused; startup pending |### 1.2 Conversation context shortcutsdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 5be7f4f3e..aba931415 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -13,23 +13,33 @@- **Preconditions:** Isolated desktop profile with Live Voice enabled and onefixture provider binding. Use a deterministic local protocol fixture; do notuse a real provider account or paid endpoint for automation.-- **Steps:** Open Voice settings, bind/select a fixture account for each- supported adapter profile, then open the Composer Live controls. Start,- cancel during permission/startup, connect, mute/unmute, interrupt playback,- inspect in-memory transcript, and end. Repeat with Dictation already holding- the microphone, a changed active binding, a provider credential removal,- renderer hide/reload, and a rejected playback gesture.-- **Expected:** Live is off by default; old Dictation settings keep their- values; only the selected Provider ID is used; secrets do not enter Renderer;+- **Steps:** Open Voice settings and confirm only Live Voice controls are+ visible; legacy Dictation toggles, microphone selection and transcription+ model controls are absent. Confirm the Composer shows Live controls without+ the old Dictation microphone button. Bind/select a fixture account for each+ supported adapter profile. In Settings → Shortcuts, customize the Live Voice+ toggle and use it to start then end a fixture call. Cancel a pending startup+ with the `voiceCancel` binding (default `Escape`); pressing `Escape` during a+ connected call must not end it. Restore the default, then start, cancel during+ permission/startup, connect, mute/unmute, interrupt playback, inspect the+ in-memory transcript, and end. Repeat with Dictation already holding the+ microphone, a changed active binding, a provider credential removal, renderer+ hide/reload, and a rejected playback gesture.+- **Expected:** Live is off by default; persisted Dictation settings remain+ unchanged but are not exposed in the UI; only the selected Provider ID is used;+ secrets do not enter Renderer;no Agent, MCP, shell or file action runs; mute gates new input immediately;cancellation stops late media; the transcript is not persisted; every endpath releases media and background-throttling leases or quarantines anunconfirmed microphone lease. A new call starts only after explicit useraction.- **Specs:** [03-runtime/live-voice.md](../03-runtime/live-voice.md),- [03-runtime/20-speech.md](../03-runtime/20-speech.md).+ [03-runtime/20-speech.md](../03-runtime/20-speech.md),+ [04-ux/09-interaction-patterns.md](../04-ux/09-interaction-patterns.md).- **Acceptance:** Adapter setup and event parsing are local fixtures; Mainlifecycle, owner, lease and settings behavior are covered by targeted tests.+ `apps/desktop/test/live-voice-shortcuts.test.mjs` covers the configurable+ toggle/cancel actions, including that Escape never ends a connected call.The full Electron flow and real-provider/device compatibility remainunverified until their respective isolated acceptance environments are run.diff --git a/docs/zh-CN/spec/03-runtime/live-voice.md b/docs/zh-CN/spec/03-runtime/live-voice.mdindex 8706b24d4..6f3ad5879 100644--- a/docs/zh-CN/spec/03-runtime/live-voice.md+++ b/docs/zh-CN/spec/03-runtime/live-voice.md@@ -36,7 +36,7 @@ PCM 采集使用 AudioWorklet,依据实际 `AudioContext.sampleRate` 进行有## 设置与兼容性-Voice 设置页允许绑定现有兼容 Provider、选择下次通话使用的绑定,以及设置模型、音色和 Realtime profile。通话进行中,当前绑定不可修改。关闭实时语音会结束通话。Provider 凭证继续由现有 Provider/secret 或 VendorOAuth 系统管理。旧设置中没有 `liveVoice` 时,会按关闭且无绑定处理;Dictation 设置在每次读写中都会保留。+Voice 设置入口现在只展示实时语音:用户可绑定现有兼容 Provider、选择下次通话使用的绑定,以及设置模型、音色和 Realtime profile。通话进行中,当前绑定不可修改。关闭实时语音会结束通话。Provider 凭证继续由现有 Provider/secret 或 VendorOAuth 系统管理。旧的本地 Dictation 设置和 Composer 入口已隐藏;已有 `voice` 设置值及底层 Dictation 能力保持不变,不会因 UI 调整而删除或改写。旧设置中没有 `liveVoice` 时,会按关闭且无绑定处理。Live DTO 与 IPC 合同位于 `packages/shared`。纯 wire 解析和 PCM 数学逻辑只从 `@pi-desktop/voice-runtime/live` 导出,不进入旧的本地转写运行时。Electron Main 保持编排角色,不接管凭证或存储所有权。diff --git a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md b/docs/zh-CN/spec/04-ux/09-interaction-patterns.mdindex 3362f4f2d..f99a60f65 100644--- a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md+++ b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md@@ -26,6 +26,8 @@| `Cmd/Ctrl + ]` | 下一个目的地 | 全球 || `Cmd/Ctrl + .` | 中止主动回合 | 全局(与中止按钮相同) || `Cmd/Ctrl + K` | 打开命令面板 | 全球 |+| `Cmd/Ctrl + Shift + V` | 空闲且有可用绑定时开始实时语音;通话中结束通话 | 应用聚焦;实时语音已启用 |+| `Escape` | 取消实时语音启动;不会结束已连接的通话 | 应用聚焦;启动准备中 |### 1. 2 对话上下文快捷方式diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex 45c06d9e8..de20ac0a8 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -795,8 +795,8 @@ sklm: {zoomIn: "Zoom in",zoomOut: "Zoom out",toggleFullScreen: "Toggle full screen",- voiceToggle: "Toggle voice input",- voiceCancel: "Cancel voice input",+ voiceToggle: "Toggle Live Voice",+ voiceCancel: "Cancel Live Voice setup",},skills: "Skills",skillsGlobalPath: "Global skills path",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex 5a72f60e7..68744425e 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -955,8 +955,8 @@ sklm: {zoomIn: "확대",zoomOut: "축소",toggleFullScreen: "전체 화면 전환",- voiceToggle: "음성 입력 전환",- voiceCancel: "음성 입력 취소",+ voiceToggle: "실시간 음성 켜기/끄기",+ voiceCancel: "실시간 음성 시작 취소",},skills: "스킬",skillsGlobalPath: "전역 스킬 경로",diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.tsindex 86ffc8ff7..9e6a1c316 100644--- a/packages/i18n/src/locales/pt-BR/index.ts+++ b/packages/i18n/src/locales/pt-BR/index.ts@@ -773,8 +773,8 @@ export const ptBR = {zoomIn: "Aumentar zoom",zoomOut: "Diminuir zoom",toggleFullScreen: "Alternar tela completa",- voiceToggle: "Alternar entrada de voz",- voiceCancel: "Cancelar entrada de voz"+ voiceToggle: "Alternar Voz em Tempo Real",+ voiceCancel: "Cancelar início da Voz em Tempo Real"},skills: "Habilidades",skillsGlobalPath: "Caminho global de habilidades",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex 36b8d0d4c..f8409455b 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -945,8 +945,8 @@ sklm: {zoomIn: "Yakınlaştır",zoomOut: "Uzaklaştır",toggleFullScreen: "Tam ekranı aç/kapat",- voiceToggle: "Sesli girişi aç/kapat",- voiceCancel: "Sesli girişi iptal et",+ voiceToggle: "Canlı Sesi Aç/Kapat",+ voiceCancel: "Canlı Ses başlatmasını iptal et",},skills: "Beceriler",skillsGlobalPath: "Genel beceriler yolu",diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex 2573e4233..832bc0494 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -932,8 +932,8 @@ sklm: {zoomIn: "放大",zoomOut: "缩小",toggleFullScreen: "切换全屏",- voiceToggle: "切换语音输入",- voiceCancel: "取消语音输入",+ voiceToggle: "切换实时语音",+ voiceCancel: "取消实时语音启动",},skills: "技能",skillsGlobalPath: "全局技能路径",diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex e8db71c92..4bd0f4c52 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -932,8 +932,8 @@ sklm: {zoomIn: "放大",zoomOut: "縮小",toggleFullScreen: "切換全屏",- voiceToggle: "切換語音輸入",- voiceCancel: "取消語音輸入",+ voiceToggle: "切換即時語音",+ voiceCancel: "取消即時語音啟動",},skills: "技能",skillsGlobalPath: "全域性技能路徑",diff --git a/packages/shared/src/keyboard-shortcuts.test.ts b/packages/shared/src/keyboard-shortcuts.test.tsindex 282721d31..6ce6a5a94 100644--- a/packages/shared/src/keyboard-shortcuts.test.ts+++ b/packages/shared/src/keyboard-shortcuts.test.ts@@ -60,6 +60,15 @@ describe("keyboard shortcut mapping", () => {expect(normalizeKeybinding("Mod+Escape")).toBeNull();});+ it("recognizes Escape for the unmodified voice-cancel shortcut", () => {+ expect(normalizeKeybinding("Escape")).toBe("Escape");+ expect(normalizeKeybinding("Mod+Escape")).toBeNull();+ expect(+ keybindingMatchesEvent("Escape", { key: "Escape", code: "Escape" }, "darwin"),+ ).toBe(true);+ expect(keybindingDisplayParts("Escape", "darwin")).toEqual(["Escape"]);+ });+it("uses platform defaults and valid overrides", () => {const fullscreen = KEYBOARD_SHORTCUTS.find((shortcut) => shortcut.id === "toggleFullScreen",diff --git a/packages/shared/src/keyboard-shortcuts.ts b/packages/shared/src/keyboard-shortcuts.tsindex 4ec1a4fa1..63650532b 100644--- a/packages/shared/src/keyboard-shortcuts.ts+++ b/packages/shared/src/keyboard-shortcuts.ts@@ -203,6 +203,7 @@ const MODIFIER_ORDER = ["Mod", "Ctrl", "Alt", "Shift"] as const;const MODIFIERS = new Set<string>(MODIFIER_ORDER);const MODIFIER_KEY_VALUES = new Set(["Alt", "AltGraph", "Control", "Meta", "Shift"]);const NAMED_KEYS = new Set([+ "Escape","Enter","Space","Tab",@@ -256,6 +257,7 @@ export function normalizeKeybinding(value: unknown): string | null {if (!key) return null;const modifiers = new Set(parts.slice(0, -1));if ([...modifiers].some((part) => !MODIFIERS.has(part))) return null;+ if (key === "Escape" && modifiers.size > 0) return null;return [...MODIFIER_ORDER.filter((part) => modifiers.has(part)), key].join("+");}