fix(tui): use git commit hash for build staleness — immune to git pull mtime changes#21837
Open
ygd58 wants to merge 2 commits into
Open
fix(tui): use git commit hash for build staleness — immune to git pull mtime changes#21837ygd58 wants to merge 2 commits into
ygd58 wants to merge 2 commits into
Conversation
…TY context After git pull, source file mtimes are newer than dist/entry.js so _tui_build_needed() returns True and triggers a rebuild. When triggered from the PTY WebSocket handler (hermes dashboard --tui), the build fails silently — sys.exit(1) is caught as SystemExit, the PTY session dies, and the Chat tab shows [session ended] immediately (issue NousResearch#21801). Fix: if dist/entry.js already exists and the rebuild fails, emit a warning and fall back to the existing build instead of calling sys.exit(1). The fallback only applies when a pre-existing dist exists; a missing dist still hard-fails as before. Users can run 'npm run build' in ui-tui/ manually to update the build. Fixes NousResearch#21801
…l mtime changes mtime-based staleness check caused _tui_build_needed() to always return True after git pull (all source files get new mtimes). In PTY/WebSocket context this triggered a rebuild that failed silently with sys.exit(1), showing [session ended] in the dashboard Chat tab (issue NousResearch#21801). Two-part fix: 1. Add _tui_get_source_hash() — uses git HEAD commit hash when available (immune to mtime changes), falls back to mtime hash for non-git installs 2. Write dist/.build-stamp after successful build; compare against current hash on next run — skips rebuild when hash matches 3. Fall back to existing dist/entry.js when rebuild fails in PTY context instead of calling sys.exit(1) Fixes NousResearch#21801
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.
Problem
mtime-based staleness check caused
_tui_build_needed()to always return True after git pull. In PTY/WebSocket context this triggered a rebuild that failed silently withsys.exit(1), showing[session ended]in the dashboard Chat tab.Fix
_tui_get_source_hash()— uses git HEAD commit hash (immune to mtime changes), falls back to mtime hash for non-git installsdist/.build-stampafter successful build; compare on next run — skips rebuild when hash matchesdist/entry.jswhen rebuild fails in PTY context instead ofsys.exit(1)Fixes #21801