8000 refactor: centralized tasks manager by gastoner · Pull Request #13223 · podman-desktop/podman-desktop · GitHub
[go: up one dir, main page]

Skip to content

Conversation

gastoner
Copy link
Contributor
@gastoner gastoner commented Jul 16, 2025

What does this PR do?

Changes logic from storing boolean value to object/undefined for experimental features, uses new experimental configuration manager #13316

More info in #13095

Screenshot / video of UI

What issues does this PR fix or reference?

Closes #13201

Needs rebase after #13227 is merged

THOSE PRs MUST be merged together:
#13225
#13224
#13223
#13226
#13227

How to test this PR?

  • Tests are covering the bug fix or the new feature

Copy link
Contributor
coderabbitai bot commented Jul 16, 2025
📝 Walkthrough

"""

Walkthrough

The changes refactor the TaskManager class and its test suite to introduce a centralized dependency on an ExperimentalConfigurationManager for managing experimental configuration features. The TaskManager constructor is updated to accept this new dependency, and its logic for checking experimental feature enablement is modified to use this manager instead of directly querying the configuration registry. Corresponding updates are made in the test suite to mock and inject this dependency, and to use a shared taskManager instance. The configuration schema for the experimental task manager is also updated from a boolean to an object type, with the default value removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Assessment against linked issues

Objective Addressed Explanation
Implement centralized object solution for tasks manager (#13201)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

Suggested reviewers

  • benoitf
  • jeffmaury

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 378f335 and c48de1f.

📒 Files selected for processing (2)
  • packages/main/src/plugin/tasks/task-manager.spec.ts (3 hunks)
  • packages/main/src/plugin/tasks/task-manager.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/main/src/plugin/tasks/task-manager.spec.ts
  • packages/main/src/plugin/tasks/task-manager.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: linter, formatters
  • GitHub Check: build website
  • GitHub Check: typecheck
  • GitHub Check: Linux
  • GitHub Check: macOS
  • GitHub Check: unit tests / windows-2025
  • GitHub Check: Windows
  • GitHub Check: smoke e2e tests (production)
  • GitHub Check: smoke e2e tests (development)
  • GitHub Check: unit tests / macos-15
  • GitHub Check: unit tests / ubuntu-24.04
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gastoner gastoner force-pushed the centralized_experimenal_features_tasks_manager branch 2 times, most recently from c827ea5 to 5e7701e Compare July 29, 2025 10:20
Copy link
codecov bot commented Jul 29, 2025

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/main/src/plugin/tasks/task-manager.ts 57.14% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor
@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @gastoner - I've reviewed your changes - here's some feedback:

  • Consider extracting the repetitive TaskManager instantiation in the tests into a helper/factory to reduce boilerplate and improve readability.
  • Since you changed the tasks.Manager schema to type object without a default, you may want to explicitly define a default value or add handling for undefined to prevent unexpected behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the repetitive TaskManager instantiation in the tests into a helper/factory to reduce boilerplate and improve readability.
- Since you changed the `tasks.Manager` schema to type `object` without a default, you may want to explicitly define a default value or add handling for `u
8000
ndefined` to prevent unexpected behavior.

## Individual Comments

### Comment 1
<location> `packages/main/src/plugin/tasks/task-manager.spec.ts:61` </location>
<code_context>

 test('task manager init should register a configuration option', async () => {
-  const taskManager = new TaskManager(apiSender, statusBarRegistry, commandRegistry, configurationRegistry);
+  const taskManager = new TaskManager(
+    apiSender,
+    statusBarRegistry,
</code_context>

<issue_to_address>
Consider introducing a factory function or shared setup to avoid repeating the five-argument TaskManager construction in every test.

Consider pulling the new fifth argument out into a small factory (or reusing a shared `taskManager` via `beforeEach`) so you don’t have to repeat all five params in every test. For example:

```ts
// near the top of the file
const experimentalConfigurationManager = {/* …your mock… */};

function createTaskManager() {
  return new TaskManager(
    apiSender,
    statusBarRegistry,
    commandRegistry,
    configurationRegistry,
    experimentalConfigurationManager,
  );
}
```

Then your tests shrink from:

```ts
const taskManager = new TaskManager(
  apiSender,
  statusBarRegistry,
  commandRegistry,
  configurationRegistry,
  experimentalConfigurationManager,
);
```

to:

```ts
const taskManager = createTaskManager();
```

—or even—

```ts
let taskManager: TaskManager;
beforeEach(() => {
  taskManager = createTaskManager();
  vi.resetAllMocks();
});

test('create task with title', () => {
  const task = taskManager.createTask({ title: 'title' });
  //
});
```

This preserves all behavior while removing the boilerplate of passing that fifth parameter everywhere.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


test('task manager init should register a configuration option', async () => {
const taskManager = new TaskManager(apiSender, statusBarRegistry, commandRegistry, configurationRegistry);
const taskManager = new TaskManager(
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider introducing a factory function or shared setup to avoid repeating the five-argument TaskManager construction in every test.

Consider pulling the new fifth argument out into a small factory (or reusing a shared taskManager via beforeEach) so you don’t have to repeat all five params in every test. For example:

// near the top of the file
const experimentalConfigurationManager = {/* …your mock… */};

function createTaskManager() {
  return new TaskManager(
    apiSender,
    statusBarRegistry,
    commandRegistry,
    configurationRegistry,
    experimentalConfigurationManager,
  );
}

Then your tests shrink from:

const taskManager = new TaskManager(
  apiSender,
  statusBarRegistry,
  commandRegistry,
  configurationRegistry,
  experimentalConfigurationManager,
);

to:

const taskManager = createTaskManager();

—or even—

let taskManager: TaskManager;
beforeEach(() => {
  taskManager = createTaskManager();
  vi.resetAllMocks();
});

test('create task with title', () => {
  const task = taskManager.createTask({ title: 'title' });
  // …
});

This preserves all behavior while removing the boilerplate of passing that fifth parameter everywhere.


test('task dispose should send `task-removed` message', async () => {
const taskManager = new TaskManager(apiSender, statusBarRegistry, commandRegistry, configurationRegistry);
const taskManager = new TaskManager(
Copy link
Contributor

Choose a reason for hiding this comment

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

I've seen that this const is used in several test. Could it be possible to move outside tests, for example in the describe block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@gastoner gastoner requested a review from MarsKubeX July 30, 2025 06:52

test('Ensure statusbar registry', async () => {
const taskManager = new TaskManager(apiSender, statusBarRegistry, commandRegistry, configurationRegistry);
const taskManager = new TaskManager(
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you forget to remove this one to use the one in beforeEach instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yess :D

@gastoner gastoner force-pushed the centralized_experimenal_features_tasks_manager branch from c0bc225 to 378f335 Compare July 30, 2025 07:02
@gastoner gastoner requested a review from feloy July 30, 2025 07:02
Copy link
Contributor
@MarsKubeX MarsKubeX left a comment

Choose a reason for hiding this comment

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

LGTM codewise

@gastoner
Copy link
Contributor Author
gastoner commented Aug 1, 2025

Needs rebase after #13227

Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
Signed-off-by: Evzen Gasta <evzen.ml@seznam.c
9E81
z>
@gastoner gastoner force-pushed the centralized_experimenal_features_tasks_manager branch from 378f335 to c48de1f Compare August 1, 2025 08:33
@gastoner gastoner merged commit 6250ba9 into podman-desktop:main Aug 1, 2025
20 of 21 checks passed
@podman-desktop-bot podman-desktop-bot added this to the 1.21.0 milestone Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement centralized object solution for tasks manager
4 participants
0