Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(chat): stop mirroring interim dictation into the agent composer

rubenluetke10-beep9a960b8a53d1
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/AgentComposer.tsx b/jarvis/ui/web/frontend/src/components/agentchat/AgentComposer.tsx
index ddaf7005a4..4cef5202e5 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/AgentComposer.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/AgentComposer.tsx
@@ -146,7 +146,7 @@ export function AgentComposer({ autoFocus = false }: { autoFocus?: boolean }) {
dictating,
stop: stopDictation,
toggle: toggleDictation,
- } = useComposerDictation(value, setValue);
+ } = useComposerDictation(setValue);
// Files going in with this message. Held here rather than in the store: they
// belong to the sentence being typed, and a chat opened elsewhere must not
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/useComposerDictation.ts b/jarvis/ui/web/frontend/src/components/agentchat/useComposerDictation.ts
index 5dce67f599..57b6e743d4 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/useComposerDictation.ts
+++ b/jarvis/ui/web/frontend/src/components/agentchat/useComposerDictation.ts
@@ -4,63 +4,49 @@ import { getWSClient } from "@/hooks/useWebSocket";
import { useEventStore } from "@/store/events";
/**
- * Microphone dictation into a composer's text box — the live interim
- * transcript mirrored while speaking, the final transcript appended once.
+ * Microphone dictation into a composer's text box — the final transcript is
+ * appended once, when the dictation ends.
*
* Lifted from components/ChatInput.tsx so the agent composer dictates the
* same way the classic one does: the same `stt_dictate` command, the same
* store flags, the same one-shot commit on `dictationCommitSeq`.
*
- * The base is the snapshot taken at dictation START only while the live
- * mirror is running — i.e. for a dictation this composer began. A dictation
- * started by the keyboard shortcut never calls `start`, so its final text
- * appends to whatever the box holds at that moment (the functional update
- * reads it without dragging `value` into a dependency array).
+ * The interim transcript is deliberately NOT mirrored into the box while
+ * speaking: the recording pill (green level meter + timer) is the only live
+ * feedback, and the partial guesses flickering in the field read as noise.
+ * The final text appends to whatever the box holds at commit time (the
+ * functional update reads it without dragging `value` into a dependency
+ * array), so text typed during the dictation is kept.
*
* The setter is read through a ref: callers pass an inline wrapper (the
* society composer mirrors into its chip field), and with that wrapper in the
- * effect deps the mirror re-ran — and re-wrote the field, jumping the caret —
- * on every render of the composer, not only when the transcript changed.
+ * effect deps the commit effect would re-run on every render of the composer.
*/
export function useComposerDictation(
- value: string,
setValue: (next: string | ((current: string) => string)) => void,
) {
const dictating = useEventStore((s) => s.dictating);
- const dictationText = useEventStore((s) => s.dictationText);
const dictationCommitSeq = useEventStore((s) => s.dictationCommitSeq);
const setDictating = useEventStore((s) => s.setDictating);
- const baseRef = useRef("");
- const mirroringRef = useRef(false);
const lastCommitSeqRef = useRef(dictationCommitSeq);
const setValueRef = useRef(setValue);
setValueRef.current = setValue;
- useEffect(() => {
- if (!dictating) return;
- const base = baseRef.current;
- const sep = base && dictationText ? " " : "";
- setValueRef.current(base + sep + dictationText);
- }, [dictating, dictationText]);
-
useEffect(() => {
if (dictationCommitSeq === lastCommitSeqRef.current) return;
lastCommitSeqRef.current = dictationCommitSeq;
const finalText = useEventStore.getState().dictationCommitText;
+ if (!finalText) return;
setValueRef.current((current) => {
- const base = mirroringRef.current ? baseRef.current : current;
- const sep = base && finalText ? " " : "";
- return base + sep + finalText;
+ const sep = current && !/\s$/.test(current) ? " " : "";
+ return current + sep + finalText;
});
- mirroringRef.current = false;
}, [dictationCommitSeq]);
const start = useCallback(() => {
- baseRef.current = value;
- mirroringRef.current = true;
setDictating(true);
getWSClient()?.send({ type: "command", action: "stt_dictate", payload: { mode: "start" } });
- }, [value, setDictating]);
+ }, [setDictating]);
const stop = useCallback(() => {
getWSClient()?.send({ type: "command", action: "stt_dictate", payload: { mode: "stop" } });
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
index 1c9b78c024..f9a17dbb5f 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
@@ -1020,7 +1020,7 @@ export function Composer({ agent, mentionable, busy, sessionId, cwd, provider, s
setValue: (next) => { setValue(next); fieldRef.current?.setText(next); },
onModel: () => composerRef.current?.querySelector<HTMLButtonElement>("[data-chat-model-trigger]")?.click(),
});
- const dictation = useComposerDictation(value, (next) => {
+ const dictation = useComposerDictation((next) => {
const text = typeof next === "function" ? next(value) : next;
setValue(text);
fieldRef.current?.setText(text);