Skip to content

fix regression due to prefix now in the keys#1553

Merged
william-schlegel merged 4 commits into
mainfrom
fix/read-screening-configuration
May 20, 2026
Merged

fix regression due to prefix now in the keys#1553
william-schlegel merged 4 commits into
mainfrom
fix/read-screening-configuration

Conversation

@william-schlegel
Copy link
Copy Markdown
Contributor

@william-schlegel william-schlegel commented May 19, 2026

Summary by CodeRabbit

  • Refactor
    • Unified dataset/topic selection and grouping so items are consistently grouped, keyed, and exported; selection handling consolidated into shared helpers.
  • Bug Fixes
    • “Select all”, individual toggles, section clears, conditional topics, tag displays and overflow now reflect and persist correct topic-group selections.

Review Change Stack

@coderabbitai coderabbitai Bot added the S small label May 19, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bffcb329-6467-4e80-9d63-2c73a6e16c93

📥 Commits

Reviewing files that changed from the base of the PR and between 7a0acea and caf7150.

📒 Files selected for processing (1)
  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
📜 Recent review details
⏰ 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). (2)
  • GitHub Check: check / main
  • GitHub Check: e2e
🧰 Additional context used
📓 Path-based instructions (2)
packages/app-builder/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/app-builder/src/**/*.{ts,tsx}: Use internal imports from @app-builder namespace for models, queries, components, and utilities
Use ui-design-system package for UI components (Button, Modal, Select) and utility functions (cn)
Use TanStack Query hooks with naming convention useGetXyzQuery for data fetching operations
Use ts-pattern for pattern matching with the match function instead of conditional logic
Use TanStack Form for form handling instead of manual form state management

Files:

  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Tailwind CSS 4 with the tailwind-preset package for consistent styling across packages

Files:

  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
🧠 Learnings (2)
📚 Learning: 2026-05-11T13:00:53.337Z
Learnt from: william-schlegel
Repo: checkmarble/marble-frontend PR: 1503
File: packages/app-builder/src/components/ContinuousScreening/context/ListAndTopicDatasetConfigurationBridge.tsx:13-20
Timestamp: 2026-05-11T13:00:53.337Z
Learning: In checkmarble/marble-frontend, calls to `createSharp` from the `sharpstate` library should be treated as if they were a React hook. In React `.tsx` components, call `createSharp` unconditionally at the top level of the component function body (not inside conditionals or nested functions). Do not place `createSharp` inside `useMemo`, `useCallback`, `useEffect`, or any other hook, and do not suggest wrapping it in `useMemo`—that is incorrect and should be flagged during review.

Applied to files:

  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
📚 Learning: 2026-05-12T19:51:39.619Z
Learnt from: Pascal-Delange
Repo: checkmarble/marble-frontend PR: 1522
File: packages/app-builder/src/components/Cases/CaseAlerts.tsx:449-449
Timestamp: 2026-05-12T19:51:39.619Z
Learning: In React (.tsx) files, when rendering translated strings that include dynamic count values, always use i18n interpolation rather than appending the count as a separate raw React text node. Prefer `t('translation.key', { count })` (or the project’s equivalent) and include `{{count}}` (or the interpolation placeholder expected by the i18n setup) inside the translation string so each locale controls placement/order. Avoid patterns like `t('key') + ' (' + count + ')'` or rendering `t('key')` followed by `(${count})` as separate nodes, since this can break RTL layout (e.g., Arabic).

Applied to files:

  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
🔇 Additional comments (1)
packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx (1)

4-4: LGTM!

Also applies to: 31-31, 46-46


📝 Walkthrough

Walkthrough

Introduce canonical dataset/topic keys and selection helpers; update UI and exports to use them; use canonical keys in FieldDataset; add DTO section→category mapping; and refactor lists-config normalization to group by section and stop mutating item names.

Changes

Selection canonicalization & UI integration

Layer / File(s) Summary
Key builders and selection utilities
packages/app-builder/src/components/ListAndTopicConfiguration/dataset-selection-provider-utils.ts
Add DTO section→category alias mapping, buildDatasetKey/buildTopicKey, update makeDatasetsMap to parse persisted composite keys, and add getCanonicalSelectedKeys, isDatasetKeySelected, setDatasetKey, isTopicKeySelected, setTopicKey, clearSectionSelections.
Dataset/topic UI integration
packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx
Import selection helpers; replace direct state.datasets reads/writes with is*/set* helpers; pass topicGroup through toggles/menus; use clearSectionSelections for section enable/disable.
Re-export selection utilities
packages/app-builder/src/components/ListAndTopicConfiguration/index.ts
Expand re-exports to include key builders and all selection helper utilities.
Consumer: FieldDataset canonicalization
packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
Use getCanonicalSelectedKeys(datasets) to derive selected datasets instead of inline filter-and-sort.
DTO mapping and lists-config normalize refactor
packages/app-builder/src/models/screening-config.ts, packages/app-builder/src/queries/screening/lists-config.ts
Add DtoSectionToCategory mapping; refactor lists-config normalize/groupBySection to build canonical dataset keys, avoid mutating item names, and emit conditional topic items using t.name directly; update top-level section key calls.

🎯 4 (Complex) | ⏱️ ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant UI as DatasetSelectionContent
  participant Utils as dataset-selection-provider-utils
  participant Consumer as FieldDataset
  participant Lists as lists-config
  participant Models as screening-config
  UI->>Utils: isDatasetKeySelected / setDatasetKey / isTopicKeySelected / setTopicKey
  UI->>Utils: clearSectionSelections(sectionKey)
  Consumer->>Utils: getCanonicalSelectedKeys(datasets)
  Lists->>Utils: buildDatasetKey(section, dataset)
  Models->>Lists: DtoSectionToCategory mapping used in getDatasetFromFilters
Loading

Possibly related PRs

Suggested reviewers

  • Djauron
  • Pascal-Delange

O let keys be names now whole and true,
No longer masked by section's borrowed hue;
The UI sings, the lists complain no more,
Canonical echoes open every door.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title refers to fixing a regression related to prefixes in keys, which aligns with the core refactoring that changes how dataset/topic keys are constructed and handled throughout the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/read-screening-configuration

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.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@coderabbitai coderabbitai Bot added M medium and removed S small labels May 20, 2026
Copy link
Copy Markdown

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx (2)

898-925: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Inconsistent selection check — still uses direct key lookup instead of isTopicKeySelected.

At line 900, isSelected is computed as !!datasets[item.name], but the rest of this refactor uses isTopicKeySelected(datasets, sectionKey, topicGroup, item.name) for topic items (see lines 693 and 859). This mismatch will cause incorrect checkbox state when composite keys are in use.

To select, or not to select, that is the question—
Whether 'tis nobler in the code to suffer
The slings and arrows of inconsistent keys...

🐛 Proposed fix
         {items.map((item) => {
-          const isSelected = !!datasets[item.name];
+          const isSelected = isTopicKeySelected(datasets, sectionKey, topicGroup, item.name);
           const itemName = item.title ?? formatItemName(item.name);
           return (
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx`
around lines 898 - 925, The checkbox selection logic uses a direct key lookup
(!!datasets[item.name]) which is inconsistent with the rest of the refactor;
replace this with a call to isTopicKeySelected(datasets, sectionKey, topicGroup,
item.name) so the selected state respects composite/topic keys used elsewhere
(update the isSelected assignment used by Checkbox and any related UI state for
the label/row), ensuring handleClickItem, Checkbox id, and disabled logic remain
unchanged.

941-957: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Same inconsistency as above — direct key lookup instead of isTopicKeySelected.

Line 943 also uses !!datasets[item.name] for the non-popover variant of the menu. Apply the same fix for consistency with the composite-key model.

🐛 Proposed fix
       {items.map((item) => {
-        const isSelected = !!datasets[item.name];
+        const isSelected = isTopicKeySelected(datasets, sectionKey, topicGroup, item.name);
         const itemName = item.title ?? formatItemName(item.name);
         return (
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx`
around lines 941 - 957, The selected-state check currently uses a direct key
lookup (!!datasets[item.name]) inside the items.map render, which is
inconsistent with the composite-key model; replace that lookup with the existing
helper isTopicKeySelected by changing the isSelected assignment to call
isTopicKeySelected(item) (use the same helper used elsewhere), so
MenuCommand.Item uses isTopicKeySelected(item) for selected state and retains
handleClickItem, value={item.name}, disabled={mode === 'view'} and the rest of
the rendering unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/app-builder/src/components/ListAndTopicConfiguration/dataset-selection-provider-utils.ts`:
- Around line 102-108: clearSectionSelections currently only clears keys
matching sectionKey and keys prefixed with `${sectionKey}:`, leaving DTO alias
keys like "other" and "adverse_media" (which map to sections such as
"third-parties" and "adverse-media") untouched; update clearSectionSelections to
also clear those legacy alias keys when sectionKey corresponds to those sections
by checking and setting datasets['other'] and datasets['adverse_media'] (or
whichever DTO alias names are used) to false whenever sectionKey ===
'third-parties' or sectionKey === 'adverse-media' (use the function
clearSectionSelections, datasets and sectionKey to locate the change).

---

Outside diff comments:
In
`@packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx`:
- Around line 898-925: The checkbox selection logic uses a direct key lookup
(!!datasets[item.name]) which is inconsistent with the rest of the refactor;
replace this with a call to isTopicKeySelected(datasets, sectionKey, topicGroup,
item.name) so the selected state respects composite/topic keys used elsewhere
(update the isSelected assignment used by Checkbox and any related UI state for
the label/row), ensuring handleClickItem, Checkbox id, and disabled logic remain
unchanged.
- Around line 941-957: The selected-state check currently uses a direct key
lookup (!!datasets[item.name]) inside the items.map render, which is
inconsistent with the composite-key model; replace that lookup with the existing
helper isTopicKeySelected by changing the isSelected assignment to call
isTopicKeySelected(item) (use the same helper used elsewhere), so
MenuCommand.Item uses isTopicKeySelected(item) for selected state and retains
handleClickItem, value={item.name}, disabled={mode === 'view'} and the rest of
the rendering unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3b1df66b-e1f8-44c2-9440-82caef5f7d4b

📥 Commits

Reviewing files that changed from the base of the PR and between f343137 and 7a0acea.

📒 Files selected for processing (6)
  • packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx
  • packages/app-builder/src/components/ListAndTopicConfiguration/dataset-selection-provider-utils.ts
  • packages/app-builder/src/components/ListAndTopicConfiguration/index.ts
  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
  • packages/app-builder/src/models/screening-config.ts
  • packages/app-builder/src/queries/screening/lists-config.ts
📜 Review details
⏰ 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). (2)
  • GitHub Check: check / main
  • GitHub Check: e2e
🧰 Additional context used
📓 Path-based instructions (2)
packages/app-builder/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/app-builder/src/**/*.{ts,tsx}: Use internal imports from @app-builder namespace for models, queries, components, and utilities
Use ui-design-system package for UI components (Button, Modal, Select) and utility functions (cn)
Use TanStack Query hooks with naming convention useGetXyzQuery for data fetching operations
Use ts-pattern for pattern matching with the match function instead of conditional logic
Use TanStack Form for form handling instead of manual form state management

Files:

  • packages/app-builder/src/components/ListAndTopicConfiguration/index.ts
  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
  • packages/app-builder/src/models/screening-config.ts
  • packages/app-builder/src/components/ListAndTopicConfiguration/dataset-selection-provider-utils.ts
  • packages/app-builder/src/queries/screening/lists-config.ts
  • packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Tailwind CSS 4 with the tailwind-preset package for consistent styling across packages

Files:

  • packages/app-builder/src/components/ListAndTopicConfiguration/index.ts
  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
  • packages/app-builder/src/models/screening-config.ts
  • packages/app-builder/src/components/ListAndTopicConfiguration/dataset-selection-provider-utils.ts
  • packages/app-builder/src/queries/screening/lists-config.ts
  • packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx
🧠 Learnings (3)
📚 Learning: 2026-05-11T13:00:53.337Z
Learnt from: william-schlegel
Repo: checkmarble/marble-frontend PR: 1503
File: packages/app-builder/src/components/ContinuousScreening/context/ListAndTopicDatasetConfigurationBridge.tsx:13-20
Timestamp: 2026-05-11T13:00:53.337Z
Learning: In checkmarble/marble-frontend, calls to `createSharp` from the `sharpstate` library should be treated as if they were a React hook. In React `.tsx` components, call `createSharp` unconditionally at the top level of the component function body (not inside conditionals or nested functions). Do not place `createSharp` inside `useMemo`, `useCallback`, `useEffect`, or any other hook, and do not suggest wrapping it in `useMemo`—that is incorrect and should be flagged during review.

Applied to files:

  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
  • packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx
📚 Learning: 2026-05-12T19:51:39.619Z
Learnt from: Pascal-Delange
Repo: checkmarble/marble-frontend PR: 1522
File: packages/app-builder/src/components/Cases/CaseAlerts.tsx:449-449
Timestamp: 2026-05-12T19:51:39.619Z
Learning: In React (.tsx) files, when rendering translated strings that include dynamic count values, always use i18n interpolation rather than appending the count as a separate raw React text node. Prefer `t('translation.key', { count })` (or the project’s equivalent) and include `{{count}}` (or the interpolation placeholder expected by the i18n setup) inside the translation string so each locale controls placement/order. Avoid patterns like `t('key') + ' (' + count + ')'` or rendering `t('key')` followed by `(${count})` as separate nodes, since this can break RTL layout (e.g., Arabic).

Applied to files:

  • packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx
  • packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx
📚 Learning: 2026-05-11T13:53:33.690Z
Learnt from: william-schlegel
Repo: checkmarble/marble-frontend PR: 1503
File: packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx:55-58
Timestamp: 2026-05-11T13:53:33.690Z
Learning: In the ListAndTopicConfiguration component system (e.g., DatasetSelectionContent.tsx), when deciding whether to include/filter server-provided “section” data, you can treat `conditionalTopics` as redundant for non-emptiness: by server contract, any section with `conditionalTopics` will also have `topics`. Therefore prefer the predicate `section.datasets?.length || section.topics` and do not add an extra `|| section.conditionalTopics` check, unless the backend schema/guarantee changes (or the frontend types allow `conditionalTopics` without `topics`).

Applied to files:

  • packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx
🔇 Additional comments (19)
packages/app-builder/src/components/ListAndTopicConfiguration/DatasetSelectionContent.tsx (10)

25-31: LGTM!


260-267: LGTM!


412-424: LGTM!


476-492: LGTM!


598-612: LGTM!


615-673: LGTM!


675-693: LGTM!


775-789: LGTM!


813-840: LGTM!


857-884: LGTM!

packages/app-builder/src/components/Scenario/Screening/FieldDataset.tsx (1)

4-4: LGTM!

Also applies to: 12-14

packages/app-builder/src/models/screening-config.ts (2)

93-98: LGTM!


136-147: LGTM!

packages/app-builder/src/queries/screening/lists-config.ts (4)

1-1: LGTM!


27-38: LGTM!


40-48: LGTM!


71-77: LGTM!

packages/app-builder/src/components/ListAndTopicConfiguration/dataset-selection-provider-utils.ts (1)

8-100: LGTM!

packages/app-builder/src/components/ListAndTopicConfiguration/index.ts (1)

7-17: LGTM!

@william-schlegel william-schlegel merged commit 25e05ac into main May 20, 2026
6 checks passed
@william-schlegel william-schlegel deleted the fix/read-screening-configuration branch May 20, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants