Skip to content

feat(metadata-editor): save metadata details on create#4499

Merged
mergify[bot] merged 2 commits intobox:masterfrom
dlasecki-box:metadata-save-details-on-create
Apr 9, 2026
Merged

feat(metadata-editor): save metadata details on create#4499
mergify[bot] merged 2 commits intobox:masterfrom
dlasecki-box:metadata-save-details-on-create

Conversation

@dlasecki-box
Copy link
Copy Markdown
Contributor

@dlasecki-box dlasecki-box commented Apr 8, 2026

Summary by CodeRabbit

  • New Features

    • Extend the createMetadataRedesign method with adding $details field to the payload when isConfidenceScoreEnabled is truthy
    • This is a part of Human-in-the-Loop Metadata Extraction functionality
  • Tests

    • Expanded test coverage for confidence score metadata handling scenarios.
Screen.Recording.2026-04-08.at.18.54.51.mov
Screenshot 2026-04-08 at 17 15 02

@dlasecki-box dlasecki-box requested review from a team as code owners April 8, 2026 15:32
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

Walkthrough

Added optional confidence-score support to metadata creation: createMetadataRedesign gains isConfidenceScoreEnabled and, when enabled, builds per-field $details (confidenceScore, confidenceLevel, optional process: AI_ACCEPTED and serialized targetLocation) and merges them into the request payload. Constant and tests added; fetcher hook forwards the flag.

Changes

Cohort / File(s) Summary
Constants
src/constants.js
Added export AI_ACCEPTED_PROCESS = 'AI_ACCEPTED'.
Metadata API
src/api/Metadata.js
Signature updated to accept isConfidenceScoreEnabled: boolean = false. When enabled, reduces template.fields into a details map per field.key with confidenceScore and confidenceLevel; sets process: AI_ACCEPTED_PROCESS if field.confidenceScore.isAccepted is true; stringifies field.targetLocation into targetLocation. Merges details into fieldsValues.$details only when non-empty.
Tests
src/api/__tests__/Metadata.test.js
Added comprehensive Jest tests for payload assembly: ensure $details omitted when flag false; included only if fields contain confidenceScore when true; verify confidenceScore, confidenceLevel, conditional process: 'AI_ACCEPTED', and targetLocation serialization and mixed-field scenarios.
Hook Integration
src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts
handleCreateMetadataInstance now forwards isConfidenceScoreEnabled to createMetadataRedesign and includes it in the memoized callback dependencies.

Sequence Diagram(s)

(Skipped — change is primarily payload construction inside the API call, not a multi-component sequential flow that benefits from a diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • Lindar90
  • reneshen0328
  • tjuanitas

Poem

🐰 Hoppity-hop, the fields align,
Confidence tucked into each little line,
AI whispers "accepted" — a gentle cheer,
Details hop along, now safely here,
A rabbit's nod: the payload's clear.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description consists entirely of a template HTML comment about merge procedures and does not provide any actual details about the changes being made. Replace the template comment with a meaningful description explaining the feature, what metadata details are being saved, why this change is needed, and any relevant implementation details.
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 (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(metadata-editor): save metadata details on create' accurately summarizes the main change—adding support for saving metadata details when creating metadata instances with confidence scores.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.1)
src/api/__tests__/Metadata.test.js

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.

@dlasecki-box dlasecki-box changed the title Metadata save details on create feat(metadata-editor): save metadata details on create Apr 8, 2026
Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
src/api/__tests__/Metadata.test.js (1)

3019-3019: Prefer using the shared constant instead of repeating 'AI_ACCEPTED' literals in expectations.

Using AI_ACCEPTED_PROCESS here keeps tests aligned with production constants if the token ever changes.

♻️ Proposed refactor
-import {
+import {
+    AI_ACCEPTED_PROCESS,
     ERROR_CODE_CREATE_METADATA,
     ERROR_CODE_DELETE_METADATA,
     ERROR_CODE_FETCH_METADATA_SUGGESTIONS,
@@
-                            process: 'AI_ACCEPTED',
+                            process: AI_ACCEPTED_PROCESS,
@@
-                            process: 'AI_ACCEPTED',
+                            process: AI_ACCEPTED_PROCESS,
@@
-                            process: 'AI_ACCEPTED',
+                            process: AI_ACCEPTED_PROCESS,
@@
-                            process: 'AI_ACCEPTED',
+                            process: AI_ACCEPTED_PROCESS,

Also applies to: 3077-3077, 3242-3242, 3366-3366

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

In `@src/api/__tests__/Metadata.test.js` at line 3019, Replace the hard-coded
'AI_ACCEPTED' string in the test expectations with the shared constant
AI_ACCEPTED_PROCESS: import AI_ACCEPTED_PROCESS from the module that exports it,
then update occurrences like the object with process: 'AI_ACCEPTED' (and the
other noted locations) to use process: AI_ACCEPTED_PROCESS so tests stay in sync
with production constants.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/api/__tests__/Metadata.test.js`:
- Line 3019: Replace the hard-coded 'AI_ACCEPTED' string in the test
expectations with the shared constant AI_ACCEPTED_PROCESS: import
AI_ACCEPTED_PROCESS from the module that exports it, then update occurrences
like the object with process: 'AI_ACCEPTED' (and the other noted locations) to
use process: AI_ACCEPTED_PROCESS so tests stay in sync with production
constants.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a6dfd577-aeab-43aa-96eb-116f08a22a23

📥 Commits

Reviewing files that changed from the base of the PR and between cf72dde and dbae50b.

📒 Files selected for processing (4)
  • src/api/Metadata.js
  • src/api/__tests__/Metadata.test.js
  • src/constants.js
  • src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts

@dlasecki-box dlasecki-box force-pushed the metadata-save-details-on-create branch from dbae50b to daf4267 Compare April 8, 2026 16:52
Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
src/constants.js (1)

447-447: Consider moving this constant to the Metadata section.

The AI_ACCEPTED_PROCESS constant is semantically related to metadata processing (used when building confidence score details), but it's placed under the "Sidebar View" section comment. For better code organization, consider relocating it to the "Metadata" section around lines 86-98 where other metadata-related constants are defined.

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

In `@src/constants.js` at line 447, Move the AI_ACCEPTED_PROCESS constant into the
Metadata constants group to improve organization: locate the export const
AI_ACCEPTED_PROCESS: 'AI_ACCEPTED' = 'AI_ACCEPTED'; declaration and cut it from
the Sidebar View section, then paste it near the other metadata-related
constants (the block that contains metadata keys and confidence-related
constants) so it lives with related symbols; ensure the export name and value
remain unchanged and update any nearby comments to reflect the metadata
grouping.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/constants.js`:
- Line 447: Move the AI_ACCEPTED_PROCESS constant into the Metadata constants
group to improve organization: locate the export const AI_ACCEPTED_PROCESS:
'AI_ACCEPTED' = 'AI_ACCEPTED'; declaration and cut it from the Sidebar View
section, then paste it near the other metadata-related constants (the block that
contains metadata keys and confidence-related constants) so it lives with
related symbols; ensure the export name and value remain unchanged and update
any nearby comments to reflect the metadata grouping.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd9b9bd9-7538-4666-9b06-43f1c5eebc27

📥 Commits

Reviewing files that changed from the base of the PR and between dbae50b and daf4267.

📒 Files selected for processing (4)
  • src/api/Metadata.js
  • src/api/__tests__/Metadata.test.js
  • src/constants.js
  • src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts
  • src/api/tests/Metadata.test.js

Copy link
Copy Markdown
Contributor

@jfox-box jfox-box left a comment

Choose a reason for hiding this comment

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

One non-blocking nit, overall LGTM

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 9, 2026

Merge Queue Status

  • Entered queue2026-04-09 08:17 UTC · Rule: Automatic strict merge
  • Checks skipped · PR is already up-to-date
  • Merged2026-04-09 08:17 UTC · at daf426752f9e7bf640c27c05274625e925911360

This pull request spent 11 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify mergify bot merged commit b455cdf into box:master Apr 9, 2026
12 of 13 checks passed
@mergify mergify bot removed the queued label Apr 9, 2026
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.

3 participants