Skip to content

Conversation

@pacmancoder
Copy link
Contributor

@pacmancoder pacmancoder commented Oct 17, 2025

Adds RDM (Remote Desktop Manager) message handling capabilities to devolutions-session, enabling bidirectional communication between the agent and RDM through the NOW protocol over the named pipe.

Blocked by: Devolutions/now-proto#57

Issue: PI-651

@github-actions
Copy link

Let maintainers know that an action is required on their side

  • Add the label release-required Please cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module) when you request a maintainer to cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module)

  • Add the label release-blocker Follow-up is required before cutting a new release if a follow-up is required before cutting a new release

  • Add the label publish-required Please publish libraries (`Devolutions.Gateway.Utils`, OpenAPI clients, etc) when you request a maintainer to publish libraries (Devolutions.Gateway.Utils, OpenAPI clients, etc.)

  • Add the label publish-blocker Follow-up is required before publishing libraries if a follow-up is required before publishing libraries

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This draft PR introduces support for Remote Desktop Manager (RDM) application lifecycle management through the NOW protocol, including capabilities detection, application launching, and window control operations.

  • Adds RDM-specific message handlers for capabilities, app start, and app actions
  • Implements registry-based RDM installation detection and version retrieval
  • Adds process monitoring and window management functionality for RDM instances

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
devolutions-session/src/main.rs Adds devolutions_agent_shared import for RDM registry access
devolutions-session/src/dvc/task.rs Implements RDM message handlers, process spawning/monitoring, and window control
devolutions-session/Cargo.toml Updates now-proto-pdu to 0.4.0 and adds devolutions-agent-shared dependency
crates/devolutions-agent-shared/src/windows/registry.rs Adds product version encoding variants and install location retrieval function
crates/devolutions-agent-shared/src/windows/mod.rs Defines RDM_UPDATE_CODE constant for registry lookups
crates/devolutions-agent-shared/src/lib.rs Updates agent version retrieval to use new encoding parameter
Cargo.lock Updates dependency versions including now-proto-pdu 0.4.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +93 to +92
let short_year = match version_encoding {
ProductVersionEncoding::Agent => (product_version >> 24) + 2000,
ProductVersionEncoding::Rdm => (product_version >> 24) + 0x700,
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Magic number: The constant 0x700 (1792 in decimal) for RDM version encoding is unexplained. This magic number makes the code difficult to understand and maintain. Consider adding a comment explaining what this value represents and why it's used for RDM version calculation, or define it as a named constant with documentation.

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

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

Good question, I found this const empirically, @thenextman, by any chance, maybe you know how RDM version is encoded in registry?

@vnikonov-devolutions vnikonov-devolutions force-pushed the feat/agent-rdm-messages-bootstrap branch from 9241bee to 6d370a2 Compare December 24, 2025 23:58
@vnikonov-devolutions vnikonov-devolutions changed the title [DRAFT][WIP] feat(session): RDM messages bootstrap [DRAFT][WIP] feat(session): RDM messages and pipe passthrough logic Dec 25, 2025
@vnikonov-devolutions vnikonov-devolutions force-pushed the feat/agent-rdm-messages-bootstrap branch from 6d370a2 to 4ab4249 Compare December 25, 2025 13:48
@vnikonov-devolutions vnikonov-devolutions changed the title [DRAFT][WIP] feat(session): RDM messages and pipe passthrough logic feat(agent): RDM messages and pipe passthrough logic Dec 25, 2025
@vnikonov-devolutions
Copy link

Technical details

  • DevolutionsAgent(devolutions-session.exe) is able now to find RDM installation, launch it on demand, and establish bidirectional communication channel.
  • RDM opens named pipe (NowRdmHost implemented in feat(client): add RDM host handler and improve RDM client API now-proto#57) which is then used by devolutions-session to proxy all RDM* messages received from client side RDM (DVC) to server side RDM (local machine).
  • Pipe readiness is ensured via NamedEvent with auto-reset. RDM signals when pipe is ready, and devolutions-session waits for pipe after RDM is launched.

Additional changes

  • Various small changeds in `win-api-wrapperss crate
  • Updated MSI version querying code to accommodate different version encodings in registry
  • Fixed bug when we crash with an insufficient buffer when receiving DVC messages.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 11 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vnikonov-devolutions
Copy link

@copilot fix/apply last batch of copilot comments/suggestions. If I left comments in those conversations - do as comment says for resolution. PR should contain all changes in a single batch.

Copy link
Contributor

Copilot AI commented Dec 25, 2025

@vnikonov-devolutions I've opened a new pull request, #1647, to work on those changes. Once the pull request is ready, I'll request review from you.

Addresses review comments on PR for RDM message handling and pipe
passthrough logic.

## Safety & Correctness

- **Integer overflow**: Use `saturating_mul` for timeout_ms calculation
(prevents overflow when timeout_secs is large)
- **Race condition**: Replace check-then-set pattern with
`compare_exchange` in `process_app_start` to atomically transition
Disconnected→Connecting
- **State recovery**: Reset `connection_state` to Disconnected when
`process_app_start_impl` fails, allowing retry
- **Channel closure**: Explicitly handle `None` from `dvc_rx.recv()` to
avoid busy loop when channel closes
- **Path comparison**: Use `eq_ignore_ascii_case` for RDM process
detection (Windows paths are case-insensitive)

## Code Quality

- **Error visibility**: Log errors when READY notification fails instead
of silent `let _ =`
- **Documentation**: Clarify capabilities negotiation semantics
(negotiated subset vs. downgraded)
- **Magic numbers**: Document 0x700 offset in RDM MSI version encoding
(empirically derived)
- **Dead code**: Remove unused environment block creation and HashMap
import

## Example: Race Condition Fix

```rust
// Before: Non-atomic check-then-set allows duplicate spawns
match current_state {
    Disconnected => {
        self.connection_state.store(Connecting, Ordering::Release);
    }
}

// After: Atomic transition prevents race
loop {
    match current_state {
        Disconnected => {
            match self.connection_state.compare_exchange(
                Disconnected, Connecting, Ordering::AcqRel, Ordering::Acquire
            ) {
                Ok(_) => break,  // Won the race
                Err(actual) => current_state = actual; continue,  // Retry
            }
        }
    }
}
```

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: vnikonov-devolutions <246051166+vnikonov-devolutions@users.noreply.github.com>
@vnikonov-devolutions vnikonov-devolutions marked this pull request as ready for review December 25, 2025 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants