Skip to content

Conversation

raghavyuva
Copy link
Owner

@raghavyuva raghavyuva commented Aug 27, 2025

Summary by CodeRabbit

  • New Features
    • Server management: add, view, edit, delete servers with password/private-key auth; searchable, sortable, paginated list.
    • Server Selector in header to activate/deactivate target server; operations (terminal, dashboard, Docker) run against selected server.
  • Improvements
    • More robust dashboard system stats collection.
    • Disk usage mounts now truncate with tooltip.
    • Added Servers translations (EN, ES, FR, KN).
  • Refactor
    • Replaced update button with Server Selector.
    • Requests/WebSockets scoped per server via header/query; context-aware SSH/Docker usage.

Copy link
Contributor

coderabbitai bot commented Aug 27, 2025

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

Adds a full “Servers” feature across API, storage, validation, middleware, WebSocket, and UI. Introduces SSH/context-aware Docker and SSH services, per-request Docker usage, server-scoped realtime flows, migrations for servers table and status enforcement, file-manager context propagation, i18n strings, Redux slice and RTK Query APIs, and a Servers settings UI with selector.

Changes

Cohort / File(s) Summary
Version manifest
api/api/versions.json
Updated v1 release_date timestamp only.
Dependencies and system stats refactor
api/go.mod, api/internal/features/dashboard/system_stats.go
Removed gopsutil and related deps; rewrote system stats to parse command outputs; added parsing helpers.
Docker service: SSH + context
api/internal/features/deploy/docker/init.go
Added SSH tunnel support, context/server-aware constructors, Close(); updated interfaces and Docker API type usage.
Container controllers: per-request Docker
api/internal/features/container/controller/get_container.go, .../get_container_logs.go, .../list_containers.go, .../list_images.go, .../prune_build_cache.go, .../prune_images.go, .../remove_container.go, .../restart_container.go, .../start_container.go, .../stop_container.go, .../init.go
Replaced controller field with c.getDockerService(ctx), added defer Close(), updated isProtectedContainer signature and flow.
Dashboard monitor init
api/internal/features/dashboard/init.go
NewDashboardMonitor now accepts server; creates SSH-based Docker service with server.
Terminal constructor
api/internal/features/terminal/init.go
NewTerminal now accepts server and uses SSH with server.
Realtime: server-aware
api/internal/realtime/init.go, api/internal/realtime/read_loop.go, api/internal/realtime/terminal_handler.go, api/internal/realtime/dashboard_monitor.go
WebSocket reads optional server param, validates ownership, passes server through read loop and handlers; monitor/terminal constructors updated.
Middleware and server utils
api/internal/middleware/auth.go, api/internal/middleware/cors.go, api/internal/utils/server.go
Added X-SERVER-ID header handling and context injection; CORS allows/exposes it; added server access helpers and getters.
Feature flags and context keys
api/internal/features/feature-flags/service/init.go, api/internal/types/feature_flags.go, api/internal/types/types.go
Added FeatureServers flag; added ServerIDKey context key; default flags include Servers.
Domain model: Server
api/internal/types/domain.go
Replaced Server schema with host/port/credentials/status, user/org relations; removed defaults helper.
Servers feature: controllers
api/internal/features/servers/controller/*.go
Added ServersController with Create/Get/List/Update/UpdateStatus/Delete endpoints, validation and error helpers.
Servers feature: service
api/internal/features/servers/service/*.go
Added ServersService with CRUD/status methods; SSH verification helper; transactions and ownership checks.
Servers feature: storage
api/internal/features/servers/storage/init.go
Added Bun-based storage with CRUD, queries, pagination, transactions.
Servers feature: types and validation
api/internal/features/servers/types/*.go, api/internal/features/servers/validation/validator.go
Added request/response types, errors, query params, pagination, valid sort fields, and validator.
Servers feature: routes
api/internal/routes.go
Registered /server and /servers routes with RBAC and feature flags.
Servers migrations
api/migrations/servers/033_*, api/migrations/servers/034_*, api/migrations/servers/035_*
Created servers table, permissions/feature flag inserts, and status column with constraints, trigger, and indexes (+ downs).
File-manager: context propagation
api/internal/features/file-manager/controller/*.go, api/internal/features/file-manager/service/init.go, api/internal/features/file-manager/service/manager.go
Service/api methods now accept context; SSH/SFTP clients created per-call via context.
View: Servers UI
view/app/settings/servers/components/create-server.tsx, .../servers-table.tsx, .../servers-table-skeleton.tsx, view/app/settings/servers/page.tsx
Added create/edit dialog, servers table, skeleton, and servers page with query state, guards, and toasts.
Layout and selector and sockets
view/components/layout/app-sidebar.tsx, view/components/layout/dashboard-layout.tsx, view/components/layout/server-selector.tsx, view/hooks/socket-provider.tsx, view/hooks/use-active-server.ts
Added Servers nav, replaced update button with ServerSelector; WebSocket appends server param; added active server hook.
Redux and API layer
view/redux/api-conf.ts, view/redux/base-query.ts, view/redux/store.ts, view/redux/features/servers/serverSlice.ts, view/redux/services/settings/serversApi.ts, view/redux/types/server.ts
Added server endpoints enum, X-SERVER-ID header from state, integrated server slice and RTK APIs, types for servers, persisted state.
i18n
view/lib/i18n/locales/en.json, .../es.json, .../fr.json, .../kn.json
Added Servers namespace and navigation labels across locales.
Dashboard UI tweak
view/app/dashboard/components/system/disk-usage.tsx
Truncated mount column with tooltip; adjusted skeleton widths.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant V as View: ServerSelector
  participant R as RTK Query
  participant API as ServersController
  participant SVC as ServersService
  participant ST as ServerStorage
  participant DB as DB

  U->>V: Select server (activate/deactivate)
  V->>R: PATCH /v1/server/status
  R->>API: UpdateServerStatus
  API->>SVC: UpdateServerStatus(req, userID)
  SVC->>ST: BeginTx / GetServer / UpdateStatus
  ST->>DB: Update status (trigger ensures single active)
  DB-->>ST: OK
  ST-->>SVC: Commit
  SVC-->>API: Updated server
  API-->>R: Response
  R-->>V: Updated server
  V-->>U: UI reflects active/inactive
Loading
sequenceDiagram
  autonumber
  actor C as Client (WebSocket)
  participant WS as SocketServer
  participant ST as ServerStorage
  participant API as Handlers
  participant D as DashboardMonitor/Terminal

  C->>WS: GET /ws?token=...&server=SERVER_ID
  WS->>ST: Validate server ownership
  ST-->>WS: Server or error
  WS->>API: readLoop(conn, server)
  API->>D: New...(conn, logger, server)
  D-->>API: Start using server-scoped SSH/Docker
Loading
sequenceDiagram
  autonumber
  participant Ctrl as ContainerController
  participant DS as DockerService
  participant DK as Docker Daemon

  Ctrl->>Ctrl: getDockerService(ctx)
  Ctrl->>DS: NewDockerServiceWithContext(ctx)
  DS->>DS: (optional) Setup SSH tunnel
  Ctrl->>DS: Perform operation (e.g., ListAllContainers)
  DS->>DK: API call
  DK-->>DS: Result
  DS-->>Ctrl: Result
  Ctrl->>DS: Close()
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~150 minutes

Possibly related PRs

Suggested labels

nixopus-api, nixopus-view, nixopus-docker

Poem

A rabbit taps the server list—click, click!
Tunnels hum, SSH picks up quick.
Context hops from UI to core,
One active burrow per org—no more.
Logs now parsed, containers neat,
New routes paved for fleet-by-fleet.
Thump! Deploy complete. 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/multi-server

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@raghavyuva
Copy link
Owner Author

@coderabbitai pause

coderabbitai[bot]

This comment was marked as abuse.

coderabbitai[bot]

This comment was marked as abuse.

Copy link
Contributor

coderabbitai bot commented Aug 27, 2025

✅ Actions performed

Reviews paused.

@raghavyuva raghavyuva moved this to In progress in Nixopus Aug 27, 2025
@raghavyuva raghavyuva added this to the Beta Release milestone Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants