Skip to content

Fix copying from Codex started manually in remote shells - #34715

Merged
nwparker merged 6 commits into
mainfrom
nwparker/remote-codex-copy
Oct 28, 2026
Merged

nwparker merged 6 commits into
mainfrom
nwparker/remote-codex-copy

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​161 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​143
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42

ELI5

Typing codex in a remote Orca shell could copy text only on the server. Newly created remote shells now make that manual launch send clipboard text back to the viewer, just like Codex launched from Orca's agent controls.

What Changed

Pass the existing remote-viewer intent into shell startup and apply the Codex clipboard environment only inside its existing Bash, Zsh, Fish, and PowerShell wrappers. Keep the parent shell and inherited SSH values intact. Forward the intent across WSL using the existing environment channel.

Route native shell-startup and daemon PTY tests through the established Node pool; unchanged Bun PTY empty-output failures also reproduce on the original baseline.

Why

The existing clipboard setup only covered launches that already identified the agent as Codex. Manual shell launches missed it. This extends the existing path without changing selection or mouse behavior.

Linked Issue

Remote-terminal report supplied for this work. Related existing setup: #34102.

Visual Proof

Before: manual remote launch has no clipboard marker and the isolated viewer clipboard sink stays empty.

Before remote manual copy

After: the same probe emits the expected text through the paired connection.

After remote manual copy

Real Codex 0.165.0 /copy, using an isolated saved response and no inference, delivered REMOTE_CODEX_COPY_PROOF through production OSC52 parsing and clipboard:writeTerminalText.

Real Codex copy

Testing

  • Independently reviewed and exercised by sub-agents.
  • 115 focused tests, 18 manual-launch matrix cases, and 15 native startup cases passed.
  • Thirty before/after Bash, Zsh, and Fish probes; PowerShell 7 container probes covering inherited SSH/TTY values, nonzero exit, and exception cleanup.
  • Fourteen real local-PTY launch tests passed, including three custom-argument regressions proven red before the correction. An independent reviewer passed 22 additional local/daemon launch controls covering custom rc paths, no-rc flags, explicit empty arguments, default clipboard wrappers, and controlled agent launches.
  • Hidden Electron with a real paired serve host: baseline/fixed wrapper probes and real Codex /copy; captured the final viewer clipboard write in an isolated sink. The real CLI also performed its native macOS host copy; that put the test marker on the host clipboard, so the sink did not isolate that native side effect.
  • Final head 6fb19ed: all 65 reported CI checks settled successfully, including all unit shards, shell contracts, E2E, packaging, native-platform persistence, all WSL variants, CodeRabbit, and JavaScript/TypeScript and Swift CodeQL.
  • Six independent Ubuntu 24.04 controls reproduced the system startup banner and verified exact profile-result extraction still rejects wrong startup, login mode, and missing markers.
  • Independent final-head Bash, Zsh, and Fish probes saved the wrapped call status immediately: all preserved nonzero status 3 before and after the bare control call, while keeping the remote marker out of the parent shell. This directly covers the nonblocking exit-status fixture suggestion from review.
  • Initial required local ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2: 22/23 checks passed. The unit check encountered 24 dependency-import failures, 20 native PTY failures, and one unrelated worktree-removal assertion. The dependency-path denial no longer reproduces with current dependency metadata; all 37 native PTY cases pass through the normal configured wrapper after the Node routing correction. The worktree assertion also fails on the original baseline with unchanged sources. Initial failure logs are retained. The final delta gate passed 20/20 selected checks, and the catalog-only gate passed 9/9; the initial broad unit check is still recorded as failed.

Review

No new polling, subprocess fanout, protocol fields, or typing-path work. Folder workspaces use the same shell path. Older hosts keep existing behavior; this fix requires updating the host and creating a new remote shell using the existing Bash, Zsh, Fish, or PowerShell wrapper. Absolute binary paths, command codex, and bare cmd.exe bypass those wrappers and retain their prior behavior. Configured shell arguments retain the existing daemon priority; custom Bash --rcfile or no-rc profiles may intentionally bypass wrapper installation. Desktop/mobile clipboard consumers use the existing OSC52 handling.

Agent skill upstream boundary

  • No upstream skill-installer source was copied.

Notes

Targets main after #34721 was merged. The original parent commit includes that already-merged one-line test-import repair.

macOS paired UI and Linux PowerShell 7 were exercised. Native Windows PowerShell 5.1, Windows .cmd, and live WSL were not run locally; CI covers supported platform checks.

Checklist

  • Focused change with before/after evidence.
  • Independent correctness, compatibility, cleanup, and performance review.
  • Final incremental local gates and final-head CI complete; the initial broad unit failure and reproduced baseline assertion remain documented above.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f074288a-bedc-4b6c-909d-604393da5a2a
Commits

Reviewing files that changed from the base of the PR and between 6fb19ed and 55b4ee2.

Files selected for processing: 5
  • config/scripts/vitest-node-runtime-files.mjs
  • src/main/daemon/pty-subprocess-env-inheritance.test.ts
  • src/main/daemon/pty-subprocess/spawn-environment.ts
  • src/main/providers/local-pty-launch-helpers.ts
  • src/main/providers/local-pty-provider-spawn-env.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Walkthrough

The launch environment now carries a remote-viewer clipboard flag through shell startup and WSL forwarding. Codex wrappers use the flag to set a temporary SSH_CONNECTION value when neither SSH_CONNECTION nor SSH_TTY is set. Environment cleanup removes inherited clipboard flags unless explicitly supplied. The shell environment finalizer also preserves terminal shell arguments in the specified launch configuration.

Priority: Normal

Merge Risk: Low · up to 55b4e

The change is mergeable with a narrow follow-up: make the POSIX and fish cases assert the wrapped Codex call’s exit status directly.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: restoring clipboard copying for Codex sessions started manually in remote shells.
Description check Passed The description is mostly complete. It covers the user impact, implementation, rationale, testing, visual proof, compatibility limits, review notes, and checklist. The linked issue is referenced as #3…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is mostly complete. It covers the user impact, implementation, rationale, testing, visual proof, compatibility limits, review notes, and checklist. The linked issue is referenced as #34102, although the description does not explicitly identify it as the issue fixed by this PR.

Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 15 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1a697286-90e5-42e3-b0e5-f219da85a850
Commits

Reviewing files that changed from the base of the PR and between 74a2ee5 and 483986d.

Files selected for processing: 15
  • config/scripts/vitest-node-runtime-files.mjs
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/ipc/pty/host-env/remote-viewer-clipboard-env.ts
  • src/main/ipc/pty/pty-spawn-env-terminal-basics.test.ts
  • src/main/pty/codex-shell-no-daemon.test.ts
  • src/main/pty/wsl-orca-env.test.ts
  • src/main/pty/wsl-orca-env.ts
  • src/main/shell-startup-features.ts
  • src/shared/codex-shell-function.ts
  • src/shared/remote-viewer-clipboard-env.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment thread src/main/shell-startup-features.ts Resolved
@nwparker nwparker mentioned this pull request Oct 28, 2026
10 tasks done
@nwparker
nwparker changed the base branch from main to nwparker/remote-validation-test-import October 28, 2026 04:26
@nwparker
nwparker force-pushed the nwparker/remote-codex-copy branch from 483986d to 1ccdcc7 Compare October 28, 2026 04:28
@nwparker
nwparker changed the base branch from nwparker/remote-validation-test-import to main October 28, 2026 05:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick comments: 1
src/main/pty/codex-shell-no-daemon.test.ts: 1

247-247: Trivial · Functional Correctness · Quick win

Check the status of codex clipboard in the POSIX and fish tests.

The POSIX and fish branches run command codex shell after codex clipboard and assert only result.status. That value comes from the trailing call, so the test never checks the clipboard call's exit status. The fake Codex returns FAKE_CODEX_EXIT for every non-help call, so a wrapper that drops or changes the clipboard status still produces the same final status and passes.

Save the status of codex clipboard before the bare call. Then exit with the saved value, or assert on it. Keep the environment check on the bare call.

This is a test-coverage gap. The current wrapper does not show a production failure.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ecf55902-087c-4ffb-b3d2-a5f42db54ba9
Commits

Reviewing files that changed from the base of the PR and between 483986d and 6984664.

Files selected for processing: 4
  • src/main/claude/claude-rewind-transcript.test.ts
  • src/main/providers/local-pty-default-shell.test.ts
  • src/main/providers/local-pty-finalize-environment.ts
  • src/main/pty/codex-shell-no-daemon.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@nwparker
nwparker force-pushed the nwparker/remote-codex-copy branch from 6fb19ed to 55b4ee2 Compare October 28, 2026 07:16
@nwparker
nwparker merged commit a21f79d into main Oct 28, 2026
70 checks passed
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