Skip to content

[codex] Add X11 forwarding support#835

Merged
binaricat merged 4 commits into
mainfrom
codex/x11-forwarding
Apr 27, 2026
Merged

[codex] Add X11 forwarding support#835
binaricat merged 4 commits into
mainfrom
codex/x11-forwarding

Conversation

@binaricat
Copy link
Copy Markdown
Owner

Summary

Adds X11 forwarding support for SSH hosts so remote graphical applications can display through a local X server such as XQuartz.

What changed

  • Added a host-level X11 forwarding toggle and a terminal setting for overriding the local X11 display.
  • Requests X11 forwarding when opening SSH shells and forwards incoming X11 channels to the local display.
  • Handles MIT-MAGIC-COOKIE-1 authentication by replacing the SSH placeholder cookie with the local X server cookie.
  • Preserves ForwardX11 yes when importing and exporting SSH config.
  • Adds tests for display parsing, local X11 channel forwarding, cookie rewriting, and SSH config import/export.

Validation

  • node --test --import tsx electron/bridges/x11Forwarding.test.cjs
  • npm run lint
  • npm test
  • npm run build
  • Manual check with XQuartz and xeyes through an SSH session.

@binaricat binaricat marked this pull request as ready for review April 25, 2026 10:02
@binaricat
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27a6efbc83

ℹ️ 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".

Comment thread electron/bridges/x11Forwarding.cjs Outdated
Comment on lines +188 to +191
const line = output
.split(/\r?\n/)
.find((entry) => new RegExp(`\\b${MIT_MAGIC_COOKIE_PROTOCOL}\\b\\s+[0-9a-fA-F]+`).test(entry));
const match = line?.match(new RegExp(`\\b${MIT_MAGIC_COOKIE_PROTOCOL}\\b\\s+([0-9a-fA-F]+)`));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Match xauth cookie to the requested display

This lookup returns the first MIT-MAGIC-COOKIE-1 entry from xauth output without checking whether it belongs to the configured display, so hosts with multiple .Xauthority records (for example :0 plus stale/forwarded :10) can get the wrong cookie and fail every forwarded X11 app auth. The selected entry should be filtered against the target display before extracting the cookie.

Useful? React with 👍 / 👎.

Comment thread electron/bridges/x11Forwarding.cjs Outdated
localSocket.on("error", () => cleanup());
acceptedChannel.on("close", () => destroyStream(localSocket));
localSocket.on("close", () => destroyStream(acceptedChannel));
const realCookie = options.localAuthCookie || readLocalX11AuthCookie({ display, platform });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Cache local X11 auth instead of blocking per channel

Each incoming X11 channel triggers readLocalX11AuthCookie() here, and that function uses execFileSync with a 2s timeout; because this runs on the Electron main process thread, apps that open multiple X11 channels can repeatedly freeze IPC/UI while cookies are fetched. Resolve the local cookie once per SSH session (or switch to async lookup) and reuse it for channel handlers.

Useful? React with 👍 / 👎.

@binaricat binaricat merged commit 08e566a into main Apr 27, 2026
@binaricat binaricat deleted the codex/x11-forwarding branch April 27, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant