Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

refactor(composer): remove transcribe and speak icons

vastsa344ef4ec27e8
diff --git a/apps/desktop/src/components/Composer.tsx b/apps/desktop/src/components/Composer.tsx
index b84d93f62..2ffc3cfc8 100644
--- a/apps/desktop/src/components/Composer.tsx
+++ b/apps/desktop/src/components/Composer.tsx
@@ -56,7 +56,6 @@ import {
import { useComposerAttachments } from "../features/chat/composer/hooks/useComposerAttachments";
import { useComposerDraft } from "../features/chat/composer/hooks/useComposerDraft";
import { useComposerSubmit } from "../features/chat/composer/hooks/useComposerSubmit";
-import { useComposerSpeech } from "../features/chat/composer/hooks/useComposerSpeech";
import { ComposerInput } from "../features/chat/composer/ComposerInput";
import { useComposerModelMenu } from "../features/chat/composer/hooks/useComposerModelMenu";
import { ComposerToolbar } from "../features/chat/composer/ComposerToolbar";
@@ -437,16 +436,6 @@ export function Composer({
submit,
} = submitController;
- const speech = useComposerSpeech({
- activeSessionId,
- value,
- enhancementDraft,
- activeFileReferences,
- applyEditorDraft,
- t,
- showToast,
- controlsBlocked,
- });
const composerAc = useComposerAutocomplete({
value,
cursor,
@@ -617,12 +606,6 @@ export function Composer({
clearEnhancementError={clearEnhancementError}
runActive={runActive}
hasDraftContent={hasDraftContent}
- transcribeEnabled={speech.transcribeEnabled}
- speakEnabled={speech.speakEnabled}
- transcribing={speech.transcribing}
- speaking={speech.speaking}
- transcribe={speech.transcribe}
- speak={speech.speak}
abort={abort}
submit={submit}
/>
diff --git a/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx b/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx
index 587e3b886..d2c899052 100644
--- a/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx
+++ b/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx
@@ -19,8 +19,6 @@ import {
IconSparkles,
IconStop,
IconUndo2,
- IconMic,
- IconAudio,
} from "../../../components/icons";
import { ModeIcon } from "./ComposerModeIcon";
import { ComposerModelPicker } from "./ComposerModelPicker";
@@ -64,12 +62,6 @@ export type ComposerToolbarProps = {
clearEnhancementError: () => void;
runActive: boolean;
hasDraftContent: boolean;
- transcribeEnabled: boolean;
- speakEnabled: boolean;
- transcribing: boolean;
- speaking: boolean;
- transcribe: () => Promise<void>;
- speak: () => Promise<void>;
abort: AppState["abort"];
submit: () => Promise<void>;
};
@@ -105,12 +97,6 @@ export function ComposerToolbar({
clearEnhancementError,
runActive,
hasDraftContent,
- transcribeEnabled,
- speakEnabled,
- transcribing,
- speaking,
- transcribe,
- speak,
abort,
submit,
}: ComposerToolbarProps) {
@@ -257,28 +243,6 @@ export function ComposerToolbar({
controlsBlocked={controlsBlocked}
onCloseOtherMenus={() => setPermissionOpen(false)}
/>
- <TooltipButton
- type="button"
- className={`icon-btn icon-btn-square${transcribing ? " is-loading" : ""}`}
- tooltip={t("chat.transcribe")}
- ariaLabel={transcribing ? t("chat.transcribing") : t("chat.transcribe")}
- aria-busy={transcribing}
- disabled={!transcribeEnabled || transcribing || speaking}
- onClick={() => void transcribe()}
- >
- {transcribing ? <span className="tool-spinner" aria-hidden="true" /> : <IconMic size={15} aria-hidden="true" />}
- </TooltipButton>
- <TooltipButton
- type="button"
- className={`icon-btn icon-btn-square${speaking ? " is-loading" : ""}`}
- tooltip={t("chat.speak")}
- ariaLabel={speaking ? t("chat.speaking") : t("chat.speak")}
- aria-busy={speaking}
- disabled={!speakEnabled || speaking || transcribing}
- onClick={() => void speak()}
- >
- {speaking ? <span className="tool-spinner" aria-hidden="true" /> : <IconAudio size={15} aria-hidden="true" />}
- </TooltipButton>
<TooltipButton
type="button"
className={`icon-btn icon-btn-square composer-enhance-btn${enhancingPrompt ? " is-loading" : ""}`}
diff --git a/apps/desktop/src/features/chat/composer/hooks/useComposerSpeech.ts b/apps/desktop/src/features/chat/composer/hooks/useComposerSpeech.ts
deleted file mode 100644
index 2f3ad494f..000000000
--- a/apps/desktop/src/features/chat/composer/hooks/useComposerSpeech.ts
+++ /dev/null
@@ -1,115 +0,0 @@
-import { useEffect, useRef, useState } from "react";
-import type { TFunction } from "i18next";
-import type { SpeechStatus } from "@pi-desktop/shared";
-import { stripInlineComposerFileReferenceTokens } from "@pi-desktop/shared";
-import { materializeDraftSession } from "../../../../stores/app-store";
-import { api } from "../../../../lib/api";
-import { isComposerAudioReference, type ComposerFileReference } from "../editor";
-
-type SpeechToast = (message: string, options?: { variant?: "error" | "info" }) => void;
-
-export function useComposerSpeech({
- activeSessionId,
- value,
- enhancementDraft,
- activeFileReferences,
- applyEditorDraft,
- t,
- showToast,
- controlsBlocked,
-}: {
- activeSessionId: string | null | undefined;
- value: string;
- enhancementDraft: string;
- activeFileReferences: ComposerFileReference[];
- applyEditorDraft: (next: string, refs: ComposerFileReference[], cursor: number) => void;
-
- t: TFunction;
- showToast: SpeechToast;
- controlsBlocked: boolean;
-}) {
- const [status, setStatus] = useState<SpeechStatus | null>(null);
- const [transcribing, setTranscribing] = useState(false);
- const [speaking, setSpeaking] = useState(false);
- const playbackRef = useRef<HTMLAudioElement | null>(null);
-
- useEffect(() => {
- let cancelled = false;
- void api.speechStatus().then(
- (next) => {
- if (!cancelled) setStatus(next);
- },
- () => {
- if (!cancelled) setStatus(null);
- },
- );
- return () => {
- cancelled = true;
- playbackRef.current?.pause();
- playbackRef.current = null;
- };
- }, []);
-
- const audioAttachments = activeFileReferences.filter(isComposerAudioReference);
- const transcribeEnabled = Boolean(status?.transcribe.available) && audioAttachments.length > 0 && !controlsBlocked;
- const speakEnabled = Boolean(status?.synthesize.available) && Boolean(enhancementDraft.trim()) && !controlsBlocked;
-
- const transcribe = async () => {
- if (!transcribeEnabled || transcribing) return;
- setTranscribing(true);
- try {
- const sessionId = activeSessionId ?? (await materializeDraftSession());
- if (!sessionId) throw new Error("session unavailable");
- const chunks: string[] = [];
- for (const file of audioAttachments) {
- const result = await api.speechTranscribe({
- sessionId,
- path: file.path,
- mimeType: file.mimeType,
- });
- if (result.text.trim()) chunks.push(result.text.trim());
- }
- if (!chunks.length) return;
- const insertion = chunks.join("\n");
- const prefix = value.trim() ? `${value.replace(/\s+$/, "")}\n` : "";
- const next = `${prefix}${insertion}`;
- applyEditorDraft(next, activeFileReferences, next.length);
- } catch (error) {
- showToast(error instanceof Error ? error.message : t("chat.transcribeFailed"), { variant: "error" });
- } finally {
- setTranscribing(false);
- }
- };
-
- const speak = async () => {
- if (!speakEnabled || speaking) return;
- const text = stripInlineComposerFileReferenceTokens(enhancementDraft, activeFileReferences).trim();
- if (!text) return;
- setSpeaking(true);
- try {
- const sessionId = activeSessionId ?? (await materializeDraftSession());
- if (!sessionId) throw new Error("session unavailable");
- const result = await api.speechSynthesize({ sessionId, text });
- if (result.dataUrl) {
- const audio = new Audio(result.dataUrl);
- playbackRef.current = audio;
- await audio.play();
- } else {
- showToast(t("chat.speakSaved", { path: result.path }), { variant: "info" });
- }
- } catch (error) {
- showToast(error instanceof Error ? error.message : t("chat.speakFailed"), { variant: "error" });
- } finally {
- setSpeaking(false);
- }
- };
-
- return {
- transcribeEnabled,
- speakEnabled,
- transcribing,
- speaking,
- transcribe,
- speak,
- };
-}