#7023: feat(ui): inject build SHA fingerprint into index.html
scripts
Cluster:
UI Improvements and Fixes
## Summary
Adds git SHA to the built index.html to enable runtime verification that the UI matches the current codebase version. This helps detect stale cached UIs after server restarts or crashes.
## Changes
- Add `getGitSha()` to read current HEAD
- Add `injectBuildSha()` to modify `dist/control-ui/index.html` after vite build
- SHA is added as both `data-build-sha` attribute on `<html>` and `<meta name="build-sha">` tag
## Use case
After a gateway restart or crash, the browser may serve a cached UI that doesn't match the new server version. This fingerprint allows the UI to detect the mismatch and prompt a refresh.
## Test plan
- [x] `pnpm ui:build` runs successfully
- [x] `dist/control-ui/index.html` contains `data-build-sha` attribute
- [x] SHA matches `git rev-parse HEAD`
🤖 Generated with [Claude Code](https://claude.ai/code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates `scripts/ui.js` so that after the UI build completes it injects the current git HEAD SHA into the generated `dist/control-ui/index.html` (as `data-build-sha` on `<html>` and as a `<meta name="build-sha">`), enabling runtime detection of stale cached UIs after restarts.
Main thing to watch is that the injection is implemented with simple string/regex replacements, which can become non-idempotent (duplicate attributes/meta tags on repeated builds) or fail silently if the generated HTML differs in casing/formatting (e.g., no literal `</head>` match, multiline `<html>` tag). Tightening the matching and/or making the operation explicitly idempotent would make this more robust in CI and across Vite output changes.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge, but the HTML injection approach is brittle and can produce incorrect or duplicated fingerprints in some build outputs.
- Change scope is small and isolated to the UI build script, but relies on regex/string replacement of generated HTML, which is prone to silent mismatch across formatting/casing changes and can become non-idempotent when builds are re-run.
- scripts/ui.js
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#21089: fix(ui): externalize all Node builtins in Vite build
by lemoz · 2026-02-19
74.8%
#7824: fix(ui): remove --prod install flag that causes vite not found error
by adityarao3 · 2026-02-03
74.8%
#9628: fix: resolve tsconfig rootDir errors by separating UI config (AI-as...
by KGBos · 2026-02-05
73.7%
#8644: Fix Control UI asset resolution for global installs
by codvik · 2026-02-04
71.4%
#18676: feat: add patch-ui.sh
by jasonkneen · 2026-02-16
70.1%
#12871: fix: use bash and warn about shell injection (issue #12836)
by ambicuity · 2026-02-09
69.8%
#9373: UI: add PWA support to control UI
by jsahagun91 · 2026-02-05
69.4%
#3973: fix: enhance npm package integrity checks and include critical files
by YeSuX · 2026-01-29
69.4%
#6812: fix(ui): make topbar height flexible to avoid header/title overlap
by x0m4ek · 2026-02-02
69.3%
#7316: fix: /chat dashboard performance
by felipcsousa · 2026-02-02
69.3%