Skip to content

Refactor task#718

Merged
randy3k merged 2 commits intomasterfrom
refactor-task
Mar 7, 2026
Merged

Refactor task#718
randy3k merged 2 commits intomasterfrom
refactor-task

Conversation

@randy3k
Copy link
Member

@randy3k randy3k commented Mar 6, 2026

I have decoupled the changes in the task manager from 0.3.17 release #717

Most significantly it fixes the coverage test issue. I have also added a functionality to prune idle sessions to reduce memory footprint. I have however also changed some of the cpu_load logic (not sure 0.8 for parsing tasks make sense, 0.8 for parsing + 0.5 for lintr > 100%), please took a look @renkun-ken.

- Overhaul session management and process termination logic.
- Resolve bugs in session teardown and task handling.
- Improve test coverage and stability for background tasks.
Copy link

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

Refactors the task execution subsystem to remove the old SessionPool abstraction, improve test/coverage reliability, and add pruning of idle callr::r_session workers to reduce memory footprint.

Changes:

  • Reworked Task/TaskManager to optionally run tasks in persistent callr::r_session workers and prune idle sessions.
  • Updated LanguageServer to use the new TaskManager session model for parse/diagnostics tasks.
  • Added/updated testthat coverage-sensitive tests and adjusted test client shutdown behavior.

Reviewed changes

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

Show a summary per file
File Description
R/task.R Implements new session-backed task execution, session creation, and idle-session pruning; adds shutdown cleanup.
R/languageserver.R Switches parse/diagnostics task managers to use_session=TRUE under the refactored TaskManager API.
R/session.R Removes the previous Session/SessionPool implementation.
tests/testthat/test-task.R Adds Task/TaskManager tests (including covr-mode and idle session pruning).
tests/testthat/helper-utils.R Changes test client shutdown/cleanup behavior, with special handling under R_COVR.

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

- Add `session_idle_timeout` to `TaskManager` (default 60s).
- Implement `prune_sessions` to automatically close and remove idle sessions.
- Add test case to verify session cleanup after inactivity.
@randy3k
Copy link
Member Author

randy3k commented Mar 6, 2026

Most of the copilot suggestions are related to closing the processes explicitly when running covr. It is however intentional because killing them will cause r-lib/covr#509

Copy link
Member

@renkun-ken renkun-ken left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!

@randy3k randy3k merged commit a344016 into master Mar 7, 2026
6 checks passed
@randy3k randy3k deleted the refactor-task branch March 7, 2026 00:24
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.

3 participants