[Feat] Inertia Context Shifting#1094
Open
RichardAnderson wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Replaces ~120 KB of shared Inertia data (Ziggy route table, provider/service catalogue, public-key text, eager-loaded sites) with a small bootstrap_version token plus on-demand endpoints, and introduces a client-side bootstrap-store (Zustand) with localStorage caching. A websocket bootstrap.invalidated event from plugin lifecycle Actions keeps connected clients in sync, and the route catalogue is now served as a cacheable /ziggy/{version}.js script.
Changes:
- New
GetBootstrap/GetZiggyRoutesActions with versioning + cache invalidation, plusBootstrapControllerandZiggyRoutesControllerendpoints. - Plugin install/enable/disable/uninstall Actions forget the bootstrap version and broadcast
bootstrap.invalidatedto all clients (newEventsHandler::broadcastToAllandproject_id=0support inWebSocketServeCommand). HandleInertiaRequestsdropsconfigs,public_key_text,server_sites, and unconditionalziggy; React components migrate fromusePage().props.configstouseConfigs()from the new store;Layoutgates rendering on bootstrap readiness and exposes an error/retry state.
Reviewed changes
Copilot reviewed 33 out of 34 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| app/Actions/Bootstrap/GetBootstrap.php | New Action that assembles configs + public key text and a stable version hash. |
| app/Actions/Ziggy/GetZiggyRoutes.php | Builds, caches, versions, and serves the Ziggy route script. |
| app/Actions/Plugins/{Install,Enable,Disable,Uninstall}Plugin.php | Invalidate bootstrap version and broadcast bootstrap.invalidated. |
| app/Http/Controllers/BootstrapController.php | Auth-protected JSON endpoint returning bootstrap payload. |
| app/Http/Controllers/ZiggyRoutesController.php | Public, immutable-cached JS endpoint serving Ziggy routes. |
| app/Http/Controllers/ApplicationController.php | Removes now-unused logs prop. |
| app/Http/Middleware/HandleInertiaRequests.php | Trims shared props; ships only bootstrap_version (+ ziggy when SSR). |
| app/WebSocket/EventsHandler.php | Adds broadcastToAll to fan out to every connection. |
| app/Console/Commands/WebSocketServeCommand.php | Treats project_id=0 as a global broadcast. |
| resources/views/app.blade.php | Replaces @routes with cached /ziggy/{version}.js script tag. |
| resources/js/app.tsx | Hydrates bootstrap store from localStorage on boot. |
| resources/js/stores/bootstrap-store.ts | New Zustand store: hydrate / fetch / sync / clear with localStorage. |
| resources/js/layouts/app/layout.tsx | Syncs bootstrap with server version, listens for invalidation, gates children and shows error/retry UI. |
| resources/js/components/{color-select,user-menu-content}.tsx | Use the new store; clear it on logout. |
| resources/js/pages/.../*.tsx (many) | Migrate from page.props.configs / public_key_text to useConfigs() / usePublicKeyText(). |
| resources/js/pages/application/index.tsx | Replaces the inline log DataTable with the shared Logs component (drops logs prop / realtime hook). |
| resources/js/pages/server-logs/components/instant-logs.tsx | Tightens typing of the query response and consolidates the two refetch effects. |
| resources/js/pages/servers/components/create-server.tsx | Adds toast on clipboard rejection; reads public key from the store. |
| resources/js/types/index.d.ts | Drops configs / public_key_text / server_sites and adds bootstrap_version; ziggy now optional. |
Member
Author
|
No comments from Copilot? Wow... thats a first! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new centralized bootstrap system to manage and cache application configuration and public key data, as well as a similar system for Ziggy route data. It refactors how this information is provided to the frontend, improving cache invalidation and real-time update mechanisms, especially around plugin lifecycle events. Additionally, it simplifies and modernizes how configuration data is accessed in React components and cleans up some controller and middleware logic.
Vito's Inertia responses were shipping ~120 KB+ of mostly-static shared data on every visit: the full Ziggy route table (~70 KB), the provider/service/site-type catalogue (~35 KB), the SSH public-key text, and an eager-loaded site-with-SSL collection on every server-route request. This PR cuts each of those pathways down to the minimum and adds a small invalidation channel so admin plugin toggles still propagate instantly to other users.
Result: typical Inertia XHR responses are now ~1–3 KB shared + page data (down from ~120 KB+). HTML first-loads no longer embed the route table. The custom
proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k;overrides in nginx are no longer needed.Centralized Bootstrap and Ziggy Route Management:
GetBootstrapandGetZiggyRoutesaction classes to encapsulate, cache, and version application configuration, public key text, and Ziggy route data, with cache invalidation and versioning methods for both. (app/Actions/Bootstrap/GetBootstrap.php,app/Actions/Ziggy/GetZiggyRoutes.php)BootstrapController) and Ziggy routes (ZiggyRoutesController), exposing these via dedicated endpoints. (app/Http/Controllers/BootstrapController.php,app/Http/Controllers/ZiggyRoutesController.php)Plugin Lifecycle and Real-Time Updates:
app/Actions/Plugins/InstallPlugin.php,app/Actions/Plugins/EnablePlugin.php,app/Actions/Plugins/DisablePlugin.php,app/Actions/Plugins/UninstallPlugin.php)app/WebSocket/EventsHandler.php,app/Console/Commands/WebSocketServeCommand.php)Frontend Integration and Refactoring:
bootstrap-storefor React to centrally manage and hydrate configuration and public key data, replacing scattered access via Inertia's shared props. (resources/js/app.tsx,resources/js/components/color-select.tsx,resources/js/components/user-menu-content.tsx)ColorSelect,UserMenuContent) to use the new store for configuration data and ensure proper clearing of bootstrap state on logout.Middleware and Controller Cleanup:
HandleInertiaRequestsmiddleware to remove direct configuration and public key data from shared props, instead providing only the bootstrap version and CSRF token. Also removed server sites data from shared props. (app/Http/Middleware/HandleInertiaRequests.php)ApplicationController. (app/Http/Controllers/ApplicationController.php)