Skip to content

fix(ssh): retry failed plugin installation on settings change - #24140

Closed
AhmedNAgy25 wants to merge 2 commits into
stablyai:mainfrom
AhmedNAgy25:fix/ssh-relay-plugin-install-settings-retry
Closed

AhmedNAgy25 wants to merge 2 commits into
stablyai:mainfrom
AhmedNAgy25:fix/ssh-relay-plugin-install-settings-retry

Conversation

@AhmedNAgy25

Copy link
Copy Markdown
Contributor

ELI5

Retry failed remote agent hook/plugin installation requests on SSH hosts with backoff when settings change, re-reading the latest configuration on each attempt.

What Changed

  • Before: When hook-related settings (disabledTuiAgents, agentStatusHooksEnabled) changed while connected to an SSH host, SshRelaySession.registerProviders called installPluginsOnRelay(mux) in the background without retry. If the agent_hook.installPlugins multiplexer request encountered a transient failure (e.g. SSH_MUX_REQUEST_TIMEOUT or network congestion), the warning was logged and the relay retained stale plugin sources until reconnect. Disabling an agent left its plugin active on the remote host, and newly enabled agents failed to report status.
  • After: Failed agent_hook.installPlugins requests automatically retry up to 3 times with a 1,000ms delay (SSH_RELAY_PLUGIN_INSTALL_MAX_RETRIES = 3, SSH_RELAY_PLUGIN_INSTALL_RETRY_DELAY_MS = 1,000ms). Each retry attempt queries the latest settings state, ensuring that subsequent settings edits during the retry window are reflected. If a new settings change occurs or if the session tears down (teardownProviders / dispose), pending retry timers are cancelled immediately to prevent leaks or duplicate requests.
  • Mechanism: Added pluginInstallRetryTimer and cancelPluginInstallRetry() in SshRelaySession. In installPluginsOnRelay(mux, retryAttempt = 0), guarded execution against disposed multiplexers or torn-down sessions (this.isDisposed(), this.mux !== mux, mux.isDisposed()). Added retry scheduling in catch for transient errors, while keeping immediate returns for unrecoverable codes (-32601, 'CONNECTION_LOST', 'DISPOSED').

Why

SSH hosts operate over remote network multiplexers where transient RPC timeouts can occur under load or connection jitter. Retrying transient failures with backoff while respecting teardown boundaries prevents status reporting from silently dropping out until the user reconnects.

Linked Issue

If you do not have one and are an outside contributors, your PR wiil be ignored. Refs is not sufficient. Link an actual issue

Fixes #24122

Visual Proof

N/A — Background SSH relay session RPC retry mechanism; no UI modifications.

Testing

  • Added unit tests in src/main/ssh/ssh-relay-session-managed-hooks.test.ts:

    • retries failed plugin installation on settings change and re-reads latest settings
    • cancels pending plugin installation retry on session teardown
  • Ran full test suites:

    • src/main/ssh/ssh-relay-session-managed-hooks.test.ts (5 passed)
    • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts (13 passed)
  • Quality gates passed:

    • check-changed-code-quality.mjs passed with 0 findings across changed files.
    • pnpm tc:node passed with 0 errors.
  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Assisted by Google DeepMind Antigravity agent.

Review

Backward-compatible RPC retry on the existing agent_hook.installPlugins channel. No protocol or serialization changes.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds retry logic for SSH plugin installation on settings change.

The PR appears safe to merge; no outstanding findings were identified.

Findings

  1. P2 Permanent errors trigger retries ▶

Summary

The PR adds bounded retries for SSH relay plugin installation, re-reads settings on each attempt, and cancels retries when settings change or providers tear down. The follow-up changes fence superseded attempts by generation, exclude known permanent errors from retry, and add regression tests.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Settings change or provider registration] --> B[Install plugins with current settings]
  B -->|Success or permanent error| C[Stop]
  B -->|Transient error| D{Retry limit reached?}
  D -->|No| E[Wait one second]
  E -->|Generation still current| B
  E -->|Superseded or torn down| C
  D -->|Yes| C
Loading

Reviews (2) · Last reviewed commit: "fix(ssh): track install generation, prev..."

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0ad1dd51-c753-419a-8567-c1b3c5661437

📥 Commits

Reviewing files that changed from the base of the PR and between b28aa0a and 069a97d.

📒 Files selected for processing (2)
  • src/main/ssh/ssh-relay-session-managed-hooks.test.ts
  • src/main/ssh/ssh-relay-session.ts

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


📝 Walkthrough

Walkthrough

The SSH relay session now retries eligible plugin-install failures up to three times after the initial attempt, with a 1,000 ms delay. It checks that the session and mux remain active before retrying and cancels a pending retry when a new install starts or provider teardown occurs. Tests cover retries using the latest settings, cancellation after session disposal, byte-cap errors, and superseded failures.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 069a9

No merge-blocking issue is identified in the supplied evidence. The retry change appears ready to merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 069a9

The retries are bounded and cancel outdated work without adding permissions or accepting new plugin-source inputs. No introduced security issue was established, but behavior across older remote installations remains partially verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The direct affected state is the receiving SSH daemon’s plugin-source cache, which feeds agent launch environments. Retries reuse this existing authority and source-production path; the inspected change does not add cross-host authority or a new arbitrary-source input.

Trust Boundaries and Controls

  • observed — Retry initiation and delayed callbacks require a live session, the same live multiplexer, and the current generation. The existing remote-hook feature gate is rechecked on each attempt. These controls prevent stale local failures from creating new requests after supersession or teardown.

Resilience and Maintainability Implications

  • inferred — A timeout can leave the installation outcome ambiguous despite sending cancellation. Repeating identical source assignments is idempotent in the inspected SSH cache implementation, and its handler applies mutations synchronously. Latest-settings convergence still depends on delivery order because no generation crosses the RPC boundary; complete queue-ordering verification remains partial.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and accurately identifies the main change: retrying failed SSH plugin installation when settings change.
Description check ✅ Passed The description covers the required sections, links issue #24122, explains the user impact and mechanism, documents testing, and marks the visual proof as not applicable. It does not include a separat…
Linked Issues check ✅ Passed The changes satisfy the coding requirements in issue #24122. installPluginsOnRelay retries transient failures up to three times with a 1,000 ms delay. Each retry reads settings again. A newer instal…
Out of Scope Changes check ✅ Passed The pull request changes SSH relay plugin-install retry handling and its tests. The changes directly support issue #24122. No unrelated protocol, serialization, or feature changes appear in the review…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.

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

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b20c0103-9f08-424c-954a-ec9cd796c3ad

📥 Commits

Reviewing files that changed from the base of the PR and between 85f8d6b and b28aa0a.

📒 Files selected for processing (2)
  • src/main/ssh/ssh-relay-session-managed-hooks.test.ts
  • src/main/ssh/ssh-relay-session.ts

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

Comment thread src/main/ssh/ssh-relay-session.ts Resolved
Comment thread src/main/ssh/ssh-relay-session.ts Resolved
Comment thread src/main/ssh/ssh-relay-session.ts Outdated
err instanceof Error ? err.message : String(err)
}`
)
if (retryAttempt < SSH_RELAY_PLUGIN_INSTALL_MAX_RETRIES) {

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 Permanent errors trigger retries The retry condition also accepts errors that another attempt cannot resolve. For example, the relay rejects an oversized plugin source, but this code sends three more installation requests and logs more warnings for the same invalid source. Limit retries to transient failures to avoid unnecessary SSH traffic and warning noise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 069a97d. Added isTransientPluginInstallError helper to filter out non-transient errors such as relay byte cap limits (PLUGIN_SOURCE_MAX_BYTES), -32602 invalid params, and teardowns. Non-transient errors log a warning once and do not schedule retries. Added unit test asserting oversized payloads are not retried.

@pullfrog pullfrog 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.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

  • Retry on transient install failure — SshRelaySession.installPluginsOnRelay now retries a failed agent_hook.installPlugins request up to 3 times at a fixed 1,000ms delay, re-reading store.getSettings() on every attempt so settings edits during the retry window are reflected (src/main/ssh/ssh-relay-session.ts).
  • Teardown-aware cancellation — a single pending retry timer is cancelled at the start of any new install and in teardownProviders; the callback re-checks isDisposed() / this.mux === mux / mux.isDisposed() before re-issuing.
  • Tests — added retry-with-latest-settings and no-retry-after-teardown cases in ssh-relay-session-managed-hooks.test.ts (I ran the file: 5 passed).

I traced the lifecycle interaction (establish / reconnect / registerProviders / teardownProviders / dispose / detach) and could not construct a sequence where a request is issued against a disposed session or a non-current mux, or where a needed retry is silently dropped. The retry budget is bounded and retryAttempt is passed by value.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/main/ssh/ssh-relay-session.ts Resolved

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Install-generation tracking — installPluginsOnRelay now carries a pluginInstallGeneration; each fresh settings-triggered install calls cancelPluginInstallRetry() (bump generation + clear timer) so superseded attempts and their retries are invalidated before issuing another request (src/main/ssh/ssh-relay-session.ts).
  • Single retry timer guaranteed — every fresh install clears the prior handle before scheduling, so at most one retry timer is live; this resolves the timer-overwrite concern raised in the prior review and by CodeRabbit.
  • Permanent-error filtering — isTransientPluginInstallError skips retries for -32601/-32602/CONNECTION_LOST/DISPOSED and the relay's byte-cap message (exceeds … byte cap), so deterministic failures no longer burn the retry budget.
  • Tests — added permanent-error and superseded/overlapping-failure cases; ran src/main/ssh/ssh-relay-session-managed-hooks.test.ts (7 passed). Both new tests can fail: the permanent-error case would retry without the filter, and the overlapping case would fire a second retry without the generation guard.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin

OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

SSH still works: Orca connects to the host over SSH and routes workspace operations through the managed remote Orca server (orcad). These merges remove the legacy SSH relay, not SSH support.

Closing as obsolete after the merged SSH relay retirement in #27214 and #27215. This PR concerns the SSH relay server and its relay-only handlers. #27214 removed the desktop relay connection/fallback path; #27215 deleted the SSH relay server, deployment assets, and relay-only tests. SSH hosts now use the managed Orca server (orcad), and unsupported hosts fail explicitly, so this relay-specific work is no longer planned. This closes the proposed relay implementation; it does not claim that any independent local, WSL, or managed-server behavior was fixed.

@OrcaWin OrcaWin closed this Oct 11, 2026
@OrcaWin

OrcaWin commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Thanks @AhmedNAgy25 — on current main, SSH hosts run Orca's managed server (orcad), which installs agent hooks itself on start (#27319) and re-applies them on the host when hook settings change, so there's no network request left to retry. Closing as fixed.

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]: A failed plugin install on an SSH host is never retried after a settings change

2 participants