/claim #200

Summary

Adds an opt-in keepalive feature to the existing windows-rdp module that prevents workspace autostop during active RDP sessions.

How it works

When keepalive = true, a background PowerShell script (coder_script) runs on workspace start that:

  1. Polls port 3389 every keepalive_interval seconds (default: 30) using Get-NetTCPConnection -LocalPort 3389 -State Established
  2. When an established RDP connection is detected, calls PUT /api/v2/workspaces/{workspace_id}/extend using the CODER_AGENT_TOKEN that the Coder agent sets automatically
  3. When the RDP session disconnects, stops sending activity bumps and the normal autostop countdown resumes

This uses the manual activity bump API recommended by @matifali in https://github.com/coder/registry/issues/200#issuecomment-3461026332.

Why this approach

  • Uses the correct API: Calls the documented workspace extend endpoint with CODER_AGENT_TOKEN rather than relying on stdout/stderr, coder stat, or registry keys (which only keep the TCP connection alive but don’t tell Coder the workspace is active)
  • Integrated into the existing module: No separate module needed; just set keepalive = true
  • Backward compatible: Defaults to false, no behavior change for existing users
  • Minimal and focused: ~80 lines of PowerShell, one new coder_script resource, two new variables

Usage

module "windows_rdp" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/windows-rdp/coder"
version = "1.4.0"
agent_id = coder_agent.main.id
keepalive = true
keepalive_interval = 30
}

Changes

  • main.tf: Added keepalive (bool) and keepalive_interval (number) variables, conditional data.coder_workspace data source, and coder_script.windows-rdp-keepalive resource
  • rdp-keepalive.ps1.tftpl: PowerShell script that monitors port 3389 and calls the extend API
  • main.tftest.hcl: Terraform plan tests for the new feature (and base module)
  • main.test.ts: TypeScript tests verifying keepalive script creation and content
  • README.md: Version bump to 1.4.0, added keep-alive usage example

Test plan

  • terraform test -verbose passes in the module directory
  • bun test main.test.ts passes (keepalive script creation, content validation, interval customization)
  • Existing tests continue to pass (backward compatibility)
  • Deploy with keepalive = true on a Windows workspace, connect via RDP, verify workspace deadline extends in Coder dashboard
  • Disconnect RDP, verify autostop countdown resumes normally

Claim

Total prize pool $151
Total paid $0
Status Pending
Submitted February 09, 2026
Last updated February 09, 2026

Contributors

BU

buildingvibes

@buildingvibes

100%

Sponsors

CO

Coder

@coder

$150
AT

Atif Ali

@matifali

$1