Skip to content

fix: show correct stats for remote environments on dashboard#549

Merged
kmendell merged 2 commits intomainfrom
fix/show-correct-stats
Sep 23, 2025
Merged

fix: show correct stats for remote environments on dashboard#549
kmendell merged 2 commits intomainfrom
fix/show-correct-stats

Conversation

@kmendell
Copy link
Copy Markdown
Member

@kmendell kmendell commented Sep 23, 2025

Fixes: #479

Summary by CodeRabbit

  • New Features

    • Access Docker details per environment via a new endpoint, now surfaced in the dashboard refresh flow.
  • Refactor

    • Consolidated system-related routes under the environment scope for clearer routing.
    • Dashboard now retrieves Docker info through the Environment API, aligning data sources and improving consistency.
    • Backend service integration updated to support system and Docker capabilities across environment operations.

@kmendell
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 23, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 23, 2025

📝 Walkthrough

Walkthrough

Added system and Docker services to EnvironmentHandler, introduced GET /:id/docker/info, and centralized system route handling. Updated router to inject new services. Frontend now fetches Docker info via EnvironmentAPI instead of SystemAPI, updating dashboard data retrieval accordingly.

Changes

Cohort / File(s) Change summary
Backend: Environment handler
backend/internal/api/environment_handler.go
Added fields systemService and dockerService; expanded NewEnvironmentHandler signature to accept them; registered route GET /:id/docker/info; added handleSystemRoutes; added GetDockerInfo delegating to /docker/info; integrated system route handling into local requests.
Backend: Router bootstrap
backend/internal/bootstrap/router_bootstrap.go
Updated all NewEnvironmentHandler call sites to pass appServices.System and appServices.Docker in both agent and non-agent paths.
Frontend: Environment API service
frontend/src/lib/services/api/environment-api-service.ts
Added getDockerInfo(): Promise<DockerInfo> calling GET /environments/{envId}/docker/info; imported DockerInfo type.
Frontend: Dashboard uses Environment API
frontend/src/routes/dashboard/+page.svelte, frontend/src/routes/dashboard/+page.ts
Switched Docker info retrieval from systemAPI.getDockerInfo() to environmentAPI.getDockerInfo(); adjusted imports; no other logic changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix: show correct stats for remote environments on dashboard" concisely and accurately summarizes the primary intent of the changes: ensure dashboard stats for remote/environment-specific Docker instances are correct. It directly matches the described code changes that move Docker info retrieval to an environment-scoped endpoint and update the dashboard to use that data. The phrasing is clear and appropriately scoped for a commit history entry.
Linked Issues Check ✅ Passed The PR implements an environment-scoped Docker info endpoint (GET /:id/docker/info), injects system/docker services into EnvironmentHandler, and updates the dashboard frontend to call environmentAPI.getDockerInfo, which directly targets the symptoms described in linked issue [#479] (incorrect container counts and Docker engine architecture for agents). Based on the provided diffs, the dashboard will now request Docker information per-environment rather than from the master, which should correct both the container count and architecture displays. I recommend validating the fix by running the reproduction from issue #479 (connect the armv7 agent to the arm64 master) in staging or CI.
Out of Scope Changes Check ✅ Passed All modified files and added logic are focused on exposing environment-specific Docker info, wiring the required services, and switching the dashboard to consume that environment-scoped data; the bootstrap changes only propagate the new dependencies and the frontend changes only switch the Docker info caller. I do not see unrelated feature work, large refactors, or modifications outside the scope of fixing agent-specific dashboard statistics in the provided diffs.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests

❌ Error creating Unit Test PR.

  • Create PR with unit tests
  • Commit unit tests in branch fix/show-correct-stats
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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
Copy Markdown
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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe7ee76 and 6b396f8.

📒 Files selected for processing (5)
  • backend/internal/api/environment_handler.go (6 hunks)
  • backend/internal/bootstrap/router_bootstrap.go (2 hunks)
  • frontend/src/lib/services/api/environment-api-service.ts (2 hunks)
  • frontend/src/routes/dashboard/+page.svelte (1 hunks)
  • frontend/src/routes/dashboard/+page.ts (2 hunks)
🧰 Additional context used
🪛 GitHub Check: Run Golangci-lint
backend/internal/api/environment_handler.go

[failure] 246-246:
singleCaseSwitch: should rewrite switch statement to if statement (gocritic)

🪛 GitHub Actions: Run Backend Linter
backend/internal/api/environment_handler.go

[error] 246-246: singleCaseSwitch: should rewrite switch statement to if statement (gocritic)

⏰ 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). (3)
  • GitHub Check: build
  • GitHub Check: test
  • GitHub Check: Analyze (go)
🔇 Additional comments (10)
frontend/src/lib/services/api/environment-api-service.ts (2)

12-12: Type import for DockerInfo aligns with new endpoint contract.


25-31: New getDockerInfo() is correctly environment-scoped.

Endpoint path and return typing look correct. Verification inconclusive: ripgrep returned "No files were searched" when run in the sandbox — confirm locally that no frontend call sites remain by running: rg -n -S -C1 '\bgetDockerInfo\s*\(' --hidden -g '!.git' -g '!node_modules/**'.

frontend/src/routes/dashboard/+page.ts (1)

1-1: Docker info now sourced from environmentAPI — matches backend route.

Also applies to: 31-34

backend/internal/bootstrap/router_bootstrap.go (1)

68-69: Injected System and Docker services into EnvironmentHandler.

Wiring looks correct in both AgentMode and standard paths.

Please confirm Services initializes System and Docker in both modes to avoid nil dereferences.

Also applies to: 79-79

backend/internal/api/environment_handler.go (5)

36-39: Added systemService and dockerService to EnvironmentHandler.


52-56: New ctor params and assignments wired correctly.

Also applies to: 68-71


147-148: New GET /:id/docker/info route registered under environments.


213-216: Local routing now includes system routes — enables docker/info locally.


254-257: GetDockerInfo wrapper correctly delegates via routeRequest.

frontend/src/routes/dashboard/+page.svelte (1)

119-119: Switched to environmentAPI.getDockerInfo() — correct for remote envs.

Dashboard files call environmentAPI.getDockerInfo (frontend/src/routes/dashboard/+page.svelte:119, frontend/src/routes/dashboard/+page.ts:32); no dashboard references to systemAPI.getDockerInfo (system-api-service.ts only defines it).

File: frontend/src/routes/dashboard/+page.svelte
Lines: 119-119

			tryCatch(environmentAPI.getDockerInfo()),

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 23, 2025

Warning

Docstrings generation is disabled for your repository or organization.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 23, 2025

Note

Unit test generation is an Early Access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

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.

🐞 Bug: Dashboard showing wrong info for agent.

1 participant