Skip to content

Conversation

@AnnaStepchenko
Copy link
Contributor

@AnnaStepchenko AnnaStepchenko commented Dec 18, 2025

Description

This PR is a recreation of #4398 originally authored by @JakubKida. The original PR could not be updated by me directly due to repository permission restrictions, so this PR re-submits the same changes via fork.

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

[x] 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
[x] Test addition or update
[ ] CI/CD configuration change

Testing done

[x] Unit tests added/updated
[ ] Integration tests added/updated
[x] 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

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

Summary by CodeRabbit

  • Bug Fixes

    • Taxonomy fields in sidebar metadata now receive AI-generated suggestions.
  • Tests

    • Added validation tests for taxonomy suggestion mapping.
  • Chores

    • Updated Box UI library dependencies.

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

@AnnaStepchenko AnnaStepchenko requested review from a team as code owners December 18, 2025 14:11
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ JakubKida
❌ Anna Stepchenko


Anna Stepchenko seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Walkthrough

This PR updates Box UI package dependencies (blueprint-web, combobox-with-api, metadata-editor) and adds support for AI suggestions in taxonomy-type fields, mapping suggestions to value/displayValue pairs when available.

Changes

Cohort / File(s) Summary
Dependency Updates
package.json
Bumped @box/blueprint-web from 12.98.0 to 12.104.1, @box/combobox-with-api from 1.3.11 to 1.18.0, and @box/metadata-editor from 1.5.3 to 1.18.0 in both devDependencies and peerDependencies.
Taxonomy Suggestions Feature
src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts
Modified extractSuggestions logic to provide aiSuggestion data for taxonomy fields when values exist. Changed early-return condition to only skip when value is absent; maps each suggestion to { value: item.id, displayValue: item.displayName }.
Taxonomy Suggestions Tests
src/elements/content-sidebar/__tests__/useSidebarMetadataFetcher.test.tsx
Added new tests validating taxonomy field mapping to aiSuggestion arrays with value and displayValue properties. Tests mock metadata retrieval and extractStructured behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Review the test duplication in the test file—verify tests are not redundantly checking identical scenarios
  • Confirm the logic change in extractSuggestions correctly handles edge cases where taxonomy fields have no suggestions or values

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • JakubKida
  • mborkowski-box
  • tjuanitas

Poem

🐰 Hops through the code with glee,
Taxonomy suggestions flow so free,
Blueprints updated, metadata bright,
AI suggestions shining light! ✨

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 describes the main change: adding correct parsing of autofill values for taxonomy fields, which aligns with the feature implementation shown in the code changes.
Description check ✅ Passed The pull request description provides a clear overview of changes, related context, and testing performed, following the repository's guidelines.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 0

🧹 Nitpick comments (2)
src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts (1)

267-279: Consider adding defensive checks for taxonomy field value structure.

The code assumes that for taxonomy fields, value is always an array and each item has id and displayName properties. If the API returns unexpected data, this could cause a runtime error.

🔎 Apply this diff to add defensive checks:
 if (field.type === 'taxonomy') {
+    const taxonomyValue = Array.isArray(value) ? value : [];
     return {
         ...field,
-        aiSuggestion: value.map(item => ({
-            value: item.id,
-            displayValue: item.displayName,
+        aiSuggestion: taxonomyValue.map(item => ({
+            value: item?.id ?? '',
+            displayValue: item?.displayName ?? '',
         })),
     };
 }
src/elements/content-sidebar/__tests__/useSidebarMetadataFetcher.test.tsx (1)

374-420: LGTM! Test validates taxonomy field mapping correctly.

The test comprehensively validates that taxonomy field suggestions are mapped to the expected {value, displayValue} structure. The setup, mocking, and assertions are all correct.

Consider adding edge case tests for taxonomy fields, such as:

  • Empty taxonomy suggestions array
  • Taxonomy items missing id or displayName properties
  • Non-array value for taxonomy field type

These would help ensure robustness if the API returns unexpected data.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8fc2b86 and a59b09b.

⛔ 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 (5)
📓 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-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/elements/content-sidebar/__tests__/useSidebarMetadataFetcher.test.tsx
📚 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
🧬 Code graph analysis (1)
src/elements/content-sidebar/__tests__/useSidebarMetadataFetcher.test.tsx (1)
src/features/unified-share-modal/__tests__/ContactsField.test.js (1)
  • suggestions (68-87)
⏰ 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: lint_test_build
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Summary
🔇 Additional comments (1)
package.json (1)

127-127: Verify package versions and security advisories for the updated Box UI dependencies.

The dependency updates include version bumps for @box/blueprint-web (^12.104.1), @box/combobox-with-api (^1.18.0), and @box/metadata-editor (^1.18.0). Ensure these versions exist in the npm registry and check for any security advisories using npm audit.

@AnnaStepchenko
Copy link
Contributor Author

The original PR has been updated with the requested changes and is ready to be merged directly. This fork-based PR was only created as a workaround for permission issues, which are no longer relevant.

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.

4 participants