Skip to content

feat: support Codex sessions over SSH remote bridge - #628

Open
SheltonZhu wants to merge 10 commits into
Octane0411:mainfrom
SheltonZhu:feat/codex-ssh-remote
Open

feat: support Codex sessions over SSH remote bridge#628
SheltonZhu wants to merge 10 commits into
Octane0411:mainfrom
SheltonZhu:feat/codex-ssh-remote

Conversation

@SheltonZhu

@SheltonZhu SheltonZhu commented Jul 31, 2026

Copy link
Copy Markdown

Summary

Extends the SSH remote bridge so Codex sessions running on a remote server (including via Codex Desktop's SSH remote / codex app-server) appear in Open Island, matching the existing Claude Code remote flow.

Changes

  • feat: support Codex sessions over SSH remote bridge (a1ac4a7)
    • Portability hook client (scripts/open-island-hooks.py) supports --source codex
    • CodexHookPayload carries a remote flag set by the Python hook client
    • Codex SessionStart / ensureSessionExists sessions are marked isRemote
    • scripts/remote-setup.sh deploys and merges Codex hooks on the remote
    • Settings copy updated to mention Codex alongside Claude Code
  • test: migrate remaining XCTest suites to Swift Testing (ef69115)
  • docs: note hook trust timing and tunnel ownership for Codex SSH remote (7cf872f)

Verification

  • Remote codex exec and Codex Desktop SSH remote sessions create sessions in Open Island (verified end-to-end over the RemoteForward Unix socket tunnel)
  • Hook events receive acknowledged bridge responses; session persisted in session-terminals.json
  • Existing Swift Testing suites pass in the repo

Summary by CodeRabbit

  • New Features

    • Added support for monitoring Codex sessions on remote servers alongside Claude Code.
    • Remote and local Codex sessions are now identified and tracked correctly.
    • Remote setup automatically configures Codex hooks while preserving existing settings.
    • Improved validation for forwarded socket access and remote session tracking.
    • Codex permission requests now remain available for up to 24 hours.
  • Documentation

    • Updated SSH setup guidance for Claude Code and Codex.
    • Documented remote-session status, trust approvals, timeout behavior, and socket-forwarding guidance.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b5236c26-f3a8-4895-a0df-1f3c538dfd75

📥 Commits

Reviewing files that changed from the base of the PR and between 8349f7a and 1a10e81.

📒 Files selected for processing (1)
  • scripts/remote-setup.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/remote-setup.sh

📝 Walkthrough

Walkthrough

Codex hook payloads now carry remote-session status through bridge session events. Remote setup configures Codex hooks and documents SSH behavior. Selected application and core tests migrate from XCTest to Swift Testing.

Changes

Codex remote-session support

Layer / File(s) Summary
Remote-session payload and bridge propagation
Sources/OpenIslandCore/CodexHooks.swift, Sources/OpenIslandCore/BridgeServer.swift, Tests/OpenIslandCoreTests/CodexRemoteSessionTests.swift, docs/hooks.md
CodexHookPayload decodes an optional remote flag. Codex session-start events set isRemote for direct and on-demand sessions. Tests cover remote, local, and omitted values.
Remote Codex setup and documentation
scripts/remote-setup.sh, scripts/open-island-hooks.py, docs/ssh-setup.md, Sources/OpenIslandApp/Views/SettingsView.swift
The setup script configures Codex hooks, preserves unrelated hook groups, enables the Codex hooks feature, and handles remote UID mapping. SSH documentation and settings describe Claude Code and Codex remote monitoring.
Swift Testing migration and validation
Tests/OpenIslandAppTests/*, Tests/OpenIslandCoreTests/OpenCodeSessionRegistryTests.swift
Selected tests use Swift Testing structures, @Test, and #expect. Terminal jump integration handling uses conditional execution and detailed AppleScript errors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Codex
  participant CodexHookPayload
  participant BridgeServer
  participant SessionStartEvent
  Codex->>CodexHookPayload: Send session-start payload
  CodexHookPayload->>BridgeServer: Decode remote flag
  BridgeServer->>SessionStartEvent: Set isRemote
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding Codex session support to the SSH remote bridge.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/remote-setup.sh`:
- Around line 115-116: Update the Codex event handling in
scripts/open-island-hooks.py so send_command uses a 3600-second timeout when
hook_event_name is PermissionRequest, while retaining the existing 45-second
timeout for all other events.

In `@Tests/OpenIslandAppTests/TerminalJumpServiceTests.swift`:
- Around line 56-62: Update
testGhosttyJumpIntegrationMatchesFocusedTerminalForLiveSurfaces so an enabled
integration run does not silently pass when liveGhosttyTerminals() returns no
terminals. Use a supported test-skip mechanism if available; otherwise record an
explicit test failure while preserving the existing behavior when terminals are
present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2508795f-308a-4435-9069-c8acf3c5bdba

📥 Commits

Reviewing files that changed from the base of the PR and between 6e5e7a6 and 7cf872f.

📒 Files selected for processing (11)
  • Sources/OpenIslandApp/Views/SettingsView.swift
  • Sources/OpenIslandCore/BridgeServer.swift
  • Sources/OpenIslandCore/CodexHooks.swift
  • Tests/OpenIslandAppTests/ForegroundTerminalSessionProbeTests.swift
  • Tests/OpenIslandAppTests/KeystrokeInjectorTests.swift
  • Tests/OpenIslandAppTests/TerminalJumpServiceTests.swift
  • Tests/OpenIslandCoreTests/CodexRemoteSessionTests.swift
  • Tests/OpenIslandCoreTests/OpenCodeSessionRegistryTests.swift
  • docs/hooks.md
  • docs/ssh-setup.md
  • scripts/remote-setup.sh

Comment thread scripts/remote-setup.sh Outdated
Comment thread Tests/OpenIslandAppTests/TerminalJumpServiceTests.swift Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
scripts/remote-setup.sh (1)

174-218: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Tighten the [features] table-header detection to avoid corrupting config.toml on nested arrays.

The section-boundary check at Line 194 (stripped.startswith("[") and stripped.endswith("]")) can misfire on a bracketed line inside a multi-line array that has no trailing comma, for example the last row of a nested array like [3, 4] right before the array's closing ]. If such a line appears inside the [features] table, the script exits in_features prematurely and can insert hooks = true in the middle of that array, corrupting the file.

This is a narrow edge case for a [features] table (which today likely only holds simple booleans), and a full switch to a TOML library isn't a clean option here: tomllib is stdlib only from Python 3.11 and cannot write TOML, and style-preserving editing of an existing file would need the third-party tomlkit package, which conflicts with the script's stated "Python 3.6+, no guaranteed extra packages" remote prerequisite. A small heuristic tightening lowers the risk without adding a dependency:

🛡️ Proposed heuristic tightening
+import re
+
+TABLE_HEADER_RE = re.compile(r'^\[+[^\[\]="]+\]+$')
+
 for line in lines:
     stripped = line.strip()
     if stripped == "[features]":
         in_features = True
         has_features = True
         out.append(line)
         continue
-    if in_features and stripped.startswith("[") and stripped.endswith("]"):
+    if in_features and TABLE_HEADER_RE.match(stripped):
         if not hooks_seen:
             out.append("hooks = true")
         in_features = False
         out.append(line)
         continue
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/remote-setup.sh` around lines 174 - 218, tighten the section-boundary
detection in the remote setup script’s features-processing loop so array
elements such as bracketed rows inside multi-line TOML arrays are not treated as
table headers. Recognize only valid single-table headers, excluding nested-array
syntax and bracketed array values, while preserving insertion and replacement of
hooks within the actual [features] table.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/remote-setup.sh`:
- Around line 147-152: Update the Python hook client’s send_command timeout
selection so hook_event_name == PermissionRequest uses 3600 seconds, while all
other Codex events retain the existing 45-second timeout. Locate the change in
the send_command flow of open-island-hooks.py and preserve the existing event
handling.
- Around line 34-38: Update the REMOTE_UID resolution command to remove the
`2>/dev/null` stderr suppression from the `ssh "$REMOTE" "id -u"` probe, while
preserving the existing output normalization and numeric validation in the
surrounding block.

---

Nitpick comments:
In `@scripts/remote-setup.sh`:
- Around line 174-218: tighten the section-boundary detection in the remote
setup script’s features-processing loop so array elements such as bracketed rows
inside multi-line TOML arrays are not treated as table headers. Recognize only
valid single-table headers, excluding nested-array syntax and bracketed array
values, while preserving insertion and replacement of hooks within the actual
[features] table.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2968c576-de23-4b2f-8d99-079455c36ba6

📥 Commits

Reviewing files that changed from the base of the PR and between 7cf872f and faf3ab6.

📒 Files selected for processing (2)
  • docs/ssh-setup.md
  • scripts/remote-setup.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/ssh-setup.md

Comment thread scripts/remote-setup.sh Outdated
Comment thread scripts/remote-setup.sh

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
scripts/remote-setup.sh (2)

204-233: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Parse TOML table headers with trailing comments.

The updater detects [features] by exact string match and treats only a line ending with "]" as a section boundary. Valid comments after table headers are not part of the header, so [features] # existing comment can create a duplicate [features] section and commented headers can let the next detected true hooks writing stay in the wrong section. Parse table headers by stripping trailing comments, or use a TOML parser.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/remote-setup.sh` around lines 204 - 233, The configuration updater’s
section detection in the shown loop fails for TOML table headers with trailing
comments. Normalize each line by removing trailing comments before checking for
“[features]” or identifying section boundaries, while preserving the original
line in out; ensure hooks = true is inserted into the existing features section
and not duplicated or carried into a later section.

74-82: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve mixed hook groups and identify managed hooks by exact command.

The current cleanup removes any hook group whose command text contains open-island-hooks.py. If a user adds another hook to that group, rerunning setup removes the whole group. Remove only matching Open Island hook entries, keep the group when other hooks remain, and use exact command identity from the installer-managed commands rather than a filename substring.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/remote-setup.sh` around lines 74 - 82, Update group_has_open_island
and the cleanup logic in scripts/remote-setup.sh to match only the exact
installer-managed Open Island commands, not filename substrings. Remove matching
hook entries individually, preserve any non-managed hooks, and retain the group
when other hooks remain.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@scripts/remote-setup.sh`:
- Around line 204-233: The configuration updater’s section detection in the
shown loop fails for TOML table headers with trailing comments. Normalize each
line by removing trailing comments before checking for “[features]” or
identifying section boundaries, while preserving the original line in out;
ensure hooks = true is inserted into the existing features section and not
duplicated or carried into a later section.
- Around line 74-82: Update group_has_open_island and the cleanup logic in
scripts/remote-setup.sh to match only the exact installer-managed Open Island
commands, not filename substrings. Remove matching hook entries individually,
preserve any non-managed hooks, and retain the group when other hooks remain.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 785e19f6-998a-4770-a4bf-02c438b07494

📥 Commits

Reviewing files that changed from the base of the PR and between faf3ab6 and 5eb6e8b.

📒 Files selected for processing (1)
  • scripts/remote-setup.sh

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.

2 participants