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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(sessions): show which voice actually spoke on every transcript turn
Ruben Lütke0c3a3138ab78
diff --git a/jarvis/core/events.py b/jarvis/core/events.pyindex 254ad3d1f1..5bbdb88722 100644--- a/jarvis/core/events.py+++ b/jarvis/core/events.py@@ -298,6 +298,14 @@ class SpeechSpoken(Event):# view surfaces this for debugging (user request 2026-06-16). None for the# common case: a plain canned phrase has no diagnostic.detail: str | None = None+ # Which voice actually spoke this text (user request 2026-07-17): the+ # resolved voice name ("Fenrir", "Charon", "leo", an ElevenLabs voice id)+ # and the speaking family ("gemini-live", "openrouter", "grok-voice").+ # None when the speaking layer cannot tell — consumers must treat that as+ # unknown, never guess from the brain provider (the speaker can differ,+ # e.g. a surface-TTS readback inside a realtime session).+ voice: str | None = None+ voice_provider: str | None = None@dataclass(frozen=True, slots=True)@@ -1137,6 +1145,10 @@ class VoiceTurnCompleted(Event):cost_usd: float = 0.0latency_total_ms: int = 0tool_calls: tuple[str, ...] = ()+ # Voice that actually spoke the reply (name + speaking family), when the+ # publisher knows it. See SpeechSpoken.voice for the semantics.+ voice: str | None = None+ voice_provider: str | None = None@dataclass(frozen=True, slots=True)diff --git a/jarvis/plugins/tts/cartesia_tts.py b/jarvis/plugins/tts/cartesia_tts.pyindex 22d7c5c26e..5cfffeee41 100644--- a/jarvis/plugins/tts/cartesia_tts.py+++ b/jarvis/plugins/tts/cartesia_tts.py@@ -75,6 +75,9 @@ class CartesiaTTS:"""name = "cartesia"+ # Which voice actually spoke last (fed to the per-turn transcript label).+ last_voice: str | None = None+ last_voice_provider: str | None = Nonesupports_streaming = True # pseudo via sentence-chunkingdef __init__(@@ -188,6 +191,9 @@ class CartesiaTTS:returnvoice_id = self._resolve_voice(text, voice, language_code)+ self.last_voice = voice_id+ self.last_voice_provider = self.name+log = logging.getLogger("jarvis.tts.cartesia")if self._quota_blocked_until and time.monotonic() < self._quota_blocked_until:@@ -373,6 +379,10 @@ class CartesiaTTS:if aclose is not None:await aclose()if produced:+ self.last_voice = getattr(fb, "last_voice", None)+ self.last_voice_provider = getattr(+ fb, "last_voice_provider", None+ ) or getattr(fb, "name", None)returnif not self._allow_sapi5_fallback:diff --git a/jarvis/plugins/tts/elevenlabs_tts.py b/jarvis/plugins/tts/elevenlabs_tts.pyindex 22b1f2d57a..db25bc2a30 100644--- a/jarvis/plugins/tts/elevenlabs_tts.py+++ b/jarvis/plugins/tts/elevenlabs_tts.py@@ -101,6 +101,9 @@ class ElevenLabsTTS:"""TTS provider for ElevenLabs (eleven_flash_v2_5 — multi-lang)."""name = "elevenlabs"+ # Which voice actually spoke last (fed to the per-turn transcript label).+ last_voice: str | None = None+ last_voice_provider: str | None = Nonesupports_streaming = Truedef __init__(@@ -171,6 +174,8 @@ class ElevenLabsTTS:voice = voice or self._default_voicelog = logging.getLogger("jarvis.tts.elevenlabs")+ self.last_voice = voice+ self.last_voice_provider = self.name# Cooldown active? Gemini first, then SAPI5 — never stay silent.if self._quota_blocked_until and time.monotonic() < self._quota_blocked_until:@@ -328,6 +333,10 @@ class ElevenLabsTTS:if aclose is not None:await aclose()if produced:+ self.last_voice = getattr(fb, "last_voice", None)+ self.last_voice_provider = getattr(+ fb, "last_voice_provider", None+ ) or getattr(fb, "name", None)returnif not self._allow_sapi5_fallback:diff --git a/jarvis/plugins/tts/fallback_tts.py b/jarvis/plugins/tts/fallback_tts.pyindex 22720136b0..c0113820cb 100644--- a/jarvis/plugins/tts/fallback_tts.py+++ b/jarvis/plugins/tts/fallback_tts.py@@ -51,6 +51,25 @@ class FallbackTTS:# Surface the primary's identity so callers/logs see the active voice.self.name = getattr(primary, "name", "fallback-tts")self.supports_streaming = bool(getattr(primary, "supports_streaming", True))+ # Which wrapped provider produced the LAST utterance — feeds the+ # per-turn "which voice actually spoke" transcript label.+ self._last_speaker: Any = primary++ @property+ def last_voice(self) -> str | None:+ """Voice name of the last utterance (from whichever provider spoke)."""+ voice = getattr(self._last_speaker, "last_voice", None)+ if voice is None and self._last_speaker is self._fallback:+ return self._fallback_voice+ return voice++ @property+ def last_voice_provider(self) -> str | None:+ """Family name of the provider that actually spoke last."""+ speaker = self._last_speaker+ return getattr(speaker, "last_voice_provider", None) or getattr(+ speaker, "name", None+ )@propertydef primary(self) -> Any:@@ -91,6 +110,7 @@ class FallbackTTS:returnproduced = 0+ self._last_speaker = self._primarytry:async for chunk in self._primary.synthesize(text, voice=voice, language_code=language_code@@ -137,6 +157,7 @@ class FallbackTTS:masculine→feminine mid-conversation. Without a match the fallbackresolves its own default voice, as before."""+ self._last_speaker = self._fallbacktry:async for chunk in self._fallback.synthesize(text, voice=self._fallback_voice, language_code=language_codediff --git a/jarvis/plugins/tts/gemini_flash_tts.py b/jarvis/plugins/tts/gemini_flash_tts.pyindex 7b90ecc8c5..2bc3df03de 100644--- a/jarvis/plugins/tts/gemini_flash_tts.py+++ b/jarvis/plugins/tts/gemini_flash_tts.py@@ -117,6 +117,9 @@ class GeminiFlashTTS:"""TTS provider for Google's Gemini 3.1 Flash TTS (AI-Studio API key)."""name = "gemini-flash-tts"+ # Which voice actually spoke last (fed to the per-turn transcript label).+ last_voice: str | None = None+ last_voice_provider: str | None = Nonesupports_streaming = True # pseudo-streaming via sentence-chunkingdef __init__(@@ -334,6 +337,8 @@ class GeminiFlashTTS:"""self._ensure_client()voice = voice or self._default_voice+ self.last_voice = voice+ self.last_voice_provider = self.name# Per-turn pronunciation pin: the pipeline resolves this turn's language# (resolve_output_language) and passes ``language_code`` here. It is# threaded down to the GenerateContentConfig so the model stopsdiff --git a/jarvis/plugins/tts/grok_voice_tts.py b/jarvis/plugins/tts/grok_voice_tts.pyindex b453a09dd2..828ff1e686 100644--- a/jarvis/plugins/tts/grok_voice_tts.py+++ b/jarvis/plugins/tts/grok_voice_tts.py@@ -97,6 +97,9 @@ class GrokVoiceTTS:"""name = "grok-voice"+ # Which voice actually spoke last (fed to the per-turn transcript label).+ last_voice: str | None = None+ last_voice_provider: str | None = Nonesupports_streaming = True # pseudo via sentence-chunkingdef __init__(@@ -196,6 +199,8 @@ class GrokVoiceTTS:voice = voice or self._default_voicelog = logging.getLogger("jarvis.tts.grok-voice")+ self.last_voice = voice+ self.last_voice_provider = self.name# Cooldown active? First Gemini, then SAPI5 — never stay silent.if self._quota_blocked_until and time.monotonic() < self._quota_blocked_until:@@ -387,6 +392,10 @@ class GrokVoiceTTS:if aclose is not None:await aclose()if produced:+ self.last_voice = getattr(fb, "last_voice", None)+ self.last_voice_provider = getattr(+ fb, "last_voice_provider", None+ ) or getattr(fb, "name", None)returnif not self._allow_sapi5_fallback:diff --git a/jarvis/plugins/tts/inworld_tts.py b/jarvis/plugins/tts/inworld_tts.pyindex b8773e9bad..8b0accff8e 100644--- a/jarvis/plugins/tts/inworld_tts.py+++ b/jarvis/plugins/tts/inworld_tts.py@@ -98,6 +98,9 @@ class InworldTTS:"""name = "inworld"+ # Which voice actually spoke last (fed to the per-turn transcript label).+ last_voice: str | None = None+ last_voice_provider: str | None = Nonesupports_streaming = True # pseudo via sentence-chunking (true NDJSON = follow-up)def __init__(@@ -185,6 +188,9 @@ class InworldTTS:returnvoice_id = self._resolve_voice(text, voice, language_code)+ self.last_voice = voice_id+ self.last_voice_provider = self.name+log = logging.getLogger("jarvis.tts.inworld")if self._quota_blocked_until and time.monotonic() < self._quota_blocked_until:@@ -363,6 +369,10 @@ class InworldTTS:if aclose is not None:await aclose()if produced:+ self.last_voice = getattr(fb, "last_voice", None)+ self.last_voice_provider = getattr(+ fb, "last_voice_provider", None+ ) or getattr(fb, "name", None)returnif not self._allow_sapi5_fallback:@@ -375,6 +385,8 @@ class InworldTTS:returnlog.warning("SAPI5 emergency active (config opt-in).")+ self.last_voice = None+ self.last_voice_provider = "sapi5"pcm = await asyncio.to_thread(_sapi5_synthesize, text, language_code or "de-DE")if pcm:yield AudioChunk(diff --git a/jarvis/plugins/tts/openrouter_tts.py b/jarvis/plugins/tts/openrouter_tts.pyindex 133fa68231..d91c20ccd4 100644--- a/jarvis/plugins/tts/openrouter_tts.py+++ b/jarvis/plugins/tts/openrouter_tts.py@@ -67,6 +67,9 @@ class OpenRouterTTS:"""name = "openrouter"+ # Which voice actually spoke last (fed to the per-turn transcript label).+ last_voice: str | None = None+ last_voice_provider: str | None = Nonesupports_streaming = Truedef __init__(@@ -270,6 +273,9 @@ class OpenRouterTTS:await self._ensure_client()resolved_voice = self._resolve_voice(voice, language_code)+ self.last_voice = resolved_voice+ self.last_voice_provider = self.name+payload: dict[str, Any] = {"model": self._model,"input": text[:_MAX_CHARS_PER_REQUEST],diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex 6efbe8a449..bb835885b0 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -686,6 +686,7 @@ class RealtimeVoiceSession:self._failed = asyncio.Event()self._failure_detail = ""self._active_model = ""+ self._active_voice = ""self._turn_id = ""self._turn_trace_id = Noneself._latency_tracker: Any = None@@ -913,6 +914,8 @@ class RealtimeVoiceSession:self._provider = providerself._session = sessionself._active_model = model+ # Retained for the per-turn "which voice spoke" transcript label.+ self._active_voice = voiceself._input_sample_rate = input_rateself._in_resampler = StreamingPcm16Resampler(self.browser_sample_rate, input_rate@@ -1801,7 +1804,7 @@ class RealtimeVoiceSession:The stored ``last_reply`` is raw Brain output; the normal path onlyspeaks it after the provider re-renders it through the scrub gate.Every direct-to-surface fallback must apply the same regex scrub- (ADR-0010, AP-11) before the text reaches TTS — the sibling+ (ADR-0010, AP-11) before the text reaches TTS — the sibling``_direct_tool_fallback_text`` already follows this contract."""raw = str(getattr(delegate_state, "last_reply", "") or "").strip()@@ -1819,7 +1822,7 @@ class RealtimeVoiceSession:"""Cancel one unsafe provider response and emit one honest fallback."""if self._scrub_cancelled_for_turn:# A second cancel in the same turn is a silent no-op by design- # (one fallback per turn) — but it must be diagnosable, or a+ # (one fallback per turn) — but it must be diagnosable, or a# caller that staged a trusted reply here loses it without a# trace (BUG-069 review; BUG-056 pattern).log.debug(@@ -2380,6 +2383,10 @@ class RealtimeVoiceSession:text=answer,language=self._language,spoken_kind=SPOKEN_KIND_REPLY,+ # The session itself rendered this audio (guard+ # above) — its handshake voice is the speaker.+ voice=self._active_voice or None,+ voice_provider=self.active_provider,))await self._bus.publish(@@ -2397,6 +2404,21 @@ class RealtimeVoiceSession:model=self._active_model,latency_total_ms=latency_total_ms,tool_calls=tuple(sorted(self._executed_tool_names)),+ # Only claim the session voice when the session+ # actually rendered audio; a surface-TTS readback+ # (provider produced no audio) reports its own+ # voice through SpeechSpoken, which wins in the+ # recorder.+ voice=(+ (self._active_voice or None)+ if self._output_samples_sent > 0+ else None+ ),+ voice_provider=(+ self.active_provider+ if self._output_samples_sent > 0+ else None+ ),))except Exception: # noqa: BLE001, S110diff --git a/jarvis/sessions/formatter.py b/jarvis/sessions/formatter.pyindex eb49b2d576..a47fd91acf 100644--- a/jarvis/sessions/formatter.py+++ b/jarvis/sessions/formatter.py@@ -184,7 +184,16 @@ def format_session_markdown(outputs = _jarvis_outputs_for_turn(t, events_map.get(t.id, []))if outputs:- lines.append(f"**🔊 Jarvis sagte** _(de={t.jarvis_lang})_")+ # Which voice actually spoke (user request 2026-07-17) — small+ # print next to the spoken block; the speaker can differ from the+ # brain provider (e.g. a surface-TTS readback in a realtime turn).+ voice_note = ""+ if getattr(t, "voice_name", ""):+ spoken_by = t.voice_name+ if getattr(t, "voice_provider", ""):+ spoken_by += f" @ {t.voice_provider}"+ voice_note = f" · _Stimme: `{spoken_by}`_"+ lines.append(f"**🔊 Jarvis sagte** _(de={t.jarvis_lang})_{voice_note}")lines.append("")for output in outputs:if output.is_reply and t.awaiting_confirmation:diff --git a/jarvis/sessions/models.py b/jarvis/sessions/models.pyindex 89f509394d..36cc7daac6 100644--- a/jarvis/sessions/models.py+++ b/jarvis/sessions/models.py@@ -130,6 +130,13 @@ class VoiceTurnRow(BaseModel):# (finish_reason="voice_confirm_pending"): the reply is a pending yes/no# question, not a normal answer, so the transcript labels it distinctly.awaiting_confirmation: bool = False+ # Which voice actually spoke the reply ("Fenrir", "Charon", an ElevenLabs+ # voice id) and the speaking family ("gemini-live", "openrouter",+ # "grok-voice"). Empty when the speaking layer could not tell — the UI+ # must show nothing rather than guess (the speaker can differ from the+ # brain provider, e.g. a surface-TTS readback inside a realtime session).+ voice_name: str = ""+ voice_provider: str = ""class VoiceSessionRow(BaseModel):diff --git a/jarvis/sessions/recorder.py b/jarvis/sessions/recorder.pyindex 6d9665bda6..3b357abf52 100644--- a/jarvis/sessions/recorder.py+++ b/jarvis/sessions/recorder.py@@ -67,6 +67,7 @@ from jarvis.core.events import (from .constants import (SPOKEN_KIND_COMPLETION,+ SPOKEN_KIND_REPLY,SPOKEN_KIND_SUBAGENT,VOICE_MODE_PIPELINE,VOICE_MODE_REALTIME,@@ -137,6 +138,11 @@ class _TurnState:cost_usd: float = 0.0latency_total_ms: int = 0tool_calls: list[str] = field(default_factory=list)+ # Which voice actually spoke the audible reply ("Fenrir", "Charon", …) and+ # the speaking family ("gemini-live", "openrouter"). Adopted from the+ # authoritative SpeechSpoken track; VoiceTurnCompleted only fills a blank.+ voice_name: str = ""+ voice_provider: str = ""# Stage boundaries for think/speak latency calculation. The first thinking# segment begins at TranscriptFinal (classic) or final TranscriptionUpdate# (Realtime); later THINKING transitions reuse transcript_final_ms as the@@ -297,9 +303,30 @@ class SessionRecorder:self._state.current_turn.cost_usd += event.cost_estimate_usdelif isinstance(event, SystemStateChanged):self._on_system_state(event)+ elif isinstance(event, SpeechSpoken):+ self._on_speech_spoken(event)self._maybe_append_raw(event, kind)+ def _on_speech_spoken(self, event: SpeechSpoken) -> None:+ """Adopt the speaking voice onto the open turn.++ ``SpeechSpoken`` is the authoritative audible track, so a voice it+ names beats the session-level claim in ``VoiceTurnCompleted`` — that is+ what makes a surface-TTS readback inside a realtime session honest+ (the surface voice spoke, not the session voice). The reply phrase+ wins over supplemental phrases; a supplemental phrase only fills a+ blank.+ """+ assert self._state is not None+ t = self._state.current_turn+ voice = getattr(event, "voice", None)+ if t is None or not voice:+ return+ if event.spoken_kind == SPOKEN_KIND_REPLY or not t.voice_name:+ t.voice_name = str(voice)+ t.voice_provider = str(getattr(event, "voice_provider", None) or "")+# -----------------------------------------------------------------# Session lifecycle# -----------------------------------------------------------------@@ -445,6 +472,11 @@ class SessionRecorder:for tc in event.tool_calls:if tc not in t.tool_calls:t.tool_calls.append(tc)+ # The audible SpeechSpoken track wins; the session-level claim only+ # fills a blank (see _on_speech_spoken).+ if getattr(event, "voice", None) and not t.voice_name:+ t.voice_name = str(event.voice)+ t.voice_provider = str(getattr(event, "voice_provider", None) or "")self._finalize_current_turn(end_ms=event.timestamp_ns // 1_000_000)def _ensure_turn_open(self, ts_ms: int) -> None:@@ -505,6 +537,8 @@ class SessionRecorder:think_ms=t.think_ms,speak_ms=t.speak_ms,awaiting_confirmation=t.awaiting_confirmation,+ voice_name=t.voice_name,+ voice_provider=t.voice_provider,)# Bump aggregatesself._state.turn_count += 1@@ -872,6 +906,11 @@ def _payload_for(event: Event) -> dict[str, Any]:# …). ``text`` + ``language`` are already whitelisted above, so a# persisted SpeechSpoken row carries {text, language, spoken_kind}."spoken_kind",+ # SpeechSpoken / VoiceTurnCompleted: which voice actually spoke+ # ("Fenrir", "Charon") and the speaking family ("gemini-live",+ # "openrouter") — user request 2026-07-17.+ "voice",+ "voice_provider",# SpeechSpoken: optional technical diagnostic NOT spoken aloud (e.g. a# failed Computer-Use exit code + harness reason). LatencySpan also# carries a ``detail`` attribute and IS a recorded kind since the Rundiff --git a/jarvis/sessions/schema.sql b/jarvis/sessions/schema.sqlindex 1e6186a267..c0014cb44a 100644--- a/jarvis/sessions/schema.sql+++ b/jarvis/sessions/schema.sql@@ -57,6 +57,11 @@ CREATE TABLE IF NOT EXISTS voice_turns (-- question, not a settled answer. Also added via _apply_migrations for-- pre-existing DBs (the idempotent PRAGMA-guard makes both paths safe).awaiting_confirmation INTEGER NOT NULL DEFAULT 0,+ -- Which voice actually spoke the reply ("Fenrir", "Charon") and the+ -- speaking family ("gemini-live", "openrouter"). Empty = unknown. Also+ -- added via _apply_migrations for pre-existing DBs.+ voice_name TEXT NOT NULL DEFAULT '',+ voice_provider TEXT NOT NULL DEFAULT '',tool_calls_json TEXT NOT NULL DEFAULT '[]' -- JSON array of tool-name strings);diff --git a/jarvis/sessions/store.py b/jarvis/sessions/store.pyindex eb0cb353ed..67d265ec99 100644--- a/jarvis/sessions/store.py+++ b/jarvis/sessions/store.py@@ -137,6 +137,17 @@ class SessionStore:"ADD COLUMN awaiting_confirmation INTEGER NOT NULL DEFAULT 0")log.info("SessionStore migration: added voice_turns.awaiting_confirmation")+ if "voice_name" not in existing:+ self._conn.execute(+ "ALTER TABLE voice_turns ADD COLUMN voice_name TEXT NOT NULL DEFAULT ''"+ )+ log.info("SessionStore migration: added voice_turns.voice_name")+ if "voice_provider" not in existing:+ self._conn.execute(+ "ALTER TABLE voice_turns "+ "ADD COLUMN voice_provider TEXT NOT NULL DEFAULT ''"+ )+ log.info("SessionStore migration: added voice_turns.voice_provider")def close(self) -> None:with self._lock:@@ -279,6 +290,8 @@ class SessionStore:think_ms: int = 0,speak_ms: int = 0,awaiting_confirmation: bool = False,+ voice_name: str = "",+ voice_provider: str = "",) -> None:with self._lock:self._c.execute(@@ -299,6 +312,8 @@ class SessionStore:think_ms = ?,speak_ms = ?,awaiting_confirmation = ?,+ voice_name = ?,+ voice_provider = ?,tool_calls_json = ?WHERE id = ?""",@@ -318,6 +333,8 @@ class SessionStore:think_ms,speak_ms,1 if awaiting_confirmation else 0,+ voice_name,+ voice_provider,json.dumps(tool_calls),turn_id,),@@ -666,10 +683,21 @@ def _row_to_turn(r: sqlite3.Row) -> VoiceTurnRow:# 1 -> True). Keep _safe_col's contract at 0/1 — a sentinel like -1 would# break the bool() mapping here.awaiting_confirmation=bool(_safe_col(r, "awaiting_confirmation", 0)),+ voice_name=_safe_text_col(r, "voice_name"),+ voice_provider=_safe_text_col(r, "voice_provider"),tool_calls=json.loads(r["tool_calls_json"] or "[]"),)+def _safe_text_col(r: sqlite3.Row, name: str) -> str:+ """Text twin of _safe_col for columns added by a not-yet-run migration."""+ try:+ v = r[name]+ return str(v) if v is not None else ""+ except (KeyError, IndexError):+ return ""++def _safe_col(r: sqlite3.Row, name: str, default: int) -> int:"""Reads a column, returns the default if it doesn't exist.diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex e7dd2fb4e0..e4338dec10 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -9419,12 +9419,23 @@ class SpeechPipeline:if bus is None:returntry:+ # Which voice actually spoke: every classic-path phrase renders+ # through self._tts, whose providers record their resolved voice+ # per utterance (last_voice protocol, 2026-07-17). Read after+ # playback so a fallback takeover reports the TAKEOVER voice.+ tts = getattr(self, "_tts", None)+ voice = getattr(tts, "last_voice", None)+ voice_provider = getattr(tts, "last_voice_provider", None) or getattr(+ tts, "name", None+ )event = SpeechSpoken(source_layer="speech.pipeline",text=text,language=(language or "de"),spoken_kind=kind,detail=(detail or None),+ voice=voice,+ voice_provider=voice_provider if voice else None,)asyncio.create_task(bus.publish(event)) # noqa: RUF006 — fire-and-forgetexcept Exception: # noqa: BLE001 — telemetry must never break the turndiff --git a/jarvis/ui/web/frontend/src/components/sessions/TurnCard.test.tsx b/jarvis/ui/web/frontend/src/components/sessions/TurnCard.test.tsxindex 37921fd94b..35960cbfb2 100644--- a/jarvis/ui/web/frontend/src/components/sessions/TurnCard.test.tsx+++ b/jarvis/ui/web/frontend/src/components/sessions/TurnCard.test.tsx@@ -32,6 +32,8 @@ function turn(over: Partial<VoiceTurnRow> = {}): VoiceTurnRow {speak_ms: 0,tool_calls: [],awaiting_confirmation: false,+ voice_name: "",+ voice_provider: "",...over,};}@@ -210,6 +212,24 @@ describe("TurnCard spoken track", () => {expect(screen.queryByText("Awaiting confirmation")).toBeNull();});+ it("shows which voice actually spoke when the turn recorded one", () => {+ render(+ <TurnCard+ turn={turn({+ jarvis_text: "Servus!", // i18n-allow: German voice fixture+ voice_name: "Fenrir",+ voice_provider: "gemini-live",+ })}+ />,+ );+ expect(screen.getByText("Fenrir · gemini-live")).toBeTruthy();+ });++ it("shows no voice badge when the speaking voice is unknown", () => {+ render(<TurnCard turn={turn({ jarvis_text: "Hallo." })} />); // i18n-allow: German voice fixture+ expect(screen.queryByText(/gemini-live/)).toBeNull();+ });+it("marks a pending confirmation in the copied plain text", () => {const copied = formatTurnPlain(turn({ jarvis_text: "Soll ich senden?", awaiting_confirmation: true }), // i18n-allow: German voice fixturediff --git a/jarvis/ui/web/frontend/src/components/sessions/TurnCard.tsx b/jarvis/ui/web/frontend/src/components/sessions/TurnCard.tsxindex 65c3000e15..eb4c64fae7 100644--- a/jarvis/ui/web/frontend/src/components/sessions/TurnCard.tsx+++ b/jarvis/ui/web/frontend/src/components/sessions/TurnCard.tsx@@ -233,6 +233,20 @@ export function TurnCard({ turn, displayNumber, spoken = [] }: Props) {<Badge variant="secondary" className="ml-1 text-[9px]">{turn.jarvis_lang}</Badge>+ {turn.voice_name && (+ <Badge+ variant="outline"+ className="ml-1 font-mono text-[9px] normal-case text-muted-foreground"+ title={+ turn.voice_provider+ ? `Voice: ${turn.voice_name} (${turn.voice_provider})`+ : `Voice: ${turn.voice_name}`+ }+ >+ {turn.voice_name}+ {turn.voice_provider ? ` · ${turn.voice_provider}` : ""}+ </Badge>+ )}{turn.awaiting_confirmation && (<Badgevariant="outline"diff --git a/jarvis/ui/web/frontend/src/components/sessions/types.ts b/jarvis/ui/web/frontend/src/components/sessions/types.tsindex 50a99e86b1..50132459b4 100644--- a/jarvis/ui/web/frontend/src/components/sessions/types.ts+++ b/jarvis/ui/web/frontend/src/components/sessions/types.ts@@ -110,6 +110,12 @@ export interface VoiceTurnRow {// (finish_reason="voice_confirm_pending"): the reply is a pending yes/no// question, not a settled answer, so the transcript labels it distinctly.awaiting_confirmation: boolean;+ // Which voice actually spoke the reply ("Fenrir", "Charon") and the+ // speaking family ("gemini-live", "openrouter"). Empty = unknown — show+ // nothing rather than guess (the speaker can differ from the brain+ // provider, e.g. a surface-TTS readback inside a realtime turn).+ voice_name: string;+ voice_provider: string;}export interface VoiceSessionRow {diff --git a/tests/unit/plugins/tts/test_fallback_voice_continuity.py b/tests/unit/plugins/tts/test_fallback_voice_continuity.pyindex 42ff471602..2d0640c3ea 100644--- a/tests/unit/plugins/tts/test_fallback_voice_continuity.py+++ b/tests/unit/plugins/tts/test_fallback_voice_continuity.py@@ -125,6 +125,28 @@ async def test_wrapper_without_pin_keeps_provider_default():assert fallback.synth_calls[0][1] is None+async def test_wrapper_reports_the_voice_that_actually_spoke():+ # Healthy primary → the wrapper reports the primary's resolved voice.+ primary = _FakeTTS("primary", chunks=1)+ primary.last_voice = "Charon"+ fallback = _FakeTTS("fallback", chunks=1)+ fallback.last_voice = "leo"+ wrapper = FallbackTTS(primary, fallback, fallback_voice="leo")+ [c async for c in wrapper.synthesize("Hallo.", language_code="de-DE")]+ assert wrapper.last_voice == "Charon"+ assert wrapper.last_voice_provider == "primary"++ # Primary dead → the wrapper reports the fallback's voice, not the+ # primary's — this is what makes the per-turn transcript label honest.+ dead = _FakeTTS("primary", raise_before=True)+ dead.last_voice = "Charon"+ wrapper = FallbackTTS(dead, fallback, fallback_voice="leo")+ [c async for c in wrapper.synthesize("Hallo.", language_code="de-DE")]+ assert wrapper.last_voice == "leo"+ assert wrapper.last_voice_provider == "fallback"++# --- Factory wiring -------------------------------------------------------------class _Cfg:diff --git a/tests/unit/sessions/test_turn_voice_label.py b/tests/unit/sessions/test_turn_voice_label.pynew file mode 100644index 0000000000..f93d5ad256--- /dev/null+++ b/tests/unit/sessions/test_turn_voice_label.py@@ -0,0 +1,220 @@+"""Per-turn "which voice actually spoke" label (user request 2026-07-17).++The user heard the voice change mid-conversation (masculine to feminine, or a+different masculine voice) with no way to tell WHO spoke: the realtime session+voice ("Fenrir" @ gemini-live), the surface TTS ("Charon" @ openrouter), or a+fallback family ("leo"/"eve" @ grok-voice). Live case: session 2026-07-17+09:21, turn 4 — an internal fast path spoke through the surface TTS while the+session otherwise spoke through Gemini Live.++Chain under test: ``SpeechSpoken``/``VoiceTurnCompleted`` carry+``voice``/``voice_provider`` → ``SessionRecorder`` adopts them onto the turn+(the audible SpeechSpoken track beats the session-level claim) → ``SessionStore``+persists ``voice_name``/``voice_provider`` → the Markdown export prints the+small-print voice note.+"""+from __future__ import annotations++import pytest++from jarvis.core.bus import EventBus+from jarvis.core.events import (+ ListeningStarted,+ SpeechSpoken,+ VoiceSessionEnded,+ VoiceSessionStarted,+ VoiceTurnCompleted,+ VoiceTurnStarted,+)+from jarvis.sessions.constants import SPOKEN_KIND_REPLY+from jarvis.sessions.formatter import format_session_markdown+from jarvis.sessions.models import VoiceSessionRow, VoiceTurnRow+from jarvis.sessions.recorder import SessionRecorder+from jarvis.sessions.store import SessionStore+++async def _run_session(tmp_path, publish_between):+ """Boilerplate: run one recorded session, return its finalized turns."""+ store = SessionStore(tmp_path / "sessions.db")+ store.open()+ try:+ bus = EventBus()+ SessionRecorder(store).attach(bus)+ await bus.publish(+ VoiceSessionStarted(+ source_layer="speech.pipeline",+ session_id="sess-voice",+ wake_keyword="hey",+ language="de",+ )+ )+ await publish_between(bus)+ await bus.publish(+ VoiceSessionEnded(+ source_layer="speech.pipeline",+ session_id="sess-voice",+ hangup_reason="voice_pattern",+ )+ )+ return store.get_turns("sess-voice"), store+ except Exception:+ store.close()+ raise+++async def test_reply_voice_lands_on_the_turn(tmp_path) -> None:+ async def scenario(bus):+ await bus.publish(ListeningStarted(source_layer="speech"))+ await bus.publish(+ SpeechSpoken(+ source_layer="speech.pipeline",+ text="Servus!", # i18n-allow: German voice fixture+ language="de",+ spoken_kind=SPOKEN_KIND_REPLY,+ voice="Charon",+ voice_provider="openrouter",+ )+ )++ turns, store = await _run_session(tmp_path, scenario)+ try:+ assert turns, "no turn was recorded"+ assert turns[0].voice_name == "Charon"+ assert turns[0].voice_provider == "openrouter"+ # The raw event payload carries the voice too (Run Inspector track).+ spoken = [+ e for e in store.get_events("sess-voice") if e.kind == "SpeechSpoken"+ ]+ assert spoken and spoken[0].payload.get("voice") == "Charon"+ assert spoken[0].payload.get("voice_provider") == "openrouter"+ finally:+ store.close()+++async def test_realtime_session_voice_fills_a_blank_turn(tmp_path) -> None:+ async def scenario(bus):+ await bus.publish(+ VoiceTurnStarted(+ source_layer="realtime.gemini-live",+ session_id="sess-voice",+ turn_id="turn-rt-1",+ )+ )+ await bus.publish(+ VoiceTurnCompleted(+ source_layer="realtime.gemini-live",+ session_id="sess-voice",+ turn_id="turn-rt-1",+ user_text="Hallo", # i18n-allow: German voice fixture+ jarvis_text="Servus!", # i18n-allow: German voice fixture+ tier="realtime",+ provider="gemini-live",+ model="gemini-3.1-flash-live-preview",+ voice="Fenrir",+ voice_provider="gemini-live",+ )+ )++ turns, store = await _run_session(tmp_path, scenario)+ try:+ assert turns+ assert turns[0].voice_name == "Fenrir"+ assert turns[0].voice_provider == "gemini-live"+ finally:+ store.close()+++async def test_audible_track_beats_the_session_level_claim(tmp_path) -> None:+ """A surface-TTS readback inside a realtime turn stays honest: the voice+ that actually rendered audio (SpeechSpoken) wins over the session voice+ claimed by VoiceTurnCompleted."""++ async def scenario(bus):+ await bus.publish(+ VoiceTurnStarted(+ source_layer="realtime.gemini-live",+ session_id="sess-voice",+ turn_id="turn-rt-2",+ )+ )+ await bus.publish(+ SpeechSpoken(+ source_layer="speech.pipeline",+ text="Servus!", # i18n-allow: German voice fixture+ language="de",+ spoken_kind=SPOKEN_KIND_REPLY,+ voice="Charon",+ voice_provider="openrouter",+ )+ )+ await bus.publish(+ VoiceTurnCompleted(+ source_layer="realtime.gemini-live",+ session_id="sess-voice",+ turn_id="turn-rt-2",+ jarvis_text="Servus!", # i18n-allow: German voice fixture+ tier="realtime",+ provider="gemini-live",+ voice="Fenrir",+ voice_provider="gemini-live",+ )+ )++ turns, store = await _run_session(tmp_path, scenario)+ try:+ assert turns+ assert turns[0].voice_name == "Charon"+ assert turns[0].voice_provider == "openrouter"+ finally:+ store.close()+++async def test_unknown_voice_stays_empty_never_guessed(tmp_path) -> None:+ async def scenario(bus):+ await bus.publish(ListeningStarted(source_layer="speech"))+ await bus.publish(+ SpeechSpoken(+ source_layer="speech.pipeline",+ text="Servus!", # i18n-allow: German voice fixture+ language="de",+ spoken_kind=SPOKEN_KIND_REPLY,+ )+ )++ turns, store = await _run_session(tmp_path, scenario)+ try:+ assert turns+ assert turns[0].voice_name == ""+ assert turns[0].voice_provider == ""+ finally:+ store.close()+++def test_markdown_export_prints_the_voice_note() -> None:+ session = VoiceSessionRow(id="s1", started_ms=1_700_000_000_000)+ turn = VoiceTurnRow(+ id="t1",+ session_id="s1",+ started_ms=1_700_000_000_000,+ jarvis_text="Servus!", # i18n-allow: German voice fixture+ voice_name="Fenrir",+ voice_provider="gemini-live",+ )+ md = format_session_markdown(session, [turn])+ assert "Stimme: `Fenrir @ gemini-live`" in md # i18n-allow: localized export label under test+++def test_markdown_export_omits_the_note_when_voice_unknown() -> None:+ session = VoiceSessionRow(id="s1", started_ms=1_700_000_000_000)+ turn = VoiceTurnRow(+ id="t1",+ session_id="s1",+ started_ms=1_700_000_000_000,+ jarvis_text="Servus!", # i18n-allow: German voice fixture+ )+ md = format_session_markdown(session, [turn])+ assert "Stimme:" not in md # i18n-allow: localized export label under test