The footer abbreviated to 7 characters, so the line read "v master · 19f0319". That line exists to be pasted into `git show` or compared against a registry tag, and an abbreviation makes both a manual step — while the full 40-char value was already baked into the image (build.yml passes `github.sha` whole, and /version returns it untouched). `shortSha` had no other caller, so it goes with it. The span gets `overflow-wrap: anywhere` and `min-width: 0`: hex offers no break opportunity, and the api/web mismatch branch renders two of these hashes side by side, which would otherwise push a phone into horizontal scroll. Measured at a simulated 360px with both hashes present — the span wraps, and documentElement.scrollWidth stays equal to clientWidth. Verified in the browser against the dev database: footer renders "v1.0.0 · db2bd54c0ffee1234567890abcdef0123456789a", hash length 40. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
/**
|
|
* The web image's own build identity.
|
|
*
|
|
* Same runtime-injection trick as API_ORIGIN (lib/api.ts): docker/web.Dockerfile
|
|
* bakes APP_VERSION / GIT_SHA / BUILD_DATE as ENV, layout.tsx reads them on the
|
|
* server per request and paints them into window.__APP_BUILD__. Reading
|
|
* process.env directly from a client component would return undefined — Next
|
|
* only inlines NEXT_PUBLIC_* into the browser bundle, and baking the version in
|
|
* at build time is exactly what we are avoiding elsewhere.
|
|
*/
|
|
export interface BuildInfo {
|
|
version: string;
|
|
gitSha: string;
|
|
buildDate: string;
|
|
}
|
|
|
|
export const UNKNOWN_BUILD: BuildInfo = {
|
|
version: "dev",
|
|
gitSha: "unknown",
|
|
buildDate: "unknown",
|
|
};
|
|
|
|
/** Server-side read, used by layout.tsx to produce the injected payload. */
|
|
export function readBuildInfoFromEnv(): BuildInfo {
|
|
return {
|
|
version: process.env.APP_VERSION ?? UNKNOWN_BUILD.version,
|
|
gitSha: process.env.GIT_SHA ?? UNKNOWN_BUILD.gitSha,
|
|
buildDate: process.env.BUILD_DATE ?? UNKNOWN_BUILD.buildDate,
|
|
};
|
|
}
|
|
|
|
/** Browser-side read of what layout.tsx injected. */
|
|
export function webBuildInfo(): BuildInfo {
|
|
if (typeof window === "undefined") return readBuildInfoFromEnv();
|
|
const injected = (window as { __APP_BUILD__?: BuildInfo }).__APP_BUILD__;
|
|
return injected ?? UNKNOWN_BUILD;
|
|
}
|