fix(dashboard): fallback to stale dist, retry build, add --skip-build flag#23859
Merged
Conversation
… flag Three improvements for non-interactive contexts (Windows Scheduled Tasks, CI/CD) where the web UI build may fail (issue #23817): 1. Retry build once after 3s — covers boot-time races (antivirus scanning Node.js, npm cache not ready, transient disk I/O) 2. Fall back to existing dist when build fails (non-fatal mode) — a stale UI is far better than no UI at all 3. Add --skip-build flag — lets callers pre-build in their wrapper script and start the dashboard without internal build attempt 4. Surface npm stderr in build failure output for easier debugging Fixes #23817
Follow-up to PR #23824. Adds two correctness fixes on top of the contributor's salvaged commit: 1. Stale-dist fallback no longer gated on `fatal=False`. `cmd_dashboard` passes `fatal=True` and is the primary scenario this fallback is for (issue #23817 — Windows Scheduled Task at logon). The previous gate meant the fallback never fired in the case it was designed for. 2. `--skip-build` now verifies the dist actually exists before starting the server. Without this, a misconfigured pre-build would launch the dashboard pointing at a missing dist and silently serve 404s. We now exit 1 with a clear "pre-build first: cd web && npm run build" message, and on success print which dist directory is being used. Verified end-to-end on Linux: - build fails + stale dist (fatal=True) -> fallback fires - build fails + no dist (fatal=True) -> exit 1 with stderr surfaced - build fails + stale dist (fatal=False) -> fallback fires - --skip-build + missing dist -> exit 1 with clear guidance - --skip-build + valid dist -> 'Skipping web UI build...'
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-argument-type |
3 |
First entries
run_agent.py:13308: [invalid-argument-type] invalid-argument-type: Argument to function `_is_oauth_token` is incorrect: Expected `str`, found `str | dict[Unknown, Unknown] | Any | ... omitted 3 union elements`
run_agent.py:13311: [invalid-argument-type] invalid-argument-type: Argument to function `len` is incorrect: Expected `Sized`, found `(str & ~AlwaysFalsy) | (dict[Unknown, Unknown] & ~AlwaysFalsy) | (Any & ~AlwaysFalsy) | ... omitted 3 union elements`
run_agent.py:7160: [invalid-argument-type] invalid-argument-type: Argument to function `build_anthropic_client` is incorrect: Expected `str`, found `str | dict[Unknown, Unknown] | Any | ... omitted 3 union elements`
✅ Fixed issues (3):
| Rule | Count |
|---|---|
invalid-argument-type |
3 |
First entries
run_agent.py:13308: [invalid-argument-type] invalid-argument-type: Argument to function `_is_oauth_token` is incorrect: Expected `str`, found `str | dict[Unknown | str, Unknown | str | dict[str, str]] | Any | ... omitted 3 union elements`
run_agent.py:13311: [invalid-argument-type] invalid-argument-type: Argument to function `len` is incorrect: Expected `Sized`, found `(str & ~AlwaysFalsy) | (dict[Unknown | str, Unknown | str | dict[str, str]] & ~AlwaysFalsy) | (Any & ~AlwaysFalsy) | ... omitted 3 union elements`
run_agent.py:7160: [invalid-argument-type] invalid-argument-type: Argument to function `build_anthropic_client` is incorrect: Expected `str`, found `str | dict[Unknown | str, Unknown | str | dict[str, str]] | Any | ... omitted 3 union elements`
Unchanged: 4274 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
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.
Salvages #23824 by @ygd58 with two correctness fixes folded in.
Fixes #23817 — Windows Scheduled Task starts the dashboard at logon, npm build fails in the non-interactive environment, and the dashboard exits with no fallback. Port 9119 stays unreachable until the user manually rebuilds.
Changes
hermes_cli/main.py:_build_web_ui: retrynpm run buildonce after 3s (covers boot-time races on Windows — antivirus scanning Node.js, npm cache not ready, transient I/O)._build_web_ui: if the build still fails AND a staleweb_dist/index.htmlexists, serve it as a fallback. A stale UI is far better than no UI for non-interactive callers._build_web_ui: surface the npm stderr tail (last 10 lines) in the failure message — previously the user just saw "✗ Web UI build failed" with no clue why.cmd_dashboard: add--skip-buildflag for callers that pre-build (e.g. a BAT wrapper around the Scheduled Task). When set, validate that the dist actually exists before starting the server, so a misconfigured pre-build exits 1 with clear guidance instead of silently serving 404s.tests/hermes_cli/test_web_ui_build.py:fatal=True, which is the issue's primary scenario), and hard-fail when no dist exists.Salvage notes
@ygd58's PR had a Python
SyntaxError(literal newline mid-string in the\"\\n \".join(...)) and gated the stale-dist fallback onnot fatal— butcmd_dashboardalways passesfatal=True, so the fallback never fired in the exact scenario the issue is about. Both fixed in the cherry-pick. Followup commit adds the--skip-builddist-existence sanity check + tests.Validation
tests/hermes_cli/test_web_ui_build.pytests/hermes_cli/test_dashboard_*--skip-build+ missing dist--skip-build+ valid distOriginal PR #23824 will be closed with credit pointing here.