Skip to content

[Fix] Available updates + kernel fixes alert#1159

Merged
RichardAnderson merged 4 commits into
vitodeploy:4.xfrom
RichardAnderson:fix/updates-available
Jun 13, 2026
Merged

[Fix] Available updates + kernel fixes alert#1159
RichardAnderson merged 4 commits into
vitodeploy:4.xfrom
RichardAnderson:fix/updates-available

Conversation

@RichardAnderson

@RichardAnderson RichardAnderson commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Kernel update detection shown separately from regular updates
    • "Update & restart" / "Update kernel" action added to server UI, banners and a new POST endpoint to trigger it
    • Server JSON now exposes a kernel_updates field; realtime server state drives sidebar/menu enablement
  • Bug Fixes / Behaviour

    • Status changes are broadcast immediately for timelier UI updates
    • Kernel updates trigger a restart automatically after upgrade completes
  • Tests

    • New tests for kernel update detection and the update‑kernel flow

@RichardAnderson RichardAnderson requested a review from Copilot June 13, 2026 15:42
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 44750f29-cfef-4319-b992-87956766841b

📥 Commits

Reviewing files that changed from the base of the PR and between f42af20 and d900d38.

📒 Files selected for processing (1)
  • resources/js/layouts/server/layout.tsx

📝 Walkthrough

Walkthrough

Adds kernel update detection, a Server.kernel_updates field and migration, an UpdateKernel action and queued job, a controller endpoint and resource field, realtime broadcasts on state change, and frontend UI for triggering kernel upgrades.

Changes

Kernel Update Detection and Upgrade

Layer / File(s) Summary
Kernel Update Detection and Model Tracking
app/SSH/OS/OS.php, resources/views/ssh/os/available-updates.blade.php, app/Models/Server.php, database/migrations/2026_06_13_162705_add_kernel_updates_to_servers_table.php, tests/Feature/ServerTest.php
SSH script parsing distinguishes kernel updates from regular updates in output; Server model adds kernel_updates integer attribute to $fillable and $casts; migration adds column with default 0; checkForUpdates() unpacks both counts from the array response; getWarnings() emits kernel_update_available when kernel_updates > 0; tests verify parsing and warning emission.
Kernel Upgrade Action and Job
app/Actions/Server/UpdateKernel.php, app/Jobs/Server/UpdateKernelJob.php, resources/views/ssh/os/upgrade-kernel.blade.php, tests/Feature/ServerTest.php
UpdateKernel action sets status to UPDATING, saves server, and dispatches UpdateKernelJob to SSH queue; job wraps upgrade in unique execution lock, runs kernel upgrade commands, re-checks connection, broadcasts server state, and reboots; failure handler sends ServerUpdateFailed notification, re-checks connection, broadcasts state, and logs error; test stubs SSH output and validates server state transitions.
API Endpoints and Resource
app/Http/Controllers/ServerController.php, app/Http/Resources/ServerResource.php, resources/js/types/server.d.ts
New POST /servers/{server}/update-kernel endpoint authorises update and invokes UpdateKernel::updateKernel(); existing checkForUpdates endpoint refreshes server and includes both updates and kernel_updates counts in flash message; ServerResource exposes kernel_updates field; TypeScript Server interface and ServerWarning union type add kernel_updates: number property and kernel_update_available warning variant with count.
Real-time State Broadcasting
app/Actions/Server/CheckConnection.php, app/Actions/Server/RebootServer.php
CheckConnection::check() broadcasts BroadcastServerUpdate after saving server as READY or DISCONNECTED; RebootServer::reboot() broadcasts state after disconnecting, ensuring connected clients see immediate status changes.
Frontend UI Components and User Interactions
resources/js/layouts/server/layout.tsx, resources/js/components/server-banners.tsx, resources/js/pages/servers/components/actions.tsx, tests/Feature/ServerTest.php
ServerLayout replaces static props with real-time useRealtimeRecord() hook so menu-disabled state reflects live server status; ServerBanners extracts kernel_update_available warning and renders a banner with destructive "Update & restart" confirmation action; ServerActions dropdown includes "Update kernel" menu item disabled when kernel_updates is 0, opening a confirmation dialog before posting to the endpoint; permission test verifies forbidden access to the new endpoint.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • saeedvaziry
🚥 Pre-merge checks | ✅ 4
✅ 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 describes fixes to available updates and kernel alerts, which aligns with the PR's substantial additions for kernel update tracking, detection, and UI/workflow components.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class tracking of kernel updates (separate from regular package updates) and exposes a dedicated “Update kernel & restart” flow across backend + UI, including warnings/banners and test coverage.

Changes:

  • Split update detection into regular vs kernel updates and persist kernel_updates on servers.
  • Add kernel upgrade SSH script + backend action/job/route to run a dist-upgrade and reboot.
  • Expose kernel-update warnings and UI actions (dropdown + banner), plus new feature tests.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/Feature/ServerTest.php Adds coverage for kernel update counting, warning exposure, and kernel update authorization.
resources/views/ssh/os/upgrade-kernel.blade.php New SSH script to perform dist-upgrade for kernel updates.
resources/views/ssh/os/available-updates.blade.php Updates the update-check script to output regular vs kernel update counts separately.
resources/js/types/server.d.ts Extends the Server type with kernel_updates and adds a new warning union case.
resources/js/pages/servers/components/actions.tsx Adds a “Update kernel” dropdown action (confirm + POST).
resources/js/layouts/server/layout.tsx Uses realtime server updates to disable/enable menu based on live status.
resources/js/components/server-banners.tsx Adds a kernel-update warning banner with “Update & restart” action.
database/migrations/2026_06_13_162705_add_kernel_updates_to_servers_table.php Adds kernel_updates column to servers.
app/SSH/OS/OS.php Adds upgradeKernel() and changes availableUpdates() to return both counts.
app/Models/Server.php Stores kernel_updates, updates update-check logic, and emits a new warning key.
app/Jobs/Server/UpdateKernelJob.php New queued job to upgrade kernel, refresh status, broadcast, and reboot.
app/Http/Resources/ServerResource.php Exposes kernel_updates to the frontend.
app/Http/Controllers/ServerController.php Adds servers.update-kernel endpoint and updates update-check flash message.
app/Actions/Server/UpdateKernel.php Action to mark server as updating and dispatch the kernel update job.
app/Actions/Server/RebootServer.php Broadcasts server updates after a reboot state change.
app/Actions/Server/CheckConnection.php Broadcasts server updates when connection status transitions.

Comment thread app/Http/Controllers/ServerController.php Outdated
Comment thread app/Jobs/Server/UpdateKernelJob.php
Comment thread app/Jobs/Server/UpdateKernelJob.php Outdated
Comment thread app/Jobs/Server/UpdateKernelJob.php Outdated
Comment thread resources/js/pages/servers/components/actions.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
resources/js/layouts/server/layout.tsx (1)

284-284: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Pass the realtime server to ServerHeader instead of page.props.server.

Line 44 creates a realtime server record that updates when server.updated socket events arrive (broadcast by UpdateKernelJob after kernel upgrades complete). Line 45 correctly uses this realtime server for isMenuDisabled, but line 284 still passes the stale page.props.server to ServerHeader.

If ServerHeader renders components that depend on server.kernel_updates or server.status (such as ServerActions from this same directory), those components will display stale data until the page refreshes, breaking the realtime update flow.

🔄 Proposed fix
-      <ServerHeader server={page.props.server} site={page.props.site} />
+      <ServerHeader server={server} site={page.props.site} />
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@resources/js/layouts/server/layout.tsx` at line 284, Replace the stale
page.props.server being passed to ServerHeader with the realtime server variable
used elsewhere in this file (the same "server" used for computing
isMenuDisabled) so ServerHeader and its children (e.g., ServerActions) receive
the live record (including kernel_updates and status) and update on realtime
socket events.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Actions/Server/UpdateKernel.php`:
- Around line 9-17: Add PHPDoc documentation for the UpdateKernel action: place
a class-level PHPDoc above class UpdateKernel summarizing the action's
responsibility, and a method-level PHPDoc above updateKernel specifying the
parameter type (Server $server), the purpose, and return void; reference the
Server model and the fact it sets Server::status to ServerStatus::UPDATING and
dispatches UpdateKernelJob to the 'ssh' queue so readers understand side effects
and expected behavior.

In `@app/Jobs/Server/UpdateKernelJob.php`:
- Around line 42-46: The log call in UpdateKernelJob (ServerLog::log invoked in
UpdateKernelJob::handle) uses a generic event type 'update-server-failed';
change that string to a kernel-specific identifier such as
'update-kernel-failed' (or 'kernel-update-failed') so kernel update failures are
distinguishable from other server update failures—update the third argument
passed to ServerLog::log in UpdateKernelJob accordingly.
- Around line 18-59: Add PHPDoc blocks to the UpdateKernelJob class and each
public/private method: document the class purpose (runs a kernel upgrade and
triggers reboot/notifications) above class UpdateKernelJob; add a constructor
PHPDoc for __construct(Server $server) describing the injected Server parameter;
add a handle() PHPDoc describing what it does and any thrown exceptions (if any
underlying calls can throw, annotate `@throws` \Exception); add a failed(Exception
$e) PHPDoc describing its error handling and the Exception parameter; and add a
short PHPDoc for private broadcastServerUpdate() describing its behavior.
Include param and return tags where appropriate (`@param` Server $server, `@param`
Exception $e, `@return` void) and `@throws` for methods that may propagate
exceptions.
- Around line 49-58: Replace the duplicated broadcast logic in the private
broadcastServerUpdate() with a call to the existing BroadcastServerUpdate
action: remove the SocketEvent::dispatch block and instead invoke the
BroadcastServerUpdate action (e.g., resolve(BroadcastServerUpdate::class) or new
BroadcastServerUpdate(...)) passing the refreshed Server instance (or project id
and ServerResource as the action expects); then update the call sites in
handle() and failed() to call that action instead of the removed private method
so the job composes the shared BroadcastServerUpdate logic rather than
reimplementing it.

In
`@database/migrations/2026_06_13_162705_add_kernel_updates_to_servers_table.php`:
- Line 12: The migration adds the kernel_updates column without explicit
positioning; update the $table->integer('kernel_updates')->default(0) definition
to include ->after('updates') so the new kernel_updates column is placed
immediately after the existing updates column for clearer schema ordering.

---

Outside diff comments:
In `@resources/js/layouts/server/layout.tsx`:
- Line 284: Replace the stale page.props.server being passed to ServerHeader
with the realtime server variable used elsewhere in this file (the same "server"
used for computing isMenuDisabled) so ServerHeader and its children (e.g.,
ServerActions) receive the live record (including kernel_updates and status) and
update on realtime socket events.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3d2822b1-7dd8-47bf-9a91-e62618e3a6c3

📥 Commits

Reviewing files that changed from the base of the PR and between 51d5a26 and fa25838.

📒 Files selected for processing (16)
  • app/Actions/Server/CheckConnection.php
  • app/Actions/Server/RebootServer.php
  • app/Actions/Server/UpdateKernel.php
  • app/Http/Controllers/ServerController.php
  • app/Http/Resources/ServerResource.php
  • app/Jobs/Server/UpdateKernelJob.php
  • app/Models/Server.php
  • app/SSH/OS/OS.php
  • database/migrations/2026_06_13_162705_add_kernel_updates_to_servers_table.php
  • resources/js/components/server-banners.tsx
  • resources/js/layouts/server/layout.tsx
  • resources/js/pages/servers/components/actions.tsx
  • resources/js/types/server.d.ts
  • resources/views/ssh/os/available-updates.blade.php
  • resources/views/ssh/os/upgrade-kernel.blade.php
  • tests/Feature/ServerTest.php

Comment thread app/Actions/Server/UpdateKernel.php
Comment thread app/Jobs/Server/UpdateKernelJob.php
Comment thread app/Jobs/Server/UpdateKernelJob.php
Comment thread app/Jobs/Server/UpdateKernelJob.php Outdated
RichardAnderson and others added 2 commits June 13, 2026 16:59
…ate, cleaner update flash message

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@RichardAnderson RichardAnderson merged commit 56f7e42 into vitodeploy:4.x Jun 13, 2026
4 checks passed
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