docs: default version selector to Cloud (Latest)#2703
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review
This pull request updates the version selector script in docs/assets/javascripts/version-select.js to explicitly set the selector's value to the current version. This prevents the browser from falling back to the last option when option elements are moved into the pre-existing select element. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Set select.value to the resolved current version after populating the options so the correct entry stays selected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30c1dc5 to
7c1cae2
Compare
There was a problem hiding this comment.
Pull Request Overview
The PR addresses the bug where the version selector would default to older or deprecated entries rather than 'Cloud (Latest)'. While the implementation fixes the UI state management issue by explicitly setting the selector value after DOM injection, there is a risk of a runtime crash if the configuration data is malformed or if the current path does not match expected version patterns.
Additionally, the PR lacks automated test coverage for the selection logic. Verification currently relies on manual path testing, which increases the risk of regression given the sensitivity of URL-based versioning logic. The Codacy analysis indicates the changes are up to standards from a static analysis perspective, but the logic issues detailed below should be addressed before merging.
About this PR
- The PR lacks automated unit or integration tests to verify the version selection logic across different URL paths or JSON response scenarios. Given the complexity of version matching, automated tests are recommended.
Test suggestions
- Verify that when the current path corresponds to VERSION_LATEST, the 'Cloud (Latest)' option is selected after initialization.
- Verify that when the current path corresponds to a specific version found in versions.json, that specific version is selected.
- Verify that the selector remains enabled and selectable after the version is set.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that when the current path corresponds to VERSION_LATEST, the 'Cloud (Latest)' option is selected after initialization.
2. Verify that when the current path corresponds to a specific version found in versions.json, that specific version is selected.
3. Verify that the selector remains enabled and selectable after the version is set.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
Problem
On the released docs.codacy.com, the version selector defaults to the last entry (
Self-hosted v2.0.387 (Deprecated)) instead of Cloud (Latest).Root cause:
versions.jsonlists thelatestentry last, andgenerateVersionSwitchermoves the freshly built<option>elements into the pre-existing#version-selectorin the header viareplaceChildren. Moving the option nodes loses the selectedness set on them, so the browser's reset falls through to the last option in the list.Fix
After populating the options, set
select.valueto the resolved current version so the correct entry stays selected —Cloud (Latest)on the cloud site, and the matching version on self-hosted/versioned paths.Verification
Reproduced against the live site DOM: the selector reported
selectedIndex: 33(the deprecated last option). Applyingselect.value = "latest"moved it toselectedIndex: 0→Cloud (Latest), which is what this change does deterministically for every version path.🤖 Generated with Claude Code