From f8f091ba7269f62f2a325083a02ed25ef1de77f2 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Tue, 20 Oct 2026 13:49:53 -0700 Subject: [PATCH] Preserve Unicode in Mac VM clipboard transfers Select UTF-8 explicitly on both host and guest clipboard tools, and document the installed access helper and verified GUI environment. Assisted-by: gpt-6-astra --- tools/code-vm | 4 ++-- tools/mac-agent-vm.md | 21 +++++++++++++++++---- tools/mac-vm-bridge.py | 3 ++- tools/mac-vm-test.py | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tools/code-vm b/tools/code-vm index 6f4e8b54dcb60c716429d0636c33c75cef33a74c..9490279dca108ba12aab62b4886cd2e3596a4893 100755 --- a/tools/code-vm +++ b/tools/code-vm @@ -7,10 +7,10 @@ import sys helper = str(Path(__file__).resolve().with_name("mac-agent-vm.py")) if sys.argv[1:] == ["--clipboard"]: - with subprocess.Popen(["/usr/bin/pbpaste"], stdout=subprocess.PIPE) as clipboard: + with subprocess.Popen(["/usr/bin/pbpaste"], env={**os.environ, "LC_CTYPE": "en_US.UTF-8"}, stdout=subprocess.PIPE) as clipboard: try: result = subprocess.run( - [sys.executable, helper, "exec", "/usr/bin/pbcopy"], + [sys.executable, helper, "exec", "/usr/bin/env", "LC_CTYPE=en_US.UTF-8", "/usr/bin/pbcopy"], stdin=clipboard.stdout, ) finally: diff --git a/tools/mac-agent-vm.md b/tools/mac-agent-vm.md index 8805311d1a59d654a1bd9d59e839befb2607d70d..6494d741ea1365aa1114e15b0900c48d106002c6 100644 --- a/tools/mac-agent-vm.md +++ b/tools/mac-agent-vm.md @@ -95,7 +95,8 @@ force-off, deletion, and preset creation are unavailable for this managed VM. ## Guest access -`~/.local/bin/code-vm` links to `tools/code-vm`: +`~/.local/bin/code-vm` links to the installed `runtime/control/code-vm` under +the VM home, alongside its helper: ```sh code-vm # Interactive SSH shell @@ -192,9 +193,21 @@ deliberately between test runs, then recheck GUI permissions and boot. Initial provisioning installed Rust/Cargo 1.99.1, Node 24.22.0 LTS, npm 11.19.1, pnpm 12.14.0, Jujutsu 0.42.0, and Apple's CLT with Clang 17 and the macOS SDK. -Subsequent guest setup manages toolchain versions and paths. Login shells load -their paths from `~/.zprofile` or `~/.profile`; use -`exec /bin/zsh -lc ...` for development commands. +Subsequent guest setup manages toolchain versions and paths in +`~/config/users/clover/agents/vm` on the host. Its installed `env.zsh` is linked +from the guest's `~/.zshenv`, including non-login shells. The development +LaunchAgent publishes the same environment to newly launched GUI apps. Existing +apps retain their inherited environment until relaunched. `/bin/zsh` has a +separate guest Full Disk Access approval so launchd can read this configuration +on Code. The Apple-tools LaunchAgent retries failed image attachment every +30 seconds and recognizes already mounted images. + +On 2026-10-20, a fresh launchd process resolved Cargo, Node, pnpm, and Zig and +reported the Code-backed cache paths. Existing Apple and kache mounts remained +available. A Mac restart was explicitly deferred by Clover; these live checks +do not establish cold-boot recovery. A dashboard clipboard round-trip preserved +accented text, emoji, and Japanese text with UTF-8 selected explicitly for +`pbcopy` and `pbpaste`. ## Provenance diff --git a/tools/mac-vm-bridge.py b/tools/mac-vm-bridge.py index 013538f7607673b9e3e453f776b5087eda96c4a6..8cecfb19245958b5edcd8b67bc71a09fdc994fef 100644 --- a/tools/mac-vm-bridge.py +++ b/tools/mac-vm-bridge.py @@ -74,7 +74,8 @@ def main(): value = request["text"] if not isinstance(value, str) or len(value.encode()) > 262144: raise ValueError("Shorten the clipboard text, then send it again.") - vm.tart("exec", "-i", vm.NAME, "/usr/bin/pbcopy", input=value.encode(), capture_output=True, timeout=15) + vm.tart("exec", "-i", vm.NAME, "/usr/bin/env", "LC_CTYPE=en_US.UTF-8", "/usr/bin/pbcopy", + input=value.encode(), capture_output=True, timeout=15) respond({"value": None}) elif action == "console" and set(request) == {"action"}: with vm.guest_screen() as upstream: diff --git a/tools/mac-vm-test.py b/tools/mac-vm-test.py index ac06814c857acf4ff0e9e29ef588b3875930196a..ae138a4badc43aa7edd59dc09ce9b93b8b40b823 100644 --- a/tools/mac-vm-test.py +++ b/tools/mac-vm-test.py @@ -38,7 +38,7 @@ class MacVMTests(unittest.TestCase): with patch.object(sys, "stdin", io.TextIOWrapper(io.BytesIO(request))), \ patch.object(bridge.vm, "tart") as tart, patch.object(bridge, "respond") as respond: bridge.main() - self.assertEqual(tart.call_args.args, ("exec", "-i", "gui-agent", "/usr/bin/pbcopy")) + self.assertEqual(tart.call_args.args, ("exec", "-i", "gui-agent", "/usr/bin/env", "LC_CTYPE=en_US.UTF-8", "/usr/bin/pbcopy")) self.assertEqual(tart.call_args.kwargs["input"], value.encode()) respond.assert_called_once_with({"value": None}) -- 2.54.1