Introduce Electron-based webui#1590
Open
BitcrushedHeart wants to merge 2 commits into
Open
Conversation
Add an Electron + React (Vite/Tailwind) desktop frontend and a FastAPI bridge in web/, giving OneTrainer a modern GUI alongside the existing customtkinter UI without touching the training backend. - web/backend: FastAPI app with routers for config, presets, concepts, samples, sampling, training, tools (dataset/video/caption utilities), converter, tensorboard, wiki, secrets, system/GPU info and mask editor, plus WebSocket handlers for training/system/terminal streams. - web/gui: Electron main process, preload/IPC bridge, splash screen, and a React renderer with pages mirroring the desktop UI's tabs (general/model/training/lora/embedding/tools/performance/etc.), Tailwind styling, and generated TypeScript types/schemas mirrored from the Python config and enum classes. - web/scripts: generators that introspect modules/util/config and modules/util/enum to emit TypeScript types, UI schemas, and metadata, plus a hardcoded-option checker and ESLint runner, keeping the web UI in sync with the Python source of truth. - Root-level start-web-ui.bat/.sh, install.bat, and CI lint workflow to build/launch the new frontend and lint it in CI. - Bug fixes folded in: path traversal hardening in path_security.py, timestep distribution correctness, performance page and system websocket fixes, safer yt-dlp invocation (video_service.py), and an eslint globals fix for Node-context scripts.
Dead code (grep-verified, pure deletion): - Delete unused useArrayField hook and Skeleton component - Remove dead configStore/uiSchemaStore/trainingStore methods and configApi.getSchema - Strip unused ErrorBoundary fallback/fallbackRender/onReset props - Prune 13 unused brandColors constants De-duplication (behavior-preserving): - Parametrize ScalarChart and delete PerformancePage's near-verbatim MetricChart copy - Extract shared SampleParamsForm from Manual/Standalone sampling modals - Factor VideoToolModal's twin extract tabs into a shared hook + scaffold - Extract hardenWindow/loadRenderer helpers in Electron main Replace 276-line hand-rolled markdown parser with marked + existing DOMPurify sanitizer. Net: 640 fewer source lines. Typecheck, ESLint (strict), and production build all pass. Claude-Session: https://claude.ai/code/session_018zFRV8uwTfLT4krm3zwVDz
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.
Summary
Adds an Electron + React desktop frontend (OneTrainerWeb) as an alternative to the customtkinter GUI, backed by a FastAPI bridge in
web/backendthat talks to the existing training backend through the currentTrainCallbacks/TrainCommandsinterface. No changes tomodules/,scripts/, ortraining_presets/, so the existing GUI and CLI training path are unaffected.What's included:
web/backend: FastAPI app with routers for config, presets, concepts, samples, sampling, training, tools (dataset/caption/video utilities), model conversion, tensorboard, wiki, secrets, and system/GPU info, plus WebSocket handlers for training progress, system metrics, and a terminal.web/gui: Electron main process (spawns the FastAPI server, manages the window, splash screen) and a React + Vite + Tailwind renderer covering the same tabs as the desktop UI (general, model, training, LoRA, embedding, concepts, sampling, tools, performance, etc.).web/scripts: generators that introspectmodules/util/configandmodules/util/enumto produce TypeScript types and UI schemas, so the web UI's parameter set stays in sync with the Python config classes instead of being hand-maintained.start-web-ui.bat/start-web-ui.shand an install step to build and launch the new frontend, plus a CI workflow to lint it.I've been running this on my own fork for months and have exercised most of the functionality end to end (training runs across several model types, config load/save, sampling, tools).
Test plan
pre-commit run --all-filespassesManual testing: used this webui as my daily driver for training on my experimental fork for several months, covering most of the app's functionality (config editing, concepts, sampling, tools, training runs) end to end.
AI assistance