codeant-ai-for-open-source[bot] commented on code in PR #39837:
URL: https://github.com/apache/superset/pull/39837#discussion_r3230646963
##########
docs/src/theme/DocVersionBadge/index.js:
##########
@@ -40,8 +40,8 @@ export default function DocVersionBadge() {
const isVersioned = [
'default', // main docs
'components',
- 'tutorials',
- 'developer_portal',
+ 'admin_docs',
+ 'developer_docs',
Review Comment:
**Suggestion:** Adding these plugin IDs enables the badge for sections whose
URL base paths use hyphens (`/admin-docs`, `/developer-docs`), but the path
extraction logic later derives `basePath` from `pluginId` (`/${pluginId}`),
which becomes `/admin_docs` and `/developer_docs`. This mismatch prevents
correct relative-path extraction and makes version switches jump to section
roots instead of the current page. Add a pluginId→routeBasePath mapping (or
read routeBasePath from plugin metadata) before enabling these IDs. [logic
error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Admin docs version switcher loses current page location.
- ⚠️ Developer docs version switching resets navigation to section root.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Observe docs plugin configuration in `docs/docusaurus.config.ts`: the
`admin_docs`
plugin is defined with `id: 'admin_docs'` at line 72 and `routeBasePath:
'admin-docs'` at
line 74, and the `developer_docs` plugin is defined with `id:
'developer_docs'` at line
100 and `routeBasePath: 'developer-docs'` at line 102 (verified via Grep
output).
2. Navigate to any admin docs page whose URL starts with `/admin-docs/`
(served by the
`admin_docs` plugin configured above) so that the React router location
pathname is like
`/admin-docs/some/section`, and `useActivePlugin()` in
`docs/src/theme/DocVersionBadge/index.js:33-37` returns
`activePlugin.pluginId ===
'admin_docs'`.
3. In `DocVersionBadge`'s `useEffect` at
`docs/src/theme/DocVersionBadge/index.js:52-80`,
`basePath` is computed as `pluginId === 'default' ? '/docs' :
\`/${pluginId}\``, so for
this page `basePath` becomes `'/admin_docs'` while `pathname` is
`'/admin-docs/…'`. The
condition `pathname.includes(basePath)` at line 59 is therefore false,
`relativePath`
remains the empty string, and `setVersionedPath('')` is called.
4. When the user opens the version dropdown rendered from `items` in
`docs/src/theme/DocVersionBadge/index.js:82-103` and selects another
version, `versionUrl`
is left as `v.path` (line 86) because `versionedPath` is empty, so the
browser navigates
to the version's root like `/admin-docs/1.1.0` instead of
`/admin-docs/1.1.0/some/section`, reproducing the behavior where version
switches in
`admin_docs`/`developer_docs` jump to section roots instead of preserving
the current page
path.
```
</details>
[Fix in
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20docs%2Fsrc%2Ftheme%2FDocVersionBadge%2Findex.js%0A%2A%2ALine%3A%2A%2A%2043%3A44%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20Adding%20these%20plugin%20IDs%20enables%20the%20badge%20for%20sections%20whose%20URL%20base%20paths%20use%20hyphens%20%28%60%2Fadmin-docs%60%2C%20%60%2Fdeveloper-docs%60%29%2C%20but%20the%20path%20extraction%20logic%20later%20derives%20%60basePath%60%20from%20%60pluginId%60%20%28%60%2F%24%7BpluginId%7D%60%29%2C%20which%20becomes%20%60%2Fadmin_docs%60%20and%20%60%2Fdeveloper_docs%60.%20This%20mismatch%20prevents%20correct%20relative-path%20extraction%20and%20makes%20version%20switches%20jump%20to%20section%20roots%20instead%20of%20the%20current%20page.%20Add%20a%20pluginId%E2%86%92routeBasePath%20mapping%20%28or%20read%20routeBasePath%20from%20plugin%20metadata%29%20before%20enabling%20these%20IDs.
%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
| [Fix in VSCode
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20docs%2Fsrc%2Ftheme%2FDocVersionBadge%2Findex.js%0A%2A%2ALine%3A%2A%2A%2043%3A44%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20Adding%20these%20plugin%20IDs%20enables%20the%20badge%20for%20sections%20whose%20URL%20base%20paths%20use%20hyphens%20%28%60%2Fadmin-docs%60%2C%20%60%2Fd
eveloper-docs%60%29%2C%20but%20the%20path%20extraction%20logic%20later%20derives%20%60basePath%60%20from%20%60pluginId%60%20%28%60%2F%24%7BpluginId%7D%60%29%2C%20which%20becomes%20%60%2Fadmin_docs%60%20and%20%60%2Fdeveloper_docs%60.%20This%20mismatch%20prevents%20correct%20relative-path%20extraction%20and%20makes%20version%20switches%20jump%20to%20section%20roots%20instead%20of%20the%20current%20page.%20Add%20a%20pluginId%E2%86%92routeBasePath%20mapping%20%28or%20read%20routeBasePath%20from%20plugin%20metadata%29%20before%20enabling%20these%20IDs.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%2
0all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** docs/src/theme/DocVersionBadge/index.js
**Line:** 43:44
**Comment:**
*Logic Error: Adding these plugin IDs enables the badge for sections
whose URL base paths use hyphens (`/admin-docs`, `/developer-docs`), but the
path extraction logic later derives `basePath` from `pluginId`
(`/${pluginId}`), which becomes `/admin_docs` and `/developer_docs`. This
mismatch prevents correct relative-path extraction and makes version switches
jump to section roots instead of the current page. Add a pluginId→routeBasePath
mapping (or read routeBasePath from plugin metadata) before enabling these IDs.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39837&comment_hash=294d25c166be62474d28ed7bb9066fc206cec1e9bef6b8b7e2c5a6c0dde7d76f&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39837&comment_hash=294d25c166be62474d28ed7bb9066fc206cec1e9bef6b8b7e2c5a6c0dde7d76f&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]