Skip to content

RFC: Optional remote backend mode (WSL2 daemon / native Windows UI) #54

Open

Description

@slkzgm

Summary

I'd like to propose an optional "remote backend" mode that would allow CodexMonitor to run a small daemon on a Linux environment (e.g. WSL2), while keeping the UI as a native desktop app on Windows.

The key constraint is: Codex must keep running in the exact same environment (WSL2) for the same performance, access, tooling, and filesystem semantics — but the UI should not depend on WSLg/gWSL.

This would be opt-in and must not change default behavior for existing users.

Motivation (Windows + WSL2)

In a Windows 11 + WSL2 setup:

  • Projects and tools live in WSL (/home/...), and codex is executed there.
  • Running a Tauri Linux build through WSLg or gWSL works, but the UI can be janky/clunky and GPU permissions can be problematic.
  • The best UX is a native Windows window (WebView2) while preserving a WSL-native codex runtime.

Additional use cases / benefits (beyond WSL)

Even without WSL, a remote backend mode could unlock:

  • Remote Linux dev machines (SSH into a workstation/VM): native UI on the laptop/desktop without X forwarding/VNC.
  • Devcontainers / sandboxes: run the backend inside a container/VM (where the repo, tools, and secrets live), while keeping the UI on the host.
  • Long-running sessions: a supervised daemon (systemd) + UI reconnects after restarts/crashes without losing in-progress work.
  • Future multi-client scenarios: groundwork for a read-only dashboard or a mobile companion UI later (still opt-in).
  • Cleaner privilege boundaries: keep repo access + keys on the backend side; UI talks over localhost + token (local-only by default).

Goals

  • Preserve the existing local backend mode (current behavior) as the default.
  • Allow running the backend in another process/environment (e.g. WSL2) while the UI stays native.
  • Keep the UI event stream and IPC surface stable.

Non-goals (initially)

  • Solving path translation for every edge case.
  • Supporting cross-machine networking by default.
  • Large UX redesign.

Proposed direction

Add an optional daemon that:

  • Runs locally (bind 127.0.0.1) and requires a token.
  • Exposes the same high-level operations as the current backend (list_workspaces, connect_workspace, send_user_message, approvals, terminal PTY, etc.).
  • Streams the same event payloads the UI already expects (e.g. app-server-event, terminal-output).

UI would gain a backend selector:

  • Local (current)
  • Remote (daemon) with URL + token

Incremental PR plan (no behavior change by default)

I'm proposing to split this into small PRs to reduce risk and improve acceptance.

PR1 (UI-only refactor, no-op)

  • Introduce a src/services/events.ts module to centralize event subscriptions.
  • Update hooks to use it (useAppServerEvents, useTerminalSession, etc.).
  • No change in event names/payloads.

PR2 (Rust refactor, no-op)

  • Separate backend "core" logic from Tauri glue to make it reusable.
  • Keep the same #[tauri::command] surface and emitted events.

PR3 (optional daemon)

  • Add a new binary (feature-gated if needed) that exposes a local-only API and event stream.

PR4 (remote backend mode)

  • Add settings + connection logic.
  • Keep default behavior unchanged.

PR5 (docs + CI)

  • Document Windows+WSL flow.
  • Ensure builds stay reasonable (feature flags, separate workflows).

Open questions / feedback wanted

  • Preferred transport: WebSocket JSON-RPC vs REST+WS events?
  • Where should the remote backend config live (app settings vs per-workspace)?
  • How to handle file picker + image attachments in remote mode (WSL paths vs upload bytes)?
  • Would maintainers accept the daemon as optional/feature-gated?

If this direction sounds acceptable, I'm happy to start with PR1 immediately (pure refactor) and keep everything else behind explicit opt-in settings.

Activity

  1. slkzgm commented on Jan 15, 2026

    @slkzgm
    ContributorAuthor

    FYI: PR1 (UI-only, no-op refactor to centralize event subscriptions) is up: #55
    This is intended to be the first incremental step from the plan above and should not impact existing behavior.

  2. Dimillian commented on Jan 15, 2026

    @Dimillian
    Owner

    So, merging #55 unlocks the rest for you?

    Keeping that behind a setting is reasonable if it doesn't complicate/load the release proccess etc...

    • Protocol: I feel like JSON-RPC is tidier
    • I think app setting simplify things quite a bit, unless adding remote workspace is a use case
    • No idea, whatever is best for you
    • Need to see, deamon is fine if optional
  3. slkzgm commented on Jan 15, 2026

    @slkzgm
    ContributorAuthor

    Thanks for the feedback!

    Yes — merging #55 is the first small step that unblocks the rest on my side: it centralizes event subscriptions so later we can swap the event source (today Tauri listen(...), later a remote transport) without having to refactor multiple hooks/components. It’s not implementing remote mode yet, but it reduces the churn surface for PR2/PR4.

    Re: release process / complexity: totally agree. The remote backend would be strictly opt-in behind an app-level setting, with no default behavior change.

    For the daemon specifically, I’d keep it optional (feature-gated and/or built only in a dedicated workflow / separate artifact) so it doesn’t complicate the default release.

    Protocol: +1 on JSON-RPC. I’m planning JSON-RPC requests/responses + event notifications (so it stays close to the existing app-server mental model).

    Config: app-level setting makes sense. Remote workspaces can remain managed on the backend side; no need for per-workspace remote config unless we discover a strong use case.

    Paths / attachments: for an initial version, I’m fine with remote mode requiring remote filesystem paths (and disabling host file pickers), and keeping image/file attachments limited to paths accessible to the backend. Upload-bytes could be a later enhancement if needed.

    If you’re OK with that direction, I’ll wait for #55 to land, then submit PR2 (backend refactor only, still no-op) before proposing anything daemon-related.

  4. Dimillian commented on Jan 15, 2026

    @Dimillian
    Owner

    Sound good! I'll look at #55!

  5. Dimillian commented on Jan 15, 2026

    @Dimillian
    Owner

    Merged!

  6. slkzgm commented on Jan 15, 2026

    @slkzgm
    ContributorAuthor

    Quick status update: I have a full working integration on my fork (branch wip/remote-backend) that demonstrates the end goal: native Windows UI (WebView2) + Codex runtime in WSL2/Linux via an opt-in remote backend daemon (local mode unchanged).

    Tested on Win11 + WSL2: workspace add via \\wsl$\\<distro>\\home\\... / \\wsl.localhost\\<distro>\\home\\... (normalized to /home/...), workspace connect, threads list/start/resume, streaming, approvals, file listing, and Git panel (status/diffs/log/branches). (GitHub issues requires gh installed on the daemon machine.)

    Fork/branch: https://github.com/slkzgm/CodexMonitor/tree/wip/remote-backend

    Happy to record a short Loom/GIF demo if that helps review.

  7. slkzgm commented on Jan 17, 2026

    @slkzgm
    ContributorAuthor

    Quick status update: I've opened the next two incremental PRs (both target main, not stacked):

    Next (after merge of #70 / #71): I'll open the proxy/event-bridging PR, then the client workspace ops + WSL path normalization PR.

  8. slkzgm commented on Jan 19, 2026

    @slkzgm
    ContributorAuthor

    Status update:

    Next (after #121): I’ll open PR6b (client workspace ops + WSL path normalization) as discussed.

  9. slkzgm commented on Jan 20, 2026

    @slkzgm
    ContributorAuthor

    Status update:

    Next incremental PR opened:

    This covers client-side workspace ops forwarding + WSL path normalization for remote backend mode.

  10. SaladDay commented on Jan 29, 2026

    @SaladDay

    May I ask, esteemed expert, do you have any work plans lately, and is there anything I can help with?

  11. Coooolfan commented on Jan 29, 2026

    @Coooolfan

    wow, cool work! I've been trying to connect to Codex on a remote device. CodexMonitor looks great, but it currently seems to be designed for local use only. I'm really looking forward to your progress on this!

  12. SebLz commented on Feb 22, 2026

    @SebLz

    This is indeed a super common use case, would be nice to have it officially supported with some basic guidelines on how to set things up properly.

    I personally tried it this way:

    1. Clone the repo in ~/projects/CodexMonitor in WSL
    2. Run the daemon in WSL:
    cd ~/projects/CodexMonitor/src-tauri
    TOKEN="xxx"
    
    cargo run --bin codex_monitor_daemon -- \
      --listen 0.0.0.0:4732 \
      --data-dir "$HOME/.local/share/codex-monitor-daemon" \
      --token "$TOKEN"
    1. Add the workspace you want to track (mine is located in WSL too), for some reason I could not get this done via the UI (it would always throw errors about invalid paths, I tried both WSL path and Windows Path), so had to run this command in WSL:
    WS="~/projects/my-proj"
    
    printf '%s\n' \
      "{\"id\":1,\"method\":\"auth\",\"params\":{\"token\":\"$TOKEN\"}}" \
      "{\"id\":2,\"method\":\"add_workspace\",\"params\":{\"path\":\"$WS\"}}" \
      "{\"id\":3,\"method\":\"list workspaces\",\"params\":{}}" \
    | nc -w 2 127.0.0.1 4732
    1. In Windows > Codex Monitor UI > Settings > Server
      Configure Backend mode to remote and set remote backend to 127.0.0.1:4732. ALso put your token defined in 2. there.
    Image

    Maybe there are better ways to do this but this is all I have found looking around together with chatgpt.

  13. Tokolosk commented on Feb 22, 2026

    @Tokolosk

    @SebLz thank you for that. I followed the same instructions but still struggled and giving up - for now.

    For the devs, if this helps:

    • I got the daemon running and connected to Codex Monitor but still got path errors.
    • After restarting, the UI cannot reconnect to the daemon: says 0.0.0.0:4732 is in use - which is the daemon itself!
    • Following SebLz's instructions, I had to use the full \wsl path for $WS, so clearly not all WSL's work the same.
    • Even when the printf query SebLz showed worked, I still could not see my files or Codex instances working.

    Let me know if I can help with more pointed information.

  14. SebLz commented on Feb 22, 2026

    @SebLz

    @SebLz thank you for that. I followed the same instructions but still struggled and giving up - for now.

    For the devs, if this helps:

    • I got the daemon running and connected to Codex Monitor but still got path errors.
    • After restarting, the UI cannot reconnect to the daemon: says 0.0.0.0:4732 is in use - which is the daemon itself!
    • Following SebLz's instructions, I had to use the full \wsl path for $WS, so clearly not all WSL's work the same.
    • Even when the printf query SebLz showed worked, I still could not see my files or Codex instances working.

    Let me know if I can help with more pointed information.

    In my case, I noticed that a daemon was running in the Windows environment even after closing the UI. You might want to try to close the UI, then check in Task Manager that no codex monitor processes are running anymore. Then launch the daemon in WSL and after that launch the UI in Windows again.

  15. arhsis commented on Feb 28, 2026

    @arhsis

    Hi there, thanks for the great work on this.

    I’m using CodexMonitor on macOS with Backend mode = Remote, connected to a Linux daemon (the connection is confirmed, and token usage is clearly from the server side).

    The issue I hit is that adding a workspace from desktop still opens the local macOS folder picker :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions