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
fix(clipboard): keep umlauts and emoji intact in pbcopy and pbpaste
rubenluetke10-beep66eb7a9d3d6b
diff --git a/jarvis/platform/clipboard.py b/jarvis/platform/clipboard.pyindex 8d6c610620..ee10c9e45a 100644--- a/jarvis/platform/clipboard.py+++ b/jarvis/platform/clipboard.py@@ -80,11 +80,24 @@ def read_text() -> str | None:return raw.replace("\r\n", "\n").replace("\r", "\n")+def _utf8_env() -> dict[str, str] | None:+ """The environment for a clipboard command: UTF-8 text on macOS.++ ``pbcopy``/``pbpaste`` encode in the locale's charset. An app started from+ Finder or the Dock has no locale, so they fell back to MacRoman and turned+ umlauts and emoji into mojibake. Linux tools take bytes as given.+ """+ if detect_platform() != "darwin":+ return None+ return {**os.environ, "LANG": "en_US.UTF-8", "LC_ALL": "en_US.UTF-8"}++def _read_command(command: Sequence[str]) -> str | None:"""Read clipboard text from a fixed OS command's stdout."""try:completed = subprocess.run( # noqa: S603 - fixed, non-shell OS commandlist(command),+ env=_utf8_env(),capture_output=True,text=True,encoding="utf-8",@@ -221,6 +234,7 @@ def _run_command(command: Sequence[str], text: str) -> bool:completed = subprocess.run( # noqa: S603 - fixed, non-shell OS commandlist(command),input=text.encode("utf-8"),+ env=_utf8_env(),stdout=subprocess.DEVNULL,stderr=err,timeout=_COMMAND_TIMEOUT_S,diff --git a/tests/unit/platform/test_clipboard.py b/tests/unit/platform/test_clipboard.pyindex ab53e2bb61..aa24ce0812 100644--- a/tests/unit/platform/test_clipboard.py+++ b/tests/unit/platform/test_clipboard.py@@ -227,3 +227,28 @@ def test_linux_picks_the_tool_for_the_session(assert written == [f"/usr/bin/{expected_write}"]assert read == [f"/usr/bin/{expected_read}"]++[email protected](("platform", "utf8"), [("darwin", True), ("linux", False)])+def test_macos_clipboard_commands_always_speak_utf8(+ monkeypatch: pytest.MonkeyPatch, platform: str, utf8: bool+) -> None:+ """An app started from Finder has no locale; pbcopy would fall back to MacRoman."""+ monkeypatch.delenv("LANG", raising=False)+ monkeypatch.delenv("LC_ALL", raising=False)+ monkeypatch.setattr(clipboard, "detect_platform", lambda: platform)+ seen: list[object] = []++ def _run(command: list[str], **kwargs: object) -> subprocess.CompletedProcess[str]:+ seen.append(kwargs.get("env"))+ return subprocess.CompletedProcess(command, 0, stdout="", stderr="")++ monkeypatch.setattr(clipboard.subprocess, "run", _run)+ clipboard._run_command(["/usr/bin/pbcopy"], "Größe ✓") # i18n-allow: non-ASCII round trip+ clipboard._read_command(["/usr/bin/pbpaste"])++ for env in seen:+ if utf8:+ assert isinstance(env, dict) and env["LC_ALL"] == "en_US.UTF-8"+ else:+ assert env is None