Repository navigation
MACBOX_VIEW_SWITCH: move the VM's window between desktop and stream without a restart (Reims 0036) - #20
Conversation
…tart (Reims 0036)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c6969b08a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| qemu_pid() { $DOCKER top "$C" -eo pid,args 2>/dev/null | awk '/qemu-system-x86_64/ {print $1; exit}'; } | ||
| view() { cat "$RUN/view" 2>/dev/null || echo stream; } | ||
| stream_socket() { # sway's socket in the container, the stream's (display-up.sh starts it if needed) | ||
| echo "/tmp/xdg/$(in_c "$REPO/src/container/display-up.sh" | sed -n 's/^WAYLAND_DISPLAY=//p')" |
There was a problem hiding this comment.
Propagate display-stack startup failures from stream_socket
With MACBOX_VIEW_SWITCH=on, if display-up.sh fails (for example, while installing Selkies on first use), the enclosing echo masks the failed pipeline and successfully returns /tmp/xdg/ instead of a socket. Consequently, cmd_up writes that directory into run/compositor, starts the VM without a usable display, and reports success; previously, the direct assignment propagated the failure and stopped startup. This was reproduced with a failing in_c stub under set -euo pipefail. Capture and check the pipeline's result separately before printing the socket path.
Useful? React with 👍 / 👎.
| to=/tmp/host-wayland/wayland-0 ;; | ||
| stream) to=$(stream_socket) ;; | ||
| esac | ||
| [ "$(cat "$RUN/compositor.on" 2>/dev/null)" = "$to" ] && { echo "$1" >"$RUN/view"; say "view: $1 (already)"; return 0; } |
There was a problem hiding this comment.
Replace pending compositor requests before returning already
If a user interrupts macbox view stream before Reims processes its request and then runs macbox view local, compositor.on can still name the local socket while compositor requests the stream. This early return reports local (already) and updates run/view without replacing the pending stream request, so Reims subsequently moves the window to the stream despite the successful local command. The same race occurs with overlapping opposite-view commands. Write the requested socket even when the acknowledgement already matches, so a previous pending request cannot override the latest selection.
Useful? React with 👍 / 👎.
What
A restart-free view switch. With
MACBOX_VIEW_SWITCH=on,macbox view local|streammoves the running VM's window between the host's Wayland desktop and the browser stream (headless sway behind Selkies) while macOS runs. Off by default; with the flag off nothing changes.REIMS_VGPU_WINDOW_COMPOSITOR_FILE=<path>). The file names a Wayland socket.SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER). It holds SDL's events apart from its video, so the threads that wake it can push their events at any time.<file>.onsays where the windows are.upsets the variable.viewrewritesrun/compositorand waits forrun/compositor.on.statusreads where the window is.Tested
/dev/dri: Reims's SDL 3.4.18, two headless sway 1.12 (pixman) and lavapipe, with the same thread shape as Reims (one Vulkan instance and device for the process, the surface and presents on a render thread). Over 100 moves in one process:cargo test -p reims-vgpu-window --libgives 111 passed, including new tests for the detach handshake and the socket file.cargo clippy --all-targetsis clean for the crate. The patch applies on 7198fe6 + 0001–0035.bash -nand shellcheck show nothing new.Verified on Atlas (2026-11-14)
Hardware: Arrow Lake iGPU, Mesa ANV, macOS 26.7.1. Production build plus this patch; Atlas's own view script has the same logic as
macbox view.launchd_sim).macbox viewend to end on a fresh macbox install. The macbox CLI side was checked withbash -nand shellcheck only.Atlas deployment note
Atlas production will run this on its sched1desk build, which also carries the local
REIMS_VGPU_STATS_FRAMESstats patch (not part of this PR). ItsREIMS_VGPU_STATS_FRAMESline in vm.toml stays until the next natural VM restart. Drop it then.