Skip to content

feat: [AH-2867]: Frontend support to add tag to docker and helm artifact#93

Open
abhinavcode wants to merge 5 commits into
mainfrom
AH-2867
Open

feat: [AH-2867]: Frontend support to add tag to docker and helm artifact#93
abhinavcode wants to merge 5 commits into
mainfrom
AH-2867

Conversation

@abhinavcode

@abhinavcode abhinavcode commented Feb 24, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added "Add Tag" capability for artifact versions (Docker & Helm): RBAC-protected menu action that opens a modal to enter tags, with validation, loading state, success/failure toasts, and automatic UI refresh on success.
    • Version actions updated to include the new Add Tag option.
  • Localization

    • Added UI strings for Add Tag action, placeholder, success, and failure messages.
  • Style

    • Constrained tag input width for the Add Tag modal for better responsiveness.

@coderabbitai

coderabbitai Bot commented Feb 24, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a new VersionAction.AddTag and enables it for Docker and Helm versions; implements an RBAC-protected Add Tag menu item and Formik modal that normalizes/validates tags, calls the add-tags mutation, shows success/error toasts, invalidates queries, and closes the modal on success. (35 words)

Changes

Cohort / File(s) Summary
Action Type & Version Config
web/src/ar/pages/version-details/components/VersionActions/types.ts, web/src/ar/pages/version-details/DockerVersion/DockerVersionType.tsx, web/src/ar/pages/version-details/HelmVersion/HelmVersionType.tsx
Added VersionAction.AddTag enum member; included AddTag in Docker and Helm allowedActionsOnVersion. Review callers that enumerate or validate actions.
Add Tag UI & Logic
web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx, web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.module.scss
New AddTagMenuItem and AddTagModalContent: Formik modal with PatternInput, tag normalization/validation, calls add-tags mutation (uses query params: account/org/project/registry + package/version/tags), shows toasts on success/failure, invalidates GetAllHarnessArtifacts and ListVersions queries, RBAC-protected; SCSS constrains input width. Verify API payload/params, error handling, and form validation.
Version Actions Integration
web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx
Wired AddTagMenuItem and modal via modal hook (useParentHooks/useModalHook), added closeMenu to coordinate menu/modal lifecycle and propagate onClose. Check modal lifecycle and onClose propagation.
Localization & Types
web/src/ar/pages/version-list/strings/strings.en.yaml, web/src/ar/strings/types.ts
Added i18n keys: versionList.actions.addTag, versionList.actions.addTagPlaceholder, versionList.messages.addTagSuccess, versionList.messages.addTagFailed and corresponding type entries. Validate usages and type alignment.

Sequence Diagram

sequenceDiagram
    participant UI as UI (VersionActions)
    participant Modal as AddTagModalContent
    participant API as AddTags API
    participant Cache as QueryClient

    UI->>UI: User selects "Add Tag"
    UI->>Modal: showAddTagModal(artifactKey, repoKey, versionKey)
    Modal->>Modal: User enters tags -> normalize & validate
    alt valid
        Modal->>API: POST add-tags (package, version, tags, queryParams)
        API-->>Modal: success
        Modal->>Cache: invalidate(GetAllHarnessArtifacts, ListVersions)
        Modal-->>UI: hideModal()/onClose
        Modal->>UI: show success toast
    else invalid
        Modal->>Modal: show validation error / show error toast
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped in with a tiny tag,
A modal open, input snug and sleek,
I trim the whitespace, press Enter quick,
I send the call and watch the cache speak,
Hooray — new labels for the build and creek.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding frontend support for tagging Docker and Helm artifacts, which aligns with all the file changes in the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch AH-2867

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
web/src/ar/pages/artifact-list/ArtifactListPage.tsx (1)

92-96: Extract the event name to a shared constant to prevent silent cross-file mismatch.

The event string 'ar-refresh-artifact-list' is duplicated across two files (ArtifactListPage.tsx and AddTagMenuItem.tsx). Any typo in either location silently breaks the feature with no runtime error. Add to the existing web/src/ar/constants.ts:

export const AR_EVENTS = {
  REFRESH_ARTIFACT_LIST: 'ar-refresh-artifact-list',
} as const

Then update both the listener and emitter to use this constant. Additionally, the redundant handler wrapper can be removed and refetch passed directly to the event listener.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/ar/pages/artifact-list/ArtifactListPage.tsx` around lines 92 - 96,
Extract the event name into the shared constant AR_EVENTS. Add the suggested
AR_EVENTS constant (REFRESH_ARTIFACT_LIST) to web/src/ar/constants.ts, then in
ArtifactListPage.tsx replace the literal 'ar-refresh-artifact-list' with
AR_EVENTS.REFRESH_ARTIFACT_LIST and simplify the useEffect by passing refetch
directly as the listener (remove the wrapper handler). Also update
AddTagMenuItem.tsx to emit the event using AR_EVENTS.REFRESH_ARTIFACT_LIST
instead of the hard-coded string so both emitter and listener use the same
constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.module.scss`:
- Around line 17-22: The Stylelint rule selector-pseudo-class-no-unknown is
tripping on the :global(.bp3-input) selector inside the .addTagInputWrapper
block; add a local suppression comment immediately before the offending line —
e.g. place /* stylelint-disable-next-line selector-pseudo-class-no-unknown */
above :global(.bp3-input) — so the CSS module global selector is preserved while
the linter is skipped for that line.

In
`@web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx`:
- Around line 214-225: The Add Tag action is not currently hidden for public
sessions; wrap the AddTagMenuItem render with the same public-session guard used
for other mutating actions so it is not shown to public users. Update the JSX
condition to require both isAllowed(VersionAction.AddTag) and
!isCurrentSessionPublic (or the existing helper used elsewhere) before rendering
AddTagMenuItem (keeping artifactKey, repoKey, versionKey, data, pageType,
readonly, onClose, openAddTagModal props unchanged).

---

Nitpick comments:
In `@web/src/ar/pages/artifact-list/ArtifactListPage.tsx`:
- Around line 92-96: Extract the event name into the shared constant AR_EVENTS.
Add the suggested AR_EVENTS constant (REFRESH_ARTIFACT_LIST) to
web/src/ar/constants.ts, then in ArtifactListPage.tsx replace the literal
'ar-refresh-artifact-list' with AR_EVENTS.REFRESH_ARTIFACT_LIST and simplify the
useEffect by passing refetch directly as the listener (remove the wrapper
handler). Also update AddTagMenuItem.tsx to emit the event using
AR_EVENTS.REFRESH_ARTIFACT_LIST instead of the hard-coded string so both emitter
and listener use the same constant.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18bd07c and 770a0e9.

📒 Files selected for processing (9)
  • web/src/ar/pages/artifact-list/ArtifactListPage.tsx
  • web/src/ar/pages/version-details/DockerVersion/DockerVersionType.tsx
  • web/src/ar/pages/version-details/HelmVersion/HelmVersionType.tsx
  • web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.module.scss
  • web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx
  • web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx
  • web/src/ar/pages/version-details/components/VersionActions/types.ts
  • web/src/ar/pages/version-list/strings/strings.en.yaml
  • web/src/ar/strings/types.ts

Comment on lines +17 to +22
/* Fixed width for the tag input bar only when rendered inside Add Tag modal */
.addTagInputWrapper {
:global(.bp3-input) {
min-width: 400px;
max-width: 400px;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Stylelint error for :global needs a fix.

The current selector trips selector-pseudo-class-no-unknown, so the lint step will fail unless the rule is configured to allow :global.

✅ One quick fix (local suppression)
 .addTagInputWrapper {
+  /* stylelint-disable-next-line selector-pseudo-class-no-unknown */
   :global(.bp3-input) {
     min-width: 400px;
     max-width: 400px;
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/* Fixed width for the tag input bar only when rendered inside Add Tag modal */
.addTagInputWrapper {
:global(.bp3-input) {
min-width: 400px;
max-width: 400px;
}
/* Fixed width for the tag input bar only when rendered inside Add Tag modal */
.addTagInputWrapper {
/* stylelint-disable-next-line selector-pseudo-class-no-unknown */
:global(.bp3-input) {
min-width: 400px;
max-width: 400px;
}
}
🧰 Tools
🪛 Stylelint (17.3.0)

[error] 19-19: Unexpected unknown pseudo-class selector ":global" (selector-pseudo-class-no-unknown)

(selector-pseudo-class-no-unknown)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.module.scss`
around lines 17 - 22, The Stylelint rule selector-pseudo-class-no-unknown is
tripping on the :global(.bp3-input) selector inside the .addTagInputWrapper
block; add a local suppression comment immediately before the offending line —
e.g. place /* stylelint-disable-next-line selector-pseudo-class-no-unknown */
above :global(.bp3-input) — so the CSS module global selector is preserved while
the linter is skipped for that line.

Comment on lines +214 to +225
{isAllowed(VersionAction.AddTag) && (
<AddTagMenuItem
artifactKey={artifactKey}
repoKey={repoKey}
versionKey={versionKey}
data={data}
pageType={pageType}
readonly={readonly}
onClose={closeMenu}
openAddTagModal={showAddTagModal}
/>
)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Hide Add Tag in public sessions for consistency.

Other mutating actions are gated by isCurrentSessionPublic, but Add Tag is currently visible. This can expose an action that will fail for public users.

Suggested guard
-      {isAllowed(VersionAction.AddTag) && (
+      {!isCurrentSessionPublic && isAllowed(VersionAction.AddTag) && (
         <AddTagMenuItem
           artifactKey={artifactKey}
           repoKey={repoKey}
           versionKey={versionKey}
           data={data}
           pageType={pageType}
           readonly={readonly}
           onClose={closeMenu}
           openAddTagModal={showAddTagModal}
         />
       )}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{isAllowed(VersionAction.AddTag) && (
<AddTagMenuItem
artifactKey={artifactKey}
repoKey={repoKey}
versionKey={versionKey}
data={data}
pageType={pageType}
readonly={readonly}
onClose={closeMenu}
openAddTagModal={showAddTagModal}
/>
)}
{!isCurrentSessionPublic && isAllowed(VersionAction.AddTag) && (
<AddTagMenuItem
artifactKey={artifactKey}
repoKey={repoKey}
versionKey={versionKey}
data={data}
pageType={pageType}
readonly={readonly}
onClose={closeMenu}
openAddTagModal={showAddTagModal}
/>
)}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx`
around lines 214 - 225, The Add Tag action is not currently hidden for public
sessions; wrap the AddTagMenuItem render with the same public-session guard used
for other mutating actions so it is not shown to public users. Update the JSX
condition to require both isAllowed(VersionAction.AddTag) and
!isCurrentSessionPublic (or the existing helper used elsewhere) before rendering
AddTagMenuItem (keeping artifactKey, repoKey, versionKey, data, pageType,
readonly, onClose, openAddTagModal props unchanged).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.module.scss (1)

18-25: ⚠️ Potential issue | 🟠 Major

Fix Stylelint violations in the global input selector block.

Both the :global selector and the blank line before box-sizing will fail Stylelint. Add a local suppression for :global and remove the empty line.

🔧 Proposed fix
 .addTagInputWrapper {
+  /* stylelint-disable-next-line selector-pseudo-class-no-unknown */
   :global(.bp3-input) {
     width: min(400px, 90vw);
     min-width: min(400px, 90vw);
     max-width: 100%;
-    
     box-sizing: border-box;
   }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.module.scss`
around lines 18 - 25, The Stylelint errors come from the `:global(.bp3-input)`
selector and the stray blank line before `box-sizing` inside the
`.addTagInputWrapper` block; update the `.addTagInputWrapper` ruleset by adding
a local Stylelint suppression comment for the `:global` selector (e.g., /*
stylelint-disable-next-line selector-pseudo-class-no-unknown */) immediately
above the `:global(.bp3-input)` line and remove the empty line so `box-sizing:
border-box;` sits directly after the other declarations, keeping the selector
and declarations otherwise unchanged.
web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx (1)

214-225: ⚠️ Potential issue | 🟡 Minor

Hide Add Tag in public sessions to match other mutating actions.

Add Tag is still shown when isCurrentSessionPublic is true, while other mutating actions are hidden.

✅ Suggested guard
-      {isAllowed(VersionAction.AddTag) && (
+      {!isCurrentSessionPublic && isAllowed(VersionAction.AddTag) && (
         <AddTagMenuItem
           artifactKey={artifactKey}
           repoKey={repoKey}
           versionKey={versionKey}
           data={data}
           pageType={pageType}
           readonly={readonly}
           onClose={closeMenu}
           openAddTagModal={showAddTagModal}
         />
       )}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx`
around lines 214 - 225, The AddTagMenuItem is still rendered even for public
sessions; update the render guard in VersionActions (around the
isAllowed(VersionAction.AddTag) check) to also check that the session is not
public (e.g., add a "!isCurrentSessionPublic" condition) so it matches the other
mutating actions' behavior; locate the JSX that renders AddTagMenuItem in
VersionActions.tsx and add the same public-session guard used for other mutating
menu items.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.module.scss`:
- Around line 18-25: The Stylelint errors come from the `:global(.bp3-input)`
selector and the stray blank line before `box-sizing` inside the
`.addTagInputWrapper` block; update the `.addTagInputWrapper` ruleset by adding
a local Stylelint suppression comment for the `:global` selector (e.g., /*
stylelint-disable-next-line selector-pseudo-class-no-unknown */) immediately
above the `:global(.bp3-input)` line and remove the empty line so `box-sizing:
border-box;` sits directly after the other declarations, keeping the selector
and declarations otherwise unchanged.

In
`@web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx`:
- Around line 214-225: The AddTagMenuItem is still rendered even for public
sessions; update the render guard in VersionActions (around the
isAllowed(VersionAction.AddTag) check) to also check that the session is not
public (e.g., add a "!isCurrentSessionPublic" condition) so it matches the other
mutating actions' behavior; locate the JSX that renders AddTagMenuItem in
VersionActions.tsx and add the same public-session guard used for other mutating
menu items.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 770a0e9 and b069cd1.

📒 Files selected for processing (3)
  • web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.module.scss
  • web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx
  • web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx`:
- Around line 70-77: The code is overwriting the base path and leaving debug
logs; replace the current URL construction so it preserves any API base prefix
and remove console.log lines. Instead of creating baseUrl from getApiBaseUrl('')
and then assigning baseUrl.pathname = path, call getApiBaseUrl with the full
path (e.g., const baseUrl = new URL(getApiBaseUrl(path),
window.location.origin)) so existing prefixes like /gateway or /api/v1 are
preserved, then set search params on baseUrl and call baseUrl.toString() to get
url; also delete the console.log('baseUrl', ...) and console.log('baseUrl after
adding path', ...) statements.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b069cd1 and 4460059.

📒 Files selected for processing (2)
  • web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx
  • web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/ar/pages/version-details/components/VersionActions/VersionActions.tsx

Comment on lines +70 to +77
const path = '/har/api/v2/oci/tags'
const baseUrl = new URL(getApiBaseUrl(''), window.location.origin)
console.log('baseUrl', baseUrl);
baseUrl.pathname = path
console.log('baseUrl after adding path', baseUrl);
baseUrl.searchParams.set('account_identifier', accountId || '')
baseUrl.searchParams.set('registry_identifier', repoKey)
const url = baseUrl.toString()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify getApiBaseUrl signature and intended base path behavior
rg -n "getApiBaseUrl" -C3

Repository: abhinavcode/harness

Length of output: 9384


🏁 Script executed:

#!/bin/bash
# View the actual file content around the problematic code
cat -n web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx | sed -n '60,85p'

Repository: abhinavcode/harness

Length of output: 1333


🏁 Script executed:

#!/bin/bash
# Check how getApiBaseUrl is used elsewhere in codebase to understand intended pattern
rg "getApiBaseUrl\(" -A2 | head -60

Repository: abhinavcode/harness

Length of output: 1934


Remove debug logs and preserve base path when building the tags URL.

Assigning baseUrl.pathname = path discards any base prefix from getApiBaseUrl (e.g., /gateway, /api/v1), causing requests to route to the wrong endpoint in non-root deployments. The pattern used elsewhere in the codebase (e.g., useGetDownloadFileURL.ts, useOpenApiClient.ts) is to pass the full path directly to getApiBaseUrl. Additionally, the console.log calls on lines 72 and 74 are debug statements that should not ship.

🔧 Suggested fix
-      const path = '/har/api/v2/oci/tags'
-      const baseUrl = new URL(getApiBaseUrl(''), window.location.origin)
-      console.log('baseUrl', baseUrl);
-      baseUrl.pathname = path
-      console.log('baseUrl after adding path', baseUrl);
-      baseUrl.searchParams.set('account_identifier', accountId || '')
-      baseUrl.searchParams.set('registry_identifier', repoKey)
-      const url = baseUrl.toString()
+      const path = 'har/api/v2/oci/tags'
+      const baseUrl = new URL(getApiBaseUrl(''), window.location.origin)
+      if (!baseUrl.pathname.endsWith('/')) baseUrl.pathname += '/'
+      const urlObj = new URL(path, baseUrl)
+      urlObj.searchParams.set('account_identifier', accountId || '')
+      urlObj.searchParams.set('registry_identifier', repoKey)
+      const url = urlObj.toString()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const path = '/har/api/v2/oci/tags'
const baseUrl = new URL(getApiBaseUrl(''), window.location.origin)
console.log('baseUrl', baseUrl);
baseUrl.pathname = path
console.log('baseUrl after adding path', baseUrl);
baseUrl.searchParams.set('account_identifier', accountId || '')
baseUrl.searchParams.set('registry_identifier', repoKey)
const url = baseUrl.toString()
const path = 'har/api/v2/oci/tags'
const baseUrl = new URL(getApiBaseUrl(''), window.location.origin)
if (!baseUrl.pathname.endsWith('/')) baseUrl.pathname += '/'
const urlObj = new URL(path, baseUrl)
urlObj.searchParams.set('account_identifier', accountId || '')
urlObj.searchParams.set('registry_identifier', repoKey)
const url = urlObj.toString()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx`
around lines 70 - 77, The code is overwriting the base path and leaving debug
logs; replace the current URL construction so it preserves any API base prefix
and remove console.log lines. Instead of creating baseUrl from getApiBaseUrl('')
and then assigning baseUrl.pathname = path, call getApiBaseUrl with the full
path (e.g., const baseUrl = new URL(getApiBaseUrl(path),
window.location.origin)) so existing prefixes like /gateway or /api/v1 are
preserved, then set search params on baseUrl and call baseUrl.toString() to get
url; also delete the console.log('baseUrl', ...) and console.log('baseUrl after
adding path', ...) statements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx (3)

25-26: Consolidate duplicate imports from the same module.

ResourceType and PermissionIdentifier are imported from @ar/common/permissionTypes on two separate lines.

♻️ Proposed fix
-import { ResourceType } from '@ar/common/permissionTypes'
-import { PermissionIdentifier } from '@ar/common/permissionTypes'
+import { ResourceType, PermissionIdentifier } from '@ar/common/permissionTypes'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx`
around lines 25 - 26, The imports for ResourceType and PermissionIdentifier are
duplicated from the same module; consolidate them into a single import statement
by combining the two separate import lines into one that imports both
ResourceType and PermissionIdentifier from '@ar/common/permissionTypes' (locate
the import statements referencing ResourceType and PermissionIdentifier in
AddTagMenuItem.tsx and merge them).

104-104: enableReinitialize has no effect here — remove it.

initialValues is a static literal ({ tagNames: [] as string[] }) that never changes between renders, so enableReinitialize is a no-op and may mislead future readers into thinking re-initialization is intentional.

♻️ Proposed fix
-    <Formik initialValues={{ tagNames: [] as string[] }} enableReinitialize onSubmit={() => undefined}>
+    <Formik initialValues={{ tagNames: [] as string[] }} onSubmit={() => undefined}>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx`
at line 104, Remove the unnecessary enableReinitialize prop from the Formik
usage in the AddTagMenuItem component: the Formik call in AddTagMenuItem.tsx
currently sets initialValues to a static literal ({ tagNames: [] as string[] })
so enableReinitialize is a no-op; delete the enableReinitialize attribute from
the Formik element (the component that wraps the form and currently has
initialValues and onSubmit) to avoid misleading readers.

115-119: Fragile DOM query to capture uncommitted PatternInput value.

Reading the raw <input> value via inputWrapperRef.current?.querySelector('input')?.value bypasses React and Formik. This pattern is brittle and will break if SimpleTagInput's internal DOM structure changes. Since PatternInput wraps MultiTagsInput which wraps SimpleTagInput (from @harnessio/uicore), the uncommitted input state is inaccessible through the component API. Consider refactoring PatternInput to expose the uncommitted input value either as a forwarded ref callback or a controlled prop, so the complete form state stays within React's data flow.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx`
around lines 115 - 119, The onClick handler in AddTagMenuItem currently reads
the uncommitted PatternInput value via a fragile DOM query
(inputWrapperRef.current?.querySelector('input')?.value), which bypasses
React/Formik; refactor PatternInput (the component wrapping
MultiTagsInput/SimpleTagInput) to expose the uncommitted input either via a
forwarded ref method (e.g., getUncommittedValue) or a controlled prop (e.g.,
uncommittedValue + onUncommittedChange), then update the AddTagMenuItem onClick
to read that value from the new ref/mapped prop and pass it to
handleSubmit(formik.values.tagNames, uncommittedValue) instead of querying the
DOM; ensure PatternInput forwards the API through MultiTagsInput/SimpleTagInput
so the component tree remains controlled by React/Formik.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx`:
- Line 68: The file contains a leftover debug statement: remove the
console.log('allTags', allTags); from the AddTagMenuItem component so it no
longer prints to the console; search for the AddTagMenuItem component or the
allTags variable in AddTagMenuItem.tsx and delete that single console.log line
(or replace it with appropriate debug-level logging via existing logger if
needed).

---

Nitpick comments:
In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx`:
- Around line 25-26: The imports for ResourceType and PermissionIdentifier are
duplicated from the same module; consolidate them into a single import statement
by combining the two separate import lines into one that imports both
ResourceType and PermissionIdentifier from '@ar/common/permissionTypes' (locate
the import statements referencing ResourceType and PermissionIdentifier in
AddTagMenuItem.tsx and merge them).
- Line 104: Remove the unnecessary enableReinitialize prop from the Formik usage
in the AddTagMenuItem component: the Formik call in AddTagMenuItem.tsx currently
sets initialValues to a static literal ({ tagNames: [] as string[] }) so
enableReinitialize is a no-op; delete the enableReinitialize attribute from the
Formik element (the component that wraps the form and currently has
initialValues and onSubmit) to avoid misleading readers.
- Around line 115-119: The onClick handler in AddTagMenuItem currently reads the
uncommitted PatternInput value via a fragile DOM query
(inputWrapperRef.current?.querySelector('input')?.value), which bypasses
React/Formik; refactor PatternInput (the component wrapping
MultiTagsInput/SimpleTagInput) to expose the uncommitted input either via a
forwarded ref method (e.g., getUncommittedValue) or a controlled prop (e.g.,
uncommittedValue + onUncommittedChange), then update the AddTagMenuItem onClick
to read that value from the new ref/mapped prop and pass it to
handleSubmit(formik.values.tagNames, uncommittedValue) instead of querying the
DOM; ensure PatternInput forwards the API through MultiTagsInput/SimpleTagInput
so the component tree remains controlled by React/Formik.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4460059 and f0a9395.

📒 Files selected for processing (1)
  • web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx

const committed = normalizeTagNames(tagNamesRaw)
const current = currentInputValue?.trim() ?? ''
const allTags = current ? [...committed, current] : committed
console.log('allTags', allTags);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove leftover console.log debug statement.

🔧 Proposed fix
-    console.log('allTags', allTags);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log('allTags', allTags);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/version-details/components/VersionActions/AddTagMenuItem.tsx`
at line 68, The file contains a leftover debug statement: remove the
console.log('allTags', allTags); from the AddTagMenuItem component so it no
longer prints to the console; search for the AddTagMenuItem component or the
allTags variable in AddTagMenuItem.tsx and delete that single console.log line
(or replace it with appropriate debug-level logging via existing logger if
needed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant