refactor(gui): remove the Services system, flatten into plain singleton modules#3405
Open
jelveh wants to merge 1 commit into
Open
refactor(gui): remove the Services system, flatten into plain singleton modules#3405jelveh wants to merge 1 commit into
jelveh wants to merge 1 commit into
Conversation
…on modules The GUI had a mini service framework in src/gui/src/services/: a `Service` base class (definitions.js) with `construct`/`init`/`__on`/`context` magic, a `globalThis.services` string-keyed registry with a two-phase construct→init lifecycle and an `emit`/`__on_*` event bus, plus a frontend↔backend `service_script` bridge for registering extra services from the backend. Nothing used the extension bridge, and the framework added indirection over what are really just nine long-lived singletons. This flattens all of it: - Move the nine services to src/gui/src/modules/ as plain classes exporting a singleton (process, exec, ipc, broadcast, theme, debug, locale, anti-csrf). `__launch-on-init` becomes a plain `launch_on_init(gui_params)` function since nothing else references it. Method bodies are unchanged. - Cross-service access is now direct ES-module imports instead of `globalThis.services.get(name)`. No base class, no registry, no lifecycle phases, no event bus. The single `gui:ready` event becomes a direct `process_service.on_gui_ready()` call from UIDesktop. - launch_services() now just calls init() on the four modules that need runtime setup (exec/debug/theme/process), then runs launch_on_init. All singletons are constructed at import, so construct-before-init ordering is preserved. - Remove the `Service` base class from definitions.js. - Remove the unused `service_script` bridge from PuterHomepageService (the `window.service_script`/`service_script_api_promise` shim, `registerScript`, `#serviceScripts`, and the `serviceScriptTags` injection point). Verified: webpack GUI build and backend tsc both clean; homepage controller tests pass; booted the app and exercised the desktop, launching an SDK app (process registration) and the Task Manager (process tree) with no console errors.
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
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.
What
Removes the GUI's mini service framework (
src/gui/src/services/) and flattens it into plain ES-module singletons.The old system had:
Servicebase class (indefinitions.js) withconstruct/init/__on/contextmagicglobalThis.servicesstring-keyed registry with a two-phase construct→init lifecycle and anemit/__on_*event busservice_scriptbridge (window.service_script/service_script_api_promise/PuterHomepageService.registerScript) for registering extra services from the backendNothing used the extension bridge, and the framework was indirection over what are really just nine long-lived singletons.
Changes
src/gui/src/modules/as plain classes exporting a singleton:process,exec,ipc,broadcast,theme,debug,locale,anti-csrf.__launch-on-initbecomes a plainlaunch_on_init(gui_params)function (nothing else referenced it). Method bodies are unchanged.globalThis.services.get(name)at every call site (IPC.js,helpers.js,helpers/launch_app.js,UIDesktop.js,UIWindowThemeDialog.js,UIWindowTaskManager.js,UIWindowNewPassword.js,UIWindowManageSessions.js, and cross-module refs).gui:readyevent (the only user of the event bus) becomes a directprocess_service.on_gui_ready()call fromUIDesktop.launch_services()now just callsinit()on the four modules that need runtime setup (exec/debug/theme/process), then runslaunch_on_init. All singletons are constructed at import time, so the original construct-before-init ordering is preserved.Servicebase class fromdefinitions.js.service_scriptbridge fromPuterHomepageService(thewindow.service_scriptshim,registerScript,#serviceScripts, and theserviceScriptTagsinjection point).No container, no string-keyed registry, no base-class lifecycle, no event emitter, no backend bridge — just singletons wired by import.
Net: +121 / −253 lines across 20 files (renames preserved).
Testing
webpackGUI build: clean (only pre-existing asset-size warnings)tsc -p tsconfig.build.json: 0 errorsHomepageController.test.ts: 8/8 pass (validates the shell HTML still renders after theservice_scriptremoval)Puter/Init,explorer/UI,dev-center/App) — validatesprocess_serviceinit + register + tree