diff --git a/internal/httpapi/assistant_diagnostic_environment.go b/internal/httpapi/assistant_diagnostic_environment.go
index 74746bcb5..5ee1a669b 100644
--- a/internal/httpapi/assistant_diagnostic_environment.go
+++ b/internal/httpapi/assistant_diagnostic_environment.go
@@ -33,6 +33,13 @@ func assistantDiagnosticEnvironment() domain.AssistantDiagnosticEnvironment {
}
}
}
+ // Release images carry the tag and commit separately from Go's VCS info.
+ if version := buildReleaseVersion(); version != "" {
+ e.PlatformVersion = version
+ }
+ if _, revision := buildCommit(); revision != "" {
+ e.Revision = revision
+ }
return e
}
diff --git a/internal/httpapi/assistant_diagnostic_environment_test.go b/internal/httpapi/assistant_diagnostic_environment_test.go
new file mode 100644
index 000000000..676e198f8
--- /dev/null
+++ b/internal/httpapi/assistant_diagnostic_environment_test.go
@@ -0,0 +1,24 @@
+package httpapi
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+func TestAssistantDiagnosticEnvironmentUsesPackagedBuildMetadata(t *testing.T) {
+ const version = "v0.4.2"
+ const commit = "4ff0e73c84987966baa109d578c93b855ab8a26f"
+ commitFile := filepath.Join(t.TempDir(), "loopforge-commit")
+ if err := os.WriteFile(commitFile, []byte(commit), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ t.Setenv("LOOPFORGE_RELEASE_VERSION", version)
+ t.Setenv("LOOPFORGE_COMMIT", "")
+ t.Setenv("LOOPFORGE_COMMIT_FILE", commitFile)
+
+ build := assistantDiagnosticEnvironment()
+ if build.PlatformVersion != version || build.Revision != commit {
+ t.Fatalf("diagnostics build version=%q revision=%q, want %q / %q", build.PlatformVersion, build.Revision, version, commit)
+ }
+}
diff --git a/internal/httpapi/studio.go b/internal/httpapi/studio.go
index 611fcf149..5ce384493 100644
--- a/internal/httpapi/studio.go
+++ b/internal/httpapi/studio.go
@@ -41,7 +41,7 @@ func stampStudioIndex(static fs.FS, raw []byte) []byte {
tag := fmt.Sprintf(``, htmlpkg.EscapeString(domain))
html = strings.Replace(html, "", tag, 1)
}
- if version := strings.TrimSpace(os.Getenv("LOOPFORGE_RELEASE_VERSION")); studioReleaseVersion.MatchString(version) {
+ if version := buildReleaseVersion(); version != "" {
meta := fmt.Sprintf(``, version)
html = strings.Replace(html, "", meta, 1)
}
@@ -49,6 +49,14 @@ func stampStudioIndex(static fs.FS, raw []byte) []byte {
return []byte(html)
}
+func buildReleaseVersion() string {
+ version := strings.TrimSpace(os.Getenv("LOOPFORGE_RELEASE_VERSION"))
+ if studioReleaseVersion.MatchString(version) {
+ return version
+ }
+ return ""
+}
+
// defaultBuildCommitFile is written by docker build from the LOOPFORGE_COMMIT
// build-arg, or from git HEAD when none was passed.
const defaultBuildCommitFile = "/app/loopforge-commit"