feat: admin system power control via microinit - #53
Conversation
Expose GET/POST /api/v1/admin/system for init-mode shutdown and restart, and add an administrator menu dialog with Cancel, Shutdown, and Restart. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
The implementation of the admin system power control feature is well-structured and robust, covering both backend and frontend aspects effectively. The error handling, especially the "fire-and-forget" mechanism for shutdown requests on the frontend, is well-considered for the nature of the operation.
| "fmt" | ||
| ) | ||
|
|
||
| var ( |
There was a problem hiding this comment.
✨ [POSITIVE] The explicit error types (ErrSystemUnavailable, ErrSystemNotInit, ErrInvalidShutdownMode) and their consistent usage throughout the service and HTTP layers provide excellent clarity and allow for precise error handling on the client side. Additionally, the design of NewSystemControl to gracefully handle nil ServiceManager implementations (e.g., for tests or --no-supervisor mode) is a good practice for robustness.
| return apiFetch<SystemInfo>("/api/v1/admin/system"); | ||
| } | ||
|
|
||
| /** Fire-and-forget host shutdown. Network errors after send are treated as success. */ |
There was a problem hiding this comment.
✨ [POSITIVE] The error handling in requestSystemShutdown is well-implemented. Specifically, treating TypeError and network-related ApiError (status undefined or 0) as success for fire-and-forget shutdown operations is crucial for a good user experience, as the server might stop before a full response can be received. This demonstrates a thoughtful approach to handling the inherent challenges of system shutdown via API.
Inject MicroinitPower instead of holding *manager; treat empty daemon mode as supervise; surface API errors in the UI; add 409/empty-mode tests. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
GET /api/v1/admin/systemandPOST /api/v1/admin/system/shutdown(admin-only)microinit/goto commit from feat: daemon mode, IPC allowlist, and initgroups for runAsUser microinit#9Dependencies
go/v0.6.0after merge)Test plan
go test ./pkgs/bigfred/server/http/... -run SystemMade with Cursor