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(pets): a notification bell with stacking cards

rubenluetke10-beep7c337772bebe
diff --git a/docs/pets.md b/docs/pets.md
index 81d4279d29..78208e6584 100644
--- a/docs/pets.md
+++ b/docs/pets.md
@@ -19,7 +19,10 @@ one click.
dragged anywhere, and its position is remembered per monitor
(`[overlay.mascot] position_*`, shared with the mascot).
- **The control strip** under the figure, from left to right:
- - pen: raise the main window and open a new chat (`ComposeRequested`);
+ - bell: notifications on or off for this run (see *Notifications*). Off
+ shows a red, struck-through bell and sends the cards on screen away; on
+ rings the bell. Like the speaker mute it never survives a restart, so a
+ bell forgotten off cannot hide tomorrow's "your agent is done";
- microphone: mute Jarvis's microphone (`VoiceMuteToggleRequested`, mirrored
from `VoiceMuteChanged`);
- talk indicator (three strokes, the Jarvis bar's equalizer cut down to
@@ -38,12 +41,44 @@ one click.
- **The pet "None"** (`pet_id = "none"`) shows the control strip and the
card without a figure.
+- **Notification cards** under the strip (under the thinking card when one
+ shows; above the pet when there is no room below). See *Notifications*.
+
The pet stays on screen while Jarvis is idle. The global shortcut
(`[trigger] hotkey_pet_toggle`, default `alt+win+p`) hides it or brings it
back and to the front; hiding lasts until the next app start. The shortcut is
changed on the My Pets page (Customize); an empty value switches it off. On
Wayland, global shortcuts are a no-op, as for every other shortcut.
+## Notifications
+
+When something happens that the user waits for while looking elsewhere, the
+bell swings and a card drops out from under the strip: a round icon (a check
+that ticks itself for `done`, `!` for `attention`, a cross for `error`, a bell
+for `info`), a bold title and one muted detail line. What becomes a card is
+decided in `jarvis/ui/pets/notices.py` (titles per interface language):
+
+| Source | Card |
+| --- | --- |
+| Agentic IDE pane entry (`NotificationCenter.subscribe`) | `<agent> finished` / `needs your answer` / `exited` / `could not start` |
+| `JarvisAgentBackgroundCompleted` | Background task done / failed |
+| `MissionCompleted` | Mission complete / failed / timed out (a cancel stays quiet) |
+| `DelegationResultReady` | `<agent> has a result` |
+| `ActionApprovalRequired` | Approval needed (not when a chat answers its own card) |
+| `WorkflowCompleted` | Routine finished / failed |
+| `ErrorOccurred(recoverable=False)` | Something went wrong |
+
+Cards stack (`ui/orb/notice_stack.py`): the newest in front, up to two older
+ones peeking out behind it, narrower and darker; at most four are kept.
+Hovering the stack fans it out into a column; leaving folds it back. A click
+dismisses the card under the pointer, which slides away. Every card leaves on
+its own (`done` 8 s, `error` 14 s, `attention` 20 s, `info` 6 s), never while
+the pointer rests on the stack. The same card twice within 3 s refreshes
+instead of stacking. Motion runs on springs at ~60 fps only while something
+moves; a resting stack costs a timer every 400 ms. Cards are dropped while the
+bell is off, the pet is hidden, or the look is not the pet. The strip stays in
+sight while cards show.
+
## The thinking card
The card mirrors Jarvis's real thinking, fed by bus events in
@@ -223,16 +258,20 @@ name.
| `set_speaker_muted(muted)` | Mirror the speaker mute on the strip |
| `set_visible(visible)` | Hide or show the whole pet (shortcut, settings) |
| `toggle_visible()` | Shortcut action: hide, or show and raise |
+| `push_notice(kind, title, detail)` | One notification card; rings the bell |
+| `set_notifications_enabled(enabled)` | Switch the bell without a click (a respawned host) |
+| `set_on_notifications_toggle(cb)` | `cb(enabled)` after the bell was clicked |
-Control-strip actions reported back through callbacks: `compose`, `mic_mute`,
-`talk`/`hangup` (the orb) and `speaker`.
+Control-strip actions: `bell` (handled in the surface, reported through
+`set_on_notifications_toggle`; the macOS host sends it up as `notify_toggle`),
+`mic_mute`, `talk`/`hangup` (the orb) and `speaker`.
### Events (`jarvis/core/events.py`)
- `VoiceSpeakerMuteChanged(muted, source)`: published by
`SpeechPipeline.set_tts_volume` when the muted-ness flips.
-- `ComposeRequested(source)`: the pen control; DesktopApp raises the window,
- the frontend opens a new chat.
+- `ComposeRequested(source)`: a new typed chat; DesktopApp raises the
+ window, the frontend opens a new chat. (The strip's pen became the bell.)
- `PetVisibilityToggleRequested(source)`: the `pet_toggle` shortcut; the
bridge calls `surface.toggle_visible()`.
- `PetChanged(pet_id, scale, bubble, visible, source)`: published by the pets
diff --git a/jarvis/agentic_ide/notifications.py b/jarvis/agentic_ide/notifications.py
index 33fd035dea..ff39d3fad1 100644
--- a/jarvis/agentic_ide/notifications.py
+++ b/jarvis/agentic_ide/notifications.py
@@ -238,9 +238,29 @@ class NotificationCenter:
def __init__(self, limit: int = MAX_ENTRIES) -> None:
self._entries: deque[Notification] = deque(maxlen=limit)
+ self._listeners: list[Callable[[Notification], None]] = []
+
+ def subscribe(self, listener: Callable[[Notification], None]) -> Callable[[], None]:
+ """Call ``listener`` with every entry filed from now on (the pet's bell).
+
+ Returns the unsubscribe. A listener runs on the event loop, inside the
+ sweep, so it must be quick; one that raises is logged and skipped.
+ """
+ self._listeners.append(listener)
+
+ def _unsubscribe() -> None:
+ if listener in self._listeners:
+ self._listeners.remove(listener)
+
+ return _unsubscribe
def add(self, entry: Notification) -> Notification:
self._entries.append(entry)
+ for listener in list(self._listeners):
+ try:
+ listener(entry)
+ except Exception as exc: # noqa: BLE001 — a listener must not stop the sweep
+ logger.warning("Agentic IDE: notification listener failed: {}", exc)
return entry
def list(self) -> list[Notification]:
diff --git a/jarvis/ui/jarvisbar/host.py b/jarvis/ui/jarvisbar/host.py
index d915286d98..dd349ec228 100644
--- a/jarvis/ui/jarvisbar/host.py
+++ b/jarvis/ui/jarvisbar/host.py
@@ -24,7 +24,7 @@ Protocol (UTF-8, one JSON object per line):
- child → parent (stdout): events — ``{"event": "ready"}`` once the surface
is initialized, plus user interactions (``talk``, ``hangup``,
``mute_toggle``, ``feedback``, ``show_window``, ``drop``, and the pet's
- ``compose``). Logging goes to stderr so stdout stays pure protocol.
+ ``compose`` and ``notify_toggle``). Logging goes to stderr so stdout stays pure protocol.
``drop`` is the one round trip: the child forwards a file/text dropped on the
hosted surface, the parent runs the intake (the brain lives there), and the
@@ -192,6 +192,16 @@ def dispatch(surface: Any, msg: dict[str, Any]) -> bool:
_call(surface, "set_visible", bool(msg.get("visible", True)))
elif op == "toggle_visible":
_call(surface, "toggle_visible")
+ elif op == "push_notice":
+ _call(
+ surface,
+ "push_notice",
+ str(msg.get("kind") or "info"),
+ str(msg.get("title") or ""),
+ str(msg.get("detail") or ""),
+ )
+ elif op == "set_notifications_enabled":
+ _call(surface, "set_notifications_enabled", bool(msg.get("enabled", True)))
else:
log.warning("bar-host: unknown op %r", op)
return True
@@ -270,6 +280,7 @@ class _EchoBar:
def set_on_show_window(self, cb: Any) -> None: ...
def set_on_speaker_toggle(self, cb: Any) -> None: ...
def set_on_compose(self, cb: Any) -> None: ...
+ def set_on_notifications_toggle(self, cb: Any) -> None: ...
def __getattr__(self, name: str) -> Any:
if name.startswith("__"):
@@ -448,6 +459,13 @@ def _wire_surface_events(surface: Any) -> None:
# The pet's pen: raising the window (and the new chat) happens in the
# parent, where the bus and the window live.
_call(surface, "set_on_compose", lambda: emit("compose"))
+ # The pet's bell lives in this process; the parent only mirrors its state
+ # so a respawned host comes back with the bell as the user left it.
+ _call(
+ surface,
+ "set_on_notifications_toggle",
+ lambda enabled: emit("notify_toggle", enabled=bool(enabled)),
+ )
_wire_drop_forwarding()
diff --git a/jarvis/ui/jarvisbar/subprocess_overlay.py b/jarvis/ui/jarvisbar/subprocess_overlay.py
index fd838bf053..e35a5c6179 100644
--- a/jarvis/ui/jarvisbar/subprocess_overlay.py
+++ b/jarvis/ui/jarvisbar/subprocess_overlay.py
@@ -730,6 +730,8 @@ class SubprocessMascotOverlay(SubprocessBarOverlay):
self._speaker_muted = False
self._user_visible = True
self._on_compose: Callable[[], None] | None = None
+ #: The pet's bell, mirrored from the host's ``notify_toggle`` events.
+ self._notifications_enabled = True
def _init_payload(self) -> dict[str, Any]:
return {
@@ -809,7 +811,23 @@ class SubprocessMascotOverlay(SubprocessBarOverlay):
def set_on_compose(self, callback: Callable[[], None] | None) -> None:
self._on_compose = callback
+ def push_notice(self, kind: str = "info", title: str = "", detail: str = "") -> None:
+ self._send(
+ {"op": "push_notice", "kind": str(kind), "title": str(title), "detail": str(detail)}
+ )
+
+ @property
+ def notifications_enabled(self) -> bool:
+ return self._notifications_enabled
+
+ def set_notifications_enabled(self, enabled: bool) -> None:
+ self._notifications_enabled = bool(enabled)
+ self._send({"op": "set_notifications_enabled", "enabled": self._notifications_enabled})
+
def _dispatch_event(self, msg: dict[str, Any]) -> None:
+ if msg.get("event") == "notify_toggle":
+ self._notifications_enabled = bool(msg.get("enabled", True))
+ return
if msg.get("event") != "compose":
super()._dispatch_event(msg)
return
@@ -828,6 +846,8 @@ class SubprocessMascotOverlay(SubprocessBarOverlay):
self._send({"op": "set_speaker_muted", "muted": True})
if not self._user_visible:
self._send({"op": "set_visible", "visible": False})
+ if not self._notifications_enabled:
+ self._send({"op": "set_notifications_enabled", "enabled": False})
def set_style(self, style: str) -> None:
"""Re-style the hosted orb window live (mascot <-> voice orb).
diff --git a/jarvis/ui/pets/notices.py b/jarvis/ui/pets/notices.py
new file mode 100644
index 0000000000..0c8395a617
--- /dev/null
+++ b/jarvis/ui/pets/notices.py
@@ -0,0 +1,229 @@
+"""What the desktop pet's bell announces, and how each card is worded.
+
+The pet shows a notification card (``OrbOverlay.push_notice``) when something
+happens that the user is likely waiting for while they look elsewhere:
+
+* a coding agent in an Agentic IDE pane finished, asks a question, exited or
+ could not start (``jarvis.agentic_ide.notifications`` entries),
+* a background Jarvis-Agent task finished or failed,
+* a mission ended (approved, failed or timed out — a cancel was the user's own
+ doing and is not news),
+* a coding result for a Jarvis conversation is ready,
+* a tool call waits for the user's approval (except approvals a chat surface
+ answers on its own cards — the user is already looking at those),
+* a scheduled workflow (routine) finished or failed,
+* an error nothing recovers from.
+
+Every function here is pure: it turns one event into ``(kind, title, detail)``
+or ``None`` (not worth a card). ``kind`` is the card's icon — ``done``,
+``attention``, ``error`` or ``info``. Titles are fixed labels per interface
+language; every supported locale has its own entry and none is a fallback for
+another.
+"""
+
+from __future__ import annotations
+
+from typing import Any
+
+from jarvis.ui.pets.status_line import condense
+
+#: One card: its icon kind, bold title and muted detail line.
+Notice = tuple[str, str, str]
+
+NOTICE_TITLE_CHARS = 60
+NOTICE_DETAIL_CHARS = 110
+
+NOTICE_LABELS: dict[str, dict[str, str]] = {
+ "agent_finished": {
+ "en": "{name} finished",
+ "de": "{name} ist fertig", # i18n-allow
+ "es": "{name} terminó", # i18n-allow
+ },
+ "agent_asks": {
+ "en": "{name} needs your answer",
+ "de": "{name} wartet auf dich", # i18n-allow
+ "es": "{name} necesita tu respuesta", # i18n-allow
+ },
+ "agent_exited": {
+ "en": "{name} exited",
+ "de": "{name} wurde beendet", # i18n-allow
+ "es": "{name} se cerró", # i18n-allow
+ },
+ "agent_failed": {
+ "en": "{name} could not start",
+ "de": "{name} konnte nicht starten", # i18n-allow
+ "es": "{name} no pudo iniciarse", # i18n-allow
+ },
+ "task_done": {
+ "en": "Background task done",
+ "de": "Hintergrundaufgabe erledigt", # i18n-allow
+ "es": "Tarea en segundo plano lista", # i18n-allow
+ },
+ "task_failed": {
+ "en": "Background task failed",
+ "de": "Hintergrundaufgabe fehlgeschlagen", # i18n-allow
+ "es": "La tarea en segundo plano falló", # i18n-allow
+ },
+ "mission_done": {
+ "en": "Mission complete",
+ "de": "Mission abgeschlossen", # i18n-allow
+ "es": "Misión completada", # i18n-allow
+ },
+ "mission_failed": {
+ "en": "Mission failed",
+ "de": "Mission fehlgeschlagen", # i18n-allow
+ "es": "La misión falló", # i18n-allow
+ },
+ "mission_timed_out": {
+ "en": "Mission timed out",
+ "de": "Mission abgelaufen", # i18n-allow
+ "es": "La misión agotó el tiempo", # i18n-allow
+ },
+ "result_ready": {
+ "en": "{name} has a result",
+ "de": "Ergebnis von {name} ist da", # i18n-allow
+ "es": "{name} tiene un resultado", # i18n-allow
+ },
+ "approval": {
+ "en": "Approval needed",
+ "de": "Freigabe nötig", # i18n-allow
+ "es": "Se necesita aprobación", # i18n-allow
+ },
+ "routine_done": {
+ "en": "Routine finished",
+ "de": "Routine erledigt", # i18n-allow
+ "es": "Rutina terminada", # i18n-allow
+ },
+ "routine_failed": {
+ "en": "Routine failed",
+ "de": "Routine fehlgeschlagen", # i18n-allow
+ "es": "La rutina falló", # i18n-allow
+ },
+ "error": {
+ "en": "Something went wrong",
+ "de": "Etwas ist schiefgelaufen", # i18n-allow
+ "es": "Algo salió mal", # i18n-allow
+ },
+ "agent": {
+ "en": "Agent",
+ "de": "Agent", # i18n-allow
+ "es": "Agente", # i18n-allow
+ },
+}
+
+
+def label(key: str, language: str, **values: str) -> str:
+ """One title in ``language`` (English when the locale is unknown)."""
+ labels = NOTICE_LABELS[key]
+ text = labels.get(language, labels["en"])
+ return text.format(**values) if values else text
+
+
+def _title(text: str) -> str:
+ return condense(text, max_chars=NOTICE_TITLE_CHARS)
+
+
+def _detail(*parts: object) -> str:
+ joined = " · ".join(str(p).strip() for p in parts if str(p or "").strip())
+ return condense(joined, max_chars=NOTICE_DETAIL_CHARS)
+
+
+def _name(value: object, language: str) -> str:
+ name = " ".join(str(value or "").split())
+ return name or label("agent", language)
+
+
+def for_pane_entry(entry: Any, language: str) -> Notice | None:
+ """An Agentic IDE notification (``agentic_ide.notifications.Notification``)."""
+ kind = str(getattr(entry, "kind", "") or "")
+ name = _name(getattr(entry, "display_name", "") or getattr(entry, "agent", "") or "", language)
+ pane = str(getattr(entry, "pane", "") or "")
+ detail = _detail(pane, getattr(entry, "detail", ""))
+ if kind == "completed":
+ return "done", _title(label("agent_finished", language, name=name)), detail
+ if kind == "needs_input":
+ return "attention", _title(label("agent_asks", language, name=name)), detail
+ if kind == "failed":
+ return "error", _title(label("agent_failed", language, name=name)), detail
+ if kind == "exited":
+ return "info", _title(label("agent_exited", language, name=name)), detail
+ return None
+
+
+def for_background_task(event: Any, language: str) -> Notice:
+ """``JarvisAgentBackgroundCompleted``."""
+ if bool(getattr(event, "success", False)):
+ detail = _detail(getattr(event, "summary", "") or getattr(event, "utterance", ""))
+ return "done", label("task_done", language), detail
+ detail = _detail(getattr(event, "error", "") or getattr(event, "utterance", ""))
+ return "error", label("task_failed", language), detail
+
+
+def for_mission(event: Any, language: str) -> Notice | None:
+ """``MissionCompleted`` — a cancel is the user's own act and stays quiet."""
+ status = str(getattr(event, "status", "") or "")
+ summary = getattr(event, "summary_de" if language == "de" else "summary_en", "") or ""
+ summary = summary or getattr(event, "summary_en", "") or ""
+ if status == "approved":
+ return "done", label("mission_done", language), _detail(summary)
+ if status == "failed":
+ return (
+ "error",
+ label("mission_failed", language),
+ _detail(getattr(event, "reason", "") or summary),
+ )
+ if status == "timed_out":
+ return "error", label("mission_timed_out", language), _detail(summary)
+ return None
+
+
+def for_delegation_result(event: Any, language: str) -> Notice | None:
+ """``DelegationResultReady`` — a coding result addressed to a conversation."""
+ name = _name(getattr(event, "agent_name", ""), language)
+ status = str(getattr(event, "status", "") or "").lower()
+ text = getattr(event, "text", "") or getattr(event, "report", "")
+ if status in ("failed", "error"):
+ return "error", _title(label("agent_failed", language, name=name)), _detail(text)
+ return "done", _title(label("result_ready", language, name=name)), _detail(text)
+
+
+def for_approval(event: Any, language: str) -> Notice | None:
+ """``ActionApprovalRequired`` — skipped when a chat answers its own cards."""
+ if getattr(event, "approval_ref", None):
+ return None
+ tool = str(getattr(event, "tool_name", "") or "").split("__")[-1]
+ tool = tool.replace("_", " ").replace("-", " ").strip()
+ tool = tool[:1].upper() + tool[1:]
+ return (
+ "attention",
+ label("approval", language),
+ _detail(tool, getattr(event, "args_preview", "")),
+ )
+
+
+def for_workflow(event: Any, language: str, name: str = "") -> Notice:
+ """``WorkflowCompleted`` — ``name`` is the routine's display name if known."""
+ if bool(getattr(event, "success", False)):
+ return "done", label("routine_done", language), _detail(name)
+ return "error", label("routine_failed", language), _detail(name, getattr(event, "error", ""))
+
+
+def for_error(event: Any, language: str) -> Notice | None:
+ """``ErrorOccurred`` — only one nothing recovers from."""
+ if bool(getattr(event, "recoverable", True)):
+ return None
+ return "error", label("error", language), _detail(getattr(event, "message", ""))
+
+
+__all__ = [
+ "NOTICE_LABELS",
+ "Notice",
+ "for_approval",
+ "for_background_task",
+ "for_delegation_result",
+ "for_error",
+ "for_mission",
+ "for_pane_entry",
+ "for_workflow",
+ "label",
+]
diff --git a/tests/unit/ui/test_orb_controls_pet.py b/tests/unit/ui/test_orb_controls_pet.py
index 808a0dc3d1..5431d2af2b 100644
--- a/tests/unit/ui/test_orb_controls_pet.py
+++ b/tests/unit/ui/test_orb_controls_pet.py
@@ -23,7 +23,7 @@ KEY = (255, 0, 255)
def _centre(action: str, scale: float = 1.0) -> tuple[float, float]:
layout = controls.pet_strip_layout(scale)
- if action == "compose":
+ if action == "bell":
return layout.pen[0], layout.pen[1]
for name, x0, x1 in layout.slots:
if name == action:
@@ -44,7 +44,7 @@ def test_every_pet_action_is_reachable_at_its_centre(scale: float) -> None:
def test_the_voice_orb_row_keeps_its_own_actions() -> None:
assert controls.ACTIONS == ("attach", "mic", "close", "speaker")
- assert controls.PET_ACTIONS == ("compose", "mic_mute", "orb", "speaker")
+ assert controls.PET_ACTIONS == ("bell", "mic_mute", "orb", "speaker")
def test_the_gap_between_pen_and_pill_is_a_drag_handle_not_a_button() -> None:
diff --git a/tests/unit/ui/test_pet_notices.py b/tests/unit/ui/test_pet_notices.py
new file mode 100644
index 0000000000..b95af68fec
--- /dev/null
+++ b/tests/unit/ui/test_pet_notices.py
@@ -0,0 +1,378 @@
+"""The desktop pet's bell and notification cards (docs/pets.md "Notifications").
+
+Pins, without a real window: which events become cards and how they are
+worded, the stack's model and geometry (newest in front, two peeking, fanned
+out on hover, mirrored upward when there is no room below), the springs that
+move it, icons that never meet the colour key, the bell glyph and its swing,
+the bell toggle on the overlay, the bridge's routing, the Agentic IDE hook, and
+the macOS proxy / host round trip that keeps the bell across a respawn.
+"""
+
+from __future__ import annotations
+
+from types import SimpleNamespace
+
+import pytest
+
+from jarvis.agentic_ide.notifications import Notification, NotificationCenter
+from jarvis.core import runtime_refs
+from jarvis.core.bus import EventBus
+from jarvis.core.events import (
+ ActionApprovalRequired,
+ ErrorOccurred,
+ JarvisAgentBackgroundCompleted,
+ MissionCompleted,
+ WorkflowCompleted,
+)
+from jarvis.ui.jarvisbar.subprocess_overlay import SubprocessMascotOverlay
+from jarvis.ui.pets import notices
+from ui.orb import controls
+from ui.orb import notice_stack as ns
+from ui.orb.bus_bridge import OrbBusBridge
+from ui.orb.overlay import OrbOverlay
+
+KEY = (255, 0, 255)
+
+
+def _entry(kind: str, **overrides: object) -> Notification:
+ values: dict[str, object] = {
+ "id": "n1",
+ "kind": kind,
+ "workspace_id": "w1",
+ "workspace": "Jarvis",
+ "pane_key": "T2",
+ "pane": "Mika",
+ "agent": "claude",
+ "display_name": "Claude",
+ "title": "Finished and waiting at its prompt",
+ "detail": "Refactor the notice stack",
+ "created_at": 1.0,
+ }
+ values.update(overrides)
+ return Notification(**values) # type: ignore[arg-type]
+
+
+# --- wording -------------------------------------------------------------------
+
+
+ ("kind", "icon", "title"),
+ [
+ ("completed", "done", "Claude finished"),
+ ("needs_input", "attention", "Claude needs your answer"),
+ ("failed", "error", "Claude could not start"),
+ ("exited", "info", "Claude exited"),
+ ],
+)
+def test_a_pane_entry_names_its_agent_and_pane(kind: str, icon: str, title: str) -> None:
+ notice = notices.for_pane_entry(_entry(kind), "en")
+ assert notice == (icon, title, "Mika · Refactor the notice stack")
+
+
+def test_every_locale_has_its_own_titles() -> None:
+ for key, labels in notices.NOTICE_LABELS.items():
+ assert set(labels) == {"en", "de", "es"}, key
+ assert notices.for_pane_entry(_entry("completed"), "de")[1] == "Claude ist fertig"
+ # An unknown interface language reads English rather than nothing.
+ assert notices.for_pane_entry(_entry("completed"), "fr")[1] == "Claude finished"
+
+
+def test_a_pane_without_names_still_says_who() -> None:
+ notice = notices.for_pane_entry(_entry("completed", display_name="", agent=""), "en")
+ assert notice is not None and notice[1] == "Agent finished"
+
+
+def test_mission_outcomes_but_not_a_cancel() -> None:
+ done = MissionCompleted(mission_id="m", status="approved", summary_en="Shipped the fix")
+ failed = MissionCompleted(mission_id="m", status="failed", reason="Tests failed")
+ cancelled = MissionCompleted(mission_id="m", status="cancelled")
+ assert notices.for_mission(done, "en") == ("done", "Mission complete", "Shipped the fix")
+ assert notices.for_mission(failed, "en") == ("error", "Mission failed", "Tests failed")
+ assert notices.for_mission(cancelled, "en") is None
+
+
+def test_an_approval_a_chat_answers_itself_is_not_a_card() -> None:
+ plain = ActionApprovalRequired(tool_name="mcp__fs__delete_file", args_preview="a.txt")
+ chat = ActionApprovalRequired(tool_name="delete_file", approval_ref="agent-chat:1")
+ assert notices.for_approval(plain, "en") == (
+ "attention",
+ "Approval needed",
+ "Delete file · a.txt",
+ )
+ assert notices.for_approval(chat, "en") is None
+
+
+def test_only_an_unrecoverable_error_is_a_card() -> None:
+ assert notices.for_error(ErrorOccurred(message="retrying", recoverable=True), "en") is None
+ card = notices.for_error(ErrorOccurred(message="Brain offline", recoverable=False), "en")
+ assert card == ("error", "Something went wrong", "Brain offline")
+
+
+def test_background_task_and_routine_outcomes() -> None:
+ ok = JarvisAgentBackgroundCompleted(success=True, summary="Report written")
+ bad = JarvisAgentBackgroundCompleted(success=False, error="Timed out")
+ assert notices.for_background_task(ok, "en") == (
+ "done",
+ "Background task done",
+ "Report written",
+ )
+ assert notices.for_background_task(bad, "en")[0] == "error"
+ assert notices.for_workflow(WorkflowCompleted(success=True), "en")[0] == "done"
+ assert notices.for_workflow(WorkflowCompleted(success=False, error="x"), "en")[0] == "error"
+
+
+# --- model ---------------------------------------------------------------------
+
+
+def test_the_newest_card_is_in_front_and_the_oldest_falls_out() -> None:
+ model = ns.NoticeModel(keep=3)
+ for i in range(4):
+ model.push("done", f"T{i}", "", now=float(i * 10))
+ assert [n.title for n in model.items] == ["T3", "T2", "T1"]
+
+
+def test_a_twin_within_the_window_refreshes_instead_of_stacking() -> None:
+ model = ns.NoticeModel()
+ first, _ = model.push("done", "Claude finished", "Mika", now=0.0)
+ again, dropped = model.push("done", "Claude finished", "Mika", now=1.0)
+ assert again is first and dropped == [] and len(model.items) == 1
+ model.push("done", "Claude finished", "Mika", now=1.0 + ns.NOTICE_DEDUPE_S)
+ assert len(model.items) == 2
+
+
+def test_cards_expire_by_kind_and_a_pause_holds_them() -> None:
+ model = ns.NoticeModel()
+ model.push("done", "a", "", now=0.0)
+ model.push("attention", "b", "", now=0.0)
+ assert model.expire(ns.NOTICE_TTL_S["done"] - 0.1) == []
+ model.pause(5.0)
+ assert model.expire(ns.NOTICE_TTL_S["done"] + 1.0) == []
+ gone = model.expire(ns.NOTICE_TTL_S["done"] + 5.0)
+ assert [n.title for n in gone] == ["a"]
+ assert [n.title for n in model.items] == ["b"]
+
+
+def test_an_unknown_kind_is_info() -> None:
+ notice, _ = ns.NoticeModel().push("party", "x", "", now=0.0)
+ assert notice.kind == "info"
+
+
+# --- geometry ------------------------------------------------------------------
+
+
+def test_a_folded_stack_peeks_two_cards_and_hides_the_rest() -> None:
+ slots = ns.stack_slots(4, expanded=False, card_h=60, scale=1.0)
+ assert [s.depth for s in slots] == [0, 1, 2, 3]
+ assert slots[0].y == 0 and slots[0].inset == 0
+ assert slots[1].y == ns.PEEK_OFFSET and slots[1].inset == ns.PEEK_INSET
+ # The fourth hides exactly behind the third.
+ assert (slots[3].y, slots[3].inset) == (slots[2].y, slots[2].inset)
+ assert ns.stack_height(4, expanded=False, card_h=60, scale=1.0) == 60 + 2 * ns.PEEK_OFFSET
+
+
+def test_a_fanned_stack_is_a_column_and_upward_mirrors_it() -> None:
+ down = ns.stack_slots(3, expanded=True, card_h=60, scale=1.0)
+ assert [s.y for s in down] == [0, 60 + ns.CARD_GAP, 2 * (60 + ns.CARD_GAP)]
+ assert all(s.depth == 0 and s.inset == 0 for s in down)
+ up = ns.stack_slots(3, expanded=True, card_h=60, scale=1.0, upward=True)
+ height = ns.stack_height(3, expanded=True, card_h=60, scale=1.0)
+ # Upward, the newest card sits at the bottom, nearest the pet.
+ assert up[0].y == height - 60 and up[-1].y == 0
+
+
+def test_a_spring_settles_on_its_target_with_a_small_overshoot() -> None:
+ spring = ns.Spring(0.0, 100.0)
+ peak = 0.0
+ for _ in range(120):
+ spring.step(1 / 60)
+ peak = max(peak, spring.value)
+ assert spring.settled
+ assert 100.0 <= peak < 108.0
+
+
[email protected]("kind", ns.NOTICE_KINDS)
+def test_icons_are_opaque_and_end_fully_drawn(kind: str) -> None:
+ bg = ns.CARD_FILL
+ first = ns.render_icon(kind, 0, 32, bg)
+ last = ns.render_icon(kind, ns.ICON_FRAMES, 32, bg)
+ assert first.mode == last.mode == "RGB" and last.size == (32, 32)
+ assert KEY not in {c for _n, c in last.getcolors(32 * 32)}
+ # Frame 0 is still empty; the last frame carries the kind's colour.
+ assert first.getcolors(1) is not None
+ glyph, _disc = ns.ICON_COLORS[kind]
+ assert any(
+ abs(c[0] - glyph[0]) < 12 and abs(c[1] - glyph[1]) < 12 for _n, c in last.getcolors(4096)
+ )
+
+
+def test_the_icon_frame_follows_the_card_age() -> None:
+ assert ns.icon_frame(0.0) == 0
+ assert 0 < ns.icon_frame(ns.ICON_ANIM_S / 2) < ns.ICON_FRAMES
+ assert ns.icon_frame(10.0) == ns.ICON_FRAMES
+
+
+# --- the bell on the strip -------------------------------------------------------
+
+
+def test_the_bell_has_a_muted_look_and_a_swing() -> None:
+ on = controls.render_pet_strip(controls.PetStripState())
+ off = controls.render_pet_strip(controls.PetStripState(notify_off=True))
+ swung = controls.render_pet_strip(controls.PetStripState(ring=2))
+ assert on.tobytes() != off.tobytes() != swung.tobytes()
+ assert controls.ring_angle(0) == 0.0
+ assert controls.ring_angle(controls.PET_RING_PHASES) == 0.0
+ assert max(abs(controls.ring_angle(i)) for i in range(controls.PET_RING_PHASES)) > 8.0
+
+
+class _Strip:
+ def __init__(self) -> None:
+ self.states: list[dict] = []
+ self.pointer_inside = False
+
+ def set_state(self, **kwargs: object) -> None:
+ self.states.append(kwargs)
+
+ def show(self) -> None:
+ pass
+
+ def hide(self) -> None:
+ pass
+
+ def hide_after_grace(self) -> None:
+ pass
+
+
+def _pet() -> tuple[OrbOverlay, _Strip]:
+ pet = OrbOverlay(style="pet")
+ strip = _Strip()
+ pet._controls = strip # type: ignore[assignment]
+ return pet, strip
+
+
+def test_the_bell_toggles_and_reports_its_state(monkeypatch: pytest.MonkeyPatch) -> None:
+ import ui.orb.overlay as overlay_mod
+
+ monkeypatch.setattr(overlay_mod, "PetControlStrip", _Strip)
+ pet, strip = _pet()
+ seen: list[bool] = []
+ pet.set_on_notifications_toggle(seen.append)
+ pet._on_control_action("bell")
+ assert pet.notifications_enabled is False
+ assert {"notify_off": True} in strip.states
+ pet._on_control_action("bell")
+ assert pet.notifications_enabled is True
+ assert seen == [False, True]
+
+
+def test_cards_are_dropped_while_the_bell_is_off_or_the_pet_hidden() -> None:
+ pet, _strip = _pet()
+ pet._notify_enabled = False
+ pet._apply_notice("done", "x", "") # no root, no bell: nothing to build
+ assert pet._notices is None
+ OrbOverlay(style="mascot").push_notice("done", "x", "") # other looks: no-op
+ pet.push_notice("done", "x", "") # before the window exists: safe
+
+
+def test_cards_keep_the_strip_in_sight() -> None:
+ pet, _strip = _pet()
+ pet._pet_id = "gigi"
+ pet._mode = "idle"
+ assert pet._pet_strip_wanted() is False
+ pet._notices = SimpleNamespace(count=2) # type: ignore[assignment]
+ assert pet._pet_strip_wanted() is True
+
+
+# --- routing ---------------------------------------------------------------------
+
+
+class _PetSurface:
+ wants_status_lines = True
+ keeps_visible_when_idle = True
+
+ def __init__(self) -> None:
+ self.notices: list[tuple[str, str, str]] = []
+
+ def show(self, mode: str = "listen") -> None:
+ pass
+
+ def hide(self) -> None:
+ pass
+
+ def push_notice(self, kind: str, title: str, detail: str) -> None:
+ self.notices.append((kind, title, detail))
+
+
[email protected](autouse=True)
+def _no_live_pipeline(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(runtime_refs, "_SPEECH_PIPELINE", [])
+
+
+async def test_the_bridge_turns_events_and_pane_entries_into_cards(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ from jarvis.agentic_ide import notifications as ide
+
+ center = NotificationCenter()
+ monkeypatch.setattr(ide, "center", lambda: center)
+ bus = EventBus()
+ pet = _PetSurface()
+ bridge = OrbBusBridge(bus=bus, orb=pet, language="en") # type: ignore[arg-type]
+ bridge.attach()
+ await bus.publish(MissionCompleted(mission_id="m", status="approved", summary_en="Done it"))
+ await bus.publish(MissionCompleted(mission_id="m", status="cancelled"))
+ await bus.publish(ErrorOccurred(message="retry", recoverable=True))
+ center.add(_entry("needs_input"))
+ assert pet.notices == [
+ ("done", "Mission complete", "Done it"),
+ ("attention", "Claude needs your answer", "Mika · Refactor the notice stack"),
+ ]
+
+
+async def test_a_bar_gets_no_cards() -> None:
+ class _Bar(_PetSurface):
+ wants_status_lines = False
+
+ bus = EventBus()
+ bar = _Bar()
+ OrbBusBridge(bus=bus, orb=bar).attach() # type: ignore[arg-type]
+ await bus.publish(MissionCompleted(mission_id="m", status="failed", reason="x"))
+ assert bar.notices == []
+
+
+def test_a_failing_listener_does_not_stop_the_centre() -> None:
+ center = NotificationCenter()
+ seen: list[str] = []
+
+ def _boom(_entry: Notification) -> None:
+ raise RuntimeError("listener broke")
+
+ center.subscribe(_boom)
+ unsubscribe = center.subscribe(lambda e: seen.append(e.id))
+ center.add(_entry("completed"))
+ unsubscribe()
+ center.add(_entry("completed", id="n2"))
+ assert seen == ["n1"]
+ assert len(center.list()) == 2
+
+
+def test_the_proxy_and_host_carry_cards_and_keep_the_bell_across_a_respawn() -> None:
+ from jarvis.ui.jarvisbar import host
+
+ proxy = SubprocessMascotOverlay(style="pet")
+ sent: list[dict] = []
+ proxy._send = sent.append # type: ignore[method-assign]
+ proxy.push_notice("done", "Claude finished", "Mika")
+ proxy._dispatch_event({"event": "notify_toggle", "enabled": False})
+ assert proxy.notifications_enabled is False
+ sent.clear()
+ proxy._reapply_desired_state()
+ assert {"op": "set_notifications_enabled", "enabled": False} in sent
+
+ calls: list[tuple] = []
+ surface = SimpleNamespace(
+ push_notice=lambda *a: calls.append(("push", *a)),
+ set_notifications_enabled=lambda flag: calls.append(("bell", flag)),
+ )
+ host.dispatch(surface, {"op": "push_notice", "kind": "done", "title": "T", "detail": "D"})
+ host.dispatch(surface, {"op": "set_notifications_enabled", "enabled": False})
+ assert calls == [("push", "done", "T", "D"), ("bell", False)]
diff --git a/ui/orb/bus_bridge.py b/ui/orb/bus_bridge.py
index c8c9f6c976..7764b6bfce 100644
--- a/ui/orb/bus_bridge.py
+++ b/ui/orb/bus_bridge.py
@@ -36,10 +36,12 @@ import time
from typing import TYPE_CHECKING, Any
from jarvis.core.events import (
+ ActionApprovalRequired,
ActionExecuted,
ActionProposed,
AudioOutFirst,
ComposeRequested,
+ DelegationResultReady,
DictationCompleted,
DictationPromptModeChanged,
DictationPromptModePauseToggleRequested,
@@ -52,6 +54,7 @@ from jarvis.core.events import (
JarvisAgentTaskCompleted,
JarvisAgentTaskStarted,
ListeningStarted,
+ MissionCompleted,
OrbResetRequested,
PetVisibilityToggleRequested,
ReasoningSummaryUpdated,
@@ -71,6 +74,7 @@ from jarvis.core.events import (
VoiceSpeakerMuteChanged,
WakeCandidateDetected,
WakeWordDetected,
+ WorkflowCompleted,
)
from jarvis.dictation.outcomes import was_delivered
from jarvis.sessions.constants import (
@@ -81,6 +85,7 @@ from jarvis.sessions.constants import (
SPOKEN_KIND_TIMEOUT,
SPOKEN_KIND_UNAVAILABLE,
)
+from jarvis.ui.pets import notices as pet_notices
from jarvis.ui.pets.actions import action_for_tool
from jarvis.ui.pets.status_line import StatusFeed, condense, parse_reasoning_summary
from ui.orb.animations import IDLE_ANIMATION_POOL
@@ -351,6 +356,8 @@ class OrbBusBridge:
# from the running pipeline's config when needed; ``UiLanguageChanged``
# overrides it live.
self._language: str | None = language if language in PET_STATUS_LANGUAGES else None
+ #: Unsubscribe from the Agentic IDE's notification centre (the bell).
+ self._pane_notice_unsub: Any = None
# ONE rate-limited feed for every card the pet shows, so a burst of
# reasoning snapshots and tool steps cannot flood the Tk thread. A
# card the feed holds back is shown by ``_status_flush_task`` once the
@@ -597,6 +604,14 @@ class OrbBusBridge:
self._bus.subscribe(ToolCallStarted, self._on_tool_call_started)
self._bus.subscribe(JarvisAgentTaskStarted, self._on_agent_task_started)
self._bus.subscribe(JarvisAgentTaskCompleted, self._on_agent_task_completed)
+ # The pet's bell (jarvis.ui.pets.notices): things the user waits
+ # for while looking elsewhere become notification cards. Coding
+ # panes report through the Agentic IDE's own notification centre.
+ self._bus.subscribe(MissionCompleted, self._on_mission_completed)
+ self._bus.subscribe(DelegationResultReady, self._on_delegation_result)
+ self._bus.subscribe(ActionApprovalRequired, self._on_approval_required)
+ self._bus.subscribe(WorkflowCompleted, self._on_workflow_completed)
+ self._subscribe_pane_notices()
# Wire the orb's double-double-click gesture to a bus publish.
# The orb requires two ``<Double-Button-1>`` events inside
# ``MUTE_GESTURE_WINDOW_MS`` (four clicks in <600 ms) before
@@ -1119,6 +1134,46 @@ class OrbBusBridge:
if event.recoverable:
return
self._pet_outcome("error")
+ self._push_notice(pet_notices.for_error(event, self._status_language()))
+
+ # -- the pet's bell ---------------------------------------------------
+
+ def _push_notice(self, notice: pet_notices.Notice | None) -> None:
+ """Hand one card to the surface (the pet; every other surface skips it)."""
+ if notice is None or not self._wants_card():
+ return
+ self._call_surface("push_notice", *notice)
+
+ def _subscribe_pane_notices(self) -> None:
+ """Follow the Agentic IDE's notifications (finished / asks / exited panes).
+
+ Lazy: the module is light, but the IDE package stays off the boot path
+ until something asks for it (AP-26). Entries are filed on the event
+ loop, so the surface call below runs there like every bus handler.
+ """
+ if self._pane_notice_unsub is not None:
+ return
+ try:
+ from jarvis.agentic_ide import notifications as ide_notifications
+ except Exception: # noqa: BLE001 — a missing IDE only costs these cards
+ log.debug("agentic IDE notifications unavailable", exc_info=True)
+ return
+ self._pane_notice_unsub = ide_notifications.center().subscribe(self._on_pane_notice)
+
+ def _on_pane_notice(self, entry: Any) -> None:
+ self._push_notice(pet_notices.for_pane_entry(entry, self._status_language()))
+
+ async def _on_mission_completed(self, event: MissionCompleted) -> None:
+ self._push_notice(pet_notices.for_mission(event, self._status_language()))
+
+ async def _on_delegation_result(self, event: DelegationResultReady) -> None:
+ self._push_notice(pet_notices.for_delegation_result(event, self._status_language()))
+
+ async def _on_approval_required(self, event: ActionApprovalRequired) -> None:
+ self._push_notice(pet_notices.for_approval(event, self._status_language()))
+
+ async def _on_workflow_completed(self, event: WorkflowCompleted) -> None:
+ self._push_notice(pet_notices.for_workflow(event, self._status_language()))
async def _on_agent_task_started(self, event: JarvisAgentTaskStarted) -> None:
"""An agent took on a task: its card stays until the task is done."""
@@ -2197,6 +2252,7 @@ class OrbBusBridge:
if event.success:
self._pet_outcome("success")
self._sync_pet_busy()
+ self._push_notice(pet_notices.for_background_task(event, self._status_language()))
if self._wants_card() and (self._card_visible or self._agent_tasks):
title = condense(event.utterance or "", max_chars=PET_CARD_TITLE_CHARS)
self._show_card(
diff --git a/ui/orb/controls.py b/ui/orb/controls.py
index 81e6c2793e..dcc5680f51 100644
--- a/ui/orb/controls.py
+++ b/ui/orb/controls.py
@@ -367,7 +367,7 @@ def render_row(
# --- The pet's control strip ------------------------------------------------
# The desktop pet (``docs/pets.md``) carries its controls in the shape the
-# Codex companion made familiar: a pen in its own filled disc, then ONE filled
+# Codex companion made familiar: a bell in its own filled disc, then ONE filled
# pill holding microphone mute, the talk orb and the speaker, with thin
# low-contrast dividers. Same hard-edge rules as the row above: every
# silhouette that meets the colour key goes through a binary mask, every glyph
@@ -376,12 +376,12 @@ def render_row(
#: The strip's actions, left to right. The voice orb's ``ACTIONS`` stay as they
#: are; the two layouts never share a hit-test.
-PET_ACTIONS: tuple[str, ...] = ("compose", "mic_mute", "orb", "speaker")
+PET_ACTIONS: tuple[str, ...] = ("bell", "mic_mute", "orb", "speaker")
#: Unscaled geometry, in logical pixels at 100 % display scaling and
#: ``pet_scale`` 1.0 — sized against the companion figure (about 180 px), so the
#: strip is roughly 0.3 x the figure's width tall, as in the Codex app.
-#: ``PET_SLOT`` is the pill's height and the pen disc's diameter.
+#: ``PET_SLOT`` is the pill's height and the bell disc's diameter.
PET_SLOT = 50
PET_ICON_SLOT = 46
PET_ORB_SLOT = 52
@@ -462,6 +462,13 @@ PET_CLOUD_SOFTNESS = 0.8
#: resting or unlit stroke still reads as sky.
PET_INDICATOR_NIGHT = (24, 44, 84)
+#: The bell rings when a notification arrives: a damped swing about its crown,
+#: ``PET_RING_PHASES`` steps of ``PET_RING_STEP_S``, peak ``PET_RING_DEG``
+#: degrees. Phase 0 is the bell at rest, so a still strip stays one cached frame.
+PET_RING_PHASES = 14
+PET_RING_STEP_S = 0.04
+PET_RING_DEG = 16.0
+
def _spx(value: float, scale: float) -> int:
"""One unscaled length at ``scale``, never below one pixel."""
@@ -474,7 +481,7 @@ class PetStripLayout:
width: int
height: int
- #: The pen disc: centre and radius.
+ #: The bell disc: centre and radius.
pen: tuple[float, float, float]
#: The pill's bounding box ``(x0, y0, x1, y1)``, x1/y1 exclusive.
pill: tuple[int, int, int, int]
@@ -545,7 +552,7 @@ def _inside_stadium(x: float, y: float, box: tuple[int, int, int, int]) -> bool:
def pet_hit_test(x: float, y: float, scale: float = 1.0) -> str | None:
"""Which pet action a click at ``(x, y)`` lands on, or ``None``.
- Outside the pen disc and the pill is nothing — that empty area is where the
+ Outside the bell disc and the pill is nothing — that empty area is where the
user grabs the strip to drag the pet (the only handle when the pet is
"None"). Inside the pill every pixel belongs to a slot: a divider resolves
to the nearer neighbour instead of eating the click.
@@ -553,7 +560,7 @@ def pet_hit_test(x: float, y: float, scale: float = 1.0) -> str | None:
layout = pet_strip_layout(scale)
pcx, pcy, pr = layout.pen
if math.hypot(x - pcx, y - pcy) <= pr:
- return "compose"
+ return "bell"
if not _inside_stadium(x, y, layout.pill):
return None
best: str | None = None
@@ -599,6 +606,10 @@ class PetStripState:
phase: int = 0
#: Which control the pointer is over, if any.
hovered: str | None = None
+ #: The user switched notifications off with the bell (this run only).
+ notify_off: bool = False
+ #: The bell's swing step (``ring_angle``); 0 is at rest.
+ ring: int = 0
# -- glyphs ------------------------------------------------------------------
@@ -639,18 +650,79 @@ class _Pen:
self.cap((x + rr * math.cos(a), y + rr * math.sin(a)), color)
-def _glyph_compose(pen: _Pen, color: _Rgb) -> None:
- """A square with a pencil writing into its corner — "new message"."""
- pen.lines([(12, 3), (5, 3)], color)
- pen.arc(5, 5, 2, 180, 270, color)
- pen.lines([(3, 5), (3, 19)], color)
- pen.arc(5, 19, 2, 90, 180, color)
- pen.lines([(5, 21), (19, 21)], color)
- pen.arc(19, 19, 2, 0, 90, color)
- pen.lines([(21, 19), (21, 12)], color)
- pen.lines(
- [(18.4, 2.6), (21.4, 5.6), (12.4, 14.6), (8.6, 15.4), (9.4, 11.6), (18.4, 2.6)], color
+def _cubic(
+ p0: tuple[float, float],
+ p1: tuple[float, float],
+ p2: tuple[float, float],
+ p3: tuple[float, float],
+ steps: int = 10,
+) -> list[tuple[float, float]]:
+ """A cubic bezier sampled into ``steps + 1`` points."""
+ out = []
+ for i in range(steps + 1):
+ t = i / steps
+ a, b, c, d = (1 - t) ** 3, 3 * (1 - t) ** 2 * t, 3 * (1 - t) * t * t, t**3
+ out.append(
+ (
+ a * p0[0] + b * p1[0] + c * p2[0] + d * p3[0],
+ a * p0[1] + b * p1[1] + c * p2[1] + d * p3[1],
+ )
+ )
+ return out
+
+
+def _arc_points(
+ cu: float, cv: float, r: float, start: float, end: float, steps: int = 12
+) -> list[tuple[float, float]]:
+ """A circular arc (degrees, y down like PIL) sampled into points."""
+ return [
+ (
+ cu + r * math.cos(math.radians(start + (end - start) * i / steps)),
+ cv + r * math.sin(math.radians(start + (end - start) * i / steps)),
+ )
+ for i in range(steps + 1)
+ ]
+
+
[email protected]_cache(maxsize=1)
+def _bell_outline() -> tuple[tuple[tuple[float, float], ...], ...]:
+ """The bell as polylines on the 24-unit grid (lucide's ``bell``).
+
+ Polylines rather than PIL arcs so the whole glyph can swing: a rotated
+ point list is still a bell, a rotated ``d.arc`` box is not.
+ """
+ body = (
+ _cubic((3, 17), (3, 17), (6, 15), (6, 8))
+ + _arc_points(12, 8, 6, 180, 360)[1:]
+ + _cubic((18, 8), (18, 15), (21, 17), (21, 17))[1:]
)
+ body.append((3, 17))
+ clapper = _arc_points(12, 20.03, 1.94, 151.2, 28.8, steps=8)
+ return (tuple(body), tuple(clapper))
+
+
+def ring_angle(phase: int) -> float:
+ """The bell's swing in degrees at ``phase`` — a damped back-and-forth."""
+ if phase <= 0 or phase >= PET_RING_PHASES:
+ return 0.0
+ t = phase / PET_RING_PHASES
+ return PET_RING_DEG * math.sin(t * 3.0 * 2.0 * math.pi) * (1.0 - t) ** 1.5
+
+
+def _glyph_bell(pen: _Pen, color: _Rgb, *, angle: float = 0.0, slashed: bool = False) -> None:
+ """A bell, swung by ``angle`` degrees about its crown; struck through when off."""
+ a = math.radians(angle)
+ cos_a, sin_a = math.cos(a), math.sin(a)
+ pivot_u, pivot_v = 12.0, 2.0
+
+ def turn(point: tuple[float, float]) -> tuple[float, float]:
+ du, dv = point[0] - pivot_u, point[1] - pivot_v
+ return (pivot_u + du * cos_a - dv * sin_a, pivot_v + du * sin_a + dv * cos_a)
+
+ for line in _bell_outline():
+ pen.lines([turn(point) for point in line], color)
+ if slashed:
+ _glyph_slash(pen, color)
def _glyph_mic(pen: _Pen, color: _Rgb) -> None:
@@ -684,8 +756,14 @@ def _draw_glyph(
stroke: float,
state: PetStripState,
) -> None:
- if action == "compose":
- _glyph_compose(_Pen(d, cx, cy, box, stroke), PET_ICON)
+ if action == "bell":
+ color = PET_ICON_MUTED if state.notify_off else PET_ICON
+ _glyph_bell(
+ _Pen(d, cx, cy, box, stroke),
+ color,
+ angle=ring_angle(state.ring),
+ slashed=state.notify_off,
+ )
elif action == "mic_mute":
color = PET_ICON_MUTED if state.mic_muted else PET_ICON
pen = _Pen(d, cx, cy, box, stroke)
@@ -846,12 +924,12 @@ def _draw_indicator(
def _render_pen_disc(state: PetStripState, diameter: int, scale: float) -> Image.Image:
size = diameter * _SS
- hovered = state.hovered == "compose"
+ hovered = state.hovered == "bell"
layer = Image.new("RGB", (size, size), PET_FILL_HOVER if hovered else PET_FILL)
d = ImageDraw.Draw(layer)
box = _spx(PET_SLOT, scale) * PET_ICON_BOX * _SS
stroke = PET_ICON_STROKE * max(0.5, scale) * _SS
- _draw_glyph("compose", d, size / 2.0, size / 2.0, box, stroke, state)
+ _draw_glyph("bell", d, size / 2.0, size / 2.0, box, stroke, state)
return layer.resize((diameter, diameter), Image.Resampling.LANCZOS)
diff --git a/ui/orb/notice_stack.py b/ui/orb/notice_stack.py
new file mode 100644
index 0000000000..86ba08e5b3
--- /dev/null
+++ b/ui/orb/notice_stack.py
@@ -0,0 +1,908 @@
+"""The desktop pet's notifications: a small stack of cards under the strip.
+
+When something the user is waiting for happens — a coding agent finished, a
+pane asks a question, a background task failed — the pet's bell rings and a
+card drops out from under the control strip. Several cards stack: the newest
+in front, up to two older ones peeking out behind it, a little narrower and a
+little darker each. Hovering the stack fans it out into a column so every card
+can be read; leaving it folds it back. A click dismisses the card under the
+pointer, and every card leaves on its own after a while (never while the
+pointer is on the stack).
+
+Split in two, like :mod:`ui.orb.controls`:
+
+* **Pure model and geometry** (:class:`NoticeModel`, :func:`stack_slots`,
+ :class:`Spring`, :func:`render_icon`) — no Tk, fully testable.
+* **The window** (:class:`PetNoticeStack`) — one frameless, colour-keyed Tk
+ toplevel whose canvas is redrawn from the model while something moves and
+ left alone while nothing does.
+
+The window is colour-keyed like every other pet window: card shapes are Tk
+canvas polygons (hard edges, no pink fringe), and the only antialiased pixels —
+the icon discs — are painted onto the card's own fill colour, never onto the
+key. Motion comes from springs rather than fixed tweens, so a card that is
+pushed back while it is still dropping in simply changes course instead of
+jumping.
+"""
+
+from __future__ import annotations
+
+import functools
+import logging
+import math
+import sys
+import time
+import tkinter as tk
+import tkinter.font as tkfont
+from dataclasses import dataclass, field
+from itertools import count
+from typing import Any
+
+from PIL import Image, ImageDraw, ImageTk
+
+log = logging.getLogger("jarvis.orb")
+
+_Rgb = tuple[int, int, int]
+
+#: What a notice is about. ``done``: something finished. ``attention``: it
+#: waits for the user (a question, an approval). ``error``: it failed.
+#: ``info``: anything else worth a glance.
+NOTICE_KINDS: tuple[str, ...] = ("done", "attention", "error", "info")
+
+#: Seconds a card stays before it leaves on its own. Something that waits for
+#: the user stays longest; a plain "done" is news for a few seconds.
+NOTICE_TTL_S: dict[str, float] = {"done": 8.0, "attention": 20.0, "error": 14.0, "info": 6.0}
+
+#: Cards kept at most; a newer one pushes the oldest out.
+NOTICE_KEEP = 4
+#: Cards visible behind the front one while the stack is folded.
+NOTICE_PEEK = 2
+#: The same notice again within this window refreshes the card instead of
+#: stacking a twin (two events for one finished job).
+NOTICE_DEDUPE_S = 3.0
+
+#: Unscaled geometry at 100 % and ``pet_scale`` 1.0.
+CARD_HEIGHT = 60
+CARD_RADIUS = 20
+CARD_PAD_X = 14
+CARD_ICON = 32
+CARD_ICON_GAP = 12
+CARD_GAP = 8
+#: How far each card behind the front one peeks out, and how much narrower it
+#: is on each side.
+PEEK_OFFSET = 9
+PEEK_INSET = 11
+CARD_TITLE_FONT_SIZE = 10
+CARD_DETAIL_FONT_SIZE = 9
+CARD_FONT_FAMILY = "Segoe UI"
+
+#: Palette — the strip's blue-black, a shade lighter so a card reads as a
+#: surface above the desktop, with a hairline rim.
+CARD_FILL: _Rgb = (21, 25, 32)
+CARD_FILL_HOVER: _Rgb = (28, 33, 43)
+CARD_BORDER: _Rgb = (46, 52, 64)
+#: A card two places back sinks this far toward the desktop-dark.
+CARD_FILL_DEEP: _Rgb = (12, 14, 19)
+CARD_BORDER_DEEP: _Rgb = (28, 32, 40)
+CARD_TITLE: _Rgb = (243, 244, 247)
+CARD_DETAIL: _Rgb = (156, 161, 172)
+
+#: Icon colours per kind: the glyph, and the disc it sits on.
+ICON_COLORS: dict[str, tuple[_Rgb, _Rgb]] = {
+ "done": ((74, 222, 128), (20, 58, 38)),
+ "attention": ((251, 191, 36), (66, 50, 14)),
+ "error": ((248, 113, 113), (70, 26, 30)),
+ "info": ((126, 186, 255), (22, 42, 74)),
+}
+
+#: The icon's entrance: the disc pops in with a slight overshoot, then the
+#: glyph draws itself — a check is ticked, not stamped.
+ICON_ANIM_S = 0.55
+ICON_FRAMES = 14
+
+#: Spring tuning: stiff enough to feel quick, damped just under critical so a
+#: card overshoots by a hair and settles.
+SPRING_STIFFNESS = 340.0
+SPRING_DAMPING = 30.0
+FRAME_MS = 16
+#: How often expiry is checked while the stack is at rest.
+EXPIRY_POLL_MS = 400
+#: Leaving the stack folds it after this long — a pointer crossing the gap
+#: between two cards must not fold it under itself.
+COLLAPSE_GRACE_MS = 280
+
+
+def _lerp(a: _Rgb, b: _Rgb, t: float) -> _Rgb:
+ t = max(0.0, min(1.0, t))
+ return (
+ int(round(a[0] + (b[0] - a[0]) * t)),
+ int(round(a[1] + (b[1] - a[1]) * t)),
+ int(round(a[2] + (b[2] - a[2]) * t)),
+ )
+
+
+def _hex(rgb: _Rgb) -> str:
+ return "#{:02x}{:02x}{:02x}".format(*rgb)
+
+
+# --- model -------------------------------------------------------------------
+
+
+@dataclass
+class Notice:
+ """One card."""
+
+ id: int
+ kind: str
+ title: str
+ detail: str
+ created: float
+ expires: float
+
+
+@dataclass
+class NoticeModel:
+ """The cards on screen, newest first. Pure: the clock is passed in."""
+
+ keep: int = NOTICE_KEEP
+ items: list[Notice] = field(default_factory=list)
+ _ids: Any = field(default_factory=lambda: count(1))
+
+ def push(self, kind: str, title: str, detail: str, now: float) -> tuple[Notice, list[Notice]]:
+ """Add a card. Returns it and the cards it pushed out of the stack.
+
+ A twin of a card added moments ago refreshes that card instead.
+ """
+ kind = kind if kind in NOTICE_KINDS else "info"
+ ttl = NOTICE_TTL_S[kind]
+ for item in self.items:
+ if (item.kind, item.title, item.detail) == (
+ kind,
+ title,
+ detail,
+ ) and now - item.created < NOTICE_DEDUPE_S:
+ item.expires = now + ttl
+ return item, []
+ notice = Notice(next(self._ids), kind, title, detail, now, now + ttl)
+ self.items.insert(0, notice)
+ dropped = self.items[self.keep :]
+ del self.items[self.keep :]
+ return notice, dropped
+
+ def dismiss(self, notice_id: int) -> Notice | None:
+ for index, item in enumerate(self.items):
+ if item.id == notice_id:
+ return self.items.pop(index)
+ return None
+
+ def expire(self, now: float) -> list[Notice]:
+ """Remove and return every card whose time is up."""
+ gone = [item for item in self.items if item.expires <= now]
+ if gone:
+ self.items = [item for item in self.items if item.expires > now]
+ return gone
+
+ def pause(self, seconds: float) -> None:
+ """Push every deadline back (the pointer rested on the stack)."""
+ if seconds <= 0:
+ return
+ for item in self.items:
+ item.expires += seconds
+
+ def clear(self) -> list[Notice]:
+ gone, self.items = self.items, []
+ return gone
+
+
+# --- geometry ----------------------------------------------------------------
+
+
+@dataclass(frozen=True)
+class Slot:
+ """Where a card wants to be: its top edge, side inset and depth (0 = front)."""
+
+ y: float
+ inset: float
+ depth: int
+
+
+def stack_slots(
+ count_: int, *, expanded: bool, card_h: int, scale: float, upward: bool = False
+) -> list[Slot]:
+ """Target slots for ``count_`` cards, newest first, inside the stack window.
+
+ Folded, the front card sits at the top and each older one peeks out below
+ it, narrower; cards past ``NOTICE_PEEK`` hide exactly behind the last
+ peeking one. Fanned out, they form a column. ``upward`` mirrors it all for
+ a stack that grows up from above the pet (no room below).
+ """
+ peek = PEEK_OFFSET * scale
+ inset = PEEK_INSET * scale
+ gap = CARD_GAP * scale
+ height = stack_height(count_, expanded=expanded, card_h=card_h, scale=scale)
+ slots: list[Slot] = []
+ for index in range(count_):
+ if expanded:
+ y, side, depth = index * (card_h + gap), 0.0, 0
+ else:
+ level = min(index, NOTICE_PEEK)
+ y, side, depth = level * peek, level * inset, min(index, NOTICE_PEEK + 1)
+ if upward:
+ y = height - card_h - y
+ slots.append(Slot(y=y, inset=side, depth=depth))
+ return slots
+
+
+def stack_height(count_: int, *, expanded: bool, card_h: int, scale: float) -> int:
+ """Height the stack takes with ``count_`` cards."""
+ if count_ <= 0:
+ return 0
+ if expanded:
+ return int(round(count_ * card_h + (count_ - 1) * CARD_GAP * scale))
+ return int(round(card_h + min(count_ - 1, NOTICE_PEEK) * PEEK_OFFSET * scale))
+
+
+def max_stack_height(card_h: int, scale: float) -> int:
+ """The tallest the stack can get: every kept card fanned out."""
+ return stack_height(NOTICE_KEEP, expanded=True, card_h=card_h, scale=scale)
+
+
+class Spring:
+ """One damped spring value. ``step`` advances it by ``dt`` seconds."""
+
+ __slots__ = ("value", "velocity", "target")
+
+ def __init__(self, value: float, target: float | None = None) -> None:
+ self.value = float(value)
+ self.velocity = 0.0
+ self.target = float(value if target is None else target)
+
+ def step(self, dt: float) -> None:
+ # Sub-steps keep the integration stable when a frame comes in late.
+ steps = max(1, int(math.ceil(dt / 0.008)))
+ h = dt / steps
+ for _ in range(steps):
+ accel = SPRING_STIFFNESS * (self.target - self.value) - SPRING_DAMPING * self.velocity
+ self.velocity += accel * h
+ self.value += self.velocity * h
+
+ @property
+ def settled(self) -> bool:
+ return abs(self.target - self.value) < 0.4 and abs(self.velocity) < 4.0
+
+ def snap(self) -> None:
+ self.value = self.target
+ self.velocity = 0.0
+
+
+# --- icons -------------------------------------------------------------------
+
+
+def _ease_out_back(t: float) -> float:
+ t = max(0.0, min(1.0, t))
+ c1 = 1.70158
+ c3 = c1 + 1.0
+ return 1.0 + c3 * (t - 1.0) ** 3 + c1 * (t - 1.0) ** 2
+
+
+def icon_frame(age_s: float) -> int:
+ """The icon animation frame at ``age_s`` seconds after the card arrived."""
+ if age_s >= ICON_ANIM_S:
+ return ICON_FRAMES
+ return max(0, min(ICON_FRAMES, int(age_s / ICON_ANIM_S * ICON_FRAMES)))
+
+
+def _partial(points: list[tuple[float, float]], share: float) -> list[tuple[float, float]]:
+ """The first ``share`` of a polyline's length."""
+ if share >= 1.0:
+ return points
+ lengths = [math.dist(a, b) for a, b in zip(points, points[1:], strict=False)]
+ want = sum(lengths) * max(0.0, share)
+ out = [points[0]]
+ for (a, b), length in zip(zip(points, points[1:], strict=False), lengths, strict=False):
+ if want <= 0:
+ break
+ if length <= want:
+ out.append(b)
+ want -= length
+ continue
+ f = want / length
+ out.append((a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f))
+ break
+ return out
+
+
[email protected]_cache(maxsize=256)
+def render_icon(kind: str, frame: int, diameter: int, background: _Rgb) -> Image.Image:
+ """The round icon for ``kind`` at animation ``frame`` on an opaque square.
+
+ Drawn at 4x and downscaled, on the card's own fill, so its antialiasing
+ never meets the colour key.
+ """
+ ss = 4
+ size = max(2, diameter) * ss
+ glyph, disc = ICON_COLORS.get(kind, ICON_COLORS["info"])
+ layer = Image.new("RGB", (size, size), background)
+ d = ImageDraw.Draw(layer)
+ t = frame / ICON_FRAMES
+ pop = _ease_out_back(min(1.0, t / 0.55))
+ r = size / 2.0 * max(0.0, pop)
+ c = size / 2.0
+ if r > 0.5:
+ d.ellipse([c - r, c - r, c + r, c + r], fill=disc)
+ draw = max(0.0, min(1.0, (t - 0.3) / 0.6))
+ width = max(1, int(round(size * 0.085)))
+ unit = size / 24.0
+
+ def pt(u: float, v: float) -> tuple[float, float]:
+ return (c + (u - 12.0) * unit, c + (v - 12.0) * unit)
+
+ def stroke(points: list[tuple[float, float]], share: float) -> None:
+ if share <= 0.0:
+ return
+ line = _partial([pt(u, v) for u, v in points], share)
+ if len(line) >= 2:
+ d.line(line, fill=glyph, width=width, joint="curve")
+ for x, y in (line[0], line[-1]):
+ d.ellipse([x - width / 2, y - width / 2, x + width / 2, y + width / 2], fill=glyph)
+
+ if kind == "done":
+ stroke([(7.2, 12.4), (10.4, 15.6), (16.8, 8.6)], draw)
+ elif kind == "attention":
+ stroke([(12, 6.8), (12, 13.2)], min(1.0, draw * 1.25))
+ if draw >= 0.85:
+ dot = width * 0.62
+ x, y = pt(12, 17.0)
+ d.ellipse([x - dot, y - dot, x + dot, y + dot], fill=glyph)
+ elif kind == "error":
+ stroke([(8.2, 8.2), (15.8, 15.8)], min(1.0, draw * 2.0))
+ stroke([(15.8, 8.2), (8.2, 15.8)], max(0.0, draw * 2.0 - 1.0))
+ else:
+ from ui.orb.controls import _bell_outline # noqa: PLC0415 — one bell, one drawing
+
+ for line in _bell_outline():
+ scaled = [(12 + (u - 12) * 0.62, 12.6 + (v - 12) * 0.62) for u, v in line]
+ stroke(scaled, draw)
+ return layer.resize((diameter, diameter), Image.Resampling.LANCZOS)
+
+
+# --- the window ----------------------------------------------------------------
+
+
+@dataclass
+class _Card:
+ notice: Notice
+ y: Spring
+ inset: Spring
+ shade: Spring
+ x: Spring
+ born: float
+ leaving: bool = False
+
+
+def _fit(text: str, font: tkfont.Font, width: int) -> str:
+ """``text`` cut with an ellipsis to fit ``width`` pixels."""
+ if width <= 0 or not text:
+ return ""
+ if font.measure(text) <= width:
+ return text
+ lo, hi = 0, len(text)
+ while lo < hi:
+ mid = (lo + hi + 1) // 2
+ if font.measure(text[:mid].rstrip() + "…") <= width:
+ lo = mid
+ else:
+ hi = mid - 1
+ return text[:lo].rstrip() + "…"
+
+
+class PetNoticeStack:
+ """The cards' own frameless window. Every method runs on the Tk thread."""
+
+ def __init__(self, parent: tk.Misc, *, scale: float = 1.0, width: int = 320) -> None:
+ self._parent = parent
+ self._scale = max(0.25, float(scale))
+ self._width = max(160, int(width))
+ self._model = NoticeModel()
+ self._cards: dict[int, _Card] = {}
+ self._leaving: list[_Card] = []
+ self._expanded = False
+ self._hovered_id: int | None = None
+ self._pointer_inside = False
+ self._hover_since: float | None = None
+ self._upward = False
+ self._anchor: tuple[int, int, int, int, int] | None = None
+ self._top: tk.Toplevel | None = None
+ self._canvas: tk.Canvas | None = None
+ self._title_font: tkfont.Font | None = None
+ self._detail_font: tkfont.Font | None = None
+ self._photos: list[ImageTk.PhotoImage] = []
+ self._frame_after: str | None = None
+ self._expiry_after: str | None = None
+ self._collapse_after: str | None = None
+ self._last_tick = 0.0
+ self._shown = False
+ self._mac_transparent = False
+ self._build()
+
+ # -- setup --------------------------------------------------------------
+
+ def _build(self) -> None:
+ from ui.orb import overlay as _ov # noqa: PLC0415 — overlay imports this module
+
+ top = tk.Toplevel(self._parent)
+ top.overrideredirect(True)
+ top.wm_attributes("-topmost", True)
+ if sys.platform == "darwin":
+ try:
+ top.wm_attributes("-transparent", True)
+ top.configure(bg="systemTransparent")
+ self._mac_transparent = True
+ except tk.TclError:
+ log.warning("macOS -transparent unsupported — notices render opaque")
+ top.configure(bg=_ov.COLOR_KEY_HEX)
+ else:
+ try:
+ top.wm_attributes("-transparentcolor", _ov.COLOR_KEY_HEX)
+ except tk.TclError:
+ log.debug("no colour key on this window system", exc_info=True)
+ top.configure(bg=_ov.COLOR_KEY_HEX)
+ _ov._hide_tk_window_from_task_switcher(top) # noqa: SLF001 — shared overlay helper
+ _ov._exclude_tk_window_from_capture(top) # noqa: SLF001 — shared overlay helper
+ top.withdraw()
+ canvas = tk.Canvas(
+ top,
+ bg="systemTransparent" if self._mac_transparent else _ov.COLOR_KEY_HEX,
+ highlightthickness=0,
+ borderwidth=0,
+ )
+ canvas.pack(fill="both", expand=True)
+ if self._mac_transparent:
+ top.update_idletasks()
+ _ov.apply_macos_clear_backing()
+ canvas.bind("<Motion>", self._on_motion)
+ canvas.bind("<Enter>", self._on_enter)
+ canvas.bind("<Leave>", self._on_leave)
+ canvas.bind("<ButtonRelease-1>", self._on_click)
+ self._title_font = tkfont.Font(
+ root=top, family=CARD_FONT_FAMILY, size=CARD_TITLE_FONT_SIZE, weight="bold"
+ )
+ self._detail_font = tkfont.Font(
+ root=top, family=CARD_FONT_FAMILY, size=CARD_DETAIL_FONT_SIZE
+ )
+ self._top = top
+ self._canvas = canvas
+
+ # -- geometry -----------------------------------------------------------
+
+ @property
+ def card_height(self) -> int:
+ return max(24, int(round(CARD_HEIGHT * self._scale)))
+
+ @property
+ def window_height(self) -> int:
+ return max_stack_height(self.card_height, self._scale) + 2
+
+ @property
+ def count(self) -> int:
+ return len(self._model.items)
+
+ @property
+ def showing(self) -> bool:
+ return self._shown
+
+ def set_scale(self, scale: float, width: int) -> None:
+ scale = max(0.25, float(scale))
+ width = max(160, int(width))
+ if (scale, width) == (self._scale, self._width):
+ return
+ self._scale, self._width = scale, width
+ self._retarget(snap=True)
+ self._place()
+ self._draw()
+
+ def set_anchor(self, anchor: tuple[int, int, int, int, int]) -> None:
+ """``(center_x, below_y, above_y, limit_bottom, screen_w)``.
+
+ The stack hangs from ``below_y`` when its fanned-out height fits above
+ ``limit_bottom``, else it grows upward from ``above_y``.
+ """
+ self._anchor = anchor
+ upward = anchor[1] + self.window_height > anchor[3]
+ if upward != self._upward:
+ self._upward = upward
+ self._retarget(snap=True)
+ self._draw()
+ self._place()
+
+ def _place(self) -> None:
+ if self._top is None or self._anchor is None:
+ return
+ center_x, below_y, above_y, _limit, screen_w = self._anchor
+ width, height = self._width, self.window_height
+ x = max(8, min(center_x - width // 2, screen_w - width - 8))
+ y = max(8, above_y - height) if self._upward else below_y
+ try:
+ self._top.geometry(f"{width}x{height}+{x}+{y}")
+ if self._canvas is not None:
+ self._canvas.configure(width=width, height=height)
+ except tk.TclError:
+ log.debug("notice stack placement failed", exc_info=True)
+
+ # -- public ---------------------------------------------------------------
+
+ def push(self, kind: str, title: str, detail: str) -> None:
+ title = " ".join(str(title or "").split())
+ detail = " ".join(str(detail or "").split())
+ if not title:
+ title, detail = detail, ""
+ if not title:
+ return
+ now = time.monotonic()
+ notice, dropped = self._model.push(kind, title, detail, now)
+ for gone in dropped:
+ self._send_off(gone.id)
+ if notice.id not in self._cards:
+ card_h = self.card_height
+ start_y = -card_h * 0.8 if not self._upward else self.window_height + card_h * 0.2
+ self._cards[notice.id] = _Card(
+ notice=notice,
+ y=Spring(start_y),
+ inset=Spring(PEEK_INSET * self._scale * 2),
+ shade=Spring(0.0),
+ x=Spring(0.0),
+ born=now,
+ )
+ else:
+ self._cards[notice.id].born = now
+ self._retarget()
+ self._show()
+ self._kick()
+
+ def clear(self) -> None:
+ """Send every card away (the bell was switched off)."""
+ for gone in self._model.clear():
+ self._send_off(gone.id)
+ self._retarget()
+ self._kick()
+
+ def hide(self) -> None:
+ """Withdraw at once (the pet was hidden); the cards are dropped."""
+ self._model.clear()
+ self._cards.clear()
+ self._leaving.clear()
+ self._withdraw()
+
+ def destroy(self) -> None:
+ self._cancel_all()
+ top, self._top, self._canvas = self._top, None, None
+ self._photos.clear()
+ if top is not None:
+ try:
+ top.destroy()
+ except tk.TclError:
+ log.debug("notice stack destroy failed", exc_info=True)
+
+ # -- motion -----------------------------------------------------------------
+
+ def _send_off(self, notice_id: int) -> None:
+ card = self._cards.pop(notice_id, None)
+ if card is None:
+ return
+ card.leaving = True
+ card.x.target = self._width + 24
+ card.x.velocity = max(card.x.velocity, 260.0)
+ self._leaving.append(card)
+
+ def _retarget(self, *, snap: bool = False) -> None:
+ items = self._model.items
+ slots = stack_slots(
+ len(items),
+ expanded=self._expanded,
+ card_h=self.card_height,
+ scale=self._scale,
+ upward=self._upward,
+ )
+ for item, slot in zip(items, slots, strict=False):
+ card = self._cards.get(item.id)
+ if card is None:
+ continue
+ card.y.target = slot.y
+ card.inset.target = slot.inset
+ card.shade.target = float(min(slot.depth, NOTICE_PEEK + 1))
+ if snap:
+ for spring in (card.y, card.inset, card.shade):
+ spring.snap()
+
+ def _kick(self) -> None:
+ if self._top is None or self._frame_after is not None:
+ return
+ self._last_tick = time.monotonic()
+ self._frame_after = self._top.after(FRAME_MS, self._tick)
+
+ def _tick(self) -> None:
+ self._frame_after = None
+ if self._top is None:
+ return
+ now = time.monotonic()
+ dt = min(0.05, max(0.001, now - self._last_tick))
+ self._last_tick = now
+ moving = False
+ for card in list(self._cards.values()) + self._leaving:
+ for spring in (card.y, card.inset, card.shade, card.x):
+ if not spring.settled:
+ spring.step(dt)
+ moving = True
+ else:
+ spring.snap()
+ if now - card.born < ICON_ANIM_S + 0.05:
+ moving = True
+ self._leaving = [c for c in self._leaving if c.x.value < self._width + 8]
+ self._draw()
+ if moving or self._leaving:
+ self._frame_after = self._top.after(FRAME_MS, self._tick)
+ return
+ if not self._cards:
+ self._withdraw()
+ return
+ self._schedule_expiry()
+
+ def _schedule_expiry(self) -> None:
+ if self._top is None or self._expiry_after is not None or not self._cards:
+ return
+ self._expiry_after = self._top.after(EXPIRY_POLL_MS, self._check_expiry)
+
+ def _check_expiry(self) -> None:
+ self._expiry_after = None
+ if self._top is None:
+ return
+ now = time.monotonic()
+ if self._pointer_inside:
+ # Reading is not idling: the clocks stand still under the pointer.
+ if self._hover_since is not None:
+ self._model.pause(now - self._hover_since)
+ self._hover_since = now
+ gone = self._model.expire(now)
+ for notice in gone:
+ self._send_off(notice.id)
+ if gone:
+ if not self._model.items:
+ self._set_expanded(False)
+ self._retarget()
+ self._kick()
+ return
+ self._schedule_expiry()
+
+ # -- pointer ------------------------------------------------------------
+
+ def _card_at(self, x: float, y: float) -> int | None:
+ """The front-most card under ``(x, y)``."""
+ card_h = self.card_height
+ for item in self._model.items:
+ card = self._cards.get(item.id)
+ if card is None:
+ continue
+ x0 = card.inset.value + card.x.value
+ x1 = self._width - card.inset.value + card.x.value
+ if x0 <= x <= x1 and card.y.value <= y <= card.y.value + card_h:
+ return item.id
+ return None
+
+ def _on_enter(self, event: tk.Event) -> None:
+ self._on_motion(event)
+
+ def _on_motion(self, event: tk.Event) -> None:
+ hit = self._card_at(event.x, event.y)
+ inside = hit is not None
+ if inside and not self._pointer_inside:
+ self._hover_since = time.monotonic()
+ self._pointer_inside = inside
+ if inside:
+ self._cancel_collapse()
+ self._set_expanded(True)
+ elif self._expanded:
+ self._schedule_collapse()
+ if hit != self._hovered_id:
+ self._hovered_id = hit
+ if self._canvas is not None:
+ try:
+ self._canvas.configure(cursor="hand2" if hit is not None else "")
+ except tk.TclError:
+ log.debug("notice cursor change failed", exc_info=True)
+ self._draw()
+
+ def _on_leave(self, _event: tk.Event) -> None:
+ if self._pointer_inside and self._hover_since is not None:
+ self._model.pause(time.monotonic() - self._hover_since)
+ self._pointer_inside = False
+ self._hover_since = None
+ if self._hovered_id is not None:
+ self._hovered_id = None
+ self._draw()
+ self._schedule_collapse()
+
+ def _on_click(self, event: tk.Event) -> None:
+ hit = self._card_at(event.x, event.y)
+ if hit is None:
+ return
+ self._model.dismiss(hit)
+ self._send_off(hit)
+ self._hovered_id = None
+ if not self._model.items:
+ self._set_expanded(False)
+ self._retarget()
+ self._kick()
+
+ def _set_expanded(self, expanded: bool) -> None:
+ if expanded == self._expanded:
+ return
+ self._expanded = expanded
+ self._retarget()
+ self._kick()
+
+ def _schedule_collapse(self) -> None:
+ if self._top is None or self._collapse_after is not None or not self._expanded:
+ return
+ self._collapse_after = self._top.after(COLLAPSE_GRACE_MS, self._collapse_now)
+
+ def _collapse_now(self) -> None:
+ self._collapse_after = None
+ if not self._pointer_inside:
+ self._set_expanded(False)
+
+ def _cancel_collapse(self) -> None:
+ if self._collapse_after is not None and self._top is not None:
+ try:
+ self._top.after_cancel(self._collapse_after)
+ except tk.TclError:
+ log.debug("collapse cancel failed", exc_info=True)
+ self._collapse_after = None
+
+ # -- painting -------------------------------------------------------------
+
+ def _show(self) -> None:
+ if self._top is None or self._shown:
+ return
+ self._place()
+ try:
+ self._top.deiconify()
+ self._top.lift()
+ except tk.TclError:
+ log.debug("notice stack show failed", exc_info=True)
+ return
+ self._shown = True
+
+ def _withdraw(self) -> None:
+ self._cancel_all()
+ self._expanded = False
+ self._pointer_inside = False
+ self._hovered_id = None
+ if self._canvas is not None:
+ try:
+ self._canvas.delete("all")
+ except tk.TclError:
+ log.debug("notice canvas clear failed", exc_info=True)
+ self._photos.clear()
+ if self._top is not None and self._shown:
+ try:
+ self._top.withdraw()
+ except tk.TclError:
+ log.debug("notice stack withdraw failed", exc_info=True)
+ self._shown = False
+
+ def _cancel_all(self) -> None:
+ top = self._top
+ for attr in ("_frame_after", "_expiry_after", "_collapse_after"):
+ after_id = getattr(self, attr)
+ if after_id is not None and top is not None:
+ try:
+ top.after_cancel(after_id)
+ except tk.TclError:
+ log.debug("notice timer cancel failed", exc_info=True)
+ setattr(self, attr, None)
+
+ def _draw(self) -> None:
+ canvas = self._canvas
+ if canvas is None or self._title_font is None or self._detail_font is None:
+ return
+ try:
+ canvas.delete("all")
+ except tk.TclError:
+ return
+ self._photos.clear()
+ order = [self._cards[i.id] for i in self._model.items if i.id in self._cards]
+ # Back to front: the deepest card first, leaving cards above the rest
+ # so a dismissed card slides out over its neighbours.
+ for card in reversed(order):
+ self._draw_card(card)
+ for card in self._leaving:
+ self._draw_card(card)
+
+ def _draw_card(self, card: _Card) -> None:
+ canvas = self._canvas
+ assert canvas is not None and self._title_font is not None # noqa: S101
+ assert self._detail_font is not None # noqa: S101
+ scale = self._scale
+ card_h = self.card_height
+ depth = max(0.0, card.shade.value)
+ if depth > NOTICE_PEEK + 0.5:
+ return
+ x0 = card.inset.value + card.x.value
+ x1 = self._width - card.inset.value + card.x.value - 1
+ y0 = card.y.value
+ y1 = y0 + card_h - 1
+ hovered = card.notice.id == self._hovered_id and not card.leaving
+ deep = min(1.0, depth / max(1, NOTICE_PEEK))
+ fill = _lerp(CARD_FILL_HOVER if hovered else CARD_FILL, CARD_FILL_DEEP, deep * 0.85)
+ border = _lerp(CARD_BORDER, CARD_BORDER_DEEP, deep)
+ radius = min(card_h / 2.0, CARD_RADIUS * scale)
+ _rounded_rect(canvas, x0, y0, x1, y1, radius, fill=_hex(fill), outline=_hex(border))
+ if depth > 0.35:
+ return # a card behind the front one shows only its edge
+ icon_d = max(8, int(round(CARD_ICON * scale)))
+ pad_x = CARD_PAD_X * scale
+ icon_x = x0 + pad_x
+ icon_y = y0 + (card_h - icon_d) / 2.0
+ age = time.monotonic() - card.born
+ image = render_icon(card.notice.kind, icon_frame(age), icon_d, fill)
+ photo = ImageTk.PhotoImage(image, master=canvas)
+ self._photos.append(photo)
+ canvas.create_image(int(round(icon_x)), int(round(icon_y)), anchor="nw", image=photo)
+ text_x = icon_x + icon_d + CARD_ICON_GAP * scale
+ text_w = int(x1 - pad_x - text_x)
+ title_lh = int(self._title_font.metrics("linespace"))
+ detail_lh = int(self._detail_font.metrics("linespace"))
+ detail = card.notice.detail
+ block = title_lh + (detail_lh + 1 if detail else 0)
+ ty = y0 + (card_h - block) / 2.0
+ canvas.create_text(
+ text_x,
+ ty,
+ text=_fit(card.notice.title, self._title_font, text_w),
+ font=self._title_font,
+ anchor="nw",
+ fill=_hex(CARD_TITLE),
+ )
+ if detail:
+ canvas.create_text(
+ text_x,
+ ty + title_lh + 1,
+ text=_fit(detail, self._detail_font, text_w),
+ font=self._detail_font,
+ anchor="nw",
+ fill=_hex(CARD_DETAIL),
+ )
+
+
+def _rounded_rect(
+ canvas: tk.Canvas, x0: float, y0: float, x1: float, y1: float, r: float, **kwargs: Any
+) -> int:
+ """A rounded rectangle with true circular corners, as one canvas polygon.
+
+ The corners are explicit arc points rather than Tk's ``smooth`` spline,
+ which pulls a corner flatter than its radius.
+ """
+ r = max(1.0, min(r, (x1 - x0) / 2.0, (y1 - y0) / 2.0))
+ steps = max(4, int(r / 2.0))
+ points: list[float] = []
+ for cx, cy, start in ((x1 - r, y0 + r, -90), (x1 - r, y1 - r, 0), (x0 + r, y1 - r, 90),
+ (x0 + r, y0 + r, 180)): # fmt: skip
+ for i in range(steps + 1):
+ a = math.radians(start + 90.0 * i / steps)
+ points.extend((cx + r * math.cos(a), cy + r * math.sin(a)))
+ return canvas.create_polygon(points, **kwargs)
+
+
+__all__ = [
+ "NOTICE_KINDS",
+ "Notice",
+ "NoticeModel",
+ "PetNoticeStack",
+ "Slot",
+ "Spring",
+ "icon_frame",
+ "max_stack_height",
+ "render_icon",
+ "stack_height",
+ "stack_slots",
+]
diff --git a/ui/orb/overlay.py b/ui/orb/overlay.py
index 03ab8c54df..b57884b6ec 100644
--- a/ui/orb/overlay.py
+++ b/ui/orb/overlay.py
@@ -90,6 +90,7 @@ from ui.orb.drag_persistence import (
save_position_to_toml,
screens_from_tk,
)
+from ui.orb.notice_stack import PetNoticeStack
from ui.orb.pet_renderer import PET_TARGET_EDGE_PX, PetRenderer, dpi_ratio_for
from ui.orb.taskbar import (
MascotAnchor,
@@ -308,6 +309,8 @@ PET_CARD_READING_LINGER_S = 6.0
#: The default linger of ``clear_status``.
PET_STATUS_LINGER_S = 1.5
PET_BUBBLE_GAP = 8
+#: The notification cards are this many times the strip's width.
+PET_NOTICE_WIDTH_PER_STRIP = 1.5
PET_BUBBLE_ELLIPSIS = "…"
@@ -1317,6 +1320,9 @@ class OrbCommentBubble:
self._status_clear_pending = False
self._status_max_w: int | None = None
self._ui_scale = 1.0
+ #: Called after the status card appeared, moved, resized or went away,
+ #: so whatever hangs below it (the notification stack) can follow.
+ self.on_status_change: Callable[[], None] | None = None
self._build()
def update_anchor(self, orb_x: int, orb_y: int, screen_w: int) -> None:
@@ -1688,6 +1694,25 @@ class OrbCommentBubble:
def status_showing(self) -> bool:
return self._status_showing
+ def status_box(self) -> tuple[int, int, int, int] | None:
+ """``(x, y, width, height)`` of the status card on screen, or ``None``."""
+ size = self._status_size
+ anchor = self._status_anchor
+ if not self._status_showing or size is None or anchor is None:
+ return None
+ x, y = self._status_position(size[0], size[1], anchor)
+ return x, y, size[0], size[1]
+
+ def _notify_status_change(self) -> None:
+ # getattr: tests build bubbles without __init__.
+ callback = getattr(self, "on_status_change", None)
+ if callback is None:
+ return
+ try:
+ callback()
+ except Exception: # noqa: BLE001 — a follower must not break the card
+ logging.getLogger("jarvis.orb").debug("status change hook failed", exc_info=True)
+
@property
def window(self) -> tk.Toplevel | None:
return self._top
@@ -1957,6 +1982,7 @@ class OrbCommentBubble:
return False
self._status_showing = True
self._status_size = (width, height)
+ self._notify_status_change()
return True
def _cancel_timers(self) -> None:
@@ -1975,9 +2001,12 @@ class OrbCommentBubble:
def hide(self) -> None:
self._cancel_clear()
+ was_showing = self._status_showing
self._status_showing = False
self._status_expanded = False
self._status_size = None
+ if was_showing:
+ self._notify_status_change()
if self._top is None:
return
if self._dismiss_after_id is not None:
@@ -2480,6 +2509,8 @@ class PetControlStrip(OrbControlRow):
level: int | None = None,
motion: str | None = None,
phase: int | None = None,
+ notify_off: bool | None = None,
+ ring: int | None = None,
) -> None:
"""Update what the strip says, repainting only on a real change."""
_ = can_attach # the pet strip has no attach control
@@ -2492,6 +2523,8 @@ class PetControlStrip(OrbControlRow):
motion=current.motion if motion is None else str(motion),
phase=current.phase if phase is None else int(phase),
hovered=current.hovered,
+ notify_off=current.notify_off if notify_off is None else bool(notify_off),
+ ring=current.ring if ring is None else int(ring),
)
if state == current:
return
@@ -2660,6 +2693,14 @@ class OrbOverlay:
#: Hidden by the shortcut or the settings page — lasts until restart.
self._user_hidden = False
self._on_compose: Callable[[], None] | None = None
+ #: The bell: notifications show (True) or stay quiet. Runtime only,
+ #: like the speaker mute — a silenced bell forgotten overnight would
+ #: hide tomorrow's "your agent is done" without a trace.
+ self._notify_enabled = True
+ self._on_notify_toggle: Callable[[bool], None] | None = None
+ #: The notification cards' window, created with the first card.
+ self._notices: PetNoticeStack | None = None
+ self._ring_after_id: str | None = None
#: The monitor's display scale (1.0 at 100 %), read once the root exists.
self._dpi_ratio = 1.0
# Frame-loop bookkeeping: ONE pending tick at most, and for renderers
@@ -2940,6 +2981,7 @@ class OrbOverlay:
theme=bubble_theme_for_style(self._style),
)
self._comment_bubble.set_ui_scale(self._dpi_ratio)
+ self._comment_bubble.on_status_change = self._sync_notice_anchor
self._ensure_controls()
if self._style == "pet":
self._sync_pet_strip_scale()
@@ -3042,6 +3084,11 @@ class OrbOverlay:
bubble.set_ui_scale(scale)
strip_w, _strip_h = orb_controls.pet_strip_size(scale)
bubble.set_status_max_width(int(round(strip_w * PET_CARD_MAX_WIDTH_PER_STRIP)))
+ notices = self._notices
+ if notices is not None:
+ strip_w, _strip_h = orb_controls.pet_strip_size(scale)
+ notices.set_scale(scale, int(round(strip_w * PET_NOTICE_WIDTH_PER_STRIP)))
+ self._sync_notice_anchor()
def _clamp_position(
self, x: int, y: int, monitor_geo: tuple[int, int, int, int]
@@ -3065,6 +3112,7 @@ class OrbOverlay:
bubble.update_anchor(x, y, screen_w)
if self._controls is not None:
self._controls.update_anchor(x, y)
+ self._sync_notice_anchor(refresh_limit=False)
def _read_dpi_ratio(self) -> float:
"""The monitor's display scale as Tk sees it (1.0 at 100 %)."""
@@ -3241,6 +3289,7 @@ class OrbOverlay:
self._controls.update_anchor(self._mascot_x, self._mascot_y)
if self._style == "pet" and self._comment_bubble is not None:
self._comment_bubble.move_status(self._status_anchor())
+ self._sync_notice_anchor()
self._manual_pinned = True
try:
@@ -3331,7 +3380,7 @@ class OrbOverlay:
speaker_muted=self._speaker_muted,
)
if isinstance(row, PetControlStrip):
- row.set_state(mic_muted=self._mic_muted)
+ row.set_state(mic_muted=self._mic_muted, notify_off=not self._notify_enabled)
self._controls = row
def _on_orb_pointer_enter(self, _event: tk.Event | None = None) -> None:
@@ -3351,6 +3400,10 @@ class OrbOverlay:
return True
if self._mode in PET_VOICE_MODES or self._mode in PET_THINK_MODES:
return True
+ notices = self._notices
+ if notices is not None and notices.count:
+ # The bell rang for these cards; it stays in sight while they do.
+ return True
row = self._controls
return self._pointer_over_orb or (row is not None and row.pointer_inside)
@@ -3421,11 +3474,56 @@ class OrbOverlay:
self._do_close()
elif action == "speaker":
self._do_speaker_toggle()
+ elif action == "bell":
+ self._do_bell_toggle()
elif action == "compose":
self._do_compose()
elif action == "mic_mute":
self._do_mic_mute()
+ def _do_bell_toggle(self) -> None:
+ """The bell: notifications on or off for this run (Tk thread).
+
+ Off sends the cards on screen away at once; on rings the bell so the
+ click is answered by something that moves.
+ """
+ self._notify_enabled = not self._notify_enabled
+ row = self._controls
+ if isinstance(row, PetControlStrip):
+ row.set_state(notify_off=not self._notify_enabled)
+ if self._notify_enabled:
+ self._ring_bell()
+ elif self._notices is not None:
+ self._notices.clear()
+ callback = self._on_notify_toggle
+ if callback is not None:
+ try:
+ callback(self._notify_enabled)
+ except Exception: # noqa: BLE001 — a bad callback must not kill the Tk loop
+ logging.getLogger("jarvis.orb").debug(
+ "notify toggle callback failed", exc_info=True
+ )
+
+ def _ring_bell(self, phase: int = 1) -> None:
+ """Swing the bell once: one strip frame per ``PET_RING_STEP_S``."""
+ root = self._root
+ row = self._controls
+ if root is None or not isinstance(row, PetControlStrip):
+ self._ring_after_id = None
+ return
+ if phase == 1 and self._ring_after_id is not None:
+ try:
+ root.after_cancel(self._ring_after_id)
+ except tk.TclError:
+ logging.getLogger("jarvis.orb").debug("bell timer cancel failed", exc_info=True)
+ if phase >= orb_controls.PET_RING_PHASES:
+ self._ring_after_id = None
+ row.set_state(ring=0)
+ return
+ row.set_state(ring=phase)
+ delay = int(orb_controls.PET_RING_STEP_S * 1000)
+ self._ring_after_id = root.after(delay, lambda: self._ring_bell(phase + 1))
+
def _do_compose(self) -> None:
"""The pen: raise the main window on a fresh chat (``ComposeRequested``).
@@ -3886,6 +3984,8 @@ class OrbOverlay:
if self._style == "pet" and self._comment_bubble is not None:
# The pet's status bubble hangs off the pet; it goes with it.
self._comment_bubble.hide()
+ if self._notices is not None:
+ self._notices.hide()
if self._root is not None:
try:
self._root.withdraw()
@@ -3923,6 +4023,13 @@ class OrbOverlay:
logging.getLogger("jarvis.orb").debug(
"orb control row teardown failed", exc_info=True
)
+ try:
+ notices = self._notices
+ self._notices = None
+ if notices is not None:
+ notices.destroy()
+ except Exception: # noqa: BLE001 — teardown must reach root.destroy
+ logging.getLogger("jarvis.orb").debug("notice stack teardown failed", exc_info=True)
try:
root.destroy()
except Exception: # noqa: BLE001 — the process may be exiting anyway
@@ -4027,6 +4134,94 @@ class OrbOverlay:
"""Inject the pen control's action (the bridge publishes ``ComposeRequested``)."""
self._on_compose = callback
+ @property
+ def notifications_enabled(self) -> bool:
+ """Is the bell on (notifications show)?"""
+ return self._notify_enabled
+
+ def set_on_notifications_toggle(self, callback: Callable[[bool], None] | None) -> None:
+ """Called on the Tk thread with the new state after the bell was clicked."""
+ self._on_notify_toggle = callback
+
+ def set_notifications_enabled(self, enabled: bool) -> None:
+ """Switch the bell without a click (a respawned host restoring it). Thread-safe."""
+ flag = bool(enabled)
+
+ def _apply() -> None:
+ self._notify_enabled = flag
+ row = self._controls
+ if isinstance(row, PetControlStrip):
+ row.set_state(notify_off=not flag)
+ if not flag and self._notices is not None:
+ self._notices.clear()
+
+ self._enqueue_ui(_apply)
+
+ def push_notice(self, kind: str = "info", title: str = "", detail: str = "") -> None:
+ """Show one notification card under the pet and ring the bell. Thread-safe.
+
+ ``kind`` is ``done``, ``attention``, ``error`` or ``info``. Dropped
+ while the bell is off, the pet is hidden, or the look is not the pet.
+ """
+ if self._style != "pet":
+ return
+ kind_text = str(kind or "info")
+ title_text = str(title or "")
+ detail_text = str(detail or "")
+ self._enqueue_ui(lambda: self._apply_notice(kind_text, title_text, detail_text))
+
+ def _apply_notice(self, kind: str, title: str, detail: str) -> None:
+ if self._style != "pet" or not self._notify_enabled or self._root is None:
+ return
+ if self._user_hidden or not self._window_mapped():
+ return
+ notices = self._notices
+ if notices is None:
+ scale = self._pet_strip_scale()
+ strip_w, _strip_h = orb_controls.pet_strip_size(scale)
+ try:
+ notices = PetNoticeStack(
+ self._root,
+ scale=scale,
+ width=int(round(strip_w * PET_NOTICE_WIDTH_PER_STRIP)),
+ )
+ except tk.TclError:
+ logging.getLogger("jarvis.orb").debug("notice stack unavailable", exc_info=True)
+ return
+ self._notices = notices
+ self._sync_notice_anchor()
+ notices.push(kind, title, detail)
+ self._sync_controls_visibility()
+ self._ring_bell()
+
+ def _notice_anchor(self, *, refresh_limit: bool = True) -> tuple[int, int, int, int, int]:
+ """``(center_x, below_y, above_y, limit_bottom, screen_w)`` for the cards.
+
+ Like the status card's, pushed past the status card when one shows:
+ the cards hang under it, or stand above it when it sits over the pet.
+ """
+ center_x, below_y, above_y, limit = self._status_anchor(refresh_limit=refresh_limit)
+ gap = max(1, int(round(PET_BUBBLE_GAP * self._pet_strip_scale())))
+ bubble = self._comment_bubble
+ box = bubble.status_box() if bubble is not None else None
+ if box is not None:
+ _x, y, _w, h = box
+ if y >= below_y - 1:
+ below_y = y + h + gap
+ else:
+ above_y = y - gap
+ try:
+ screen_w = int(self._root.winfo_screenwidth()) if self._root is not None else 1920
+ except tk.TclError:
+ screen_w = 1920
+ return center_x, below_y, above_y, limit, screen_w
+
+ def _sync_notice_anchor(self, *, refresh_limit: bool = True) -> None:
+ notices = self._notices
+ if notices is None or self._style != "pet":
+ return
+ notices.set_anchor(self._notice_anchor(refresh_limit=refresh_limit))
+
def set_pet(self, pet_id: str) -> None:
"""Swap the figure live; ``"none"`` keeps the strip without a figure. Thread-safe."""
pet = str(pet_id or "").strip() or NO_PET_ID
@@ -4416,6 +4611,9 @@ class OrbOverlay:
# ghost's yellow bubble (and vice versa).
if self._comment_bubble is not None:
self._comment_bubble.set_theme(bubble_theme_for_style(style))
+ if style != "pet" and self._notices is not None:
+ # Notifications are the pet's; the other looks have no bell.
+ self._notices.hide()
self._ensure_controls()
self._sync_controls_visibility()
self._kick_frame()