Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(pets): every pet holds a real corded handset to its head in a call
rubenluetke10-beep56928301ba5c
diff --git a/docs/pets.md b/docs/pets.mdindex ceb8e285a2..390b36b87b 100644--- a/docs/pets.md+++ b/docs/pets.md@@ -40,10 +40,13 @@ one click.while it dials — or, during a conversation, hang up (the handset liesflat).- **On the phone**: while a voice conversation runs (listen / think / speak)- the pet holds a small pixel-art handset to the right side of its head- (`pet_renderer.with_phone`), drawn at the pack's own pixel factor and found- per frame, so it follows a bobbing head. Every pack gets it; no sprite row- is needed.+ the pet holds a corded handset to its head, drawn into the pet's own+ `phone.png` rows (one per `CALL_STATES` state, `"phone"` and+ `"phone_sheet"` in `pet.json`). Each built-in pet grips it its own way+ (`PhoneRig` in `scripts/pets/build_pets.py`): Gigi, Miso, Bolt and Ember+ raise an arm or paw, Mochi pulls out a soft nub, Shelly curls up a fold of+ its foot, and Brew cradles the handset in its handle. A pet without phone+ rows (an uploaded one) keeps its plain rows during a call.- **The thought bubble** above the pet's head while Jarvis thinks, drawn inthe pets' pixel art: a white pixel cloud with a dark outline and two smallpuffs trailing down to the head. Bobbing dots while Jarvis just thinks, the@@ -234,6 +237,12 @@ Two row conventions make the pet feel alive:act twice in a row; any other state cancels it, and the overlay's frametimer covers the wait, so idling costs nothing extra. A user upload is asingle sheet, so the store drops `acts` from an uploaded `pet.json`.+- **On the phone.** A pet may also draw its call states holding a handset:+ `"phone_sheet": "phone.png"` and `"phone": {"listening": {...},+ "thinking": {...}, "talking": {...}}` (only the `CALL_STATES`, rows of+ their own sheet). During a voice conversation the renderer shows those+ rows instead of the plain ones; a call state without its own phone row+ borrows the `listening` one. Uploads drop `phone` like `acts`.Rules the loader enforces (`jarvis/ui/pets/manifest.py`):diff --git a/jarvis/ui/pets/builtin/bolt/pet.json b/jarvis/ui/pets/builtin/bolt/pet.jsonindex b5b87fbb6e..00fd38778c 100644--- a/jarvis/ui/pets/builtin/bolt/pet.json+++ b/jarvis/ui/pets/builtin/bolt/pet.json@@ -107,5 +107,26 @@"fps": 8,"loop": false}+ },+ "phone_sheet": "phone.png",+ "phone": {+ "listening": {+ "row": 0,+ "frames": 6,+ "fps": 8,+ "loop": true+ },+ "thinking": {+ "row": 1,+ "frames": 8,+ "fps": 8,+ "loop": true+ },+ "talking": {+ "row": 2,+ "frames": 4,+ "fps": 10,+ "loop": true+ }}}diff --git a/jarvis/ui/pets/builtin/bolt/phone.png b/jarvis/ui/pets/builtin/bolt/phone.pngnew file mode 100644index 0000000000..2222115d72Binary files /dev/null and b/jarvis/ui/pets/builtin/bolt/phone.png differdiff --git a/jarvis/ui/pets/builtin/brew/pet.json b/jarvis/ui/pets/builtin/brew/pet.jsonindex 527b2732ba..a1a4a3ddc3 100644--- a/jarvis/ui/pets/builtin/brew/pet.json+++ b/jarvis/ui/pets/builtin/brew/pet.json@@ -101,5 +101,26 @@"fps": 10,"loop": false}+ },+ "phone_sheet": "phone.png",+ "phone": {+ "listening": {+ "row": 0,+ "frames": 6,+ "fps": 8,+ "loop": true+ },+ "thinking": {+ "row": 1,+ "frames": 8,+ "fps": 8,+ "loop": true+ },+ "talking": {+ "row": 2,+ "frames": 4,+ "fps": 10,+ "loop": true+ }}}diff --git a/jarvis/ui/pets/builtin/brew/phone.png b/jarvis/ui/pets/builtin/brew/phone.pngnew file mode 100644index 0000000000..9451f0775bBinary files /dev/null and b/jarvis/ui/pets/builtin/brew/phone.png differdiff --git a/jarvis/ui/pets/builtin/ember/pet.json b/jarvis/ui/pets/builtin/ember/pet.jsonindex e9a5ffc42e..79124e825f 100644--- a/jarvis/ui/pets/builtin/ember/pet.json+++ b/jarvis/ui/pets/builtin/ember/pet.json@@ -107,5 +107,26 @@"fps": 8,"loop": false}+ },+ "phone_sheet": "phone.png",+ "phone": {+ "listening": {+ "row": 0,+ "frames": 6,+ "fps": 8,+ "loop": true+ },+ "thinking": {+ "row": 1,+ "frames": 8,+ "fps": 8,+ "loop": true+ },+ "talking": {+ "row": 2,+ "frames": 4,+ "fps": 10,+ "loop": true+ }}}diff --git a/jarvis/ui/pets/builtin/ember/phone.png b/jarvis/ui/pets/builtin/ember/phone.pngnew file mode 100644index 0000000000..c18221d1f4Binary files /dev/null and b/jarvis/ui/pets/builtin/ember/phone.png differdiff --git a/jarvis/ui/pets/builtin/gigi/pet.json b/jarvis/ui/pets/builtin/gigi/pet.jsonindex b503410744..eafef04b2a 100644--- a/jarvis/ui/pets/builtin/gigi/pet.json+++ b/jarvis/ui/pets/builtin/gigi/pet.json@@ -107,5 +107,26 @@"fps": 7,"loop": false}+ },+ "phone_sheet": "phone.png",+ "phone": {+ "listening": {+ "row": 0,+ "frames": 6,+ "fps": 8,+ "loop": true+ },+ "thinking": {+ "row": 1,+ "frames": 8,+ "fps": 8,+ "loop": true+ },+ "talking": {+ "row": 2,+ "frames": 4,+ "fps": 10,+ "loop": true+ }}}diff --git a/jarvis/ui/pets/builtin/gigi/phone.png b/jarvis/ui/pets/builtin/gigi/phone.pngnew file mode 100644index 0000000000..16a1fd34b5Binary files /dev/null and b/jarvis/ui/pets/builtin/gigi/phone.png differdiff --git a/jarvis/ui/pets/builtin/miso/pet.json b/jarvis/ui/pets/builtin/miso/pet.jsonindex f8095f3fb1..0bf79e1e91 100644--- a/jarvis/ui/pets/builtin/miso/pet.json+++ b/jarvis/ui/pets/builtin/miso/pet.json@@ -107,5 +107,26 @@"fps": 8,"loop": false}+ },+ "phone_sheet": "phone.png",+ "phone": {+ "listening": {+ "row": 0,+ "frames": 6,+ "fps": 8,+ "loop": true+ },+ "thinking": {+ "row": 1,+ "frames": 8,+ "fps": 8,+ "loop": true+ },+ "talking": {+ "row": 2,+ "frames": 4,+ "fps": 10,+ "loop": true+ }}}diff --git a/jarvis/ui/pets/builtin/miso/phone.png b/jarvis/ui/pets/builtin/miso/phone.pngnew file mode 100644index 0000000000..d0e75dd119Binary files /dev/null and b/jarvis/ui/pets/builtin/miso/phone.png differdiff --git a/jarvis/ui/pets/builtin/mochi/pet.json b/jarvis/ui/pets/builtin/mochi/pet.jsonindex 88bab2707c..eb7c3f9975 100644--- a/jarvis/ui/pets/builtin/mochi/pet.json+++ b/jarvis/ui/pets/builtin/mochi/pet.json@@ -107,5 +107,26 @@"fps": 8,"loop": false}+ },+ "phone_sheet": "phone.png",+ "phone": {+ "listening": {+ "row": 0,+ "frames": 6,+ "fps": 8,+ "loop": true+ },+ "thinking": {+ "row": 1,+ "frames": 8,+ "fps": 8,+ "loop": true+ },+ "talking": {+ "row": 2,+ "frames": 4,+ "fps": 10,+ "loop": true+ }}}diff --git a/jarvis/ui/pets/builtin/mochi/phone.png b/jarvis/ui/pets/builtin/mochi/phone.pngnew file mode 100644index 0000000000..d8b71c1fdfBinary files /dev/null and b/jarvis/ui/pets/builtin/mochi/phone.png differdiff --git a/jarvis/ui/pets/builtin/shelly/pet.json b/jarvis/ui/pets/builtin/shelly/pet.jsonindex 9cf702bb3a..97af9055fb 100644--- a/jarvis/ui/pets/builtin/shelly/pet.json+++ b/jarvis/ui/pets/builtin/shelly/pet.json@@ -107,5 +107,26 @@"fps": 8,"loop": false}+ },+ "phone_sheet": "phone.png",+ "phone": {+ "listening": {+ "row": 0,+ "frames": 6,+ "fps": 8,+ "loop": true+ },+ "thinking": {+ "row": 1,+ "frames": 8,+ "fps": 8,+ "loop": true+ },+ "talking": {+ "row": 2,+ "frames": 4,+ "fps": 10,+ "loop": true+ }}}diff --git a/jarvis/ui/pets/builtin/shelly/phone.png b/jarvis/ui/pets/builtin/shelly/phone.pngnew file mode 100644index 0000000000..fc88976070Binary files /dev/null and b/jarvis/ui/pets/builtin/shelly/phone.png differdiff --git a/jarvis/ui/pets/loader.py b/jarvis/ui/pets/loader.pyindex ba0cc4aaf6..021ae0f553 100644--- a/jarvis/ui/pets/loader.py+++ b/jarvis/ui/pets/loader.py@@ -28,6 +28,7 @@ from jarvis.ui.pets.manifest import (PetManifestError,check_act_cells,check_cells,+ check_phone_cells,check_sheet_size,parse_manifest,)@@ -62,6 +63,10 @@ class PetPack:acts: Mapping[str, tuple[Image.Image, ...]] = field(default_factory=lambda: MappingProxyType({}))+ #: Decoded on-the-phone rows by call state (empty when the pet has none).+ phone: Mapping[str, tuple[Image.Image, ...]] = field(+ default_factory=lambda: MappingProxyType({})+ )def builtin_root() -> Path:@@ -123,6 +128,10 @@ def read_manifest(pet_dir: Path, *, builtin: bool) -> PetManifest:check_cells(manifest, *_probe_png(pet_dir / manifest.sheet, manifest.sheet))if manifest.acts and manifest.acts_sheet is not None:check_act_cells(manifest, *_probe_png(pet_dir / manifest.acts_sheet, manifest.acts_sheet))+ if manifest.phone and manifest.phone_sheet is not None:+ check_phone_cells(+ manifest, *_probe_png(pet_dir / manifest.phone_sheet, manifest.phone_sheet)+ )return manifest@@ -186,11 +195,21 @@ def load_pet(pet_dir: Path, *, builtin: bool) -> PetPack:acts_sheet.crop((col * size, top, (col + 1) * size, top + size))for col in range(spec.frames))+ phone: dict[str, tuple[Image.Image, ...]] = {}+ if manifest.phone and manifest.phone_sheet is not None:+ phone_sheet = _decode(pet_dir / manifest.phone_sheet)+ for state, spec in manifest.phone.items():+ top = spec.row * size+ phone[state] = tuple(+ phone_sheet.crop((col * size, top, (col + 1) * size, top + size))+ for col in range(spec.frames)+ )return PetPack(manifest=manifest,directory=pet_dir,frames=MappingProxyType(frames),acts=MappingProxyType(acts),+ phone=MappingProxyType(phone),)diff --git a/jarvis/ui/pets/manifest.py b/jarvis/ui/pets/manifest.pyindex 7852481779..7c0cab98e4 100644--- a/jarvis/ui/pets/manifest.py+++ b/jarvis/ui/pets/manifest.py@@ -19,6 +19,7 @@ from dataclasses import dataclass, fieldfrom types import MappingProxyTypefrom jarvis.ui.pets.states import (+ CALL_STATES,FRAME_SIZES,MAX_FRAMES_PER_STATE,NO_PET_ID,@@ -100,6 +101,11 @@ class PetManifest:#: ``acts_sheet``. Optional; without them the pet just idles.acts: Mapping[str, AnimationSpec] = field(default_factory=lambda: MappingProxyType({}))acts_sheet: str | None = None+ #: The pet on the phone: rows for the ``CALL_STATES`` in ``phone_sheet``,+ #: shown instead of the plain rows while a voice conversation runs.+ #: Optional; without them the pet just listens and talks as usual.+ phone: Mapping[str, AnimationSpec] = field(default_factory=lambda: MappingProxyType({}))+ phone_sheet: str | None = Nonedef spec_for(self, state: str) -> tuple[str, AnimationSpec]:"""Return ``(resolved_state, spec)`` for ``state``.@@ -138,6 +144,13 @@ class PetManifest:if self.acts and self.acts_sheet is not None:out["acts_sheet"] = self.acts_sheetout["acts"] = {name: spec_json(spec) for name, spec in self.acts.items()}+ if self.phone and self.phone_sheet is not None:+ out["phone_sheet"] = self.phone_sheet+ out["phone"] = {+ state: spec_json(spec)+ for state in CALL_STATES+ if (spec := self.phone.get(state)) is not None+ }return out@@ -266,6 +279,7 @@ def parse_manifest(data: object, *, builtin: bool) -> PetManifest:}acts, acts_sheet = _parse_acts(data, sheet)+ phone, phone_sheet = _parse_phone(data, sheet, acts_sheet)return PetManifest(id=pet_id,@@ -277,6 +291,8 @@ def parse_manifest(data: object, *, builtin: bool) -> PetManifest:builtin=builtin,acts=MappingProxyType(acts),acts_sheet=acts_sheet,+ phone=MappingProxyType(phone),+ phone_sheet=phone_sheet,)@@ -312,6 +328,34 @@ def _parse_acts(data: Mapping, sheet: str) -> tuple[dict[str, AnimationSpec], streturn acts, acts_sheet+def _parse_phone(+ data: Mapping, sheet: str, acts_sheet: str | None+) -> tuple[dict[str, AnimationSpec], str | None]:+ """The optional on-the-phone rows and their sheet; both keys or neither."""+ raw_phone = data.get("phone")+ phone_sheet = data.get("phone_sheet")+ if raw_phone is None and phone_sheet is None:+ return {}, None+ if not isinstance(raw_phone, Mapping) or not raw_phone:+ raise PetManifestError("'phone' must be an object with at least one state.")+ if (+ not isinstance(phone_sheet, str)+ or not _SHEET_NAME_RE.match(phone_sheet)+ or ".." in phone_sheet+ or phone_sheet in (sheet, acts_sheet)+ ):+ raise PetManifestError("'phone_sheet' must be its own PNG file name inside the pet folder.")+ unknown = sorted(str(key) for key in raw_phone if key not in CALL_STATES)+ if unknown:+ raise PetManifestError(f"'{unknown[0]}' has no phone row; use one of the call states.")+ phone = {+ state: _parse_animation(f"phone {state}", raw_phone[state])+ for state in CALL_STATES+ if state in raw_phone+ }+ return phone, phone_sheet++def check_sheet_size(width: int, height: int) -> None:"""Reject a sheet larger than ``MAX_SHEET_EDGE`` on either side."""if width < 1 or height < 1:@@ -338,3 +382,12 @@ def check_act_cells(manifest: PetManifest, width: int, height: int) -> None:for name, spec in manifest.acts.items():if (spec.row + 1) * size > height or spec.frames * size > width:raise PetManifestError(f"Act '{name}' reaches outside the acts sheet.")+++def check_phone_cells(manifest: PetManifest, width: int, height: int) -> None:+ """Reject phone rows that reach outside a ``width x height`` phone sheet."""+ check_sheet_size(width, height)+ size = manifest.frame_size+ for state, spec in manifest.phone.items():+ if (spec.row + 1) * size > height or spec.frames * size > width:+ raise PetManifestError(f"Phone row '{state}' reaches outside the phone sheet.")diff --git a/jarvis/ui/pets/states.py b/jarvis/ui/pets/states.pyindex 5790d35af7..2a67cda2a0 100644--- a/jarvis/ui/pets/states.py+++ b/jarvis/ui/pets/states.py@@ -18,6 +18,7 @@ Adding a state = add it here (at the END, so existing sheets keep their rows),give it a fallback, teach the state machine when it applies, and add the labelto every locale. Nothing else needs touching."""+from __future__ import annotations#: Every animation state a pet can show, in sprite-sheet row order.@@ -67,6 +68,12 @@ STATE_FALLBACKS: dict[str, str] = {"held": "listening",}+#: States a pet may also draw "on the phone" (``phone`` rows in ``pet.json``):+#: the three a voice conversation runs through. While a call is live the+#: renderer shows these rows instead of the plain ones; a pet without them+#: simply keeps its plain rows.+CALL_STATES: tuple[str, ...] = ("listening", "thinking", "talking")+#: The pet id that shows the control strip with no figure ("None" in the UI).NO_PET_ID: str = "none"diff --git a/jarvis/ui/pets/store.py b/jarvis/ui/pets/store.pyindex 3f24a42bd6..21f31d9a1f 100644--- a/jarvis/ui/pets/store.py+++ b/jarvis/ui/pets/store.py@@ -121,10 +121,10 @@ class PetStore:data: dict = {}if manifest_json is not None and manifest_json.strip():data = _manifest_data(manifest_json)- # An upload is ONE sheet: idle acts would point at a file that- # never arrives, so they are dropped rather than rejected.- data.pop("acts", None)- data.pop("acts_sheet", None)+ # An upload is ONE sheet: idle acts and phone rows would point+ # at a file that never arrives, so they are dropped, not rejected.+ for key in ("acts", "acts_sheet", "phone", "phone_sheet"):+ data.pop(key, None)if frame_size is None and "frame_size" in data:frame_size = data["frame_size"]size = _pick_frame_size(width, height, frame_size)diff --git a/scripts/pets/build_pets.py b/scripts/pets/build_pets.pyindex 9dbd9a12cb..89a761d5ce 100644--- a/scripts/pets/build_pets.py+++ b/scripts/pets/build_pets.py@@ -41,6 +41,7 @@ sys.path.insert(0, str(REPO_ROOT))from PIL import Image # noqa: E402from jarvis.ui.pets.states import ( # noqa: E402+ CALL_STATES,MAX_FRAMES_PER_STATE,ONE_SHOT_STATES,PET_FORMAT,@@ -356,6 +357,9 @@ class Pose:#: The idle act this frame belongs to (``""`` outside acts); ``state`` is#: then ``"idle"`` so a pet's ordinary idle drawing still applies.act: str = ""+ #: The pet is on the phone (a ``phone`` row): its ``PhoneRig`` limb holds+ #: the handset, so the pet's own drawing leaves that limb out.+ phone: bool = Falsedef base_pose(state: str, i: int) -> Pose:@@ -696,6 +700,108 @@ def fx_held(f: Frame, i: int, left: Px, right: Px) -> None:f.paint(line(right[0] - 2, right[1] - 6, right[0], right[1] - 8), ARC)+# ---------------------------------------------------------------------------+# On the phone: a corded handset every pet holds to its head during a call.+# ---------------------------------------------------------------------------++PHONE_BODY = hexc("#f1ebdf")+PHONE_SHADE = hexc("#c4b8a4")+PHONE_GRILL = hexc("#6e6355")++#: The handset's two cups (earpiece, mouthpiece) and the bar between them.+#: Seen from the front, a handset held to the head is a "bone": two round+#: ends joined by a thick bar, lying diagonally across the cheek.+HANDSET_CUP = (3.1, 2.7)+#: Where a paw grips the bar: this share of the way from ear to mouth.+HANDSET_GRIP_T = 0.55+#: The coiled cord's sideways sway per frame, so it hangs and swings a little.+_CORD_SWAY = (0, 0, 1, 1, 0, 0, -1, -1)+++def handset_mask(ear: tuple[float, float], mouth: tuple[float, float]) -> tuple[Mask, Mask]:+ """(cups, bar): the two round ends and the thick bar joining them."""+ cups = ellipse(ear[0], ear[1], *HANDSET_CUP) | ellipse(mouth[0], mouth[1], *HANDSET_CUP)+ bar = thick(shifted(thick(line(int(ear[0]), int(ear[1]), int(mouth[0]), int(mouth[1]))), -1, 0))+ return cups, bar+++def draw_handset(f: Frame, ear: tuple[float, float], mouth: tuple[float, float]) -> None:+ cups, bar = handset_mask(ear, mouth)+ body = cups | bar+ colors = shade(body, PHONE_BODY, light=FX_WHITE, dark=PHONE_SHADE, dark_depth=1)+ f.part(body, colors)+++def handset_grip(ear: tuple[float, float], mouth: tuple[float, float]) -> Px:+ t = HANDSET_GRIP_T+ return (round(ear[0] + (mouth[0] - ear[0]) * t), round(ear[1] + (mouth[1] - ear[1]) * t))+++def draw_cord(f: Frame, start: Px, end: Px, i: int) -> None:+ """A coiled cord sagging from the mouthpiece down to ``end``.++ Two pixels wide with alternating light and shaded cells inside a dark+ outline: at this size that zigzag is what reads as a coil.+ """+ (x0, y0), (x1, y1) = start, end+ sway = _CORD_SWAY[i % len(_CORD_SWAY)]+ # A quadratic sag: straight down first, then over to ``end``.+ cx, cy = x0 + sway, y1+ cells: dict[Px, RGBA] = {}+ steps = max(abs(x1 - x0), abs(y1 - y0)) * 2 + 2+ for k in range(steps + 1):+ t = k / steps+ x = round((1 - t) ** 2 * x0 + 2 * (1 - t) * t * cx + t * t * x1)+ y = round((1 - t) ** 2 * y0 + 2 * (1 - t) * t * cy + t * t * y1)+ for dx in (0, 1):+ cells[(x + dx, y)] = PHONE_BODY if (x + dx + y) % 2 == 0 else PHONE_SHADE+ f.paint(outer_ring(set(cells)), OUTLINE)+ f.paint_map(cells)+++@dataclass(frozen=True)+class PhoneRig:+ """How one pet holds the handset during a call (``Pose.phone``).++ ``ear`` and ``mouth`` are the centres of the earpiece and mouthpiece cups+ in cell coordinates before the pose offset: the earpiece at the side of+ the head, the mouthpiece over the cheek towards the mouth. ``hold`` draws+ the limb that grips the bar — an arm, a paw, a pseudopod, a handle —+ from the body to the grip it is given, on top of the handset. The coiled+ cord sags from the mouthpiece to ``cord_end``.+ """++ ear: tuple[float, float]+ mouth: tuple[float, float]+ hold: Callable[[Frame, Pose, Px], None]+ cord_end: Px = (40, 44)+++def draw_phone(f: Frame, pose: Pose, rig: PhoneRig) -> None:+ """The cord, the handset, then the limb over its grip."""+ with f.offset(pose.dx, pose.dy):+ mouth = (round(rig.mouth[0]), round(rig.mouth[1] + HANDSET_CUP[1]))+ end = (rig.cord_end[0], rig.cord_end[1] - pose.dy)+ draw_cord(f, mouth, end, pose.i)+ draw_handset(f, rig.ear, rig.mouth)+ rig.hold(f, pose, handset_grip(rig.ear, rig.mouth))+++def paw_hold(+ shoulder: Px, fill: RGBA, light: RGBA, dark: RGBA, *, paw: tuple[float, float] = (2.2, 2.0)+) -> Callable[[Frame, Pose, Px], None]:+ """A round paw on the grip with a stubby arm back to ``shoulder``."""++ def hold(f: Frame, pose: Pose, grip: Px) -> None:+ gx, gy = grip+ arm = thick(line(shoulder[0], shoulder[1], gx, gy + 1))+ ball = ellipse(gx + 0.5, gy + 0.5, *paw)+ limb = arm | ball+ f.part(limb, shade(limb, fill, light=light, dark=dark, dark_depth=1))++ return hold++@dataclass(frozen=True)class Anchors:"""Where a pet's effects go (cell coordinates, before the pose offset)."""@@ -789,6 +895,9 @@ class PetDesign:#: Idle acts: little one-shot scenes the pet plays now and then while#: nothing happens (``docs/pets.md``). Written to their own ``acts.png``.acts: tuple[IdleAct, ...] = ()+ #: How the pet holds a phone during a call; its ``phone.png`` rows are+ #: the ``CALL_STATES`` drawn with it. ``None`` = no phone rows.+ phone: PhoneRig | None = Nonedef counts(self) -> Mapping[str, int]:return {**FRAME_COUNTS, **(self.frame_counts or {})}@@ -894,6 +1003,10 @@ _GIGI_TYPE = (def _gigi_arms(pose: Pose) -> tuple[Mask, Mask]:"""The left and the right arm for this pose."""+ if pose.phone:+ # The right arm holds the handset (``_gigi_phone_arm``).+ left, _right = _gigi_arms(replace(pose, phone=False))+ return left, set()if pose.act:left, right = _GIGI_ACT_ARMS[pose.act][pose.i]return set(_GIGI_ARMS[left]), mirrored(_GIGI_ARMS[right])@@ -1501,6 +1614,17 @@ def gigi_post(img: Image.Image, pose: Pose) -> Image.Image:return img+def _gigi_phone_arm(f: Frame, pose: Pose, grip: Px) -> None:+ """Gigi's thin white arm, raised from the band to a hand on the grip."""+ gx, gy = grip+ arm = polyline([(37, 26), (38, 26), (39, 25), (gx + 1, gy + 2)])+ hand = ellipse(gx + 0.5, gy + 0.5, 1.6, 1.6)+ f.paint(outer_ring(arm | hand), OUTLINE)+ f.paint(arm | hand, GIGI_WHITE)+++GIGI_PHONE = PhoneRig(ear=(39.0, 13.0), mouth=(33.0, 25.5), hold=_gigi_phone_arm)+GIGI_ANCHORS = Anchors(arcs_left=(9, 16),arcs_right=(38, 16),@@ -1531,6 +1655,7 @@ GIGI = PetDesign("held": _gigi_held_fx,},acts=GIGI_ACTS,+ phone=GIGI_PHONE,)@@ -1763,10 +1888,12 @@ def _draw_miso_sitting(f: Frame, pose: Pose) -> None:f.paint(ellipse(CX, 38, 5, 4), MISO_CREAM)paws_up = state == "success" and pose.dy <= -4if state == "thinking":- _miso_paw(f, 28.5, 43) # the other paw is at the chin+ if not pose.phone: # on the phone that paw holds the handset+ _miso_paw(f, 28.5, 43) # the other paw is at the chinelif state != "working" and not paws_up:_miso_paw(f, 19.5, 43)- _miso_paw(f, 28.5, 43)+ if not pose.phone:+ _miso_paw(f, 28.5, 43)ears = ("rest", "rest")whiskers = 0if state == "listening":@@ -2455,6 +2582,17 @@ _MISO_ACT_BODIES: dict[str, Callable[[Frame, Pose], None]] = {}+def _miso_phone_paw(f: Frame, pose: Pose, grip: Px) -> None:+ """Miso's right front leg, raised from the chest to the handset."""+ gx, gy = grip+ arm = thick(line(30, 35, gx, gy + 2))+ _miso_fur(f, arm, 1)+ _miso_paw(f, gx + 0.5, gy + 0.5)+++MISO_PHONE = PhoneRig(ear=(40.5, 18.0), mouth=(34.5, 28.5), hold=_miso_phone_paw)++MISO_ANCHORS = Anchors(arcs_left=(10, 18),arcs_right=(37, 18),@@ -2482,6 +2620,7 @@ MISO = PetDesign("held": _miso_held_fx,},acts=MISO_ACTS,+ phone=MISO_PHONE,)@@ -3145,6 +3284,21 @@ BREW_ACTS = ()+def _brew_phone_handle(f: Frame, pose: Pose, grip: Px) -> None:+ """No arms: the bar runs through the handle, whose outer half is drawn+ again in front of it, so the teapot cradles the handset in its loop."""+ _ = grip+ base, light, dark = BREW_GLAZE+ ring = ellipse(9, 31, 6, 6) - ellipse(9, 31, 3, 3)+ front = {p for p in ring if p[0] <= 6}+ f.part(front, _shade(front, base, light, dark, 1))+++BREW_PHONE = PhoneRig(+ ear=(5.0, 23.5), mouth=(13.0, 35.0), hold=_brew_phone_handle, cord_end=(5, 45)+)++BREW_ANCHORS = Anchors(arcs_left=(11, 17),arcs_right=(32, 17),@@ -3176,6 +3330,7 @@ BREW = PetDesign("held": brew_held,},waist=39,+ phone=BREW_PHONE,)@@ -3325,6 +3480,9 @@ def _bolt_arms(pose: Pose) -> tuple[Mask | None, Mask | None]:"""The left and the right arm (``None``: drawn by the state's effect)."""if pose.act:return _bolt_act_arms(pose)+ if pose.phone:+ # The right arm holds the handset (``_bolt_phone_arm``).+ return _bolt_arms(replace(pose, phone=False))[0], Nonerest, up, swing = _BOLT_ARM_REST, _BOLT_ARM_UP, _BOLT_ARM_SWINGs, i = pose.state, pose.iif s == "success":@@ -4068,6 +4226,16 @@ BOLT_ACTS = ()+def _bolt_phone_arm(f: Frame, pose: Pose, grip: Px) -> None:+ """Bolt's right metal arm, bent up from the case to the handset."""+ gx, gy = grip+ arm = thick(line(38, 26, gx, gy + 2)) | ellipse(gx + 0.5, gy + 0.5, 2.0, 2.0)+ f.part(arm, _shade(arm, BOLT_METAL, FX_WHITE, BOLT_METAL_DARK, 1))+++BOLT_PHONE = PhoneRig(ear=(41.5, 12.5), mouth=(35.5, 22.5), hold=_bolt_phone_arm)++BOLT_ANCHORS = Anchors(arcs_left=(12, 15),arcs_right=(35, 15),@@ -4100,6 +4268,7 @@ BOLT = PetDesign("held": bolt_held,},acts=BOLT_ACTS,+ phone=BOLT_PHONE,)@@ -4497,6 +4666,16 @@ def mochi_held(f: Frame, pose: Pose) -> None:f.paint({(20, top + 1), (19, top), (28, top + 1), (29, top)}, ARC)+def _mochi_phone_nub(f: Frame, pose: Pose, grip: Px) -> None:+ """No arms either: Mochi pulls a soft nub out of its body to hold it."""+ paw_hold((37, 38), MOCHI_BASE, MOCHI_LIGHT, MOCHI_DARK, paw=(2.4, 2.2))(f, pose, grip)+++MOCHI_PHONE = PhoneRig(+ ear=(41.5, 25.5), mouth=(35.5, 35.5), hold=_mochi_phone_nub, cord_end=(42, 45)+)++MOCHI_ANCHORS = Anchors(arcs_left=(8, 24),arcs_right=(39, 17),@@ -4949,6 +5128,7 @@ MOCHI = PetDesign("held": mochi_held,},acts=MOCHI_ACTS,+ phone=MOCHI_PHONE,)@@ -5696,6 +5876,16 @@ SHELLY_ACTS: tuple[IdleAct, ...] = ()+def _shelly_phone_foot(f: Frame, pose: Pose, grip: Px) -> None:+ """A snail has only its foot: a soft fold of it curls up to the handset."""+ paw_hold((12, 40), SHELLY_BODY, SHELLY_BODY_LIGHT, SHELLY_BODY_DARK)(f, pose, grip)+++SHELLY_PHONE = PhoneRig(+ ear=(5.0, 26.0), mouth=(10.0, 37.0), hold=_shelly_phone_foot, cord_end=(3, 45)+)++SHELLY = PetDesign(id="shelly",name="Shelly",@@ -5723,6 +5913,7 @@ SHELLY = PetDesign("held": _shelly_held_fx,},acts=SHELLY_ACTS,+ phone=SHELLY_PHONE,)@@ -6095,6 +6286,9 @@ def _ember_tail_for(pose: Pose) -> tuple[int, int]:def _ember_arms(pose: Pose) -> tuple[tuple[Px, Px], ...]:"""(shoulder, claw) of each arm of the sitting dragon."""+ if pose.phone:+ # The right arm holds the handset (``_ember_phone_arm``).+ return _ember_arms(replace(pose, phone=False))[:1]state, i = pose.state, pose.irest = (((16, 32), (14, 37)), ((31, 32), (33, 37)))if state == "thinking":@@ -6153,7 +6347,7 @@ def _draw_ember_sitting(f: Frame, pose: Pose) -> None:cap = (0, 1, 1, 0, 1, 1, 0, 0)[i % 8] # the cap jiggles on the hopwith f.offset(tilt, 0):_ember_head(f, pose, fins, cap=cap, soot=state == "error" and i >= 3)- if state == "thinking":+ if state == "thinking" and not pose.phone:# The tapping claw sits in front of the chin.tap = 1 if i % 4 in (1, 2) else 0_ember_hand(f, 29, 28 + tap)@@ -7056,6 +7250,14 @@ EMBER_ACTS = ()+def _ember_phone_arm(f: Frame, pose: Pose, grip: Px) -> None:+ """Ember's right arm, raised from the shoulder to a claw on the handset."""+ _ember_arm(f, (31, 32), grip)+++EMBER_PHONE = PhoneRig(ear=(39.0, 16.0), mouth=(33.0, 27.5), hold=_ember_phone_arm)++EMBER = PetDesign(id="ember",name="Ember",@@ -7084,6 +7286,7 @@ EMBER = PetDesign("held": _ember_held_fx,},acts=EMBER_ACTS,+ phone=EMBER_PHONE,)@@ -7154,6 +7357,43 @@ def render_frame(pet: PetDesign, state: str, i: int) -> Image.Image:return image+def render_phone_frame(pet: PetDesign, state: str, i: int) -> Image.Image:+ """Frame ``i`` of ``state`` with the pet on the phone.++ The pet's own pose and drawing (minus the limb its rig uses), the+ handset with its cord and the holding limb on top. Listening and talking+ drop the shared effect: the phone at the ear already says "in a call",+ and sound arcs would run into the handset. Thinking keeps its own.+ """+ assert pet.phone is not None # noqa: S101 — callers check+ pose = replace(pet.pose(state, i), phone=True)+ body = Frame()+ pet.draw(body, pose)+ draw_phone(body, pose, pet.phone)+ image = breathe(body.image(), pose.stretch, pet.waist + pose.dy)+ if pet.post is not None:+ image = pet.post(image, pose)+ if state == "thinking":+ fx = Frame()+ own = pet.fx.get(state)+ if own is not None:+ own(fx, pose)+ else:+ draw_effects(fx, pose, pet.anchors)+ image.alpha_composite(fx.image())+ return image+++def build_phone_sheet(pet: PetDesign) -> Image.Image:+ """One row per call state (``CALL_STATES`` order), the pet on the phone."""+ counts = pet.counts()+ sheet = Image.new("RGBA", (CELL * MAX_FRAMES_PER_STATE, CELL * len(CALL_STATES)), (0, 0, 0, 0))+ for row, state in enumerate(CALL_STATES):+ for i in range(counts[state]):+ sheet.paste(render_phone_frame(pet, state, i), (i * CELL, row * CELL))+ return sheet++def build_sheet(pet: PetDesign) -> Image.Image:sheet = Image.new("RGBA", (CELL * MAX_FRAMES_PER_STATE, CELL * len(PET_STATES)), (0, 0, 0, 0))counts = pet.counts()@@ -7165,6 +7405,8 @@ def build_sheet(pet: PetDesign) -> Image.Image:#: File name of a pet's idle-act sheet.ACTS_SHEET = "acts.png"+#: File name of a pet's on-the-phone sheet.+PHONE_SHEET = "phone.png"def build_manifest(pet: PetDesign) -> dict:@@ -7187,6 +7429,12 @@ def build_manifest(pet: PetDesign) -> dict:act.name: {"row": row, "frames": act.frames, "fps": act.fps, "loop": False}for row, act in enumerate(pet.acts)}+ if pet.phone is not None:+ manifest["phone_sheet"] = PHONE_SHEET+ manifest["phone"] = {+ state: {**_animation(state, row, counts, fps), "row": row}+ for row, state in enumerate(CALL_STATES)+ }return manifest@@ -7262,6 +7510,9 @@ def build_all(out_dir: Path) -> list[Path]:if pet.acts:save_png(build_acts_sheet(pet), folder / ACTS_SHEET)written.append(folder / ACTS_SHEET)+ if pet.phone is not None:+ save_png(build_phone_sheet(pet), folder / PHONE_SHEET)+ written.append(folder / PHONE_SHEET)folder = out_dir / "template"folder.mkdir(parents=True, exist_ok=True)sheet, manifest = build_template()diff --git a/tests/unit/ui/pets/test_builtin_pets.py b/tests/unit/ui/pets/test_builtin_pets.pyindex 2fa531cfe0..2d591e95aa 100644--- a/tests/unit/ui/pets/test_builtin_pets.py+++ b/tests/unit/ui/pets/test_builtin_pets.py@@ -12,7 +12,7 @@ import pytestfrom PIL import Imagefrom jarvis.ui.pets.loader import COLOR_KEY, builtin_root, list_pets, load_pet-from jarvis.ui.pets.states import DEFAULT_PET_ID, PET_STATES+from jarvis.ui.pets.states import CALL_STATES, DEFAULT_PET_ID, PET_STATESREPO_ROOT = Path(__file__).resolve().parents[4]BUILD_SCRIPT = REPO_ROOT / "scripts" / "pets" / "build_pets.py"@@ -89,10 +89,11 @@ def test_committed_pet_matches_the_generator(generated: Path, pet_id: str) -> Noassert (ours / "pet.json").read_text(encoding="utf-8") == (fresh / "pet.json").read_text(encoding="utf-8")- if (fresh / "acts.png").exists():- assert _pixels(ours / "acts.png") == _pixels(fresh / "acts.png"), (- f"{pet_id}: run `python scripts/pets/build_pets.py` and commit the result"- )+ for extra in ("acts.png", "phone.png"):+ if (fresh / extra).exists():+ assert _pixels(ours / extra) == _pixels(fresh / extra), (+ f"{pet_id}: run `python scripts/pets/build_pets.py` and commit the result"+ )def test_committed_template_matches_the_generator(generated: Path) -> None:@@ -136,3 +137,15 @@ def test_every_builtin_pet_has_idle_acts(pet_id: str) -> None:for frame in frames:assert frame.getchannel("A").getbbox() is not None, f"{name} has an empty frame"assert any(frame.tobytes() != idle for frame in frames), f"{name} never moves"++[email protected]("pet_id", EXPECTED_PETS)+def test_every_builtin_pet_can_hold_a_phone(pet_id: str) -> None:+ """In a call every built-in pet holds a handset (docs/pets.md, On the phone)."""+ pack = load_pet(builtin_root() / pet_id, builtin=True)+ assert set(pack.phone) == set(CALL_STATES)+ for state in CALL_STATES:+ plain, phone = pack.frames[state], pack.phone[state]+ assert len(phone) == len(plain) == pack.manifest.phone[state].frames+ for before, after in zip(plain, phone, strict=True):+ assert before.tobytes() != after.tobytes(), f"{state}: no handset drawn"diff --git a/tests/unit/ui/pets/test_manifest.py b/tests/unit/ui/pets/test_manifest.pyindex 02b3310190..a80baa1159 100644--- a/tests/unit/ui/pets/test_manifest.py+++ b/tests/unit/ui/pets/test_manifest.py@@ -13,6 +13,7 @@ from jarvis.ui.pets.manifest import (PetManifestError,check_act_cells,check_cells,+ check_phone_cells,check_sheet_size,parse_manifest,)@@ -266,3 +267,49 @@ def test_an_act_must_fit_its_sheet() -> None:check_act_cells(manifest, 48 * 5, 48 * 2)with pytest.raises(PetManifestError):check_act_cells(manifest, 48 * 6, 48)+++# --- On the phone ------------------------------------------------------------------+++def _phone(**overrides: object) -> dict:+ phone: dict = {+ "listening": {"row": 0, "frames": 6, "fps": 8, "loop": True},+ "talking": {"row": 2, "frames": 4, "fps": 10, "loop": True},+ }+ phone.update(overrides)+ return phone+++def test_phone_rows_are_optional_call_states_on_their_own_sheet() -> None:+ manifest = parse_manifest(_data(phone=_phone(), phone_sheet="phone.png"), builtin=True)+ assert list(manifest.phone) == ["listening", "talking"]+ assert manifest.phone_sheet == "phone.png"+ again = parse_manifest(manifest.to_json(), builtin=True)+ assert again.phone == manifest.phone and again.phone_sheet == "phone.png"+ plain = parse_manifest(_data(), builtin=True)+ assert not plain.phone and plain.phone_sheet is None+ assert "phone" not in plain.to_json()+++ "overrides",+ [+ {"phone": _phone()}, # no sheet+ {"phone_sheet": "phone.png"}, # no rows+ {"phone": {}, "phone_sheet": "phone.png"},+ {"phone": _phone(), "phone_sheet": "sheet.png"}, # the state sheet+ {"phone": _phone(), "phone_sheet": "../phone.png"},+ {"phone": {"sleeping": {"row": 0, "frames": 2, "fps": 3}}, "phone_sheet": "p.png"},+ ],+)+def test_broken_phone_rows_are_rejected(overrides: dict) -> None:+ with pytest.raises(PetManifestError):+ parse_manifest(_data(**overrides), builtin=True)+++def test_a_phone_row_must_fit_its_sheet() -> None:+ manifest = parse_manifest(_data(phone=_phone(), phone_sheet="phone.png"), builtin=True)+ check_phone_cells(manifest, 48 * 6, 48 * 3)+ with pytest.raises(PetManifestError):+ check_phone_cells(manifest, 48 * 6, 48 * 2)diff --git a/tests/unit/ui/test_pet_overlay_renderer.py b/tests/unit/ui/test_pet_overlay_renderer.pyindex 81da777f5a..e15ca528b6 100644--- a/tests/unit/ui/test_pet_overlay_renderer.py+++ b/tests/unit/ui/test_pet_overlay_renderer.py@@ -537,46 +537,22 @@ def test_a_pet_without_acts_just_idles() -> None:# --- on the phone -------------------------------------------------------------_KEY = (255, 0, 255)--def _keyed_figure(factor: int = 3) -> Image.Image:- """A 30 x 30 source-pixel window with a 16 x 24 figure in the middle."""- frame = Image.new("RGB", (30 * factor, 30 * factor), _KEY)- frame.paste((200, 60, 60), (7 * factor, 3 * factor, 23 * factor, 27 * factor))- return frame---def _phone_pixels(frame: Image.Image) -> int:- white = pr.PHONE_COLORS["W"]- return sum(1 for px in frame.getdata() if px[:3] == white)---def test_the_phone_is_held_at_the_side_of_the_head_inside_the_frame() -> None:- frame = _keyed_figure()- held = pr.with_phone(frame, 3, _KEY)- assert held.size == frame.size- assert _phone_pixels(frame) == 0 # the cached original is never painted on- box = Image.new("1", held.size)- box.putdata([px[:3] == pr.PHONE_COLORS["W"] for px in held.getdata()])- x0, y0, _x1, y1 = box.getbbox()- # Earpiece overlapping the figure's right edge (source x 22), in its top half.- assert 18 * 3 <= x0 <= 23 * 3- assert 3 * 3 <= y0 and y1 <= 27 * 3---def test_an_empty_frame_gets_no_phone() -> None:- blank = Image.new("RGB", (60, 60), _KEY)- assert pr.with_phone(blank, 2, _KEY) is blank---def test_a_voice_conversation_puts_the_phone_to_the_ear_and_ending_it_puts_it_away() -> None:+def test_a_voice_call_shows_the_pets_phone_rows_and_hanging_up_puts_them_away() -> None:renderer = pr.PetRenderer("gigi")- idle_key = renderer.frame_key()- assert _phone_pixels(renderer.render()) == 0renderer.on_mode("speak")- assert renderer.on_call and renderer.frame_key() != idle_key- assert _phone_pixels(renderer.render()) > 0+ renderer.on_mode("listen")+ assert renderer.on_call+ assert renderer.frame_key()[2] == "phone:listening"+ on_call = renderer.render()renderer.on_mode("idle")assert not renderer.on_call- assert _phone_pixels(renderer.render()) == 0+ assert not str(renderer.frame_key()[2]).startswith("phone:")+ assert renderer.render() is not on_call+++def test_a_pet_without_phone_rows_keeps_its_plain_rows_in_a_call() -> None:+ renderer = pr.PetRenderer("fake", loader=_Loader({"fake": _Pack()}))+ renderer.on_mode("listen")+ assert renderer.on_call+ assert renderer.frame_key()[2] == "listening"diff --git a/ui/orb/pet_renderer.py b/ui/orb/pet_renderer.pyindex 92a76f3343..baa49d59a4 100644--- a/ui/orb/pet_renderer.py+++ b/ui/orb/pet_renderer.py@@ -43,7 +43,7 @@ from typing import Anyfrom PIL import Image-from jarvis.ui.pets.states import NO_PET_ID+from jarvis.ui.pets.states import CALL_STATES, NO_PET_IDfrom ui.orb import controls as orb_controlslog = logging.getLogger("jarvis.orb")@@ -90,110 +90,13 @@ _ACT_KEY = "act:"_ColorKey = tuple[int, int, int]-#: The handset a pet holds to its ear while a voice conversation runs — the-#: figure's half of the strip's phone button. Pixel art in source pixels,-#: drawn at the pet's own factor so it matches every pack's pixel grid. The-#: open side (earpiece and mouthpiece) faces the pet; the spine is on the right.-#: ``O`` outline, ``B`` body, ``H`` highlight, ``.`` transparent.-PHONE_SPRITE: tuple[str, ...] = (- ".OOOOO.",- "OWWWHWO",- "OWWWWWO",- ".OOOWWO",- "....OWO",- "....OWO",- "....OHO",- "....OWO",- ".OOOWWO",- "OWWWWWO",- "OWWWHWO",- ".OOOOO.",-)-#: The strip's glyph white and its sky-blue accent inside a near-black-#: outline: light enough to read against a dark desktop and a dark pet alike.-PHONE_COLORS: dict[str, tuple[int, int, int]] = {- "O": (13, 17, 23),- "W": (232, 233, 238),- "H": (126, 186, 255),-}-#: Where the ear is looked for: a band of the figure's height, from the top.-PHONE_EAR_BAND = (0.22, 0.5)-#: The earpiece's top, as a share of the figure's height from its top.-PHONE_TOP = 0.2-#: How many source pixels of the earpiece overlap the side of the head.-PHONE_OVERLAP = 3+#: Frame-key prefix of an on-the-phone row (``pet.json`` ``phone``).+_PHONE_KEY = "phone:"#: Voice modes in which the pet is "on the phone" — the same set that turns#: the strip's phone button into hang-up.CALL_MODES: frozenset[str] = frozenset({"listen", "think", "speak"})-def _figure_rows(frame: Image.Image, factor: int, key: _ColorKey) -> list[list[bool]]:- """Which source pixels of a scaled, colour-keyed frame are painted."""- width, height = frame.size- f = max(1, int(factor))- px = frame.load()- half = f // 2- return [- [px[x * f + half, y * f + half][:3] != key for x in range(width // f)]- for y in range(height // f)- ]---def _head_edge(row: list[bool]) -> int | None:- """The head's right edge on one row: walk out from the centre column.-- Walking (and tolerating one-pixel gaps) instead of taking the rightmost- painted pixel keeps loose sparkles or floating marks beside a pet from- being mistaken for its ear.- """- x = len(row) // 2- if not any(row[max(0, x - 2) : x + 3]):- return None- edge = None- while x < len(row):- if row[x]:- edge = x- elif not (x + 1 < len(row) and row[x + 1]):- break- x += 1- return edge---def with_phone(frame: Image.Image, factor: int, key: _ColorKey) -> Image.Image:- """``frame`` with the handset held at the right side of the pet's head.-- The ear is the rightmost painted pixel in the head band of THIS frame, so- the phone follows a bobbing head. The prop is clamped inside the frame:- the window never grows for it, and nothing is drawn off-screen.- """- rows = _figure_rows(frame, factor, key)- painted = [y for y, row in enumerate(rows) if any(row)]- if not painted:- return frame- top, bottom = painted[0], painted[-1]- fig_h = bottom - top + 1- band = range(top + int(fig_h * PHONE_EAR_BAND[0]), top + max(1, int(fig_h * PHONE_EAR_BAND[1])))- ear = max((e for e in (_head_edge(rows[y]) for y in band) if e is not None), default=None)- if ear is None:- return frame- width_s = len(rows[0]) if rows else 0- sprite_w = len(PHONE_SPRITE[0])- x0 = min(ear + 1 - PHONE_OVERLAP, width_s - sprite_w)- y0 = min(top + int(fig_h * PHONE_TOP), len(rows) - len(PHONE_SPRITE))- if x0 < 0 or y0 < 0:- return frame- out = frame.copy()- f = max(1, int(factor))- for sy, line in enumerate(PHONE_SPRITE):- for sx, cell in enumerate(line):- color = PHONE_COLORS.get(cell)- if color is None:- continue- x, y = (x0 + sx) * f, (y0 + sy) * f- out.paste(color, (x, y, x + f, y + f))- return out--def dpi_ratio_for(points_per_inch: float | None, platform: str = sys.platform) -> float:"""The display scale factor from what Tk reports as one inch, in pixels.@@ -413,7 +316,6 @@ class PetRenderer:self._smoothed = 0.0#: A voice conversation runs: the pet holds the phone to its ear.self._on_call = False- self._phone_frames: dict[Hashable, Image.Image] = {}self.load(pet_id)# -- pack ------------------------------------------------------------@@ -449,7 +351,6 @@ class PetRenderer:def _rescale(self) -> None:self._frames = {}- self._phone_frames = {}self._act_names: tuple[str, ...] = ()self._act = Noneself._blank = None@@ -459,11 +360,14 @@ class PetRenderer:returnedge = int(pack.manifest.frame_size)acts: Mapping[str, Any] = getattr(pack, "acts", None) or {}+ # Phone rows join the crop too: the handset reaches past the head.+ phone: Mapping[str, Any] = getattr(pack, "phone", None) or {}# Act frames join the crop (a flame may reach past the idle figure)# and are scaled with the states, under a prefixed key.source: Mapping[str, Any] = {**pack.frames,**{_ACT_KEY + str(name): seq for name, seq in acts.items()},+ **{_PHONE_KEY + str(state): seq for state, seq in phone.items()},}try:crop, (idle_w, idle_h) = figure_crop(source, edge)@@ -623,6 +527,22 @@ class PetRenderer:elapsed = max(0.0, now - started)return _ACT_KEY + name, spec, frame_index(elapsed, spec.frames, spec.fps, False), elapsed+ def _phone_spec(self, state: str) -> tuple[str, Any] | None:+ """The on-the-phone row for ``state`` during a call, or ``None``.++ A pet with phone rows but none for this exact state borrows its+ ``listening`` phone row, so the handset never vanishes mid-call; a pet+ without phone rows (an uploaded one) keeps its plain rows.+ """+ if not self._on_call:+ return None+ phone = getattr(self._pack.manifest, "phone", None) or {}+ for name in (state, "listening"):+ spec = phone.get(name)+ if spec is not None and state in CALL_STATES and self._frames.get(_PHONE_KEY + name):+ return _PHONE_KEY + name, spec+ return None+def _current(self) -> tuple[str, Any, int, float, bool]:"""(resolved state, spec, frame index, elapsed seconds, level-driven) for now."""state = self.state()@@ -630,7 +550,7 @@ class PetRenderer:if act is not None:key, spec, index, elapsed = actreturn key, spec, index, elapsed, False- resolved, spec = self._pack.manifest.spec_for(state)+ resolved, spec = self._phone_spec(state) or self._pack.manifest.spec_for(state)resolved = str(resolved)sequence = self._frames.get(resolved) or self._frames.get(state) or ()frames = len(sequence) or max(1, int(getattr(spec, "frames", 1)))@@ -655,7 +575,7 @@ class PetRenderer:if self._pack is None:return ("none", self._size)resolved, _spec, index, _elapsed, _driven = self._current()- return (self._pet_id, self._factor, resolved, index, self._on_call)+ return (self._pet_id, self._factor, resolved, index)def next_frame_delay_ms(self, t: float = 0.0) -> int:"""How long the overlay may sleep before the next repaint is due."""@@ -701,12 +621,4 @@ class PetRenderer:if self._blank is None:self._blank = Image.new("RGB", self._size, self._color_key)return self._blank- frame = sequence[min(index, len(sequence) - 1)]- if not self._on_call:- return frame- cache_key = (resolved, min(index, len(sequence) - 1))- held = self._phone_frames.get(cache_key)- if held is None:- held = with_phone(frame, self._factor, self._color_key)- self._phone_frames[cache_key] = held- return held+ return sequence[min(index, len(sequence) - 1)]