Skip to content

Fix SSH OpenCode commit message generation#5197

Open
andy-murr wants to merge 1 commit into
stablyai:mainfrom
andy-murr:fix/ssh-opencode-shell-path
Open

Fix SSH OpenCode commit message generation#5197
andy-murr wants to merge 1 commit into
stablyai:mainfrom
andy-murr:fix/ssh-opencode-shell-path

Conversation

@andy-murr

@andy-murr andy-murr commented Jun 11, 2026

Copy link
Copy Markdown

Excited to hopefully make my first contribution!

Video

opencode-ssh-fix.mov

Summary

  • Route SSH Source Control AI commit/PR generation through the user's login shell when requested, so agents installed by shell startup files (like OpenCode via nvm/Homebrew PATH setup) can be found.
  • Pass the shell-launch request from the SSH git provider for commit message and PR field generation, while preserving the existing Windows-safe spawn path.

Closes #4720.

Screenshots

No visual change.

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/relay/agent-exec-handler.test.ts src/main/providers/ssh-git-provider.test.ts
  • pnpm run build:relay
  • Manual SSH repro: configured an SSH target where plain non-interactive PATH did not find opencode, while $SHELL -ilc "command -v opencode" did; verified OpenCode Source Control generation filled the commit message instead of showing the remote PATH error.
  • pnpm run typecheck - currently fails on current origin/main in src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts, which is outside this PR's diff.
  • pnpm run lint - currently fails on current origin/main max-lines findings in existing renderer files outside this PR's diff.
  • pnpm test - focused SSH tests pass, but the full suite currently has unrelated failures in sidebar and PTY tests outside this PR's diff.
  • pnpm build - not run; this change only touches relay/provider behavior, and pnpm run build:relay was run for the changed relay path.

AI Review Report

Reviewed the code paths for SSH commit-message and PR-field generation, relay subprocess spawning, cancellation lanes, argument passing, and regression coverage. The main risk checked was introducing shell injection while switching to shell-based launch. The implementation uses exec "$@" with the binary and args passed as positional shell parameters instead of string-concatenating user input.

Cross-platform compatibility was checked explicitly:

  • macOS/Linux: only bash/zsh shell launch uses -ilc to inherit login/interactive PATH setup for SSH relay commands.
  • Windows: shell launch keeps the existing Windows-safe spawn path, including .cmd/.bat handling through cmd.exe.
  • SSH relay cancellation and operation-lane behavior remains covered by existing and updated tests.

Security Audit

Reviewed command execution and IPC payload handling. The new shell flag is only honored as a strict boolean, and the shell command does not interpolate the agent binary, model, cwd, or prompt into shell source. The prompt still travels through stdin for OpenCode/Codex-style agents, and existing timeout/cancellation limits remain in place.

No secrets, auth flows, or dependency changes are introduced.

Notes

The fix is intentionally scoped to non-interactive SSH Source Control AI generation. Normal non-shell execution remains the default unless the caller asks for shell PATH resolution.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 89dd0bbb-8c55-4e73-8745-015fed39bf80

📥 Commits

Reviewing files that changed from the base of the PR and between cc13535 and d5d50c9.

📒 Files selected for processing (4)
  • src/main/providers/ssh-git-provider.test.ts
  • src/main/providers/ssh-git-provider.ts
  • src/relay/agent-exec-handler.test.ts
  • src/relay/agent-exec-handler.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/providers/ssh-git-provider.ts
  • src/relay/agent-exec-handler.ts
  • src/relay/agent-exec-handler.test.ts

📝 Walkthrough

Walkthrough

This PR adds optional shell-wrapped execution support to remote command invocation. The SSH Git provider can now request shell execution by passing shell: true in the payload. The relay Agent Exec Handler receives this flag and, on macOS/Linux, resolves the user's default shell (bash or zsh) and wraps the command with -ilc flags to invoke it as an interactive login shell; Windows behavior and non-shell paths remain unchanged. Type contracts are extended across both sides, tests verify delegation and correct spawn behavior, and the implementation preserves existing Windows-safe spawn paths when shell execution is not requested.

🚥 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
Title check ✅ Passed The title 'Fix SSH OpenCode commit message generation' accurately describes the main change: enabling OpenCode to work for commit message generation over SSH by routing through the user's login shell.
Description check ✅ Passed The PR description includes most template sections: summary, screenshots, testing details, AI review report covering cross-platform compatibility, and security audit. However, it lacks explicit checkboxes for build and lint steps that were not completed.
Linked Issues check ✅ Passed The PR implementation meets the primary objective from issue #4720: enabling SSH commit-message generation to discover OpenCode and similar agents installed via shell startup files by routing through the user's login shell.
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving issue #4720: SSH git provider routing, relay agent-exec handler for shell-based spawning, and corresponding test updates. No unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c55ce06e-e56e-44a6-8a61-afd19944fb19

📥 Commits

Reviewing files that changed from the base of the PR and between 3607180 and cc13535.

📒 Files selected for processing (4)
  • src/main/providers/ssh-git-provider.test.ts
  • src/main/providers/ssh-git-provider.ts
  • src/relay/agent-exec-handler.test.ts
  • src/relay/agent-exec-handler.ts

Comment thread src/main/providers/ssh-git-provider.ts
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.

[Bug]: unable to use OpenCode as the agent for PR commits message generation

2 participants