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.

feat(voice): one grounded progress line, the chat pre-ack bubble, and the topic-line opt-in

Harald7a86286b016b
diff --git a/docs/adr/0033-instant-acknowledgment.md b/docs/adr/0033-instant-acknowledgment.md
index 5c7aa69d13..54b6150c2f 100644
--- a/docs/adr/0033-instant-acknowledgment.md
+++ b/docs/adr/0033-instant-acknowledgment.md
@@ -60,6 +60,22 @@ One shared core, `jarvis/voice/instant_ack.py`, used by both voice engines.
predecessor); the "user holds the floor" and "Jarvis already speaking"
drops and the `should_play` predicate still apply. `[ack_brain].instant_ack
= false` is the kill switch. Mission heartbeat first beat 30 → 20 s.
+6. **One grounded progress line.** When the work outlasts the first line by
+ `PROGRESS_AFTER_S` (8 s), both engines speak ONE more line grounded in
+ the tool the turn is actually running — `ToolExecutor`'s `ActionProposed`
+ is classified into search / read / screen / handover / other pools
+ ("Still searching.", "Still on the screen."); a handover speaks nothing
+ (the spawn reply states it). At most one per turn, and never within 8 s
+ of any other interim line (the grounded router ack may have covered it).
+7. **Chat surface.** The text-chat path (desktop app and headless launcher)
+ shows the same first line as a muted pre-ack bubble
+ (`MessageSent(role="preamble")`, the bubble the chat view already
+ renders), armed before the brain call and cancelled the moment the reply
+ is in. Never spoken.
+8. **Opt-in topic lines for pooled classes.** `[ack_brain].instant_ack_compose_all
+ = true` lets the composer / live model produce a request-specific line for
+ research / personal / screen / mission too, under the same validator, with
+ the pool line as fallback. Off by default.
## Consequences
@@ -88,6 +104,12 @@ One shared core, `jarvis/voice/instant_ack.py`, used by both voice engines.
the ACTION-only path (and an Etappe-2 opt-in elsewhere).
- **Prompt-only "do not invent" for the action line** — BUG-054 proved
prompt compliance is not a boundary; the structural validator is.
+- **A bridge for provider-requested `jarvis_action` calls** — the live model
+ usually speaks its own line before calling; injecting a response while a
+ native function call is pending behaves differently per transport (Gemini
+ Live blocks on the tool response) and cannot be verified without a live
+ session, so this path keeps the model's own pre-call line as its ack.
+ Follow-up once a transport declares the capability.
## References
diff --git a/jarvis/brain/ack_brain/config.py b/jarvis/brain/ack_brain/config.py
index bbe68ca7d9..8ccfe5a446 100644
--- a/jarvis/brain/ack_brain/config.py
+++ b/jarvis/brain/ack_brain/config.py
@@ -145,6 +145,12 @@ class AckBrainConfig(BaseModel):
# class alone uses the flash composer and stays silent without one.
# False = back to the pre-2026-08-17 silence until the router acks.
instant_ack: bool = Field(default=True)
+ # Opt-in: request-specific lines for the POOLED instant-ack classes too
+ # ("I'm pulling the flight data for Friday." instead of "I'm looking that
+ # up online."). Same flash composer / live model, same structural
+ # validator, the pool line stays the instant fallback. Off by default:
+ # the pool lines already fit their class at 0 ms and zero cost.
+ instant_ack_compose_all: bool = Field(default=False)
# 2026-07-06 interim-ack redesign (spec: docs/superpowers/specs/
# 2026-07-06-interim-ack-redesign-design.md). Forensic finding: one voice
# session spoke the identical grounded ack once per utterance, three
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index 31a648eff4..562cc0a566 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -77,14 +77,19 @@ from jarvis.speech.interrupt_intent import (
classify_interrupt,
)
from jarvis.voice.instant_ack import (
+ PROGRESS_AFTER_S,
InstantAckPlan,
+ ToolActivity,
WorkClass,
all_instant_ack_lines,
+ all_progress_lines,
+ classify_tool_activity,
compose_contextual_ack,
contextual_ack_is_valid,
contextual_ack_prompt,
instant_ack_pool,
pick_instant_ack_text,
+ pick_progress_text,
plan_instant_ack,
)
@@ -1086,6 +1091,15 @@ def _delegate_bridge_texts(language: str) -> tuple[str, ...]:
return _DELEGATE_BRIDGE_TEXTS.get(language, _DELEGATE_BRIDGE_TEXTS["en"])
+def _all_progress_pool_lines(language: str) -> tuple[str, ...]:
+ """Every progress-pool line (jarvis.voice.instant_ack), rendered."""
+ from jarvis.voice.instant_ack import progress_pool
+
+ return tuple(
+ line for activity in ToolActivity for line in progress_pool(activity, language)
+ )
+
+
def _all_instant_ack_pool_lines(language: str, agent_brand: str) -> tuple[str, ...]:
"""Every closed instant-ack pool line (jarvis.voice.instant_ack), rendered.
@@ -1835,6 +1849,19 @@ class RealtimeVoiceSession:
# task — it must never hold a turn open, defer a VAD edge, or refuse
# an announcement on behalf of work that is merely a sleeping timer.
self._delegate_bridge_task: asyncio.Task[None] | None = None
+ # The tool the delegated turn is ACTUALLY running (ToolExecutor's
+ # ActionProposed on the bus) — grounds the +8 s progress line
+ # ("still searching" / "still on the screen") instead of a filler.
+ self._running_tool_name = ""
+ self._action_proposed_subscribed = False
+ if self._bus is not None:
+ try:
+ from jarvis.core.events import ActionProposed
+
+ self._bus.subscribe(ActionProposed, self._on_action_proposed)
+ self._action_proposed_subscribed = True
+ except Exception: # noqa: BLE001 — telemetry-grade, never load-bearing
+ log.debug("realtime: ActionProposed subscription failed", exc_info=True)
self._delegate_turns: dict[str, _DelegateTurnState] = {}
self._delegate_history: list[BrainMessage] = []
self._announcement_context_signatures: list[tuple[str, str, str]] = []
@@ -4476,6 +4503,7 @@ class RealtimeVoiceSession:
allowed_bridge_lines |= all_instant_ack_lines(
self._language, agent_brand=agent_brand
)
+ allowed_bridge_lines |= all_progress_lines(self._language)
expected_bridge = (
delegate_state.bridge_expected_text
or next(iter(_delegate_bridge_texts(self._language)))
@@ -4555,6 +4583,7 @@ class RealtimeVoiceSession:
*_all_instant_ack_pool_lines(
self._language, agent_brand
),
+ *_all_progress_pool_lines(self._language),
)
if _normalized_bridge_text(candidate)
== _normalized_bridge_text(bridge_text)
@@ -6214,6 +6243,16 @@ class RealtimeVoiceSession:
if tracker is not None and phase not in tracker.stages_snapshot():
tracker.mark(phase, detail=self._latency_detail(detail))
+ async def _on_action_proposed(self, event: Any) -> None:
+ """Remember the tool a delegated turn is running (progress line grounding)."""
+ if self._ended:
+ return
+ self._running_tool_name = str(getattr(event, "tool_name", "") or "")
+
+ def _instant_ack_compose_all(self) -> bool:
+ ack_cfg = getattr(self._config, "ack_brain", None)
+ return bool(getattr(ack_cfg, "instant_ack_compose_all", False))
+
def _agent_brand(self) -> str:
"""The wake-word-derived agent brand for spoken lines (never hardcoded)."""
try:
@@ -8149,12 +8188,12 @@ class RealtimeVoiceSession:
turn_id: str,
turn_state: _DelegateTurnState,
) -> None:
- """Speak the turn's first sign of life while the delegate is running.
+ """Speak the turn's first sign of life, then one honest progress line.
Instant acknowledgment (2026-08-17): the delay comes from the
instant-ack plan decided at dispatch — immediately for long work
(research, screen, mission), after a short grace for actions and
- memory reads so a fast result stays chatter-free — capped by the
+ personal lookups so a fast result stays chatter-free — capped by the
legacy ``_DELEGATE_BRIDGE_DELAY_S`` (which alone applies to
unclassified turns). The line names the KIND of work from a closed
pool, or for actions is a model-composed line naming the request's
@@ -8162,6 +8201,11 @@ class RealtimeVoiceSession:
complete transcript is a closed-pool member or passes the structural
contextual validator. A trusted result that is ready before the line
was released preempts it; a line already playing finishes.
+
+ When the work outlasts the first line by ``PROGRESS_AFTER_S`` the
+ same machinery speaks ONE progress line grounded in the tool the
+ delegate is actually running ("still searching" / "still on the
+ screen"), or the generic pool when no tool is known. At most one.
"""
try:
capability_limited = not bool(
@@ -8185,129 +8229,204 @@ class RealtimeVoiceSession:
pass
else:
return # the result beat the bridge — no interim line needed
- if self._delegate_bridge_must_stand_down(turn_id, turn_state):
+ self._running_tool_name = ""
+ await self._inject_delegate_bridge_line(
+ turn_id,
+ turn_state,
+ plan=plan,
+ progress=False,
+ delay_s=bridge_delay_s,
+ )
+ if plan is None:
+ # Unclassified turn: the legacy single late line, as before.
return
- await self._await_provider_response_boundary(turn_state)
+ try:
+ await asyncio.wait_for(
+ turn_state.result_ready.wait(),
+ timeout=PROGRESS_AFTER_S,
+ )
+ except TimeoutError:
+ pass
+ else:
+ return
+ if turn_state.bridge_delivery_started and not turn_state.provider_boundary_seen:
+ # The first line's response never closed in 8 s: the provider
+ # is stuck, not the action — a second order would only pile up.
+ return
+ # Re-arm the bridge slot for the progress line (the first line's
+ # response is closed; its audio was released or dropped).
+ turn_state.bridge_delivery_started = False
+ await self._inject_delegate_bridge_line(
+ turn_id,
+ turn_state,
+ plan=None,
+ progress=True,
+ delay_s=bridge_delay_s + PROGRESS_AFTER_S,
+ )
+ except asyncio.CancelledError:
+ raise
+ except Exception: # noqa: BLE001 — the bridge is best-effort by design
+ log.debug(
+ "realtime[%s] delegate bridge failed",
+ self.session_id,
+ exc_info=True,
+ )
+
+ async def _inject_delegate_bridge_line(
+ self,
+ turn_id: str,
+ turn_state: _DelegateTurnState,
+ *,
+ plan: InstantAckPlan | None,
+ progress: bool,
+ delay_s: float,
+ ) -> None:
+ """Order one bridge line from the live model (or the direct-speech channel).
+
+ ``progress=False``: the instant ack for ``plan`` (class pool line, or a
+ model-composed ACTION line under the structural validator).
+ ``progress=True``: one honest progress line grounded in the running
+ tool. Both stay muted until the transcript validates at the response
+ boundary; a broken injection resets the bridge slot and stays silent.
+ """
+ if self._delegate_bridge_must_stand_down(turn_id, turn_state):
+ return
+ await self._await_provider_response_boundary(turn_state)
+ if self._delegate_bridge_must_stand_down(turn_id, turn_state):
+ return
+ send_text = getattr(self._session, "send_text", None)
+ send_speech = getattr(self._session, "send_speech", None)
+ authoritative_speech = bool(
+ callable(send_speech)
+ and getattr(
+ self._session,
+ "direct_speech_is_authoritative",
+ False,
+ )
+ )
+ if not authoritative_speech and not callable(send_text):
+ return
+ contextual = bool(not progress and plan is not None and plan.contextual)
+ # Opt-in: request-specific lines for the pooled classes too — the
+ # live model composes, the same validator decides, the pool line is
+ # the whitelist fallback (a pool transcript still passes).
+ compose_pooled = bool(
+ not progress
+ and plan is not None
+ and not plan.contextual
+ and not authoritative_speech
+ and self._instant_ack_compose_all()
+ )
+ activity = ToolActivity.OTHER
+ if progress:
+ activity = classify_tool_activity(self._running_tool_name)
+ if activity is ToolActivity.HANDOVER:
+ # A background agent took over; its reply states the handover.
+ return
+ bridge_line = pick_progress_text(activity, self._language)
+ if not bridge_line:
+ return
+ elif contextual and authoritative_speech:
+ # A verbatim direct-speech channel cannot compose; ask the
+ # flash composer the Brain already carries (bounded, breaker
+ # guarded). No composer or no valid line -> stay silent: a
+ # stock line is exactly what an ACTION ack must not be, and
+ # the result speaks for itself.
+ composed = await compose_contextual_ack(
+ getattr(self._brain, "_readback_composer", None),
+ utterance=turn_state.user_text,
+ language=self._language,
+ agent_brand=self._agent_brand(),
+ )
if self._delegate_bridge_must_stand_down(turn_id, turn_state):
return
- send_text = getattr(self._session, "send_text", None)
- send_speech = getattr(self._session, "send_speech", None)
- authoritative_speech = bool(
- callable(send_speech)
- and getattr(
- self._session,
- "direct_speech_is_authoritative",
- False,
+ if not composed:
+ log.debug(
+ "realtime[%s] instant ack skipped: no valid contextual "
+ "action line for a verbatim-speech transport",
+ self.session_id,
)
- )
- if not authoritative_speech and not callable(send_text):
return
- contextual = bool(plan is not None and plan.contextual)
- if contextual and authoritative_speech:
- # A verbatim direct-speech channel cannot compose; ask the
- # flash composer the Brain already carries (bounded, breaker
- # guarded). No composer or no valid line -> stay silent: a
- # stock line is exactly what an ACTION ack must not be, and
- # the result speaks for itself.
- composed = await compose_contextual_ack(
- getattr(self._brain, "_readback_composer", None),
- utterance=turn_state.user_text,
- language=self._language,
- agent_brand=self._agent_brand(),
+ bridge_line = composed
+ elif contextual:
+ bridge_line = ""
+ elif plan is not None:
+ bridge_line = pick_instant_ack_text(
+ plan.work_class,
+ self._language,
+ agent_brand=self._agent_brand(),
+ )
+ else:
+ bridge_line = _pick_delegate_bridge_text(self._language)
+ turn_state.bridge_delivery_started = True
+ turn_state.bridge_preempted = False
+ turn_state.bridge_direct_speech = False
+ turn_state.bridge_direct_audio_emitted = False
+ turn_state.bridge_contextual = contextual or compose_pooled
+ turn_state.bridge_expected_text = bridge_line
+ turn_state.bridge_transcript_parts.clear()
+ turn_state.bridge_audio_chunks.clear()
+ # The bridge renderer starts a distinct provider response. The
+ # trusted result must wait for THIS boundary, not one observed
+ # before the bridge began.
+ turn_state.provider_boundary_seen = False
+ turn_state.provider_ready.clear()
+ drop_before_bridge = self._drop_provider_output_until_new_response
+ self._drop_provider_output_until_new_response = False
+ try:
+ if authoritative_speech:
+ turn_state.bridge_direct_speech = True
+ self._register_spoken_reference(
+ turn_state.bridge_expected_text,
+ slot=f"bridge:{turn_id}",
)
- if self._delegate_bridge_must_stand_down(turn_id, turn_state):
- return
- if not composed:
- log.debug(
- "realtime[%s] instant ack skipped: no valid contextual "
- "action line for a verbatim-speech transport",
- self.session_id,
+ await send_speech(turn_state.bridge_expected_text)
+ elif contextual or compose_pooled:
+ await send_text(
+ _contextual_bridge_prompt(
+ language=self._language,
+ utterance=turn_state.user_text,
)
- return
- bridge_line = composed
- elif contextual:
- bridge_line = ""
- elif plan is not None:
- bridge_line = pick_instant_ack_text(
- plan.work_class,
- self._language,
- agent_brand=self._agent_brand(),
)
else:
- bridge_line = _pick_delegate_bridge_text(self._language)
- turn_state.bridge_delivery_started = True
- turn_state.bridge_preempted = False
- turn_state.bridge_direct_speech = False
- turn_state.bridge_direct_audio_emitted = False
- turn_state.bridge_contextual = contextual
- turn_state.bridge_spoken_text = ""
- turn_state.bridge_expected_text = bridge_line
- turn_state.bridge_transcript_parts.clear()
- turn_state.bridge_audio_chunks.clear()
- # The bridge renderer starts a distinct provider response. The
- # trusted result must wait for THIS boundary, not one observed
- # before the bridge began.
- turn_state.provider_boundary_seen = False
- turn_state.provider_ready.clear()
- drop_before_bridge = self._drop_provider_output_until_new_response
- self._drop_provider_output_until_new_response = False
- try:
- if authoritative_speech:
- turn_state.bridge_direct_speech = True
- self._register_spoken_reference(
- turn_state.bridge_expected_text,
- slot=f"bridge:{turn_id}",
- )
- await send_speech(turn_state.bridge_expected_text)
- elif contextual:
- await send_text(
- _contextual_bridge_prompt(
- language=self._language,
- utterance=turn_state.user_text,
- )
- )
- else:
- await send_text(
- _delegate_bridge_prompt(
- language=self._language,
- exact_text=turn_state.bridge_expected_text,
- )
+ await send_text(
+ _delegate_bridge_prompt(
+ language=self._language,
+ exact_text=turn_state.bridge_expected_text,
)
- except Exception: # noqa: BLE001 — a broken bridge must not hurt the action
- turn_state.bridge_delivery_started = False
- self._drop_provider_output_until_new_response = drop_before_bridge
- log.debug(
- "realtime[%s] delegate bridge injection failed",
- self.session_id,
- exc_info=True,
)
- return
- self._mark_latency_named(
- "REALTIME_DELEGATE_BRIDGE_REQUESTED",
- detail=(
- f"class={plan.work_class.value if plan is not None else 'unclassified'};"
- f"delay_s={bridge_delay_s:.2f};contextual={contextual}"
- ),
- )
- log.info(
- "realtime[%s] delegate bridge: %s line requested %.2f s after "
- "dispatch while the action is still running",
- self.session_id,
- (
- "contextual action"
- if contextual
- else (plan.work_class.value if plan is not None else "progress")
- ),
- bridge_delay_s,
- )
- except asyncio.CancelledError:
- raise
- except Exception: # noqa: BLE001 — the bridge is best-effort by design
+ except Exception: # noqa: BLE001 — a broken bridge must not hurt the action
+ turn_state.bridge_delivery_started = False
+ self._drop_provider_output_until_new_response = drop_before_bridge
log.debug(
- "realtime[%s] delegate bridge failed",
+ "realtime[%s] delegate bridge injection failed",
self.session_id,
exc_info=True,
)
+ return
+ kind = (
+ f"progress:{activity.value}"
+ if progress
+ else (
+ "contextual action"
+ if contextual
+ else (plan.work_class.value if plan is not None else "unclassified")
+ )
+ )
+ self._mark_latency_named(
+ "REALTIME_DELEGATE_BRIDGE_REQUESTED",
+ detail=(
+ f"kind={kind};delay_s={delay_s:.2f};"
+ f"contextual={contextual or compose_pooled}"
+ ),
+ )
+ log.info(
+ "realtime[%s] delegate bridge: %s line requested %.2f s after "
+ "dispatch while the action is still running",
+ self.session_id,
+ kind,
+ delay_s,
+ )
async def _preempt_delegate_bridge(
self,
@@ -9703,6 +9822,14 @@ class RealtimeVoiceSession:
):
self._delegate_bridge_task.cancel()
self._delegate_bridge_task = None
+ if self._action_proposed_subscribed and self._bus is not None:
+ try:
+ from jarvis.core.events import ActionProposed
+
+ self._bus.unsubscribe(ActionProposed, self._on_action_proposed)
+ except Exception: # noqa: BLE001, S110 — teardown is best-effort
+ pass
+ self._action_proposed_subscribed = False
if (
self._late_delegate_flush_task is not None
and not self._late_delegate_flush_task.done()
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.py
index 60e4113e21..9553998a65 100644
--- a/jarvis/speech/pipeline.py
+++ b/jarvis/speech/pipeline.py
@@ -54,6 +54,7 @@ from jarvis.core.events import (
CU_PROGRESS_EVENTS,
DICTATION_REFUSAL_REASONS,
ActionPlanned,
+ ActionProposed,
AnnouncementRequested,
AudioOutFirst,
BrainTTFT,
@@ -151,9 +152,12 @@ from jarvis.trigger.hotkey import HotkeyTrigger
from jarvis.voice.instant_ack import (
PROGRESS_AFTER_S,
InstantAckPlan,
+ ToolActivity,
+ classify_tool_activity,
compose_contextual_ack,
note_spoken,
pick_instant_ack_text,
+ pick_progress_text,
plan_instant_ack,
)
@@ -2644,6 +2648,10 @@ class SpeechPipeline:
# Wave 0 (omni-latency): perceived time-to-first-audio (ack OR
# brain, whichever speaks first) feeds the per-turn latency tracker.
self._bus.subscribe(AudioOutFirst, self._on_audio_out_first)
+ # Instant-ack progress line (2026-08-17): remember which tool the
+ # turn is actually running so a long wait gets an HONEST "still
+ # searching" instead of a generic filler.
+ self._bus.subscribe(ActionProposed, self._on_action_proposed)
# Computer-use liveness: a desktop-automation loop (computer_use)
# runs as ONE opaque tool call that streams NO text, so the brain
# stall guard cannot tell "stepping through a 20-action plan" from
@@ -4451,15 +4459,16 @@ class SpeechPipeline:
if (
is_preamble
and source_layer == "brain.router.ack"
- and self._instant_ack_spoke_recently(PROGRESS_AFTER_S)
+ and self._interim_line_spoke_recently(PROGRESS_AFTER_S)
):
- # Instant acknowledgment (2026-08-17): the user just heard the
- # turn's first line. A second "let me check" seconds later is the
- # double-tap; the grounded router ack is welcome again only once
- # the wait has grown long enough to deserve a progress line.
+ # Instant acknowledgment (2026-08-17): the user just heard an
+ # interim line for this turn. A second "let me check" seconds later
+ # is the double-tap; the grounded router ack is welcome again only
+ # once the wait has grown long enough to deserve a progress line.
+ last = getattr(self, "_last_preamble_spoken", None)
log.info(
- "Grounded ack dropped — instant ack spoken %.1fs ago: %r",
- time.monotonic() - float(getattr(self, "_instant_ack_spoken_at", 0.0)),
+ "Grounded ack dropped — an interim line spoke %.1fs ago: %r",
+ time.monotonic() - (last[1] if last else time.monotonic()),
event.text[:80],
)
return
@@ -4816,10 +4825,18 @@ class SpeechPipeline:
plan.delay_s,
plan.contextual,
)
+ self._turn_tool_activity = ""
self._instant_ack_task = asyncio.create_task(
self._instant_ack_body(plan, text, language, seq),
name="instant-ack",
)
+ previous_progress = getattr(self, "_instant_progress_task", None)
+ if previous_progress is not None and not previous_progress.done():
+ previous_progress.cancel()
+ self._instant_progress_task = asyncio.create_task(
+ self._instant_progress_body(language, seq),
+ name="instant-ack-progress",
+ )
async def _instant_ack_body(
self, plan: InstantAckPlan, text: str, language: str, seq: int
@@ -4850,9 +4867,21 @@ class SpeechPipeline:
)
return
else:
- line = pick_instant_ack_text(
- plan.work_class, language, agent_brand=self._agent_brand_name()
- )
+ line = ""
+ if self._instant_ack_compose_all():
+ # Opt-in: a request-specific line for the pooled classes
+ # too ("I'm pulling the flight data for Friday."), same
+ # validator, the pool line as the instant fallback.
+ line = await compose_contextual_ack(
+ getattr(self._brain, "_readback_composer", None),
+ utterance=text,
+ language=language,
+ agent_brand=self._agent_brand_name(),
+ )
+ if not line:
+ line = pick_instant_ack_text(
+ plan.work_class, language, agent_brand=self._agent_brand_name()
+ )
if not line or not self._instant_ack_still_wanted(seq):
return
tracker = getattr(self, "_latency_tracker", None)
@@ -4875,6 +4904,62 @@ class SpeechPipeline:
except Exception: # noqa: BLE001 — the ack is best-effort by design
log.warning("Instant ack failed", exc_info=True)
+ def _instant_ack_compose_all(self) -> bool:
+ ack_cfg = getattr(getattr(self, "_config", None), "ack_brain", None)
+ return bool(getattr(ack_cfg, "instant_ack_compose_all", False))
+
+ async def _on_action_proposed(self, event: ActionProposed) -> None:
+ """Remember the tool the current voice turn is running (progress line)."""
+ if getattr(self, "_turn_state", TurnTakingState.IDLE) is not TurnTakingState.PROCESSING:
+ return
+ self._turn_tool_activity = str(getattr(event, "tool_name", "") or "")
+
+ async def _instant_progress_body(self, language: str, seq: int) -> None:
+ """One honest progress line when the work outlasts the ack by 8 s.
+
+ Grounded in the tool the turn is ACTUALLY running (``ActionProposed``):
+ "still searching", "still reading through your records", "still on the
+ screen" — the generic pool only when no tool is known. Skipped when a
+ background agent took over (its reply states the handover) or when
+ any interim line spoke in the last 8 s (the grounded router ack may
+ have covered it). At most one per turn.
+ """
+ try:
+ await asyncio.sleep(PROGRESS_AFTER_S)
+ if not self._instant_ack_still_wanted(seq):
+ return
+ if self._interim_line_spoke_recently(PROGRESS_AFTER_S):
+ return
+ activity = classify_tool_activity(getattr(self, "_turn_tool_activity", ""))
+ if activity is ToolActivity.HANDOVER:
+ return
+ line = pick_progress_text(activity, language)
+ if not line or not self._instant_ack_still_wanted(seq):
+ return
+ log.info("Instant progress line (activity=%s): %r", activity.value, line)
+ # kind="preamble", not "progress": a progress announcement is the
+ # background-mission heartbeat and is dropped unless LISTENING; this
+ # line belongs to the FOREGROUND turn that is still PROCESSING and
+ # obeys the same gates as the instant ack (speaking answer, floor).
+ await self._publish_event(
+ AnnouncementRequested(
+ source_layer=self._INSTANT_ACK_SOURCE_LAYER,
+ text=line,
+ priority="normal",
+ language=language,
+ kind="preamble",
+ )
+ )
+ except asyncio.CancelledError:
+ raise
+ except Exception: # noqa: BLE001 — best-effort by design
+ log.warning("Instant progress line failed", exc_info=True)
+
+ def _interim_line_spoke_recently(self, within_s: float) -> bool:
+ """Any preamble/progress line (instant ack, router ack, heartbeat) just spoke."""
+ last = getattr(self, "_last_preamble_spoken", None)
+ return bool(last is not None and (time.monotonic() - last[1]) < within_s)
+
def _instant_ack_still_wanted(self, seq: int) -> bool:
"""The line is only coherent while THIS turn is still thinking."""
if int(getattr(self, "_instant_ack_turn_seq", 0)) != seq:
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.py
index 67794e5a29..cc533d7881 100644
--- a/jarvis/ui/desktop_app.py
+++ b/jarvis/ui/desktop_app.py
@@ -1889,6 +1889,26 @@ class DesktopApp:
return
loop = asyncio.get_running_loop()
+ # Instant acknowledgment (2026-08-17): the chat path has no
+ # streaming, so a heavy turn shows only "thinking…" until the whole
+ # reply returns. Show the same first-sign-of-life line the voice
+ # engines speak as a muted pre-ack bubble; cancelled the moment the
+ # reply is in (a fast turn shows nothing).
+ ack_task = None
+ try:
+ from jarvis.brain.assistant_name import agent_brand
+ from jarvis.voice.instant_ack import start_chat_instant_ack
+
+ ack_task = start_chat_instant_ack(
+ server.bus,
+ text=evt.text,
+ thread_id=thread_id,
+ trace_id=evt.trace_id,
+ brain=brain,
+ agent_brand=agent_brand(self.cfg),
+ )
+ except Exception: # noqa: BLE001 — a missing ack must never block chat
+ logger.opt(exception=True).debug("chat instant ack not armed")
try:
await supervisor.set_state("THINKING")
generate = getattr(brain, "generate", None)
@@ -1918,6 +1938,8 @@ class DesktopApp:
detail = f"{type(exc).__name__}: {exc}"
message = f"Brain error: {detail}"
logger.opt(exception=exc).warning("BrainManager call failed")
+ if ack_task is not None and not ack_task.done():
+ ack_task.cancel()
await server.bus.publish(
ErrorOccurred(
layer="brain",
@@ -1943,6 +1965,8 @@ class DesktopApp:
await supervisor.set_state("IDLE")
return
+ if ack_task is not None and not ack_task.done():
+ ack_task.cancel()
if reply is _CHAT_TURN_ABORTED:
# The user pressed the bar's X mid-think — honour it and drop
# back to IDLE instead of speaking a half-finished turn.
diff --git a/jarvis/ui/web/launcher.py b/jarvis/ui/web/launcher.py
index 805e3a1577..f98fde1ea5 100644
--- a/jarvis/ui/web/launcher.py
+++ b/jarvis/ui/web/launcher.py
@@ -604,6 +604,26 @@ async def _run_headless(args) -> int:
text=message,
)
return
+ # Instant acknowledgment (2026-08-17): the same first-sign-of-life
+ # line the voice engines speak, as a muted pre-ack bubble; cancelled
+ # the moment the reply is in (desktop_app.py mirrors it).
+ ack_task = None
+ try:
+ from jarvis.brain.assistant_name import agent_brand
+ from jarvis.voice.instant_ack import start_chat_instant_ack
+
+ ack_task = start_chat_instant_ack(
+ server.bus,
+ text=evt.text,
+ thread_id=thread_id,
+ trace_id=evt.trace_id,
+ brain=brain,
+ agent_brand=agent_brand(server.cfg),
+ )
+ except Exception: # noqa: BLE001 — a missing ack must never block chat
+ import logging as _ack_logging
+
+ _ack_logging.getLogger(__name__).debug("chat instant ack not armed", exc_info=True)
try:
generate = getattr(brain, "generate", None)
if callable(generate):
@@ -620,6 +640,8 @@ async def _run_headless(args) -> int:
else:
reply = await brain(evt.text)
except Exception as exc: # noqa: BLE001
+ if ack_task is not None and not ack_task.done():
+ ack_task.cancel()
detail = f"{type(exc).__name__}: {exc}"
message = f"Brain error: {detail}"
await server.bus.publish(
@@ -636,6 +658,8 @@ async def _run_headless(args) -> int:
text=message,
)
return
+ if ack_task is not None and not ack_task.done():
+ ack_task.cancel()
if reply:
role = "system" if _is_brain_diagnostic(reply) else "assistant"
await chat_store.add_message(thread_id=thread_id, role=role, text=reply)
diff --git a/jarvis/voice/instant_ack.py b/jarvis/voice/instant_ack.py
index 40c98aca6b..2110844c2e 100644
--- a/jarvis/voice/instant_ack.py
+++ b/jarvis/voice/instant_ack.py
@@ -37,6 +37,8 @@ German/Spanish strings below are runtime voice output (CLAUDE.md §1).
from __future__ import annotations
+import asyncio
+import logging
import random
import re
import time
@@ -44,9 +46,12 @@ import unicodedata
from collections import deque
from dataclasses import dataclass
from enum import StrEnum
+from typing import Any
from jarvis.brain.turn_planner import TurnPlan, TurnReason, is_lookup_shape
+log = logging.getLogger(__name__)
+
_SUPPORTED_LANGUAGES = ("de", "en", "es")
_DEFAULT_LANGUAGE = "en"
@@ -954,6 +959,268 @@ def recently_spoken(within_s: float = PROGRESS_AFTER_S, *, now: float | None = N
return line if (current - at) < float(within_s) else ""
+# ---------------------------------------------------------------------------
+# Progress line — grounded in the tool that is ACTUALLY running
+# ---------------------------------------------------------------------------
+
+
+class ToolActivity(StrEnum):
+ """Coarse class of a running tool, for an honest "still on it" line."""
+
+ SEARCH = "search"
+ READ = "read"
+ SCREEN = "screen"
+ HANDOVER = "handover" # a background agent took over — the reply says so
+ OTHER = "other"
+
+
+_TOOL_ACTIVITY_MARKERS: tuple[tuple[ToolActivity, tuple[str, ...]], ...] = (
+ (ToolActivity.HANDOVER, ("spawn", "mission", "dispatch_harness", "worker")),
+ (
+ ToolActivity.SCREEN,
+ (
+ "computer_use",
+ "click",
+ "type_text",
+ "hotkey",
+ "scroll",
+ "screen",
+ "open_app",
+ "switch_window",
+ "move_mouse",
+ "window",
+ "screenshot",
+ ),
+ ),
+ (ToolActivity.SEARCH, ("search", "web", "browse", "fetch", "http", "crawl")),
+ (
+ ToolActivity.READ,
+ (
+ "wiki",
+ "memory",
+ "recall",
+ "note",
+ "read",
+ "calendar",
+ "mail",
+ "gmail",
+ "contact",
+ "list",
+ "get",
+ "inspect",
+ "status",
+ "lookup",
+ ),
+ ),
+)
+
+
+def classify_tool_activity(tool_name: str) -> ToolActivity:
+ """Map a tool name (any registry, any casing) onto a progress class."""
+ name = str(tool_name or "").casefold()
+ if not name:
+ return ToolActivity.OTHER
+ for activity, markers in _TOOL_ACTIVITY_MARKERS:
+ if any(marker in name for marker in markers):
+ return activity
+ return ToolActivity.OTHER
+
+
+# i18n-allow: localized runtime voice output (whole table)
+_PROGRESS_POOLS: dict[ToolActivity, dict[str, tuple[str, ...]]] = {
+ ToolActivity.SEARCH: {
+ "de": ( # i18n-allow: localized runtime voice output
+ "Die Suche läuft noch.", # i18n-allow
+ "Ich bin noch am Suchen.", # i18n-allow
+ "Die Online-Suche braucht noch einen Moment.", # i18n-allow
+ ),
+ "en": (
+ "Still searching.",
+ "The search is still running.",
+ "The online lookup needs another moment.",
+ ),
+ "es": ( # i18n-allow: localized runtime voice output
+ "Sigo buscando.",
+ "La búsqueda sigue en marcha.",
+ "La consulta en línea necesita un momento más.",
+ ),
+ },
+ ToolActivity.READ: {
+ "de": ( # i18n-allow: localized runtime voice output
+ "Ich lese noch in deinen Unterlagen.", # i18n-allow
+ "Bin noch am Nachlesen.", # i18n-allow
+ "Ich gehe das noch durch.", # i18n-allow
+ ),
+ "en": (
+ "Still reading through your records.",
+ "Still going through it.",
+ "Reading on, one moment.",
+ ),
+ "es": ( # i18n-allow: localized runtime voice output
+ "Sigo leyendo tus registros.",
+ "Todavía lo estoy revisando.",
+ "Sigo con ello, un momento.",
+ ),
+ },
+ ToolActivity.SCREEN: {
+ "de": ( # i18n-allow: localized runtime voice output
+ "Ich bin noch am Bildschirm dran.", # i18n-allow
+ "Der Bildschirm-Schritt läuft noch.", # i18n-allow
+ "Noch einen Moment am Bildschirm.", # i18n-allow
+ ),
+ "en": (
+ "Still working on the screen.",
+ "The screen step is still running.",
+ "One more moment on the screen.",
+ ),
+ "es": ( # i18n-allow: localized runtime voice output
+ "Sigo con la pantalla.",
+ "El paso en pantalla sigue en marcha.",
+ "Un momento más en la pantalla.",
+ ),
+ },
+ ToolActivity.OTHER: {
+ "de": ( # i18n-allow: localized runtime voice output
+ "Ich bin noch dran.", # i18n-allow
+ "Dauert noch einen kleinen Moment.", # i18n-allow
+ "Bin gleich so weit.", # i18n-allow
+ ),
+ "en": (
+ "I'm still working on it.",
+ "Still on it, give me a moment.",
+ "Almost there.",
+ ),
+ "es": ( # i18n-allow: localized runtime voice output
+ "Sigo trabajando en ello.",
+ "Un momento más.",
+ "Ya casi está.",
+ ),
+ },
+ # HANDOVER: no line of its own — the spawn reply states the handover.
+ ToolActivity.HANDOVER: {"de": (), "en": (), "es": ()},
+}
+
+_RECENT_PROGRESS: dict[tuple[ToolActivity, str], deque[str]] = {}
+
+
+def progress_pool(activity: ToolActivity, language: str) -> tuple[str, ...]:
+ return tuple(_PROGRESS_POOLS.get(activity, {}).get(_language_key(language), ()))
+
+
+def pick_progress_text(activity: ToolActivity, language: str) -> str:
+ """One honest progress line for the running activity; ``""`` for handover."""
+ pool = progress_pool(activity, language)
+ if not pool:
+ return ""
+ key = (activity, _language_key(language))
+ recent = _RECENT_PROGRESS.setdefault(key, deque(maxlen=_RECENT_DEPTH))
+ candidates = [line for line in pool if line not in recent] or list(pool)
+ # noqa comment: variety, not security — any pool member is equally safe.
+ chosen = random.choice(candidates) # noqa: S311
+ recent.append(chosen)
+ return chosen
+
+
+def all_progress_lines(language: str) -> frozenset[str]:
+ """Every progress-pool line for ``language``, normalized (transcript whitelist)."""
+ return frozenset(
+ normalize_ack_line(line)
+ for activity in ToolActivity
+ for line in progress_pool(activity, language)
+ )
+
+
+# ---------------------------------------------------------------------------
+# Chat surface — the visual twin of the spoken line
+# ---------------------------------------------------------------------------
+
+
+def start_chat_instant_ack(
+ bus: Any,
+ *,
+ text: str,
+ thread_id: str,
+ trace_id: Any = None,
+ brain: Any = None,
+ agent_brand: str = "",
+ language: str = "",
+) -> asyncio.Task[None] | None:
+ """Show the instant ack as a muted pre-ack bubble in a text-chat thread.
+
+ The chat path has no streaming and no interim voice: the user sees
+ "thinking…" until the whole turn returns. This publishes the same line the
+ voice engines would speak — as ``MessageSent(role="preamble")``, the
+ bubble the chat view already renders for pre-acks — after the plan's
+ delay, and only if the task is still alive (the caller cancels it the
+ moment the reply arrives, so a fast turn shows nothing). Never speaks:
+ it is a bus message for the UI, not an announcement.
+
+ Returns the task (cancel it in the caller's ``finally``) or ``None`` when
+ the turn warrants no ack.
+ """
+ request = str(text or "").strip()
+ if bus is None or not request:
+ return None
+ try:
+ from jarvis.brain.ack_generator import is_voice_control_utterance
+ from jarvis.brain.turn_planner import plan_turn
+
+ if is_voice_control_utterance(request):
+ return None
+ plan = plan_instant_ack(plan_turn(request), request)
+ except Exception: # noqa: BLE001 — planning must never break a chat turn
+ log.debug("chat instant ack: planning failed", exc_info=True)
+ return None
+ if plan is None:
+ return None
+ if not language:
+ try:
+ from jarvis.core.turn_language import resolve_output_language
+
+ language = resolve_output_language(
+ getattr(brain, "_reply_language", None),
+ "unknown",
+ request,
+ conversation_language=getattr(brain, "_conversation_language", None),
+ )
+ except Exception: # noqa: BLE001 — fall back to the module default
+ language = _DEFAULT_LANGUAGE
+
+ async def _body() -> None:
+ try:
+ if plan.delay_s > 0:
+ await asyncio.sleep(plan.delay_s)
+ if plan.contextual:
+ line = await compose_contextual_ack(
+ getattr(brain, "_readback_composer", None),
+ utterance=request,
+ language=language,
+ agent_brand=agent_brand,
+ )
+ else:
+ line = pick_instant_ack_text(plan.work_class, language, agent_brand=agent_brand)
+ if not line:
+ return
+ from jarvis.core.events import MessageSent
+
+ kwargs: dict[str, Any] = {
+ "thread_id": thread_id,
+ "role": "preamble",
+ "text": line,
+ "source_layer": "brain.instant_ack",
+ }
+ if trace_id is not None:
+ kwargs["trace_id"] = trace_id
+ await bus.publish(MessageSent(**kwargs))
+ note_spoken(line)
+ except asyncio.CancelledError:
+ raise
+ except Exception: # noqa: BLE001 — best-effort by design
+ log.debug("chat instant ack failed", exc_info=True)
+
+ return asyncio.create_task(_body(), name="chat-instant-ack")
+
+
#: Hard budget for a flash-LLM composed ACTION line. The line is worthless
#: after the result, so a slow provider simply costs the ack, never the turn.
CONTEXTUAL_BUDGET_MS = 700
diff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.py
index 2368f3c50d..0d1815a52c 100644
--- a/tests/unit/realtime/test_session.py
+++ b/tests/unit/realtime/test_session.py
@@ -4029,6 +4029,113 @@ async def test_action_delegate_speaks_a_contextual_line(monkeypatch):
await sess.end(reason="test")
+class _TwoLineBridgeSession(FakeSession):
+ """Speak the instant line, then the progress line, then the result."""
+
+ def __init__(self, *, lines, orders_sent, result_delivered, utterance, result_line):
+ super().__init__([])
+ self._lines = list(lines)
+ self._orders_sent = orders_sent # list of asyncio.Event, one per line
+ self._result_delivered = result_delivered
+ self._utterance = utterance
+ self._result_line = result_line
+ self.orders: list[str] = []
+
+ async def receive(self):
+ yield RealtimeEvent(type="input_transcript", text=self._utterance, is_final=True)
+ for line, sent in zip(self._lines, self._orders_sent, strict=True):
+ await sent.wait()
+ yield RealtimeEvent(type="output_transcript_delta", text=line)
+ yield RealtimeEvent(
+ type="audio_delta",
+ audio=AudioChunk(pcm=b"\x01\x02" * 8, sample_rate=24_000, timestamp_ns=0),
+ )
+ yield RealtimeEvent(type="turn_complete")
+ await self._result_delivered.wait()
+ yield RealtimeEvent(type="output_transcript_delta", text=self._result_line)
+ yield RealtimeEvent(
+ type="audio_delta",
+ audio=AudioChunk(pcm=b"\x03\x04" * 8, sample_rate=24_000, timestamp_ns=0),
+ )
+ yield RealtimeEvent(type="turn_complete")
+
+ async def send_text(self, text):
+ await super().send_text(text)
+ if "<trusted_action_result>" in text:
+ self._result_delivered.set()
+ return
+ self.orders.append(text)
+ index = len(self.orders) - 1
+ if index < len(self._orders_sent):
+ self._orders_sent[index].set()
+
+
+class _TwoLineBridgeProvider(FakeProvider):
+ def __init__(self, **kwargs):
+ super().__init__([])
+ self._kwargs = kwargs
+
+ async def open_session(self, cfg):
+ self.opened_with = cfg
+ self.session = _TwoLineBridgeSession(**self._kwargs)
+ return self.session
+
+
+async def test_long_delegate_gets_one_grounded_progress_line_after_the_ack(monkeypatch):
+ """Instant ack, then — when the work outlasts it — ONE progress line that
+ names the tool actually running (search_web -> the search pool), then the
+ result. Never a second ack, never a third line."""
+ monkeypatch.setattr("jarvis.realtime.session._DELEGATE_BRIDGE_DELAY_S", 6.0)
+ monkeypatch.setattr("jarvis.realtime.session.PROGRESS_AFTER_S", 0.15)
+ _pin_instant_ack(monkeypatch, "I'm still working on it.")
+ monkeypatch.setattr(
+ "jarvis.realtime.session.pick_progress_text",
+ lambda activity, language: "Still searching."
+ if activity.value == "search"
+ else "I'm still working on it.",
+ )
+ from jarvis.core.events import ActionProposed
+
+ gate = asyncio.Event()
+ orders_sent = [asyncio.Event(), asyncio.Event()]
+ result_delivered = asyncio.Event()
+ brain = FakeBrain(replies=(_RESEARCH_RESULT,), gate=gate)
+ provider = _TwoLineBridgeProvider(
+ lines=("I'm still working on it.", "Still searching."),
+ orders_sent=orders_sent,
+ result_delivered=result_delivered,
+ utterance=_RESEARCH_UTTERANCE,
+ result_line=_RESEARCH_RESULT,
+ )
+ bus = FakeBus()
+ binaries: list[bytes] = []
+ sess = _session(provider, brain=brain, jsons=[], binaries=binaries, bus=bus)
+
+ await sess.handle_control({"type": "audio_start", "sample_rate": 16_000})
+ await asyncio.wait_for(orders_sent[0].wait(), timeout=2)
+ # The delegate is running a web search (ToolExecutor publishes this).
+ await sess._on_action_proposed(ActionProposed(tool_name="search_web"))
+ await asyncio.wait_for(orders_sent[1].wait(), timeout=2)
+ orders = provider.session.orders
+ assert len(orders) == 2
+ assert "I'm still working on it." in orders[0]
+ assert "Still searching." in orders[1]
+ # Nothing else is ordered while the action keeps running.
+ await asyncio.sleep(0.4)
+ assert len(provider.session.orders) == 2
+ gate.set()
+ await asyncio.wait_for(result_delivered.wait(), timeout=2)
+ await sess.wait_finished()
+ spoken = [event for event in bus.events if isinstance(event, SpeechSpoken)]
+ assert [(event.text, event.spoken_kind) for event in spoken] == [
+ ("I'm still working on it.", "progress"),
+ ("Still searching.", "progress"),
+ (_RESEARCH_RESULT, "reply"),
+ ]
+ await sess.end(reason="test")
+
+
@pytest.mark.asyncio
async def test_contextual_action_line_that_claims_a_result_is_dropped(monkeypatch):
"""A contextual ACTION ack is trusted only through the structural validator:
diff --git a/tests/unit/speech/test_instant_ack_pipeline.py b/tests/unit/speech/test_instant_ack_pipeline.py
index a73828370e..e063f9182a 100644
--- a/tests/unit/speech/test_instant_ack_pipeline.py
+++ b/tests/unit/speech/test_instant_ack_pipeline.py
@@ -12,6 +12,7 @@ exempt from the anti-loop cap because it is one line per user utterance.
from __future__ import annotations
import asyncio
+import time
from collections.abc import AsyncIterator
from dataclasses import dataclass, field
from types import SimpleNamespace
@@ -298,6 +299,8 @@ async def test_router_ack_shortly_after_an_instant_ack_is_dropped(monkeypatch) -
# Long wait: the router ack becomes the progress line.
pipeline._instant_ack_spoken_at -= 30.0
+ last_text, last_at = pipeline._last_preamble_spoken
+ pipeline._last_preamble_spoken = (last_text, last_at - 30.0)
await bus.publish(
AnnouncementRequested(
text="Still checking your calendar for tomorrow.",
@@ -361,3 +364,83 @@ async def test_a_new_utterance_cancels_the_pending_ack_of_the_previous_one(
assert first is not None and first.cancelled()
assert _instant_acks(seen) == []
+
+
+async def test_long_turn_gets_one_progress_line_grounded_in_the_running_tool(
+ monkeypatch,
+) -> None:
+ """Instant ack, then — after PROGRESS_AFTER_S with the turn still
+ processing — ONE line that names the tool actually running (search_web
+ -> the search pool). A handover (spawn_worker) speaks nothing: its reply
+ states the handover."""
+ from jarvis.core.events import ActionProposed
+ from jarvis.speech import pipeline as pipeline_module
+
+ monkeypatch.setattr(pipeline_module, "PROGRESS_AFTER_S", 0.2)
+ monkeypatch.setattr(
+ instant_ack_module,
+ "_POOLS",
+ {
+ **instant_ack_module._POOLS,
+ instant_ack_module.WorkClass.RESEARCH: {
+ "de": ("Ich suche das gerade online.",), # i18n-allow: fixture
+ "en": ("I'm looking that up online.",),
+ "es": ("Lo estoy buscando en línea.",),
+ },
+ },
+ )
+ bus = EventBus()
+ seen: list[AnnouncementRequested] = []
+ bus.subscribe(AnnouncementRequested, lambda e: seen.append(e))
+ tts = FakeTTS()
+ player = FakePlayer()
+ pipeline = _make_pipeline(tts, bus, player)
+
+ pipeline._arm_instant_ack("What's the weather in Berlin right now?", "en")
+ await _settle(0.05)
+ await bus.publish(ActionProposed(tool_name="search_web"))
+ await _settle(0.35)
+
+ texts = [a.text for a in _instant_acks(seen)]
+ assert texts[0] == "I'm looking that up online."
+ assert len(texts) == 2
+ assert texts[1] in instant_ack_module.progress_pool(
+ instant_ack_module.ToolActivity.SEARCH, "en"
+ )
+ assert player.plays == 2
+ # Nothing more while the turn keeps running: one progress line per turn.
+ await _settle(0.3)
+ assert len(_instant_acks(seen)) == 2
+
+ # Handover: the spawn reply states it — no progress line.
+ seen.clear()
+ pipeline._arm_instant_ack("What's the weather in Berlin right now?", "en")
+ await _settle(0.05)
+ await bus.publish(ActionProposed(tool_name="spawn_worker"))
+ await _settle(0.4)
+ assert len(_instant_acks(seen)) == 1
+
+
+async def test_progress_line_yields_to_a_router_ack_that_just_spoke(monkeypatch) -> None:
+ """If the grounded router ack covered the wait seconds ago, the progress
+ line stays silent (no two interim lines within the window)."""
+ from jarvis.speech import pipeline as pipeline_module
+
+ monkeypatch.setattr(pipeline_module, "PROGRESS_AFTER_S", 0.2)
+ bus = EventBus()
+ seen: list[AnnouncementRequested] = []
+ bus.subscribe(AnnouncementRequested, lambda e: seen.append(e))
+ tts = FakeTTS()
+ player = FakePlayer()
+ pipeline = _make_pipeline(tts, bus, player)
+
+ pipeline._arm_instant_ack("What's the weather in Berlin right now?", "en")
+ await _settle(0.05)
+ assert player.plays == 1
+ # A router ack 0.25 s later is still inside the window -> dropped; then
+ # simulate that one DID speak just before the progress deadline.
+ pipeline._last_preamble_spoken = ("Checking the weather for you.", time.monotonic())
+ await _settle(0.35)
+ assert len(_instant_acks(seen)) == 1, "the progress line spoke over a fresh interim line"
diff --git a/tests/unit/voice/test_instant_ack.py b/tests/unit/voice/test_instant_ack.py
index 8b4c7c5ba9..845eca721b 100644
--- a/tests/unit/voice/test_instant_ack.py
+++ b/tests/unit/voice/test_instant_ack.py
@@ -2,19 +2,28 @@
from __future__ import annotations
+import asyncio
+
import pytest
from jarvis.brain.turn_planner import plan_turn
from jarvis.voice.instant_ack import (
+ _POOLS,
IMMEDIATE_DELAY_S,
SHORT_GRACE_S,
+ ToolActivity,
WorkClass,
all_instant_ack_lines,
+ all_progress_lines,
+ classify_tool_activity,
contextual_ack_is_valid,
instant_ack_pool,
normalize_ack_line,
pick_instant_ack_text,
+ pick_progress_text,
plan_instant_ack,
+ progress_pool,
+ start_chat_instant_ack,
)
# ---------------------------------------------------------------------------
@@ -241,3 +250,110 @@ def test_a_digit_from_the_request_is_allowed_a_new_one_is_not():
assert not contextual_ack_is_valid(
"I'm opening terminal 4.", utterance="Open terminal 3", language="en"
)
+
+
+# ---------------------------------------------------------------------------
+# progress line — grounded in the running tool
+# ---------------------------------------------------------------------------
+
+
+ ("tool_name", "activity"),
+ [
+ ("search_web", ToolActivity.SEARCH),
+ ("browse_url", ToolActivity.SEARCH),
+ ("wiki_recall", ToolActivity.READ),
+ ("gmail_list_messages", ToolActivity.READ),
+ ("computer_use", ToolActivity.SCREEN),
+ ("open_app", ToolActivity.SCREEN),
+ ("spawn_worker", ToolActivity.HANDOVER),
+ ("run_shell", ToolActivity.OTHER),
+ ("", ToolActivity.OTHER),
+ ],
+)
+def test_tool_names_map_onto_progress_activities(tool_name, activity):
+ assert classify_tool_activity(tool_name) is activity
+
+
[email protected]("language", ["de", "en", "es"])
+def test_progress_pools_exist_for_every_activity_except_handover(language):
+ for activity in ToolActivity:
+ pool = progress_pool(activity, language)
+ if activity is ToolActivity.HANDOVER:
+ assert pool == ()
+ assert pick_progress_text(activity, language) == ""
+ else:
+ assert len(pool) >= 2
+ assert pick_progress_text(activity, language) in pool
+
+
+def test_all_progress_lines_are_normalized():
+ assert normalize_ack_line("Still searching.") in all_progress_lines("en")
+
+
+# ---------------------------------------------------------------------------
+# chat surface — the visual twin
+# ---------------------------------------------------------------------------
+
+
+class _Bus:
+ def __init__(self) -> None:
+ self.events: list = []
+
+ async def publish(self, event) -> None:
+ self.events.append(event)
+
+
+async def test_chat_instant_ack_publishes_a_preamble_bubble(monkeypatch):
+ monkeypatch.setattr(
+ "jarvis.voice.instant_ack._POOLS",
+ {
+ **_POOLS,
+ WorkClass.RESEARCH: {
+ "de": ("Ich suche das gerade online.",), # i18n-allow: fixture
+ "en": ("I'm looking that up online.",),
+ "es": ("Lo estoy buscando en línea.",),
+ },
+ },
+ )
+ bus = _Bus()
+ task = start_chat_instant_ack(
+ bus,
+ text="What's the weather in Berlin right now?",
+ thread_id="t-1",
+ language="en",
+ )
+ assert task is not None
+ await asyncio.wait_for(task, timeout=2)
+ assert len(bus.events) == 1
+ event = bus.events[0]
+ assert event.role == "preamble"
+ assert event.thread_id == "t-1"
+ assert event.text == "I'm looking that up online."
+ assert event.source_layer == "brain.instant_ack"
+
+
+async def test_chat_instant_ack_is_silent_when_cancelled_before_the_grace(monkeypatch):
+ monkeypatch.setattr("jarvis.voice.instant_ack.SHORT_GRACE_S", 0.2)
+ bus = _Bus()
+ task = start_chat_instant_ack(
+ bus, text="What's in my notes about Albel?", thread_id="t-1", language="en"
+ )
+ assert task is not None
+ await asyncio.sleep(0.02)
+ task.cancel()
+ await asyncio.sleep(0.3)
+ assert bus.events == []
+
+
+async def test_chat_instant_ack_skips_plain_conversation_and_voice_control():
+ bus = _Bus()
+ assert (
+ start_chat_instant_ack(bus, text="Hallo, wie geht's?", thread_id="t") is None
+ ) # i18n-allow
+ assert start_chat_instant_ack(bus, text="Sei still", thread_id="t") is None # i18n-allow
+ assert start_chat_instant_ack(bus, text="", thread_id="t") is None
+ assert start_chat_instant_ack(None, text="Open Spotify", thread_id="t") is None