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.

chore(i18n): translate committed German to English in jarvis/ui/{icon_utils,shell} (isolated drain, batch 07_3_jarvis)

Ruben Lütke31963c403031
diff --git a/jarvis/ui/icon_utils.py b/jarvis/ui/icon_utils.py
index 7f44def600..53e994bf45 100644
--- a/jarvis/ui/icon_utils.py
+++ b/jarvis/ui/icon_utils.py
@@ -1,11 +1,12 @@
-"""Win32-Helper zum Setzen des Fenster-Icons einer pywebview-Instanz.
+"""Win32 helper for setting the window icon of a pywebview instance.
-Warum braucht Jarvis das? pywebview ``create_window`` hat auf Windows keinen
-``icon``-Parameter — das Taskbar- und Titlebar-Icon erbt daher vom Prozess
-(``python.exe`` / ``pythonw.exe``), also das generische Python-Logo. Wir setzen
-es nach dem ``shown``-Event per ``WM_SETICON`` direkt gegen das Window-Handle.
+Why does Jarvis need this? pywebview's ``create_window`` has no ``icon``
+parameter on Windows — the taskbar and titlebar icon therefore inherits from
+the process (``python.exe`` / ``pythonw.exe``), i.e. the generic Python logo.
+We set it after the ``shown`` event via ``WM_SETICON`` directly against the
+window handle.
-Alle Funktionen sind No-Ops auf Nicht-Windows-Plattformen.
+All functions are no-ops on non-Windows platforms.
"""
from __future__ import annotations
@@ -24,11 +25,11 @@ _IMAGE_ICON = 1
_LR_LOADFROMFILE = 0x00000010
_LR_DEFAULTSIZE = 0x00000040
-# Class-Icon-Slots (negative Indices fuer SetClassLongPtrW). Das Class-Icon
-# wird von Windows fuer den Taskbar-Eintrag verwendet, wenn beim ersten
-# Anzeigen noch kein Window-Icon (WM_SETICON) gesetzt ist. Ohne Class-Icon
-# faellt die Taskbar auf das Process-Icon (pythonw.exe → Python-Logo) zurueck
-# und cached die Zuordnung fuer den Rest der Session.
+# Class icon slots (negative indices for SetClassLongPtrW). Windows uses the
+# class icon for the taskbar entry when no window icon (WM_SETICON) has been
+# set yet at first display. Without a class icon, the taskbar
+# falls back to the process icon (pythonw.exe → Python logo)
+# and caches that mapping for the rest of the session.
_GCLP_HICON = -14
_GCLP_HICONSM = -34
@@ -235,7 +236,7 @@ def ensure_windows_app_identity(app_id: str = APP_USER_MODEL_ID) -> bool:
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
return True
except Exception as exc: # noqa: BLE001
- logger.debug("AppUserModelID konnte nicht gesetzt werden: {}", exc)
+ logger.debug("AppUserModelID could not be set: {}", exc)
return False
@@ -246,14 +247,14 @@ def _apply_icon_to_hwnd(hwnd: int, ico_path: Path) -> bool:
if not hwnd:
return False
if not ico_path.is_file():
- logger.warning("Icon-Datei fehlt: {}", ico_path)
+ logger.warning("Icon file missing: {}", ico_path)
return False
try:
import ctypes
from ctypes import wintypes
except Exception as exc: # noqa: BLE001
- logger.opt(exception=exc).warning("ctypes nicht verfügbar")
+ logger.opt(exception=exc).warning("ctypes not available")
return False
user32 = ctypes.windll.user32
@@ -273,7 +274,7 @@ def _apply_icon_to_hwnd(hwnd: int, ico_path: Path) -> bool:
None, path_str, _IMAGE_ICON, 16, 16, _LR_LOADFROMFILE | _LR_DEFAULTSIZE
)
if not hicon_big or not hicon_small:
- logger.warning("LoadImageW schlug fehl für {}", path_str)
+ logger.warning("LoadImageW failed for {}", path_str)
return False
# WM_SETICON: titlebar + Alt-Tab switcher.
@@ -284,7 +285,7 @@ def _apply_icon_to_hwnd(hwnd: int, ico_path: Path) -> bool:
# window registers its own class, so we only affect Jarvis windows.
user32.SetClassLongPtrW(hwnd, _GCLP_HICON, hicon_big)
user32.SetClassLongPtrW(hwnd, _GCLP_HICONSM, hicon_small)
- logger.debug("Icon gesetzt (window+class): hwnd={} path={}", hwnd, path_str)
+ logger.debug("Icon set (window+class): hwnd={} path={}", hwnd, path_str)
return True
@@ -300,33 +301,33 @@ def set_window_icon_by_hwnd(hwnd: int, ico_path: Path) -> bool:
def set_window_icon_by_title(
title: str, ico_path: Path, *, quiet: bool = False
) -> bool:
- """Setzt Taskbar- und Titlebar-Icon des Fensters mit passendem ``title``.
+ """Sets the taskbar and titlebar icon of the window matching ``title``.
- Benötigt, weil pywebview das HWND nicht stabil exposed. ``FindWindowW``
- gegen den Titel ist ein pragmatischer Weg — der Jarvis-Window-Title ist
- konstant ("Personal Jarvis") und einzigartig.
+ Needed because pywebview doesn't stably expose the HWND. ``FindWindowW``
+ against the title is a pragmatic way — the Jarvis window title is
+ constant ("Personal Jarvis") and unique.
Args:
- title: Window-Titel exakt wie von pywebview gesetzt.
- ico_path: Pfad zur ``.ico``-Datei.
- quiet: Wenn True, werden "hwnd nicht gefunden"-Hinweise auf debug
- geloggt statt warning. Fuer Polling-Loops, bei denen das Fenster
- erwartungsgemaess erst nach einigen Iterationen auftaucht.
+ title: Window title exactly as set by pywebview.
+ ico_path: Path to the ``.ico`` file.
+ quiet: If True, "hwnd not found" notices are logged at debug
+ instead of warning. For polling loops where the window is
+ expected to appear only after a few iterations.
Returns:
- True wenn beide Icons gesetzt werden konnten.
+ True if both icons could be set.
"""
if sys.platform != "win32":
return False
if not ico_path.is_file():
- logger.warning("Icon-Datei fehlt: {}", ico_path)
+ logger.warning("Icon file missing: {}", ico_path)
return False
try:
import ctypes
from ctypes import wintypes
except Exception as exc: # noqa: BLE001
- logger.opt(exception=exc).warning("ctypes nicht verfügbar")
+ logger.opt(exception=exc).warning("ctypes not available")
return False
user32 = ctypes.windll.user32
@@ -334,9 +335,9 @@ def set_window_icon_by_title(
hwnd = user32.FindWindowW(None, title)
if not hwnd:
if quiet:
- logger.debug("Fenster '{}' (noch) nicht gefunden", title)
+ logger.debug("Window '{}' not found (yet)", title)
else:
- logger.warning("Fenster '{}' nicht gefunden — Icon nicht gesetzt", title)
+ logger.warning("Window '{}' not found — icon not set", title)
return False
return _apply_icon_to_hwnd(int(hwnd), ico_path)
@@ -358,7 +359,7 @@ def set_window_icon_for_pid(pid: int, ico_path: Path) -> bool:
import ctypes
from ctypes import wintypes
except Exception as exc: # noqa: BLE001
- logger.opt(exception=exc).warning("ctypes nicht verfügbar")
+ logger.opt(exception=exc).warning("ctypes not available")
return False
user32 = ctypes.windll.user32
@@ -388,36 +389,36 @@ def set_window_icon_for_pid(pid: int, ico_path: Path) -> bool:
def load_ico_as_pil_image(ico_path: Path, size: int = 64) -> Any | None:
- """Lädt ``.ico`` als ``PIL.Image`` für pystray-Tray-Icon.
+ """Loads a ``.ico`` as a ``PIL.Image`` for the pystray tray icon.
- pystray braucht ein Image-Objekt, keine Datei-Referenz. Wir laden die
- größte verfügbare Repräsentation und skalieren auf ``size``.
+ pystray needs an Image object, not a file reference. We load the
+ largest available representation and scale it to ``size``.
"""
if not ico_path.is_file():
return None
try:
from PIL import Image
except Exception as exc: # noqa: BLE001
- logger.opt(exception=exc).warning("Pillow nicht verfügbar")
+ logger.opt(exception=exc).warning("Pillow not available")
return None
try:
img = Image.open(ico_path)
- # .ico enthält typischerweise mehrere Größen — Pillow wählt die erste,
- # wir forcen eine saubere Zielgröße via resize.
+ # .ico typically contains multiple sizes — Pillow picks the first,
+ # we force a clean target size via resize.
if img.mode != "RGBA":
img = img.convert("RGBA")
if img.size != (size, size):
img = img.resize((size, size), Image.LANCZOS)
return img
except Exception as exc: # noqa: BLE001
- logger.opt(exception=exc).warning("ICO-Load schlug fehl: {}", ico_path)
+ logger.opt(exception=exc).warning("ICO load failed: {}", ico_path)
return None
def project_icon_path() -> Path:
- """Auflösung des Standard-Icon-Pfads: ``<projekt-root>/assets/icons/jarvis.ico``.
+ """Resolves the default icon path: ``<project-root>/assets/icons/jarvis.ico``.
- Die Datei liegt außerhalb des ``jarvis``-Packages. Wir gehen von
- ``jarvis/ui/icon_utils.py`` drei Ebenen hoch zum Projekt-Root.
+ The file lives outside the ``jarvis`` package. We go up three levels
+ from ``jarvis/ui/icon_utils.py`` to the project root.
"""
return Path(__file__).resolve().parents[2] / "assets" / "icons" / "jarvis.ico"
diff --git a/jarvis/ui/shell/__init__.py b/jarvis/ui/shell/__init__.py
index b98736e5e0..5e7b1beae9 100644
--- a/jarvis/ui/shell/__init__.py
+++ b/jarvis/ui/shell/__init__.py
@@ -1,10 +1,10 @@
-"""pywebview-Shell für die Desktop-App.
+"""pywebview shell for the desktop app.
-**Warum eine eigene Schicht zwischen pywebview und __main__?** pywebview ist
-blocking-callback-driven und hat Main-Thread-Requirement. Der Rest von Jarvis
-ist async und thread-agnostisch. Diese Schicht kapselt die Thread-Grenzen
-hinter einer API die andere Layer (Tray, WebSocket, Single-Instance)
-ansteuern können ohne pywebview-Interna zu kennen.
+**Why a separate layer between pywebview and __main__?** pywebview is
+blocking-callback-driven and has a main-thread requirement. The rest of Jarvis
+is async and thread-agnostic. This layer encapsulates the thread boundaries
+behind an API other layers (tray, WebSocket, single-instance)
+can drive without knowing pywebview internals.
"""
from __future__ import annotations
diff --git a/jarvis/ui/shell/runtime_check.py b/jarvis/ui/shell/runtime_check.py
index a5c6b61619..ace7bdc3d9 100644
--- a/jarvis/ui/shell/runtime_check.py
+++ b/jarvis/ui/shell/runtime_check.py
@@ -1,10 +1,10 @@
-"""WebView2-Runtime-Check für Windows 11.
+"""WebView2 runtime check for Windows 11.
-**Kontext:** Auf Windows 11 ist die Evergreen-WebView2-Runtime standardmässig
-vorinstalliert ([Microsoft Learn: Evergreen vs. Fixed][ms]). LTSC-, Validation-
-und alte Enterprise-Images können sie jedoch missen, und Custom-Deployments
-ebenfalls. Dieser Check verhindert, dass pywebview beim Start mit einer
-kryptischen `InitializationError` bricht.
+**Context:** On Windows 11 the evergreen WebView2 runtime is preinstalled by
+default ([Microsoft Learn: Evergreen vs. Fixed][ms]). LTSC, Validation,
+and old Enterprise images can be missing it, though, and so can custom
+deployments. This check prevents pywebview from crashing at startup with a
+cryptic `InitializationError`.
[ms]: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/evergreen-vs-fixed-version
"""
@@ -14,8 +14,8 @@ from dataclasses import dataclass
WEBVIEW2_CLIENT_GUID = "{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
-# 64-Bit-Installationen liegen unter dem WOW6432Node-Pfad (Edge ist als 32-Bit
-# Client registriert, die Binaries selbst sind aber 64-Bit).
+# 64-bit installations live under the WOW6432Node path (Edge is registered as a
+# 32-bit client, but the binaries themselves are 64-bit).
_CANDIDATE_KEYS: tuple[tuple[int, str], ...] = (
(0x80000002, rf"SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{WEBVIEW2_CLIENT_GUID}"),
(0x80000002, rf"SOFTWARE\Microsoft\EdgeUpdate\Clients\{WEBVIEW2_CLIENT_GUID}"),
@@ -33,16 +33,16 @@ class WebView2CheckResult:
def check_webview2() -> WebView2CheckResult:
- """Prüft ob WebView2-Runtime installiert ist.
+ """Checks whether the WebView2 runtime is installed.
- Gibt Version + Scope zurück; bei fehlender Installation `installed=False`.
- Kein Raise — der Aufrufer entscheidet ob er abbricht oder den User zum
- Bootstrapper-Download weiterleitet.
+ Returns version + scope; `installed=False` if it's missing.
+ No raise — the caller decides whether to abort or redirect the user to
+ the bootstrapper download.
"""
try:
import winreg # type: ignore[import-not-found]
except ImportError:
- # Nicht-Windows — WebView2 ist irrelevant, pywebview nutzt andere Engines.
+ # Non-Windows — WebView2 is irrelevant, pywebview uses other engines.
return WebView2CheckResult(installed=True, version=None, scope="none")
for hive_key, subkey in _CANDIDATE_KEYS:
@@ -57,8 +57,8 @@ def check_webview2() -> WebView2CheckResult:
except OSError:
continue
- # Fallback: die HKEYType-Ableitung oben schlägt auf manchen Systemen fehl.
- # Direkter Zugriff über die OpenKey-Constants.
+ # Fallback: the HKEYType derivation above fails on some systems.
+ # Direct access via the OpenKey constants.
try:
import winreg # type: ignore[import-not-found]
diff --git a/jarvis/ui/shell/shell.py b/jarvis/ui/shell/shell.py
index bce9742020..f4212f9e72 100644
--- a/jarvis/ui/shell/shell.py
+++ b/jarvis/ui/shell/shell.py
@@ -1,19 +1,19 @@
-"""pywebview-Shell-Orchestrator.
-
-**Thread-Choreografie** (siehe Plan §5.1, §5.2):
-
-- Main-Thread: `webview.start()` — blockt bis Window-Close
-- Daemon-Thread 1: Uvicorn (WebServer)
-- Daemon-Thread 2: pystray (JarvisTray) — Doppelklick-Handler emittiert
- ``TrayCommand("open_ui")`` in die Queue
-- Daemon-Thread 3: Tray→Shell-Bridge (diese Klasse) — konsumiert die Queue
- thread-safely und ruft `request_show()` via
- `webview.windows[0].show()` auf
-
-**Warum Close-Button = hide statt destroy?** pywebview's Default-Handler
-beendet bei Close den Main-Loop. User-Entscheidung (2026-04-20): Close =
-Minimize-to-Tray. `on_closing`-Callback gibt `False` zurück → Window wird
-versteckt statt zerstört.
+"""pywebview shell orchestrator.
+
+**Thread choreography** (see Plan §5.1, §5.2):
+
+- Main thread: `webview.start()` — blocks until window close
+- Daemon thread 1: Uvicorn (web server)
+- Daemon thread 2: pystray (JarvisTray) — the double-click handler emits
+ ``TrayCommand("open_ui")`` into the queue
+- Daemon thread 3: Tray→shell bridge (this class) — consumes the queue
+ thread-safely and calls `request_show()` via
+ `webview.windows[0].show()`
+
+**Why does the close button hide instead of destroy?** pywebview's default
+handler ends the main loop on close. User decision (2026-04-20): close =
+minimize-to-tray. The `on_closing` callback returns `False` → the window is
+hidden instead of destroyed.
"""
from __future__ import annotations
@@ -30,7 +30,7 @@ if TYPE_CHECKING:
class JarvisShell:
- """Kapselt pywebview-Fenster + Tray-Bridge + Shutdown-Hook."""
+ """Encapsulates the pywebview window + tray bridge + shutdown hook."""
def __init__(
self,
@@ -55,7 +55,7 @@ class JarvisShell:
return self._window
def request_show(self) -> None:
- """Holt das Fenster nach vorne — thread-safe callable."""
+ """Brings the window to the front — thread-safe callable."""
if self._window is None:
return
try:
@@ -72,7 +72,7 @@ class JarvisShell:
logger.opt(exception=exc).warning("Window.hide() failed")
def run(self) -> None:
- """Erstellt das Window und startet pywebview — blockt Main-Thread."""
+ """Creates the window and starts pywebview — blocks the main thread."""
import webview # type: ignore[import-untyped]
self._window = webview.create_window(
@@ -88,10 +88,10 @@ class JarvisShell:
confirm_close=self._cfg.confirm_close,
)
- # Close-Button = hide (Minimize-to-Tray-Verhalten)
+ # Close button = hide (minimize-to-tray behavior)
def _on_closing() -> bool:
- # Wenn wir wirklich beenden wollen (via Tray-Menu "Beenden"), wurde
- # `_close_requested = True` gesetzt → echtes Close zulassen.
+ # If we really want to quit (via the tray menu "Quit"),
+ # `_close_requested = True` was set → allow a real close.
if self._close_requested:
return True
self.request_hide()
@@ -99,7 +99,7 @@ class JarvisShell:
self._window.events.closing += _on_closing
- # Token ins Frontend injecten, sobald das DOM geladen ist.
+ # Inject the token into the frontend as soon as the DOM has loaded.
def _on_loaded() -> None:
try:
self._window.evaluate_js(
@@ -111,7 +111,7 @@ class JarvisShell:
self._window.events.loaded += _on_loaded
- # Tray→Shell Bridge starten, falls Tray vorhanden
+ # Start the tray→shell bridge, if a tray exists
if self._tray is not None:
bridge = threading.Thread(
target=self._tray_bridge_loop,
@@ -126,7 +126,7 @@ class JarvisShell:
self._on_close()
def quit(self) -> None:
- """Wirkliches Beenden — wird vom Tray-Menu "Beenden" aufgerufen."""
+ """Actual quit — called from the tray menu "Quit"."""
self._close_requested = True
if self._window is not None:
try:
@@ -135,11 +135,11 @@ class JarvisShell:
logger.opt(exception=exc).warning("Window.destroy() failed")
def _tray_bridge_loop(self) -> None:
- """Pollt die Tray-Command-Queue und reagiert auf open_ui/quit.
+ """Polls the tray command queue and reacts to open_ui/quit.
- **Wichtig:** wir rufen `show()`/`hide()` **aus diesem Thread**, nicht
- aus dem pystray-Thread direkt — pystray-Callbacks dürfen nicht in
- pywebview-APIs reingreifen (WinForms-Deadlock-Risiko).
+ **Important:** we call `show()`/`hide()` **from this thread**, not
+ directly from the pystray thread — pystray callbacks must not reach
+ into pywebview APIs (WinForms deadlock risk).
"""
assert self._tray is not None
import queue