Skip to content

Refactor: split session.rs (1162 lines) into focused modules #17

@CREVIOS

Description

@CREVIOS

Problem

`src-tauri/src/rdp/session.rs` is 1,162 lines — a god module containing:

  • `SessionActor` struct and all its methods
  • `SessionManager` struct (registry + lifecycle)
  • `PerformanceMetrics` struct
  • `SessionState` enum
  • `SessionInfo` struct (serialized to frontend)
  • Mock session loop
  • Real RDP session loop
  • Frame emission logic
  • Input forwarding
  • Clipboard message flushing
  • Auto-reconnect with backoff
  • Helper functions (`normalize_remote_resolution`)

This makes it hard for contributors to understand the codebase and find where to make changes.

Proposed split

New file Contents ~Lines
`session/mod.rs` Re-exports, `SessionState`, `SessionInfo`, `PerformanceMetrics` ~80
`session/actor.rs` `SessionActor` struct + `new()` + `run()` ~200
`session/rdp_loop.rs` `run_real_session_loop()` — the main PDU processing loop ~300
`session/mock_loop.rs` `run_mock_session_loop()` — for testing without a server ~80
`session/manager.rs` `SessionManager` — registry, create/remove/list sessions ~200
`session/reconnect.rs` Auto-reconnect logic with exponential backoff ~150

Rules for the split

  • No behavior changes — pure refactor
  • All public APIs remain the same
  • `SessionActor` fields stay private (accessed via methods)
  • Use `pub(crate)` for inter-module visibility
  • Run `cargo test` before and after to verify no regressions

Files to modify

  • `src-tauri/src/rdp/session.rs` → split into `src-tauri/src/rdp/session/` directory
  • `src-tauri/src/rdp/mod.rs` — update module declaration

Priority: P2 — improves contributor experience

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions