[WIP] feat(version): add server version endpoint and client version display#664
[WIP] feat(version): add server version endpoint and client version display#664ilopezluna wants to merge 3 commits intomainfrom
Conversation
Summary of ChangesHello @ilopezluna, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a robust versioning mechanism across the application. It ensures that version details are embedded into compiled binaries during the build process, exposes this information via a dedicated server API endpoint, and enhances the command-line interface to display both client and server version details. This provides improved transparency and diagnostic capabilities regarding the application's deployed state. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces versioning support by adding a /version endpoint to the server and a version command to the CLI. The version is injected at build time using ldflags, both in the Dockerfile and the local Makefile build. The CLI now displays both client and server versions. My review identifies a logic bug in the new CLI command that incorrectly reports server information in standalone mode, and a minor issue where an error is ignored in the new server endpoint. Code suggestions are provided for both issues.
| if desktopClient == nil { | ||
| cmd.Println(" Version: (not reachable)") | ||
| cmd.Println(" Engine: (not reachable)") | ||
| return | ||
| } | ||
| sv, err := desktopClient.ServerVersion() | ||
| if err != nil { | ||
| cmd.Println(" Version: (not reachable)") | ||
| } else { | ||
| cmd.Printf(" Version: %s\n", sv.Version) | ||
| } | ||
| cmd.Printf(" Engine: %s\n", modelRunner.EngineKind()) |
There was a problem hiding this comment.
The current logic for displaying server information in the version command has a couple of issues. First, it incorrectly reports the engine as (not reachable) when running in standalone mode (when desktopClient is nil). The engine kind is a client-side property and should be available. Second, the logic is a bit repetitive and can be simplified for better readability and correctness.
I suggest refactoring this section to always display the engine kind and to determine the server version more concisely.
serverVersion := "(not reachable)"
if desktopClient != nil {
if sv, err := desktopClient.ServerVersion(); err == nil {
serverVersion = sv.Version
}
}
cmd.Printf(" Version: %s\n", serverVersion)
cmd.Printf(" Engine: %s\n", modelRunner.EngineKind())| // Register /version endpoint | ||
| router.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { | ||
| w.Header().Set("Content-Type", "application/json") | ||
| _ = json.NewEncoder(w).Encode(map[string]string{"version": Version}) |
There was a problem hiding this comment.
The error returned by json.NewEncoder(w).Encode() is being ignored. While errors are unlikely when writing to an http.ResponseWriter, they can occur (e.g., if the client closes the connection). It's a good practice to handle this error, for example by logging it, to aid in debugging potential network issues.
if err := json.NewEncoder(w).Encode(map[string]string{"version": Version}); err != nil {
log.Warnf("failed to write version response: %v", err)
}# Conflicts: # .github/workflows/release.yml
No description provided.