Skip to content

Conversation

@JakubKida
Copy link
Contributor

@JakubKida JakubKida commented Dec 16, 2025

Description

Adds support for taxonomy field suggestions in the metadata sidebar fetcher. Taxonomy suggestions are now properly mapped with value and displayValue properties for AI-generated suggestions.

Related issues

N/A

Changes made

  • Updated useSidebarMetadataFetcher to map taxonomy field suggestions with value and displayValue properties
  • Added test coverage for taxonomy field suggestion mapping

Type of change

  • New feature (non-breaking change adding functionality)
  • Bug fix (non-breaking change addressing an issue)
  • Breaking change (fix or feature causing existing functionality to change)
  • Code refactor (no functional changes)
  • Documentation update
  • Performance improvement
  • Test addition or update
  • CI/CD configuration change

Testing done

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Screenshots/Videos

image

Dependencies

None

Deployment notes

None

How to test

N/A

How to review

Review the implementation in useSidebarMetadataFetcher.ts to ensure taxonomy suggestions are properly mapped. Verify the test case covers the expected behavior.

Self-review checklist

  • Code follows the project's style guidelines
  • Code is properly documented (comments, JSDoc/docstrings, etc.)
  • Changes are covered by tests
  • All tests pass locally
  • No unnecessary console logs or debugging code
  • No sensitive information is exposed
  • No new warnings or errors are introduced
  • PR title follows conventional commit format

Additional notes

None

Summary by CodeRabbit

  • Chores

    • Updated dependency versions for blueprint components and metadata editor.
  • Bug Fixes

    • Fixed taxonomy field suggestions to now correctly map to suggestion structures in the metadata sidebar, enabling proper suggestion handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@JakubKida JakubKida requested review from a team as code owners December 16, 2025 16:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • src/elements/content-sidebar/__tests__/__snapshots__/SidebarFileProperties.test.js.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR updates three Box package dependencies (@box/blueprint-web, @box/combobox-with-api, @box/metadata-editor) to newer versions in both devDependencies and peerDependencies, and modifies the taxonomy field suggestion mapping in the sidebar metadata fetcher to construct AI suggestions from taxonomy item IDs and display names.

Changes

Cohort / File(s) Summary
Dependency version updates
package.json
Updated devDependencies and peerDependencies: @box/blueprint-web to ^12.104.1, @box/combobox-with-api to ^1.18.0, @box/metadata-editor to ^1.18.0
Taxonomy AI suggestion mapping
src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts
Modified extractSuggestions to map taxonomy field suggestions to aiSuggestion array with { value: id, displayValue: displayName } structure instead of bypassing AI suggestions for taxonomy fields
Taxonomy suggestion mapping test
src/elements/content-sidebar/__tests__/useSidebarMetadataFetcher.test.tsx
Added test case verifying taxonomy field suggestions are correctly transformed into aiSuggestion structure with mapped value and displayValue properties

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Focused scope: Only 3 files modified with straightforward changes
  • Logic simplicity: Taxonomy suggestion mapping is a basic transformation (id/displayName → value/displayValue)
  • Test coverage: New test directly validates the behavior change

Possibly related PRs

Suggested reviewers

  • tjuanitas
  • marcoartaviaq

Poem

🐰 A rabbit hops through metadata,
With taxonomy now suggests it better,
Dependencies leap to versions new,
Display values mapped, AI suggestions true!

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for parsing autofill values correctly for taxonomy fields in the metadata editor.
Description check ✅ Passed The description is well-structured with clear sections covering purpose, changes made, type of change, testing, and instructions for reviewers, though it follows a custom format rather than the repository template.

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (1)
src/elements/content-sidebar/__tests__/useSidebarMetadataFetcher.test.tsx (1)

374-420: Good test coverage for the taxonomy mapping feature.

The test correctly verifies that taxonomy field suggestions are mapped to the expected {value, displayValue} structure. The test setup is clean and the assertions are appropriate.

Consider adding edge case tests for robustness:

  • Empty taxonomy array
  • Taxonomy items with missing id or displayName
  • Mixed field types (taxonomy and non-taxonomy) in the same template
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03bd678 and c1817b1.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • package.json (2 hunks)
  • src/elements/content-sidebar/__tests__/useSidebarMetadataFetcher.test.tsx (1 hunks)
  • src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: tjuanitas
Repo: box/box-ui-elements PR: 4224
File: package.json:296-297
Timestamp: 2025-08-12T18:04:17.698Z
Learning: In the box-ui-elements project, the team is comfortable with raising peerDependency minimum versions when upgrading blueprint-web packages, even if it's a breaking change for consumers.
Learnt from: jpan-box
Repo: box/box-ui-elements PR: 4248
File: src/elements/content-explorer/MetadataViewContainer.tsx:30-44
Timestamp: 2025-08-27T15:25:53.253Z
Learning: In the Box API, there is an inconsistency where some endpoints require trimmed metadata field names (e.g., "industry") while others require the full field path (e.g., "metadata.enterprise_1515946.templateName.industry"). The trimMetadataFieldPrefix helper function in MetadataViewContainer.tsx correctly trims the field names for API endpoints that expect the shorter format.
📚 Learning: 2025-08-25T16:19:22.007Z
Learnt from: greg-in-a-box
Repo: box/box-ui-elements PR: 4235
File: src/elements/content-explorer/MetadataQueryBuilder.ts:103-110
Timestamp: 2025-08-25T16:19:22.007Z
Learning: In src/elements/content-explorer/MetadataQueryBuilder.ts, the getSelectFilter function has a special case that maps 'mimetype-filter' to 'item.extension' because mimetype-filter is a multi-select field but the actual database field is 'item.extension'. This mapping is necessary and should not be removed.

Applied to files:

  • src/elements/content-sidebar/__tests__/useSidebarMetadataFetcher.test.tsx
  • src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts
📚 Learning: 2025-08-12T18:04:17.698Z
Learnt from: tjuanitas
Repo: box/box-ui-elements PR: 4224
File: package.json:296-297
Timestamp: 2025-08-12T18:04:17.698Z
Learning: In the box-ui-elements project, the team is comfortable with raising peerDependency minimum versions when upgrading blueprint-web packages, even if it's a breaking change for consumers.

Applied to files:

  • package.json
📚 Learning: 2025-08-21T19:19:44.584Z
Learnt from: jpan-box
Repo: box/box-ui-elements PR: 4237
File: src/api/ZipDownload.ts:6-8
Timestamp: 2025-08-21T19:19:44.584Z
Learning: For Box TypeScript SDK integrations, jpan-box prefers deep imports (e.g., from box-typescript-sdk-gen/lib/schemas/...generated.d.ts.js) over defining local types, citing that Box v2 APIs don't typically have breaking changes, making the deep import approach more viable despite potential brittleness.

Applied to files:

  • package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Summary
🔇 Additional comments (2)
package.json (1)

299-305: Confirm that the dependency updates are intentional and tested.

Multiple Box package dependencies have been updated:

  • @box/blueprint-web to ^12.104.1
  • @box/combobox-with-api to ^1.18.0

These appear to be significant minor version bumps. Please confirm that these updates have been tested and are compatible with the current codebase, especially given the changes to taxonomy field handling in this PR.

src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts (1)

268-284: Add defensive checks for taxonomy field values to handle API response variability.

The code assumes taxonomy field value is always an array of objects with id and displayName properties without runtime validation. Given that Box API response structures have been known to change frequently, consider adding guards to safely access these properties:

if (!value) {
    return field;
}
if (field.type === 'taxonomy') {
    return {
        ...field,
        aiSuggestion: Array.isArray(value)
            ? value.map(item => ({
                value: item?.id,
                displayValue: item?.displayName,
              }))
            : value,
    };
}

Alternatively, verify the TypeScript types guarantee this structure is always enforced.

@CLAassistant
Copy link

CLAassistant commented Dec 18, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/components/sidebar-toggle-button/SidebarToggleButton.js (1)

66-79: Add inline comments to clarify the icon selection logic.

The renderModernizedIcon function has complex branching based on breakpoint, direction, and open state. The icon behavior is unintuitive because RightSidebarChevron* icons are used for both sidebar directions with reversed semantics. Consider adding comments explaining:

  1. Why ChevronUp and ChevronDown are used below the medium breakpoint
  2. Why the RightSidebarChevron* icons have inverted meanings between left and right directions (e.g., RightSidebarChevronOpen means "opened left sidebar" but "closed right sidebar")
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1817b1 and 7c93883.

⛔ Files ignored due to path filters (2)
  • i18n/ja-JP.properties is excluded by !i18n/**
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • flow-typed/npm/@box/blueprint-web-assets_vx.x.x.js (1 hunks)
  • package.json (2 hunks)
  • src/components/sidebar-toggle-button/SidebarToggleButton.js (4 hunks)
  • src/components/sidebar-toggle-button/SidebarToggleButton.scss (1 hunks)
  • src/components/sidebar-toggle-button/__tests__/SidebarToggleButton.test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: tjuanitas
Repo: box/box-ui-elements PR: 4224
File: package.json:296-297
Timestamp: 2025-08-12T18:04:17.698Z
Learning: In the box-ui-elements project, the team is comfortable with raising peerDependency minimum versions when upgrading blueprint-web packages, even if it's a breaking change for consumers.
📚 Learning: 2025-09-03T18:10:42.760Z
Learnt from: fpan225
Repo: box/box-ui-elements PR: 4239
File: src/elements/content-sidebar/SidebarNav.js:195-206
Timestamp: 2025-09-03T18:10:42.760Z
Learning: In src/elements/content-sidebar/SidebarNav.js, the maintainer wants users to be able to override data-* attributes (data-resin-target, data-target-id, data-testid) through navButtonProps for custom tabs. The spread of {...navButtonProps} should come after the data-* attributes to allow overriding, not before them.

Applied to files:

  • src/components/sidebar-toggle-button/SidebarToggleButton.scss
  • src/components/sidebar-toggle-button/SidebarToggleButton.js
  • src/components/sidebar-toggle-button/__tests__/SidebarToggleButton.test.js
📚 Learning: 2025-09-03T18:10:29.467Z
Learnt from: fpan225
Repo: box/box-ui-elements PR: 4239
File: src/elements/content-sidebar/SidebarNav.js:94-106
Timestamp: 2025-09-03T18:10:29.467Z
Learning: In the ContentSidebar CustomSidebarPanel API, the navButtonProps spread should come after explicit data-* attributes to allow users to override analytics tracking attributes like data-resin-target, data-target-id, and data-testid when needed. This is intentional API design for flexibility.

Applied to files:

  • src/components/sidebar-toggle-button/SidebarToggleButton.scss
  • src/components/sidebar-toggle-button/SidebarToggleButton.js
📚 Learning: 2025-06-25T13:09:54.538Z
Learnt from: rafalmaksymiuk
Repo: box/box-ui-elements PR: 4160
File: src/elements/content-sidebar/SidebarToggle.js:21-27
Timestamp: 2025-06-25T13:09:54.538Z
Learning: The box-ui-elements project uses Flow for type annotations in JavaScript files, as indicated by flow directives in file headers. Type annotations like `: Props` are valid Flow syntax, not TypeScript syntax.

Applied to files:

  • flow-typed/npm/@box/blueprint-web-assets_vx.x.x.js
📚 Learning: 2025-06-17T13:30:02.172Z
Learnt from: rafalmaksymiuk
Repo: box/box-ui-elements PR: 4144
File: src/elements/content-sidebar/versions/VersionsList.js:24-33
Timestamp: 2025-06-17T13:30:02.172Z
Learning: In the box-ui-elements codebase, Flow components use .flow.js type definition files, not TypeScript .ts files. The InternalSidebarNavigation type is a union type where different variants may have different properties like versionId, and proper type safety is ensured through conditional checks in methods like getSelectedVersionId.

Applied to files:

  • flow-typed/npm/@box/blueprint-web-assets_vx.x.x.js
📚 Learning: 2025-08-12T18:04:17.698Z
Learnt from: tjuanitas
Repo: box/box-ui-elements PR: 4224
File: package.json:296-297
Timestamp: 2025-08-12T18:04:17.698Z
Learning: In the box-ui-elements project, the team is comfortable with raising peerDependency minimum versions when upgrading blueprint-web packages, even if it's a breaking change for consumers.

Applied to files:

  • flow-typed/npm/@box/blueprint-web-assets_vx.x.x.js
📚 Learning: 2025-06-25T13:10:19.128Z
Learnt from: rafalmaksymiuk
Repo: box/box-ui-elements PR: 4160
File: src/elements/content-sidebar/SidebarToggle.js:11-11
Timestamp: 2025-06-25T13:10:19.128Z
Learning: In the box-ui-elements codebase, Flow files support `import type` syntax for type-only imports. The `import type` statement is valid Flow syntax, not just TypeScript, and should not be flagged as an error when used in Flow files (indicated by flow comments).

Applied to files:

  • flow-typed/npm/@box/blueprint-web-assets_vx.x.x.js
📚 Learning: 2025-09-03T18:30:44.447Z
Learnt from: fpan225
Repo: box/box-ui-elements PR: 4239
File: src/elements/content-sidebar/SidebarPanels.js:0-0
Timestamp: 2025-09-03T18:30:44.447Z
Learning: In the CustomSidebarPanel type, the component field is required (React.ComponentType<any>), so runtime checks for component existence are unnecessary since Flow will catch missing components at compile time. User fpan225 prefers to rely on the type system rather than adding redundant runtime checks.

Applied to files:

  • flow-typed/npm/@box/blueprint-web-assets_vx.x.x.js
📚 Learning: 2025-07-11T14:43:02.677Z
Learnt from: jpan-box
Repo: box/box-ui-elements PR: 4166
File: src/elements/content-sidebar/SidebarNav.js:126-126
Timestamp: 2025-07-11T14:43:02.677Z
Learning: In the box-ui-elements repository, there's a file-type-based pattern for internationalization: TypeScript files (.tsx) predominantly use the modern useIntl hook (41 vs 15 files), while JavaScript files (.js) predominantly use the legacy injectIntl HOC (64 vs 5 files). New TypeScript components should use useIntl, while existing JavaScript components typically continue using injectIntl for consistency.

Applied to files:

  • src/components/sidebar-toggle-button/SidebarToggleButton.js
📚 Learning: 2025-08-27T17:03:48.322Z
Learnt from: bxie-box
Repo: box/box-ui-elements PR: 4250
File: src/features/classification/applied-by-ai-classification-reason/__tests__/AppliedByAiClassificationReason.test.tsx:44-51
Timestamp: 2025-08-27T17:03:48.322Z
Learning: In test files for bxie-box, prefer using queryByTestId over getByTestId when testing for expected elements that should always exist, as null access serves as validation for regressions or unexpected changes rather than masking issues with defensive assertions.

Applied to files:

  • src/components/sidebar-toggle-button/__tests__/SidebarToggleButton.test.js
🧬 Code graph analysis (2)
src/components/sidebar-toggle-button/SidebarToggleButton.js (2)
src/elements/content-sidebar/additional-tabs/AdditionalTabTooltip.js (1)
  • isPreviewModernizationEnabled (23-23)
src/elements/common/feature-checking/hooks.js (1)
  • useFeatureConfig (6-9)
src/components/sidebar-toggle-button/__tests__/SidebarToggleButton.test.js (1)
src/components/sidebar-toggle-button/SidebarToggleButton.js (1)
  • isPreviewModernizationEnabled (44-44)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: lint_test_build
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Summary
🔇 Additional comments (9)
src/components/sidebar-toggle-button/SidebarToggleButton.scss (2)

33-38: LGTM: Well-documented stacking context fix.

The comment clearly explains why position: relative is needed for z-index layering with ContentSidebar.


40-46: LGTM: Modernized hover interaction.

The hover transform is applied only to the modernized variant, while the legacy styles remain intact for backward compatibility.

flow-typed/npm/@box/blueprint-web-assets_vx.x.x.js (1)

12-15: LGTM: Icon type declarations added.

The Flow type declarations for the new chevron icons follow the existing pattern and support the modernized SidebarToggleButton rendering path.

src/components/sidebar-toggle-button/__tests__/SidebarToggleButton.test.js (1)

68-75: LGTM: Test assertions updated for modernization flag.

The conditional assertions correctly verify that the modernized class is present when the feature flag is enabled and absent when disabled, ensuring proper feature flag behavior.

src/components/sidebar-toggle-button/SidebarToggleButton.js (5)

43-56: LGTM: Feature flag and direction logic.

The useBreakpoint hook is called unconditionally (following React's rules of hooks), and the direction/tooltip position logic is clear and well-structured.


96-101: LGTM: Legacy icon rendering extracted.

Extracting the icon selection logic into renderIcon improves code organization while preserving the original behavior.


103-116: LGTM: Legacy rendering path preserved.

The non-modernized path maintains backward compatibility while benefiting from the renderIcon refactoring. This is a solid feature flag implementation pattern.


82-93: Verify BPTooltip side prop API.

The modernized path uses side={tooltipPositionModernized} with values 'right' or 'left', while the legacy path uses position={tooltipPosition} with values 'middle-right' or 'middle-left'. Confirm that BPTooltip's side prop accepts these values and that the positioning behavior is equivalent.


7-13: Verify library API compatibility.

The component now uses IconButton, useBreakpoint, Breakpoint, and new icon imports from upgraded package versions. Ensure these APIs are available and stable in the specified versions.

#!/bin/bash
# Verify the package versions and exports exist

# Check @box/blueprint-web version in package.json
echo "=== Checking @box/blueprint-web version ==="
cat package.json | jq '.dependencies["@box/blueprint-web"], .peerDependencies["@box/blueprint-web"]'

# Check @box/blueprint-web-assets version
echo "=== Checking @box/blueprint-web-assets version ==="
cat package.json | jq '.dependencies["@box/blueprint-web-assets"], .peerDependencies["@box/blueprint-web-assets"]'

# Search for other usages of IconButton, useBreakpoint, Breakpoint in the codebase
echo "=== Checking IconButton usage ==="
rg -n --type=js --type=tsx -C2 "import.*IconButton.*from.*blueprint-web"

echo "=== Checking useBreakpoint usage ==="
rg -n --type=js --type=tsx -C2 "import.*useBreakpoint.*from.*blueprint-web"

@AnnaStepchenko AnnaStepchenko force-pushed the metadata-editor-taxonomy-ai-autofill branch from 7c93883 to f65ec63 Compare December 18, 2025 16:59
tjuanitas
tjuanitas previously approved these changes Dec 18, 2025
@AnnaStepchenko AnnaStepchenko force-pushed the metadata-editor-taxonomy-ai-autofill branch from f65ec63 to 4f03993 Compare December 18, 2025 17:10
@mergify mergify bot added the queued label Dec 18, 2025
@mergify mergify bot merged commit 65f764d into master Dec 18, 2025
11 checks passed
@mergify mergify bot deleted the metadata-editor-taxonomy-ai-autofill branch December 18, 2025 18:56
@mergify
Copy link
Contributor

mergify bot commented Dec 18, 2025

Merge Queue Status

✅ The pull request has been merged at adfb61b

This pull request spent 7 seconds in the queue, with no time running CI.
The checks were run in-place.

Required conditions to merge

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants