Skip to content

docs: plan for #305 — workbench idle session auto-suspend behavior#315

Open
posit-vip-triage[bot] wants to merge 5 commits into
mainfrom
bot-plan-issue-305-6102e32e540a2d44
Open

docs: plan for #305 — workbench idle session auto-suspend behavior#315
posit-vip-triage[bot] wants to merge 5 commits into
mainfrom
bot-plan-issue-305-6102e32e540a2d44

Conversation

@posit-vip-triage

@posit-vip-triage posit-vip-triage Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Plan for issue #305: workbench idle session auto-suspend behavior

This PR revises the generated plan with two critical design fixes applied on top of the #349/#336 merges.

What the plan proposes

  • New [workbench] idle_timeout_minutes and idle_grace_seconds TOML fields in WorkbenchConfig (alongside job_timeout and test_packages, not after kubernetes)
  • Two new scenarios in src/vip_tests/workbench/test_session_idle.feature tagged @workbench @performance:
    • Idle session auto-suspends after the configured timeout — waits for Suspended state with a configurable grace window (idle_grace_seconds, default 60 s)
    • Active session is not suspended while work is running — drives the session with periodic activity, then asserts still Active

Design: periodic activity loop (not a blocking Sys.sleep)

The active-session scenario keeps the session alive by sending periodic interactive input events via rstudio_eval every 90 seconds across the idle-timeout window — not a single blocking Sys.sleep spanning the whole window. A console blocked in Sys.sleep is R being busy, not a session registering user activity; Workbench's idle timeout is driven by interactive input events. The loop:

POLL_INTERVAL_S = 90
end_time = time.monotonic() + (idle_timeout_minutes * 60) + idle_grace_seconds
while time.monotonic() < end_time:
    rstudio_eval(page, "invisible(NULL)", timeout=15_000)
    remaining = end_time - time.monotonic()
    if remaining > 0:
        time.sleep(min(POLL_INTERVAL_S, remaining))

Each rstudio_eval call types a trivial expression into the RStudio console, emitting a real input event that resets the idle clock — faithful to "activity correctly resets the idle clock" from the issue.

Configurable grace window

The grace window added on top of idle_timeout_minutes is exposed as idle_grace_seconds: int = 60 in WorkbenchConfig. Deployments with high clock drift or slow suspend response can increase this value in vip.toml. The vip.toml.example documents both fields:

idle_timeout_minutes = 5   # must be ≤ 15 for the idle scenarios to run
idle_grace_seconds = 60    # seconds added on top of idle_timeout_minutes before asserting suspend

Runtime ceiling: 15 minutes

These scenarios are only viable against deployments configured with a short idle timeout. The implementation skips (with a clear message) when idle_timeout_minutes > 15:

MAX_VIABLE_IDLE_TIMEOUT_MINUTES = 15

if timeout > MAX_VIABLE_IDLE_TIMEOUT_MINUTES:
    pytest.skip(
        f"idle_timeout_minutes={timeout} exceeds the test ceiling of "
        f"{MAX_VIABLE_IDLE_TIMEOUT_MINUTES} min — configure the deployment "
        "with a shorter timeout to run these scenarios"
    )

The vip.toml.example will use idle_timeout_minutes = 5 (not 120) and note the ceiling. A 120-minute example value would imply a 2+ hour test run, which is not viable.

Note on TERMINAL_SESSION_FAILURE_STATES

TERMINAL_SESSION_FAILURE_STATES in src/vip_tests/workbench/conftest.py:39 contains only ("Failed",)"Suspended" is intentionally absent, so PR #320's fail-fast logic will not false-fail the idle scenario when the session legitimately reaches Suspended state.


Implements plan for #305

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown


## Open questions

- The issue proposes a grace window (timeout + 60s) to account for clock drift. Should this be a fixed 60-second buffer, a configurable field, or a percentage of the timeout? Defaulting to a fixed 60-second buffer is simplest and matches the issue's suggestion. This can be revisited if deployments with high clock drift are encountered.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot configurable

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.

Done — the grace window is now a configurable idle_grace_seconds: int = 60 field in WorkbenchConfig (alongside idle_timeout_minutes). The plan has been updated throughout: config wiring, fixture snippet, activity loop, vip.toml.example docs, and verification selftest list. The open question is resolved. Commit: docs: make idle grace window configurable via idle_grace_seconds field.

Co-authored-by: ian-flores <18703558+ian-flores@users.noreply.github.com>
Copilot AI requested a review from ian-flores June 11, 2026 17:33
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.

2 participants