mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-08 18:05:10 +00:00
74964b0e26
Each container's onmessage handler was calling setContainerStats() independently, causing React to schedule up to N separate reconciliation passes per second (one per container). With 20 containers streaming Docker stats at ~1 update/s, EditorLayout was re-rendering up to 20 times/s. Fix: incoming stats are written into pendingStatsRef (no re-render cost), then flushed to React state in one batched setContainerStats call every 1.5s. Two bugs in the original proposal are addressed: - rawBytesRef (never cleared) owns rx/tx tracking so net I/O rate is always accurate; avoids the stale containerStats closure that would have shown 0 B/s after every flush cycle - pending snapshot is captured and cleared BEFORE calling setState so the functional updater stays pure (no side-effects inside it) - pendingStatsRef is cleared in the effect cleanup so stale entries from the previous stack don't briefly appear on stack switch
21 KiB
21 KiB
Changelog
All notable changes to this project will be documented in this file. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased]
- Fixed: Container stats WebSocket flooding React with up to 20+
setStatecalls per second inEditorLayout— each container'sonmessagehandler calledsetContainerStatsindependently, causing React to schedule a separate reconciliation pass per container per second. Replaced with a ref-buffer + 1.5 s flush interval pattern: incoming stats are written topendingStatsRef(no re-render cost), snapshotted and cleared before a single batchedsetContainerStatscall every 1.5 s. A separaterawBytesRef(never cleared) tracks raw rx/tx bytes for accurate rate calculation, avoiding the stale-closure bug that would have produced 0 B/s net I/O after every flush cycle. Buffer is also cleared on cleanup so stale entries from the previous stack don't flash in on stack switch. - Fixed: Browser Out of Memory crash in
GlobalObservabilityView(Logs view) — the component rendered all log entries (up to 1,859+) as real DOM nodes with no virtualization, causing ~9,600 DOM nodes and ~25 MB of GC pressure every 5-second poll cycle. On RAM-constrained hosts (host system was at 97% usage) the browser renderer process OOMed within minutes. Fixed by capping DOM rendering to the last 300 entries (MAX_DISPLAY_ROWS), reducing the in-memory SSE log cap from 10,000 to 2,000 entries (MAX_LOG_ENTRIES), switching auto-scroll frombehavior: 'smooth'(stacked layout animations) tobehavior: 'instant', and reducing the backend polling response limit from 2,000 to 500 lines. Also replacedkey={idx}(array index) with a monotonic_idcounter stamped at ingestion time so the slice window shifting no longer forces O(n) DOM mutations per new log line — React now only reconciles the one entry that actually changed. - Fixed:
HomeDashboardcreate-stack error handling — HTTP error responses were thrown as hardcoded strings, discarding the server's actual error message (e.g. "Stack already exists", "Invalid stack name"). Now reads the JSON error body before throwing, and uses the defensiveerror?.message || error?.error || fallbacktoast pattern. - Fixed: LogViewer (container SSE log stream) returning 404 on remote nodes — the
?nodeId=query param was forwarded byremoteNodeProxyto the remote server, wherenodeContextMiddlewarerejected it withNode X not foundbecause the gateway's node IDs don't exist on the remote instance. Fixed by strippingnodeIdfromproxyReq.pathinonProxyReq, mirroring the existingx-node-idheader removal. - Fixed: Terminal logs and container stats WebSockets failing with "HTTP Authentication failed" on remote nodes — the WebSocket upgrade proxy was forwarding the browser's
cookieheader to the remote Sencho instance. The remote'sauthMiddlewarepickscookieTokenbeforebearerToken, and the cookie (signed with the local JWT secret) fails verification on the remote, returning 401. Fixed by deleting thecookieheader beforewsProxyServer.ws(), mirroring theproxyReq.removeHeader('cookie')already present in the HTTP proxy. Also strips the gateway'snodeIdquery param from the forwarded URL so the remote defaults cleanly to its own local node. - Fixed:
streamStatsDocker stats stream leaking after WebSocket client disconnect — the Docker daemon stream was never destroyed when the WS closed, causing orphaned streams to poll the daemon indefinitely. Fixed by adding aws.on('close')handler that callsstats.destroy(). Also guards allws.send()calls with areadyState === OPENcheck to prevent silent errors on a closed socket. - Fixed:
streamStatsandexecContainercalled unawaited in the WSconnectionhandler — unhandled promise rejections (e.g., invalid container ID, Docker daemon unavailable) would terminate the Node.js process in production (Node ≥ 15). Fixed by chaining.catch()on both calls, logging the error, and closing the WebSocket cleanly. - Fixed: Per-connection
WebSocket.Serverinstances for stack logs and host console never closed after upgrade — each WS connection allocated a persistentws.Serverobject accumulating listeners. Fixed by callingwss.close()immediately afterhandleUpgradecompletes. - Fixed:
authMiddlewareand WS upgrade handler evaluatedcookieToken || bearerToken— a browser cookie present alongside a valid Bearer token would shadow it, risking 401 on node-to-node proxy calls. Fixed by inverting precedence tobearerToken || cookieTokenin both places. - Fixed:
remoteNodeProxyerror handler unsafely castproxyRestoResponse— on WebSocket or TCP-level proxy errorsproxyResis a rawSocket, so calling.status()would throw. Fixed by type-narrowing before sending the 502 response. - Fixed: Container stats (CPU/RAM/NET), bash exec terminal, and "Open App" button all broken for remote nodes — stats and exec WebSockets connected to the bare root (
ws://host) with no?nodeId=query param, so the upgrade handler couldn't detect the remote node and skipped the WS proxy. Moved all generic WebSockets to/ws?nodeId=path; upgrade handler now correctly proxies them to the remote Sencho instance. - Fixed: Bash exec and stats WebSockets not reaching the backend in
npm run dev— Vite proxy config now includesws: trueon/apiand a new/wsproxy entry so all WebSocket upgrades are forwarded tolocalhost:3000. - Fixed: Backend WS message handler crashing when a proxied WebSocket arrives from a gateway and the forwarded
nodeIddoesn't exist in the remote instance's DB — now falls back to the default local node instead of throwing. - Fixed: "Open App" button opening
http://localhost:{port}for remote node containers — now resolves the hostname from the remote node'sapi_urlso the correct remote host is used. - Fixed: Remote node system stats, container stats, logs, and exec returning errors —
remoteNodeProxymiddleware was already positioned before API route definitions, but/api/system/statscontained a dead remote branch that calledNodeRegistry.getDocker()for remote nodes, which throws since remote nodes have no direct Docker socket access. Removed the broken branch; remote requests are correctly intercepted by the proxy middleware before reaching any route handler. - Added: Background image update checker —
ImageUpdateServicepolls OCI-compliant registries (Docker Hub, GHCR, LSCR, etc.) every 6 hours using manifest digest comparison against localRepoDigests. Results cached in a newstack_update_statusSQLite table. A pulsing blue dot badge appears in the stack list sidebar for stacks with available updates. Manual refresh available viaPOST /api/image-updates/refresh(rate-limited to once per 10 minutes). - Fixed:
AppStoreViewandGlobalObservabilityViewusing rawfetch()instead ofapiFetch()— all calls now inject thex-node-idheader so templates, deploys, stacks, and logs are correctly proxied to the active remote node. - Fixed:
HostConsoleWebSocket URL missing?nodeId=query parameter — the upgrade handler now receives the active node ID and routes the PTY session to the correct node. - Added: Two-tier Option A scoped navigation UX — a context pill in the top header bar always shows the active node name (pulsing blue for remote, green for local).
- Added: Remote-aware headers in
HostConsole("Host Console — [Node Name]"),ResourcesView("Resources Hub — [Node Name]"),GlobalObservabilityView(floating node badge), andAppStoreViewdeploy sheet ("Deploying to: [Node Name]"). - Added:
SettingsModalnow scopes its sidebar to the active node type — when a remote node is selected, global-only tabs (Account, Appearance, Notifications, Nodes) are hidden, and the header subtitle shows the remote node name. - Fixed: A massive memory leak (browser Out of Memory crash) by throttling historical metrics polling down to 60s and downsampling SQLite metrics payload sizes by 12x.
- Fixed: A bug where the active node UI dropdown would desync from the actual API requests on initial page load by properly hydrating state from localStorage.
- Fixed: Remote node proxy forwarding the browser's
sencho_tokencookie to the remote Sencho instance — the remote'sauthMiddlewareevaluatescookieToken || bearerTokenand the cookie (signed with the local JWT secret) was validated before the valid Bearer token, causing 401 on all proxied API calls. Fixed by stripping thecookieheader inproxyReqso only the Bearer token is used for remote authentication. - Fixed:
nodeContextMiddlewareblocking/api/nodeswhenx-node-idreferences a deleted/non-existent node — the nodes list endpoint must always succeed so the frontend can re-sync a stale node ID in localStorage; exempted alongside/api/auth/. - Fixed: Remote node proxy stripping the
/apipath prefix —remoteNodeProxyis mounted atapp.use('/api/', ...)so Express strips that prefix fromreq.urlbeforehttp-proxy-middlewaresees it; addedpathRewrite: (path) => '/api' + pathto restore the full path when forwarding to the remote Sencho instance (e.g./stats→/api/stats). This was the root cause of all remote API calls returning the remote's SPA HTML instead of JSON. - Fixed: Dashboard cards (Active Containers, Host CPU, Host RAM, Docker Network) showing stale local-node data after switching to a remote node —
HomeDashboardpolling effects now depend onactiveNode?.idand clear state immediately on node change. - Fixed:
refreshStackscrashing withSyntaxErrororTypeErrorwhen the remote proxy returns a non-JSON response (e.g., connection refused to unreachable remote node) — now checksres.okbefore callingres.json()and iterates a typedfileListinstead of the raw parsed value. - Fixed: Restored Local/Remote type selector and fixed state resets in the Add Node modal — form now resets to defaults every time the dialog opens, and the title reflects the chosen type dynamically.
- Fixed: Remote node connection details failing to display Containers, Images, and CPU metrics —
testRemoteConnectionnow fires parallel requests to/api/stats,/api/system/stats, and/api/system/imagesafter auth succeeds, mapping real values into the info panel. - Fixed: Suppressed
[DEP0060] DeprecationWarning: util._extendfromhttp-proxy@1.18.1— override is applied toprocess.emitWarningbefore the proxy instances are created, cleanly intercepting the warning at its call site without suppressing other warnings. - Fixed: Backend memory leak caused by improper proxy middleware instantiation -
createProxyMiddlewarewas called inside the request handler on every API call, spawning a newhttp-proxyinstance (and registering new server listeners) per request. Refactored to a single globally-instantiated proxy using therouteroption for dynamic per-request target resolution. - Fixed:
[DEP0060] DeprecationWarning: util._extenddeprecation eliminated as a side-effect of the above fix (deprecation was triggered on every newhttp-proxyinitialisation). - Fixed: Remote node authentication failures -
authMiddlewareand WebSocket upgrade handler both acceptAuthorization: Bearertokens (Sencho-to-Sencho proxy auth). - Fixed: Node connection testing logic updated to perform authenticated HTTP pings to
/api/auth/checkon the remote instance. - Fixed: Node switcher dropdown failing to trigger data refreshes -
EditorLayoutnow reacts toactiveNodechanges, re-fetching stacks and clearing stale editor/container state when the user switches nodes. - Fixed: API Token copy button failing silently on HTTP / non-localhost deployments where
navigator.clipboardis unavailable - addedtry/catchwithdocument.execCommand('copy')fallback. - Fixed: Remote node authentication failures by updating middleware to support Bearer tokens in WebSocket upgrade handler (node-to-node WS proxy now authenticates correctly on the receiving instance).
- Fixed: Node connection testing logic updated to normalize
api_urltrailing slashes before constructing the authenticated HTTP ping URL. - Fixed: Memory leak in
GlobalObservabilityViewSSE mode - log array now capped at 10,000 entries (.slice(-10000)) to prevent unbounded accumulation across long sessions. - Fixed: Infinite re-fetch loop in
NodeContext-refreshNodesuseCallback no longer depends onactiveNodestate; replaced with auseRefto read current node inside the callback without being a reactive dependency. - Fixed: Infinite page reload loop -
apiFetchwas callingwindow.location.href = '/'on every 401, causing a full browser reload before auth could complete. Replaced with asencho-unauthorizedcustom event thatAuthContexthandles by settingappStatustonotAuthenticated. - Fixed:
NodeProviderwas mounted outside the auth gate inApp.tsx, causingrefreshNodesto fire before authentication was established (hitting 401 immediately on boot). MovedNodeProviderinside the authenticated branch so it only mounts after login. - Removed: SSH/SFTP file adapters and remote Docker TCP connections (net negative ~500 lines of code).
- Added: Distributed API proxying using http-proxy-middleware for HTTP and WebSockets.
- Added: Long-lived JWT generation for Sencho-to-Sencho API authentication (
POST /api/auth/generate-node-token). - Changed: Node Manager UI vastly simplified - remote nodes now only require an API URL and Token.
- Fixed: Critical port routing conflict - separated Docker API port (
port) from SSH/SFTP port (ssh_port) in thenodesschema. Previously, a singleportfield served both protocols, causing ECONNREFUSED. - Fixed:
FileSystemServicenow reads the node'scompose_dirfrom the database for remote nodes instead of always using theCOMPOSE_DIRenv var. - Fixed: SSH/SFTP connections in
SSHFileAdapter,ComposeService.executeRemote(), andComposeService.streamLogs()now usessh_port(default 22) instead of Docker APIport. - Added: Full SSH credential fields (SSH Port, Username, Password, Private Key) to the Node Manager Add/Edit forms.
- Added:
ssh_portcolumn to thenodesdatabase table with migration support (default: 22). - Changed: Global
FileSystemServiceandComposeServicesingletons refactored into node-aware instances. - Added:
IFileAdapter,LocalFileAdapter, andSSHFileAdapterto abstract all filesystem interactions for remote node support. - Changed:
MonitorServicenow evaluates limits, fetches metrics, and detects container crashes across all registered nodes concurrently. - Added: Node Context Middleware in Express API to dynamically extract
x-node-idheaders and parse WebSocket query parameters. - Added: Remote Nodes Foundation -
nodestable in SQLite with auto-seeded default local node. - Added:
NodeRegistryservice for managing multiple Docker daemon connections (local socket + TCP). - Added: Node management API endpoints: list, get, create, update, delete, and test connection.
- Added: Settings Hub → Nodes tab with full CRUD UI, connection testing, and Docker info display.
- Added: Node switcher dropdown in sidebar (auto-visible when multiple nodes are configured).
- Added:
NodeContextfor frontend-wide active node state management. - Fixed: Global logs false-positive error misclassifications caused by Docker containers writing INFO logs to STDERR. Replaced naive regex with a robust 3-tier classification engine supporting
level=info,[INFO], andINFOformat standards. - Added: Developer Mode setting to enable true Real-Time (SSE) global log streaming and infinite scroll.
- Added: Configurable polling rates for standard global logs monitoring.
- Added: React Throttle Buffer to prevent UI freezing during heavy real-time log ingestion.
- Fixed: Global Logs aggressive auto-scrolling preventing users from reading log history.
- Fixed: Quiet stacks missing from the Global Logs filter dropdown by fetching the definitive stack list independently.
- Fixed: Global logs misclassifying INFO messages as errors due to naive string matching.
- Changed: Global logs now display chronologically (newest at bottom) with smooth auto-scrolling.
- Changed: Renamed Observability navigation tab to Logs.
- Fixed: TTY container log streams failing to parse globally.
- Fixed: Global logs displaying in UTC instead of local browser timezone.
- Changed: Global Logs UI revamped to use a floating, hover-based action bar to maximize terminal space.
- Fixed: Docker raw byte multiplex headers leaking into global logs stream.
- Changed: Relocated historical CPU/RAM charts to the Home Dashboard and normalized data values (CPU relative to host cores, RAM to GB).
- Added: Dozzle-style Action Bar to Global Logs with multi-select stack filtering, search, and STDOUT/STDERR toggles.
- Added: Centralized observability dashboard tracking 24-hour historical metrics and aggregating global tail logs across all running containers.
- Added: Live Container Logs viewer using Server-Sent Events (SSE) for real-time terminal output.
- Added: Pre-deploy folder collision check to prevent silent configuration overwrites in the App Store.
- Added: UI subtitle during deployment to reassure users during long image downloads.
- Changed: Standardized manual stack deletion to use the Two-Stage Teardown (Compose Down -> File Wipe) to prevent ghost networks.
- Fixed: Atomic Rollback failure where non-empty directories caused silent file system errors.
- Added: Two-Stage Teardown mechanism to ensure
docker compose downsweeps up ghost networks before deployment files are deleted.
Deprecated
- (Planned) Port 2375 (TCP) fallback support; future releases may require SSH-only for Node config.
Fixed
- Fixed backend MonitorService crash (
Cannot read properties of undefined (reading 'cpu_usage')) occurring when Docker containers lacked CPU telemetry during transition states. - Handled UI deleted nodes ghost API calls by intercepting 404 errors globally in API and forcing the UI to resync to the default Node context.
- Hardened
nodeContextMiddlewarein Express to intercept queries to invalid or deleted Node IDs gracefully instead of bubbling to Docker API 500 crashes. - Hardened Remote Node connection testing (
docker.info()) to explicitly validate expected Docker API daemon properties instead of merely checking string length. - Caught Unhandled SFTP Promise Rejections in Node registry gracefully returning empty arrays to prevent frontend loading UI stalls.
- Fixed horizontal UI overflowing in Node Manager settings on smaller resolutions.
- Fixed: Docker API parsing bug where HTML string responses from misconfigured ports were counted as containers.
- Fixed: Stack list crashing when SFTP connections fail by gracefully catching SSH errors and returning empty arrays.
Changed
- Changed: Expanded Node Manager UI width and added horizontal scrollbars for better data visibility.
- Added: Smart Error Parser with telemetry-ready rule IDs to translate cryptic Docker output.
- Added: Post-Deploy Health Probe to catch immediate container crashes that slip past Compose.
- Changed: Rollback engine respects a
canSilentlyRollbackflag to protect user-authored configurations. - Changed: Removed rigid volume sanitization, allowing full user control over bind paths.
- Added: Editable Host Volumes in the deployment UI.
- Added: Custom Environment Variable injection tool.
- Fixed: ScrollArea UI height rendering and dynamic browser timezone detection.
- Changed: Rebranded "Templates" to "App Store" across the UI.
- Added: Advanced deployment configuration panel (Editable Ports and Environment Variables) with smart defaults.
- Fixed: Implemented smart image fallbacks for broken registry logos and added expandable descriptions.
- Added: Atomic Deployments: Failed App Store deployments now automatically roll back and delete their orphaned folders.
- Fixed: Global dark mode scrollbar styling to eliminate blinding white native scrollbars.
- Fixed: Input overlap UI bug in the App Store deployment panel.
Added
- Added: Official LinuxServer.io API integration as the default Template Registry.
- Added: Rich metadata display in the App Store (Architectures, Documentation links, GitHub repository links).
- Added: Dynamic Template Registry URL support via global settings, defaulting to LinuxServer.io templates.
- Fixed: Smart Volume Sanitizer to automatically rewrite messy Portainer bind mounts into clean, relative paths (Sencho 1:1 path rule).
- Git Flow branching strategy and branch protection.
- GitHub Actions CI pipeline for automated TypeScript build verification.
- Added: Automated Docker Hub CI/CD pipeline for the
devandlatesttags. - Added: App Templates (App Store) with One-Click deployment, utilizing Portainer v2 JSON registries and auto-generating compose files.