Skip to content

Conversation

@lklimek
Copy link
Contributor

@lklimek lklimek commented Oct 26, 2025

Enhance the dashmate restart functionality to ensure that both rs-dapi and envoy services restart correctly when using the --platform option. This includes improvements to profile handling in the start and stop node tasks.

Summary by CodeRabbit

  • Refactor
    • Unified platform profile derivation logic in node management by consolidating previously scattered inline configuration across start and stop operations.
    • Introduced centralized profile computation with automatic fallback defaults, improving consistency and maintainability in platform-specific service orchestration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 26, 2025

Walkthrough

Both startNodeTaskFactory and stopNodeTaskFactory now accept getConfigProfiles as a dependency and use a new internal helper function to derive platform profiles, centralizing the logic previously scattered across task implementations.

Changes

Cohort / File(s) Summary
Profile Computation Refactoring
packages/dashmate/src/listr/tasks/startNodeTaskFactory.js, packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js
Added getConfigProfiles parameter to both factories. Introduced getPlatformProfiles(config) helper that filters getConfigProfiles results for entries starting with "platform", defaults to ["platform"] if none match, and deduplicates. Replaced inline platform profile logic in node start/stop tasks with calls to the centralized helper.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • The refactoring applies the same consistent pattern across two files, reducing cognitive load.
  • Logic changes are straightforward: a single helper function and its consistent application in two task factories.
  • No complex algorithms or significant behavioral alterations; primarily extraction and centralization of existing logic.

Poem

🐰 A helper hops in, tidy and neat,
Platform profiles now skip the repeat,
Profiles flow once through factory's care,
Less tangled logic floating in air! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix(dashmate): restart for rs-dapi and envoy" is fully related to the changeset's main objective. The PR aims to enhance dashmate restart functionality to ensure rs-dapi and envoy services restart correctly when using the --platform option, and the title accurately captures this fix. The title is concise, uses conventional commit format (fix type with scope), and specifically identifies the affected services, which aligns with the guidance that titles should highlight the most important change without requiring implementation details. A teammate scanning commit history would clearly understand that a restart fix was applied to these two services.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/dashmate-restart

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js (1)

19-28: Refactor to avoid mutating a const array.

While mutating a const array is valid JavaScript, it violates the Airbnb style guide convention (referenced in coding guidelines) which prefers signaling mutation intent with let or avoiding mutation entirely.

Apply this diff to use a functional approach without mutation:

 function getPlatformProfiles(config) {
   const platformProfiles = getConfigProfiles(config)
     .filter((profile) => profile.startsWith('platform'));
-
-  if (platformProfiles.length === 0) {
-    platformProfiles.push('platform');
-  }
-
-  return Array.from(new Set(platformProfiles));
+  
+  const result = platformProfiles.length === 0 ? ['platform'] : platformProfiles;
+  
+  return Array.from(new Set(result));
 }

Or more concisely:

 function getPlatformProfiles(config) {
   const platformProfiles = getConfigProfiles(config)
     .filter((profile) => profile.startsWith('platform'));
-
-  if (platformProfiles.length === 0) {
-    platformProfiles.push('platform');
-  }
-
-  return Array.from(new Set(platformProfiles));
+  
+  return Array.from(new Set(
+    platformProfiles.length > 0 ? platformProfiles : ['platform']
+  ));
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29f7492 and 8802753.

📒 Files selected for processing (2)
  • packages/dashmate/src/listr/tasks/startNodeTaskFactory.js (4 hunks)
  • packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
packages/**/**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/**/**/*.{js,ts,jsx,tsx}: Adhere to ESLint with Airbnb/TypeScript configs for JS/TS code
Use camelCase for JS/TS variables and functions
Use PascalCase for JS/TS classes
Prefer kebab-case filenames within JS packages

Files:

  • packages/dashmate/src/listr/tasks/startNodeTaskFactory.js
  • packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js
🔇 Additional comments (6)
packages/dashmate/src/listr/tasks/startNodeTaskFactory.js (3)

22-22: LGTM!

The getConfigProfiles dependency has been correctly added to both the JSDoc and function signature, maintaining consistency.

Also applies to: 34-34


105-105: LGTM!

The use of getPlatformProfiles(config) correctly centralizes platform profile derivation and aligns with the PR objective to enhance restart functionality for platform services.


160-160: LGTM!

Consistent with the profile derivation logic at line 105. The centralized approach ensures both service checking and startup use the same platform profile resolution.

packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js (3)

10-10: LGTM: Dependency injection looks correct.

The getConfigProfiles parameter is properly documented and added to the function signature, following camelCase conventions.

Also applies to: 17-17


43-43: LGTM: Profile derivation logic is correct.

The conditional logic properly uses getPlatformProfiles(config) when platform-only mode is enabled, falling back to an empty array otherwise.


83-84: LGTM: Consistent profile handling.

The profile derivation here mirrors the logic in the "Check node is running" task, ensuring consistent behavior across both stop operations.

Comment on lines +36 to +45
function getPlatformProfiles(config) {
const platformProfiles = getConfigProfiles(config)
.filter((profile) => profile.startsWith('platform'));

if (platformProfiles.length === 0) {
platformProfiles.push('platform');
}

return Array.from(new Set(platformProfiles));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix const mutation error.

platformProfiles is declared as const but is mutated on line 41 with .push(). This will cause a runtime error when no platform profiles exist.

Apply this diff to fix the issue:

-  function getPlatformProfiles(config) {
-    const platformProfiles = getConfigProfiles(config)
-      .filter((profile) => profile.startsWith('platform'));
+  function getPlatformProfiles(config) {
+    let platformProfiles = getConfigProfiles(config)
+      .filter((profile) => profile.startsWith('platform'));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function getPlatformProfiles(config) {
const platformProfiles = getConfigProfiles(config)
.filter((profile) => profile.startsWith('platform'));
if (platformProfiles.length === 0) {
platformProfiles.push('platform');
}
return Array.from(new Set(platformProfiles));
}
function getPlatformProfiles(config) {
let platformProfiles = getConfigProfiles(config)
.filter((profile) => profile.startsWith('platform'));
if (platformProfiles.length === 0) {
platformProfiles.push('platform');
}
return Array.from(new Set(platformProfiles));
}
🤖 Prompt for AI Agents
In packages/dashmate/src/listr/tasks/startNodeTaskFactory.js around lines 36 to
45, platformProfiles is declared as const but mutated with .push(), causing an
error; change the declaration to let (or create a new array when adding the
default) so it can be mutated — e.g., declare let platformProfiles =
getConfigProfiles(config).filter(...); then if length is 0 push 'platform', and
return Array.from(new Set(platformProfiles)).

@QuantumExplorer QuantumExplorer changed the title Fix dashmate restart for rs-dapi and envoy fix(dashmate): restart for rs-dapi and envoy Oct 27, 2025
@QuantumExplorer QuantumExplorer merged commit 5a193d4 into v2.1-dev Oct 27, 2025
41 of 44 checks passed
@QuantumExplorer QuantumExplorer deleted the fix/dashmate-restart branch October 27, 2025 07:50
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