Skip to content

WEB-4654 - Summary Period - #1989

Open
henry-tp wants to merge 24 commits into
WEB-4654-data-recencyfrom
WEB-4654-summary-period
Open

WEB-4654 - Summary Period#1989
henry-tp wants to merge 24 commits into
WEB-4654-data-recencyfrom
WEB-4654-summary-period

Conversation

@henry-tp

@henry-tp henry-tp commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@henry-tp
henry-tp changed the base branch from develop to WEB-4654-data-recency July 15, 2026 19:16
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (4)
  • master
  • main
  • develop
  • release.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 11d10dd4-ffd7-4063-9910-63a9a15c8d3b

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Clinic patient filtering is reorganized into reusable dropdowns, applied-filter chips, shared query-state controls, clinic-admin actions, and updated ClinicPatients wiring with supporting translations.

Changes

Clinic patient filtering

Layer / File(s) Summary
Filter state and applied-filter controls
app/pages/clinicworkspace/components/AppliedFilters.js, app/pages/clinicworkspace/AppliedFiltersAdapter.js, app/pages/clinicworkspace/components/ClearFilterButtons.js, app/pages/clinicworkspace/ClinicPatients.js, app/pages/clinicworkspace/useClinicPatientsFilters.js
Adds filter chips, removal handling, shared query-state constants, and clear/reset controls for filter and search states.
Recency and summary-period filters
app/pages/clinicworkspace/FilterByDataRecency.js, app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js, app/pages/clinicworkspace/FilterBySummaryPeriod.js, app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js
Extracts recency and summary-period selection into popup-based filters with pending values, apply/cancel behavior, and tracking callbacks.
Clinic site and patient-tag filters
app/pages/clinicworkspace/FilterBySites.js, app/pages/clinicworkspace/components/SiteFilterDropdown.js, app/pages/clinicworkspace/FilterByTags.js, app/pages/clinicworkspace/components/TagFilterDropdown.js, app/pages/clinicworkspace/useIsClinicAdmin.js
Adds searchable site and tag filters, special no-site/no-tag states, and clinic-admin edit actions that load clinic data and open dialogs.
ClinicPatients integration and presentation
app/pages/clinicworkspace/ClinicPatients.js, locales/en/translation.json
Threads the new query state and clear controls through patient-table empty states, integrates extracted filters, updates filter labels/layout, and adds pluralized translations.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • tidepool-org/blip#1986: Covers the same applied-filter components, shared query-state controls, and ClinicPatients filter-reset refactor.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is only an issue reference and provides no meaningful summary of the changes. Add a brief description of the implemented clinic workspace filter and summary period updates.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title matches the main change, which centers on summary period filtering in the clinic workspace.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch WEB-4654-summary-period

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.

@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: 12

Caution

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

⚠️ Outside diff range comments (1)
app/pages/clinicworkspace/ClinicPatients.js (1)

4125-4138: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Include the search text in the callback dependencies.

renderPeopleTable derives patientQueryState from patientListSearchTextInput, but the value is omitted here. During debounced typing, the clear controls and empty-state copy can therefore use stale query state.

Proposed fix
   }, [
     activeFilters,
     clinic?.fetchedPatientCount,
     columns,
     data,
     defaultPatientFetchOptions.sort,
     handlePageChange,
     handleSortChange,
     loading,
     patientFetchOptions,
+    patientListSearchTextInput,
     setActiveFilters,
     showSummaryData,
     tableStyle,
   ]);

As per coding guidelines: respect react-hooks/exhaustive-deps.

🤖 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 `@app/pages/clinicworkspace/ClinicPatients.js` around lines 4125 - 4138, Update
the dependency array for renderPeopleTable to include
patientListSearchTextInput, ensuring its derived patientQueryState and related
clear controls or empty-state text refresh during debounced typing while
preserving the existing dependencies.

Source: Coding guidelines

🧹 Nitpick comments (3)
app/pages/clinicworkspace/FilterBySites.js (3)

1-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Apply the required import grouping consistently.

  • app/pages/clinicworkspace/FilterBySites.js#L1-L9: move local actions after Lodash and separate React/Redux groups.
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L1-L39: move all imports before declarations and reorder the groups.
  • app/pages/clinicworkspace/FilterByTags.js#L1-L9: move local actions after Lodash and separate React/Redux groups.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L1-L39: move all imports before declarations and reorder the groups.
  • app/pages/clinicworkspace/useIsClinicAdmin.js#L1-L4: add blank lines between React, Redux, and Lodash.

As per coding guidelines, group imports in the prescribed order with blank lines between groups.

🤖 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 `@app/pages/clinicworkspace/FilterBySites.js` around lines 1 - 9, Normalize
import grouping across app/pages/clinicworkspace/FilterBySites.js (lines 1-9),
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 1-39),
app/pages/clinicworkspace/FilterByTags.js (lines 1-9),
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 1-39), and
app/pages/clinicworkspace/useIsClinicAdmin.js (lines 1-4): place every import
before declarations, separate React, Redux, Lodash, and local imports with blank
lines, and order the groups according to the project convention, with local
actions after Lodash.

Source: Coding guidelines


13-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add PropTypes for every new component contract.

  • app/pages/clinicworkspace/FilterBySites.js#L13-L18: define the wrapper’s prop types.
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L218-L222: define prop types for the exported and nested prop-taking components.
  • app/pages/clinicworkspace/FilterByTags.js#L13-L18: define the wrapper’s prop types.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L214-L218: define prop types for the exported and nested prop-taking components.

As per coding guidelines, define PropTypes for all component props.

🤖 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 `@app/pages/clinicworkspace/FilterBySites.js` around lines 13 - 18, Define
PropTypes for every prop-taking component in
app/pages/clinicworkspace/FilterBySites.js (lines 13-18),
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 218-222),
app/pages/clinicworkspace/FilterByTags.js (lines 13-18), and
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 214-218),
covering both exported wrappers and nested components and matching each
component’s existing prop contract.

Source: Coding guidelines


23-33: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Memoize callbacks passed between components.

  • app/pages/clinicworkspace/FilterBySites.js#L23-L33: memoize both dropdown callbacks.
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L233-L235: memoize handleCloseDropdown.
  • app/pages/clinicworkspace/FilterByTags.js#L23-L33: memoize both dropdown callbacks.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L229-L231: memoize handleCloseDropdown.

As per coding guidelines, use useCallback for callback props.

🤖 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 `@app/pages/clinicworkspace/FilterBySites.js` around lines 23 - 33, Memoize
callback props with useCallback: wrap handleChange and handleClickEditSites in
app/pages/clinicworkspace/FilterBySites.js at lines 23-33, handleCloseDropdown
in app/pages/clinicworkspace/components/SiteFilterDropdown.js at lines 233-235,
handleChange and handleClickEditTags in
app/pages/clinicworkspace/FilterByTags.js at lines 23-33, and
handleCloseDropdown in app/pages/clinicworkspace/components/TagFilterDropdown.js
at lines 229-231; include each callback’s current dependencies.

Source: Coding guidelines

🤖 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 `@app/pages/clinicworkspace/AppliedFiltersAdapter.js`:
- Around line 10-60: Define PropTypes for every component prop across the
extracted filter components: in
app/pages/clinicworkspace/AppliedFiltersAdapter.js lines 10-60, declare
activeFilters, setActiveFilters, and rightContent; in
app/pages/clinicworkspace/components/ClearFilterButtons.js lines 25-60, declare
the query-state and callback props; in
app/pages/clinicworkspace/components/AppliedFilters.js lines 104-171, declare
props for Chip, ChipGroup, and AppliedFilters; and in
app/pages/clinicworkspace/ClinicPatients.js lines 241-252, declare
patientQueryState and children for EmptyContentNode.

In `@app/pages/clinicworkspace/components/AppliedFilters.js`:
- Around line 119-143: Update the filter container styles around
.remove-filter-icon to apply the same reveal behavior for :focus-within as for
:hover, and configure the Icon component to render as a focusable button so
keyboard users can reach and see the remove action.

In `@app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js`:
- Line 194: Add PropTypes for all props accepted by the
DataRecencyFilterDropdown component, using the component’s existing prop usage
to declare each expected type and requiredness. Keep the default export
unchanged and ensure the declarations are attached to DataRecencyFilterDropdown.
- Around line 1-23: Reorganize imports in DataRecencyFilterDropdown.js into the
required groups—React, PropTypes, Redux, third-party libraries, Lodash,
theme-ui, and local modules—with blank lines between groups. Remove the unused
borders, DialogContent, and DialogActions imports while preserving all imports
referenced by the component.
- Line 24: The prefixPopHealthMetric helper currently returns noop instead of an
event-name string, causing trackMetric calls to receive a function. Update
prefixPopHealthMetric in
app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js:24-24 and
app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js:19-19 to use
the shared string prefix behavior, returning “Clinic - Population Health - ”
followed by the metric.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js`:
- Around line 101-107: Update SiteFilterDropdown.js lines 101-107 and
TagFilterDropdown.js lines 101-107 so the populated-state CloseRoundedIcon
receives the translated accessible label “Clear search,” while preserving the
SearchIcon behavior. Update the clinic-site trigger in SiteFilterDropdown.js
lines 245-252 and patient-tag trigger in TagFilterDropdown.js lines 241-248 to
use translated labels via the existing react-i18next translation mechanism.

In `@app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js`:
- Line 172: Add PropTypes for every prop consumed by the
SummaryPeriodFilterDropdown component, using the appropriate type and
requiredness for each existing prop; import PropTypes and assign the component’s
propTypes before the existing default export.
- Around line 1-18: Reorder the imports in SummaryPeriodFilterDropdown.js into
the required groups: React, PropTypes, Redux, third-party libraries,
Lodash-specific imports, theme-ui, and local imports, keeping a blank line
between each group. Preserve all existing imports and their usage.

In `@app/pages/clinicworkspace/FilterByDataRecency.js`:
- Around line 1-25: Update FilterByDataRecency to follow the import grouping
order, adding the required PropTypes import and separating import groups with
blank lines. Define PropTypes for activeFilters and setActiveFilters, and wrap
handleChange in useCallback with its relevant dependencies while preserving the
existing filter update behavior.

In `@app/pages/clinicworkspace/FilterBySites.js`:
- Line 11: Replace the placeholder metrics helpers so filter metrics are emitted
through the real implementations: import and use the real trackMetric in
app/pages/clinicworkspace/FilterBySites.js (line 11) and
app/pages/clinicworkspace/FilterByTags.js (line 11), and import and use the real
metric and prefix helpers in
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 33-34) and
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 33-34). Remove
the noop/TODO substitutions without changing the existing metric call sites.
- Around line 29-32: Update handleClickEditSites and the corresponding tag
handler to dispatch the async fetch before tracking, then use past-tense event
names. In SiteFilterDropdown.js lines 188-202 and 239-283, and
TagFilterDropdown.js lines 184-198 and 235-279, rename clear/apply and
open/close metrics to their past-tense equivalents while preserving their
existing behavior; apply the dispatch-order change in FilterBySites.js lines
29-32 and FilterByTags.js lines 29-32.

In `@app/pages/clinicworkspace/FilterBySummaryPeriod.js`:
- Around line 1-22: Update FilterBySummaryPeriod imports to follow the project’s
required grouping and spacing, add PropTypes definitions for activeSummaryPeriod
and setActiveSummaryPeriod, and wrap handleChange in useCallback with the
appropriate dependency. Preserve the existing dropdown behavior and default
no-op callback.

---

Outside diff comments:
In `@app/pages/clinicworkspace/ClinicPatients.js`:
- Around line 4125-4138: Update the dependency array for renderPeopleTable to
include patientListSearchTextInput, ensuring its derived patientQueryState and
related clear controls or empty-state text refresh during debounced typing while
preserving the existing dependencies.

---

Nitpick comments:
In `@app/pages/clinicworkspace/FilterBySites.js`:
- Around line 1-9: Normalize import grouping across
app/pages/clinicworkspace/FilterBySites.js (lines 1-9),
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 1-39),
app/pages/clinicworkspace/FilterByTags.js (lines 1-9),
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 1-39), and
app/pages/clinicworkspace/useIsClinicAdmin.js (lines 1-4): place every import
before declarations, separate React, Redux, Lodash, and local imports with blank
lines, and order the groups according to the project convention, with local
actions after Lodash.
- Around line 13-18: Define PropTypes for every prop-taking component in
app/pages/clinicworkspace/FilterBySites.js (lines 13-18),
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 218-222),
app/pages/clinicworkspace/FilterByTags.js (lines 13-18), and
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 214-218),
covering both exported wrappers and nested components and matching each
component’s existing prop contract.
- Around line 23-33: Memoize callback props with useCallback: wrap handleChange
and handleClickEditSites in app/pages/clinicworkspace/FilterBySites.js at lines
23-33, handleCloseDropdown in
app/pages/clinicworkspace/components/SiteFilterDropdown.js at lines 233-235,
handleChange and handleClickEditTags in
app/pages/clinicworkspace/FilterByTags.js at lines 23-33, and
handleCloseDropdown in app/pages/clinicworkspace/components/TagFilterDropdown.js
at lines 229-231; include each callback’s current dependencies.
🪄 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 Plus

Run ID: 45ef73b3-a35e-4081-ba48-b7cbadd4ee98

📥 Commits

Reviewing files that changed from the base of the PR and between 1ea3534 and f860429.

⛔ Files ignored due to path filters (1)
  • app/core/icons/tagIcon.svg is excluded by !**/*.svg
📒 Files selected for processing (15)
  • app/pages/clinicworkspace/AppliedFiltersAdapter.js
  • app/pages/clinicworkspace/ClinicPatients.js
  • app/pages/clinicworkspace/FilterByDataRecency.js
  • app/pages/clinicworkspace/FilterBySites.js
  • app/pages/clinicworkspace/FilterBySummaryPeriod.js
  • app/pages/clinicworkspace/FilterByTags.js
  • app/pages/clinicworkspace/components/AppliedFilters.js
  • app/pages/clinicworkspace/components/ClearFilterButtons.js
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js
  • app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js
  • app/pages/clinicworkspace/components/TagFilterDropdown.js
  • app/pages/clinicworkspace/useClinicPatientsFilters.js
  • app/pages/clinicworkspace/useIsClinicAdmin.js
  • locales/en/translation.json

@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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 12

Caution

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

⚠️ Outside diff range comments (1)
app/pages/clinicworkspace/ClinicPatients.js (1)

4125-4138: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Include the search text in the callback dependencies.

renderPeopleTable derives patientQueryState from patientListSearchTextInput, but the value is omitted here. During debounced typing, the clear controls and empty-state copy can therefore use stale query state.

Proposed fix
   }, [
     activeFilters,
     clinic?.fetchedPatientCount,
     columns,
     data,
     defaultPatientFetchOptions.sort,
     handlePageChange,
     handleSortChange,
     loading,
     patientFetchOptions,
+    patientListSearchTextInput,
     setActiveFilters,
     showSummaryData,
     tableStyle,
   ]);

As per coding guidelines: respect react-hooks/exhaustive-deps.

🤖 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 `@app/pages/clinicworkspace/ClinicPatients.js` around lines 4125 - 4138, Update
the dependency array for renderPeopleTable to include
patientListSearchTextInput, ensuring its derived patientQueryState and related
clear controls or empty-state text refresh during debounced typing while
preserving the existing dependencies.

Source: Coding guidelines

🧹 Nitpick comments (3)
app/pages/clinicworkspace/FilterBySites.js (3)

1-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Apply the required import grouping consistently.

  • app/pages/clinicworkspace/FilterBySites.js#L1-L9: move local actions after Lodash and separate React/Redux groups.
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L1-L39: move all imports before declarations and reorder the groups.
  • app/pages/clinicworkspace/FilterByTags.js#L1-L9: move local actions after Lodash and separate React/Redux groups.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L1-L39: move all imports before declarations and reorder the groups.
  • app/pages/clinicworkspace/useIsClinicAdmin.js#L1-L4: add blank lines between React, Redux, and Lodash.

As per coding guidelines, group imports in the prescribed order with blank lines between groups.

🤖 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 `@app/pages/clinicworkspace/FilterBySites.js` around lines 1 - 9, Normalize
import grouping across app/pages/clinicworkspace/FilterBySites.js (lines 1-9),
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 1-39),
app/pages/clinicworkspace/FilterByTags.js (lines 1-9),
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 1-39), and
app/pages/clinicworkspace/useIsClinicAdmin.js (lines 1-4): place every import
before declarations, separate React, Redux, Lodash, and local imports with blank
lines, and order the groups according to the project convention, with local
actions after Lodash.

Source: Coding guidelines


13-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add PropTypes for every new component contract.

  • app/pages/clinicworkspace/FilterBySites.js#L13-L18: define the wrapper’s prop types.
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L218-L222: define prop types for the exported and nested prop-taking components.
  • app/pages/clinicworkspace/FilterByTags.js#L13-L18: define the wrapper’s prop types.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L214-L218: define prop types for the exported and nested prop-taking components.

As per coding guidelines, define PropTypes for all component props.

🤖 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 `@app/pages/clinicworkspace/FilterBySites.js` around lines 13 - 18, Define
PropTypes for every prop-taking component in
app/pages/clinicworkspace/FilterBySites.js (lines 13-18),
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 218-222),
app/pages/clinicworkspace/FilterByTags.js (lines 13-18), and
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 214-218),
covering both exported wrappers and nested components and matching each
component’s existing prop contract.

Source: Coding guidelines


23-33: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Memoize callbacks passed between components.

  • app/pages/clinicworkspace/FilterBySites.js#L23-L33: memoize both dropdown callbacks.
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L233-L235: memoize handleCloseDropdown.
  • app/pages/clinicworkspace/FilterByTags.js#L23-L33: memoize both dropdown callbacks.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L229-L231: memoize handleCloseDropdown.

As per coding guidelines, use useCallback for callback props.

🤖 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 `@app/pages/clinicworkspace/FilterBySites.js` around lines 23 - 33, Memoize
callback props with useCallback: wrap handleChange and handleClickEditSites in
app/pages/clinicworkspace/FilterBySites.js at lines 23-33, handleCloseDropdown
in app/pages/clinicworkspace/components/SiteFilterDropdown.js at lines 233-235,
handleChange and handleClickEditTags in
app/pages/clinicworkspace/FilterByTags.js at lines 23-33, and
handleCloseDropdown in app/pages/clinicworkspace/components/TagFilterDropdown.js
at lines 229-231; include each callback’s current dependencies.

Source: Coding guidelines

🤖 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 `@app/pages/clinicworkspace/AppliedFiltersAdapter.js`:
- Around line 10-60: Define PropTypes for every component prop across the
extracted filter components: in
app/pages/clinicworkspace/AppliedFiltersAdapter.js lines 10-60, declare
activeFilters, setActiveFilters, and rightContent; in
app/pages/clinicworkspace/components/ClearFilterButtons.js lines 25-60, declare
the query-state and callback props; in
app/pages/clinicworkspace/components/AppliedFilters.js lines 104-171, declare
props for Chip, ChipGroup, and AppliedFilters; and in
app/pages/clinicworkspace/ClinicPatients.js lines 241-252, declare
patientQueryState and children for EmptyContentNode.

In `@app/pages/clinicworkspace/components/AppliedFilters.js`:
- Around line 119-143: Update the filter container styles around
.remove-filter-icon to apply the same reveal behavior for :focus-within as for
:hover, and configure the Icon component to render as a focusable button so
keyboard users can reach and see the remove action.

In `@app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js`:
- Line 194: Add PropTypes for all props accepted by the
DataRecencyFilterDropdown component, using the component’s existing prop usage
to declare each expected type and requiredness. Keep the default export
unchanged and ensure the declarations are attached to DataRecencyFilterDropdown.
- Around line 1-23: Reorganize imports in DataRecencyFilterDropdown.js into the
required groups—React, PropTypes, Redux, third-party libraries, Lodash,
theme-ui, and local modules—with blank lines between groups. Remove the unused
borders, DialogContent, and DialogActions imports while preserving all imports
referenced by the component.
- Line 24: The prefixPopHealthMetric helper currently returns noop instead of an
event-name string, causing trackMetric calls to receive a function. Update
prefixPopHealthMetric in
app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js:24-24 and
app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js:19-19 to use
the shared string prefix behavior, returning “Clinic - Population Health - ”
followed by the metric.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js`:
- Around line 101-107: Update SiteFilterDropdown.js lines 101-107 and
TagFilterDropdown.js lines 101-107 so the populated-state CloseRoundedIcon
receives the translated accessible label “Clear search,” while preserving the
SearchIcon behavior. Update the clinic-site trigger in SiteFilterDropdown.js
lines 245-252 and patient-tag trigger in TagFilterDropdown.js lines 241-248 to
use translated labels via the existing react-i18next translation mechanism.

In `@app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js`:
- Line 172: Add PropTypes for every prop consumed by the
SummaryPeriodFilterDropdown component, using the appropriate type and
requiredness for each existing prop; import PropTypes and assign the component’s
propTypes before the existing default export.
- Around line 1-18: Reorder the imports in SummaryPeriodFilterDropdown.js into
the required groups: React, PropTypes, Redux, third-party libraries,
Lodash-specific imports, theme-ui, and local imports, keeping a blank line
between each group. Preserve all existing imports and their usage.

In `@app/pages/clinicworkspace/FilterByDataRecency.js`:
- Around line 1-25: Update FilterByDataRecency to follow the import grouping
order, adding the required PropTypes import and separating import groups with
blank lines. Define PropTypes for activeFilters and setActiveFilters, and wrap
handleChange in useCallback with its relevant dependencies while preserving the
existing filter update behavior.

In `@app/pages/clinicworkspace/FilterBySites.js`:
- Line 11: Replace the placeholder metrics helpers so filter metrics are emitted
through the real implementations: import and use the real trackMetric in
app/pages/clinicworkspace/FilterBySites.js (line 11) and
app/pages/clinicworkspace/FilterByTags.js (line 11), and import and use the real
metric and prefix helpers in
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 33-34) and
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 33-34). Remove
the noop/TODO substitutions without changing the existing metric call sites.
- Around line 29-32: Update handleClickEditSites and the corresponding tag
handler to dispatch the async fetch before tracking, then use past-tense event
names. In SiteFilterDropdown.js lines 188-202 and 239-283, and
TagFilterDropdown.js lines 184-198 and 235-279, rename clear/apply and
open/close metrics to their past-tense equivalents while preserving their
existing behavior; apply the dispatch-order change in FilterBySites.js lines
29-32 and FilterByTags.js lines 29-32.

In `@app/pages/clinicworkspace/FilterBySummaryPeriod.js`:
- Around line 1-22: Update FilterBySummaryPeriod imports to follow the project’s
required grouping and spacing, add PropTypes definitions for activeSummaryPeriod
and setActiveSummaryPeriod, and wrap handleChange in useCallback with the
appropriate dependency. Preserve the existing dropdown behavior and default
no-op callback.

---

Outside diff comments:
In `@app/pages/clinicworkspace/ClinicPatients.js`:
- Around line 4125-4138: Update the dependency array for renderPeopleTable to
include patientListSearchTextInput, ensuring its derived patientQueryState and
related clear controls or empty-state text refresh during debounced typing while
preserving the existing dependencies.

---

Nitpick comments:
In `@app/pages/clinicworkspace/FilterBySites.js`:
- Around line 1-9: Normalize import grouping across
app/pages/clinicworkspace/FilterBySites.js (lines 1-9),
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 1-39),
app/pages/clinicworkspace/FilterByTags.js (lines 1-9),
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 1-39), and
app/pages/clinicworkspace/useIsClinicAdmin.js (lines 1-4): place every import
before declarations, separate React, Redux, Lodash, and local imports with blank
lines, and order the groups according to the project convention, with local
actions after Lodash.
- Around line 13-18: Define PropTypes for every prop-taking component in
app/pages/clinicworkspace/FilterBySites.js (lines 13-18),
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 218-222),
app/pages/clinicworkspace/FilterByTags.js (lines 13-18), and
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 214-218),
covering both exported wrappers and nested components and matching each
component’s existing prop contract.
- Around line 23-33: Memoize callback props with useCallback: wrap handleChange
and handleClickEditSites in app/pages/clinicworkspace/FilterBySites.js at lines
23-33, handleCloseDropdown in
app/pages/clinicworkspace/components/SiteFilterDropdown.js at lines 233-235,
handleChange and handleClickEditTags in
app/pages/clinicworkspace/FilterByTags.js at lines 23-33, and
handleCloseDropdown in app/pages/clinicworkspace/components/TagFilterDropdown.js
at lines 229-231; include each callback’s current dependencies.
🪄 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 Plus

Run ID: 45ef73b3-a35e-4081-ba48-b7cbadd4ee98

📥 Commits

Reviewing files that changed from the base of the PR and between 1ea3534 and f860429.

⛔ Files ignored due to path filters (1)
  • app/core/icons/tagIcon.svg is excluded by !**/*.svg
📒 Files selected for processing (15)
  • app/pages/clinicworkspace/AppliedFiltersAdapter.js
  • app/pages/clinicworkspace/ClinicPatients.js
  • app/pages/clinicworkspace/FilterByDataRecency.js
  • app/pages/clinicworkspace/FilterBySites.js
  • app/pages/clinicworkspace/FilterBySummaryPeriod.js
  • app/pages/clinicworkspace/FilterByTags.js
  • app/pages/clinicworkspace/components/AppliedFilters.js
  • app/pages/clinicworkspace/components/ClearFilterButtons.js
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js
  • app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js
  • app/pages/clinicworkspace/components/TagFilterDropdown.js
  • app/pages/clinicworkspace/useClinicPatientsFilters.js
  • app/pages/clinicworkspace/useIsClinicAdmin.js
  • locales/en/translation.json
🛑 Comments failed to post (12)
app/pages/clinicworkspace/AppliedFiltersAdapter.js (1)

10-60: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add the missing PropTypes contracts across the extracted filter components.

  • app/pages/clinicworkspace/AppliedFiltersAdapter.js#L10-L60: declare activeFilters, setActiveFilters, and rightContent.
  • app/pages/clinicworkspace/components/ClearFilterButtons.js#L25-L60: declare the query-state and callback props.
  • app/pages/clinicworkspace/components/AppliedFilters.js#L104-L171: declare props for Chip, ChipGroup, and AppliedFilters.
  • app/pages/clinicworkspace/ClinicPatients.js#L241-L252: declare patientQueryState and children for EmptyContentNode.

As per coding guidelines: “Define PropTypes for all component props.”

📍 Affects 4 files
  • app/pages/clinicworkspace/AppliedFiltersAdapter.js#L10-L60 (this comment)
  • app/pages/clinicworkspace/components/ClearFilterButtons.js#L25-L60
  • app/pages/clinicworkspace/components/AppliedFilters.js#L104-L171
  • app/pages/clinicworkspace/ClinicPatients.js#L241-L252
🤖 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 `@app/pages/clinicworkspace/AppliedFiltersAdapter.js` around lines 10 - 60,
Define PropTypes for every component prop across the extracted filter
components: in app/pages/clinicworkspace/AppliedFiltersAdapter.js lines 10-60,
declare activeFilters, setActiveFilters, and rightContent; in
app/pages/clinicworkspace/components/ClearFilterButtons.js lines 25-60, declare
the query-state and callback props; in
app/pages/clinicworkspace/components/AppliedFilters.js lines 104-171, declare
props for Chip, ChipGroup, and AppliedFilters; and in
app/pages/clinicworkspace/ClinicPatients.js lines 241-252, declare
patientQueryState and children for EmptyContentNode.

Source: Coding guidelines

app/pages/clinicworkspace/components/AppliedFilters.js (1)

119-143: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Expose the remove action on keyboard focus.

The icon expands only on :hover, leaving keyboard users with an invisible focused control. Apply the same reveal styles for :focus-within and ensure Icon renders a focusable button.

Proposed focus styling
-      '&:hover .remove-filter-icon': {
+      '&:hover .remove-filter-icon, &:focus-within .remove-filter-icon': {
         width: '14px',
         ml: 1,
         mr: 1,
         opacity: 1,
       },
📝 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.

      '.remove-filter-icon': {
        color: vizColors.blue80,
        minWidth: 0,
        width: 0,
        mr: 1,
        opacity: 0,
        overflow: 'hidden',
        transition: transitions.easeOut,
      },
      '&:hover .remove-filter-icon, &:focus-within .remove-filter-icon': {
        width: '14px',
        ml: 1,
        mr: 1,
        opacity: 1,
      },
    }}
  >
    <Text sx={{ textDecoration: 'underline', whiteSpace: 'nowrap' }}>{label}</Text>
    <Icon
      className="remove-filter-icon"
      variant="static"
      icon={CloseRoundedIcon}
      label={t('Remove {{ label }} filter', { label })}
      onClick={onRemove}
      sx={{ fontSize: '14px', color: vizColors.indigo50, flexShrink: 0 }}
🤖 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 `@app/pages/clinicworkspace/components/AppliedFilters.js` around lines 119 -
143, Update the filter container styles around .remove-filter-icon to apply the
same reveal behavior for :focus-within as for :hover, and configure the Icon
component to render as a focusable button so keyboard users can reach and see
the remove action.
app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js (3)

1-23: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Apply coding guidelines for import grouping and remove unused imports.

As per coding guidelines, imports should be grouped in the required order with blank lines between groups: React, PropTypes, Redux, third-party libraries, Lodash specific imports, theme-ui, then local imports. Additionally, borders, DialogContent, and DialogActions are unused and should be removed.

♻️ Proposed fix
-import React, { useState } from 'react';
+import React, { useState } from 'react';
+
+import PropTypes from 'prop-types';
+
 import { useSelector } from 'react-redux';
+
 import { useTranslation } from 'react-i18next';
-import { trackMetric } from '../../../core/metricUtils';
+import { bindPopover, bindTrigger, usePopupState } from 'material-ui-popup-state/hooks';
 import { colors as vizColors } from '`@tidepool/viz`';
-
-import { Box, Grid, Text } from 'theme-ui';
 import KeyboardArrowDownRoundedIcon from '`@material-ui/icons/KeyboardArrowDownRounded`';
 
 import reject from 'lodash/reject';
 import noop from 'lodash/noop';
 
-import { bindPopover, bindTrigger, usePopupState } from 'material-ui-popup-state/hooks';
-
+import { Box, Grid, Text } from 'theme-ui';
+
+import { trackMetric } from '../../../core/metricUtils';
 import Button from '../../../components/elements/Button';
 import Popover from '../../../components/elements/Popover';
 import RadioGroup from '../../../components/elements/RadioGroup';
 import { Body0 } from '../../../components/elements/FontStyles';
-
-import { borders } from '../../../themes/baseTheme';
-import { DialogContent, DialogActions } from '../../../components/elements/Dialog';
 import { lastDataFilterOptions } from '../../../core/clinicUtils';
📝 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.

import React, { useState } from 'react';

import PropTypes from 'prop-types';

import { useSelector } from 'react-redux';

import { useTranslation } from 'react-i18next';
import { bindPopover, bindTrigger, usePopupState } from 'material-ui-popup-state/hooks';
import { colors as vizColors } from '`@tidepool/viz`';
import KeyboardArrowDownRoundedIcon from '`@material-ui/icons/KeyboardArrowDownRounded`';

import reject from 'lodash/reject';
import noop from 'lodash/noop';

import { Box, Grid, Text } from 'theme-ui';

import { trackMetric } from '../../../core/metricUtils';
import Button from '../../../components/elements/Button';
import Popover from '../../../components/elements/Popover';
import RadioGroup from '../../../components/elements/RadioGroup';
import { Body0 } from '../../../components/elements/FontStyles';
import { lastDataFilterOptions } from '../../../core/clinicUtils';
🤖 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 `@app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js` around
lines 1 - 23, Reorganize imports in DataRecencyFilterDropdown.js into the
required groups—React, PropTypes, Redux, third-party libraries, Lodash,
theme-ui, and local modules—with blank lines between groups. Remove the unused
borders, DialogContent, and DialogActions imports while preserving all imports
referenced by the component.

Source: Coding guidelines


24-24: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg 'prefixPopHealthMetric'

Repository: tidepool-org/blip

Length of output: 155


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the two target files around the relevant lines
sed -n '1,120p' app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js
printf '\n---\n'
sed -n '1,120p' app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js

printf '\n=== search for metric helper usage ===\n'
rg -n "trackMetric|prefixPopHealthMetric|popHealthMetric|noop" app/pages/clinicworkspace app -g '*.js'

Repository: tidepool-org/blip

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '=== metricUtils ===\n'
sed -n '1,220p' app/core/metricUtils.js

printf '\n=== clinicworkspace prefix helper examples ===\n'
sed -n '810,840p' app/pages/clinicworkspace/ClinicPatients.js

printf '\n=== other dropdown stubs ===\n'
sed -n '1,70p' app/pages/clinicworkspace/components/SiteFilterDropdown.js
printf '\n---\n'
sed -n '1,70p' app/pages/clinicworkspace/components/TagFilterDropdown.js

printf '\n=== trackMetric call sites in target files ===\n'
sed -n '85,125p' app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js
printf '\n---\n'
sed -n '75,105p' app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js

Repository: tidepool-org/blip

Length of output: 9672


Replace the noop metric prefix stub

trackMetric() receives the return value of prefixPopHealthMetric(...); returning noop passes a function instead of an event name, so these events won’t record correctly.

  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js#L24
  • app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js#L19

Use the same string prefix helper used elsewhere: metric => \Clinic - Population Health - ${metric}``

📍 Affects 2 files
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js#L24-L24 (this comment)
  • app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js#L19-L19
🤖 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 `@app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js` at line
24, The prefixPopHealthMetric helper currently returns noop instead of an
event-name string, causing trackMetric calls to receive a function. Update
prefixPopHealthMetric in
app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js:24-24 and
app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js:19-19 to use
the shared string prefix behavior, returning “Clinic - Population Health - ”
followed by the metric.

194-194: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Define PropTypes for components.

As per coding guidelines, define PropTypes for all component props.

♻️ Proposed fix
+DropdownContent.propTypes = {
+  onClose: PropTypes.func,
+  onChange: PropTypes.func,
+  lastData: PropTypes.number,
+  lastDataType: PropTypes.string,
+};
+
+DataRecencyFilterDropdown.propTypes = {
+  onChange: PropTypes.func,
+  lastData: PropTypes.number,
+  lastDataType: PropTypes.string,
+};
+
 export default DataRecencyFilterDropdown;
📝 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.

DropdownContent.propTypes = {
  onClose: PropTypes.func,
  onChange: PropTypes.func,
  lastData: PropTypes.number,
  lastDataType: PropTypes.string,
};

DataRecencyFilterDropdown.propTypes = {
  onChange: PropTypes.func,
  lastData: PropTypes.number,
  lastDataType: PropTypes.string,
};

export default DataRecencyFilterDropdown;
🤖 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 `@app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js` at line
194, Add PropTypes for all props accepted by the DataRecencyFilterDropdown
component, using the component’s existing prop usage to declare each expected
type and requiredness. Keep the default export unchanged and ensure the
declarations are attached to DataRecencyFilterDropdown.

Source: Coding guidelines

app/pages/clinicworkspace/components/SiteFilterDropdown.js (1)

101-107: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Provide accurate, translated accessible labels.

  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L101-L107: label the populated-state icon “Clear search.”
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L245-L252: translate the clinic-site trigger label.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L101-L107: label the populated-state icon “Clear search.”
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L241-L248: translate the patient-tag trigger label.

As per coding guidelines, use react-i18next for translations.

📍 Affects 2 files
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L101-L107 (this comment)
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L245-L252
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L101-L107
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L241-L248
🤖 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 `@app/pages/clinicworkspace/components/SiteFilterDropdown.js` around lines 101
- 107, Update SiteFilterDropdown.js lines 101-107 and TagFilterDropdown.js lines
101-107 so the populated-state CloseRoundedIcon receives the translated
accessible label “Clear search,” while preserving the SearchIcon behavior.
Update the clinic-site trigger in SiteFilterDropdown.js lines 245-252 and
patient-tag trigger in TagFilterDropdown.js lines 241-248 to use translated
labels via the existing react-i18next translation mechanism.

Source: Coding guidelines

app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js (2)

1-18: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Apply coding guidelines for import grouping.

As per coding guidelines, imports should be grouped in the required order with blank lines between groups: React, PropTypes, Redux, third-party libraries, Lodash specific imports, theme-ui, then local imports.

♻️ Proposed fix
-import React, { useState } from 'react';
+import React, { useState } from 'react';
+
+import PropTypes from 'prop-types';
+
 import { useSelector } from 'react-redux';
+
 import { useTranslation } from 'react-i18next';
-import { trackMetric } from '../../../core/metricUtils';
+import { bindPopover, bindTrigger, usePopupState } from 'material-ui-popup-state/hooks';
 import { colors as vizColors } from '`@tidepool/viz`';
-
-import { Box, Grid } from 'theme-ui';
 import KeyboardArrowDownRoundedIcon from '`@material-ui/icons/KeyboardArrowDownRounded`';
 
 import noop from 'lodash/noop';
 
-import { bindPopover, bindTrigger, usePopupState } from 'material-ui-popup-state/hooks';
-
+import { Box, Grid } from 'theme-ui';
+
+import { trackMetric } from '../../../core/metricUtils';
 import Button from '../../../components/elements/Button';
 import Popover from '../../../components/elements/Popover';
 import RadioGroup from '../../../components/elements/RadioGroup';
 import { Body0, Body1 } from '../../../components/elements/FontStyles';
📝 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.

import React, { useState } from 'react';

import PropTypes from 'prop-types';

import { useSelector } from 'react-redux';

import { useTranslation } from 'react-i18next';
import { bindPopover, bindTrigger, usePopupState } from 'material-ui-popup-state/hooks';
import { colors as vizColors } from '`@tidepool/viz`';
import KeyboardArrowDownRoundedIcon from '`@material-ui/icons/KeyboardArrowDownRounded`';

import noop from 'lodash/noop';

import { Box, Grid } from 'theme-ui';

import { trackMetric } from '../../../core/metricUtils';
import Button from '../../../components/elements/Button';
import Popover from '../../../components/elements/Popover';
import RadioGroup from '../../../components/elements/RadioGroup';
import { Body0, Body1 } from '../../../components/elements/FontStyles';
🤖 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 `@app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js` around
lines 1 - 18, Reorder the imports in SummaryPeriodFilterDropdown.js into the
required groups: React, PropTypes, Redux, third-party libraries, Lodash-specific
imports, theme-ui, and local imports, keeping a blank line between each group.
Preserve all existing imports and their usage.

Source: Coding guidelines


172-172: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Define PropTypes for components.

As per coding guidelines, define PropTypes for all component props.

♻️ Proposed fix
+DropdownContent.propTypes = {
+  onClose: PropTypes.func,
+  onChange: PropTypes.func,
+  activeSummaryPeriod: PropTypes.string,
+};
+
+SummaryPeriodFilterDropdown.propTypes = {
+  onChange: PropTypes.func,
+  activeSummaryPeriod: PropTypes.string,
+};
+
 export default SummaryPeriodFilterDropdown;
📝 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.

DropdownContent.propTypes = {
  onClose: PropTypes.func,
  onChange: PropTypes.func,
  activeSummaryPeriod: PropTypes.string,
};

SummaryPeriodFilterDropdown.propTypes = {
  onChange: PropTypes.func,
  activeSummaryPeriod: PropTypes.string,
};

export default SummaryPeriodFilterDropdown;
🤖 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 `@app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js` at line
172, Add PropTypes for every prop consumed by the SummaryPeriodFilterDropdown
component, using the appropriate type and requiredness for each existing prop;
import PropTypes and assign the component’s propTypes before the existing
default export.

Source: Coding guidelines

app/pages/clinicworkspace/FilterByDataRecency.js (1)

1-25: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Apply coding guidelines for imports, PropTypes, and hooks.

As per coding guidelines:

  • Imports must be grouped in the required order with blank lines between groups (React, PropTypes, Redux, third-party libraries, Lodash, theme-ui, local imports).
  • Component props must have PropTypes defined.
  • Callback props should be wrapped in useCallback.
♻️ Proposed fixes
-import React from 'react';
-import noop from 'lodash/noop';
+import React, { useCallback } from 'react';
+
+import PropTypes from 'prop-types';
+
+import noop from 'lodash/noop';
 
 import DataRecencyFilterDropdown from './components/DataRecencyFilterDropdown';
 
 const FilterByDataRecency = ({
   activeFilters = {},
   setActiveFilters = noop,
 }) => {
-  const handleChange = ({ lastData, lastDataType }) => {
+  const handleChange = useCallback(({ lastData, lastDataType }) => {
     setActiveFilters({ ...activeFilters, lastData, lastDataType });
-  };
+  }, [activeFilters, setActiveFilters]);
 
   const { lastData, lastDataType } = activeFilters;
 
   return (
     <DataRecencyFilterDropdown
       onChange={handleChange}
       lastData={lastData}
       lastDataType={lastDataType}
     />
   );
 };
+
+FilterByDataRecency.propTypes = {
+  activeFilters: PropTypes.object,
+  setActiveFilters: PropTypes.func,
+};
 
 export default FilterByDataRecency;
📝 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.

import React, { useCallback } from 'react';

import PropTypes from 'prop-types';

import noop from 'lodash/noop';

import DataRecencyFilterDropdown from './components/DataRecencyFilterDropdown';

const FilterByDataRecency = ({
  activeFilters = {},
  setActiveFilters = noop,
}) => {
  const handleChange = useCallback(({ lastData, lastDataType }) => {
    setActiveFilters({ ...activeFilters, lastData, lastDataType });
  }, [activeFilters, setActiveFilters]);

  const { lastData, lastDataType } = activeFilters;

  return (
    <DataRecencyFilterDropdown
      onChange={handleChange}
      lastData={lastData}
      lastDataType={lastDataType}
    />
  );
};

FilterByDataRecency.propTypes = {
  activeFilters: PropTypes.object,
  setActiveFilters: PropTypes.func,
};

export default FilterByDataRecency;
🤖 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 `@app/pages/clinicworkspace/FilterByDataRecency.js` around lines 1 - 25, Update
FilterByDataRecency to follow the import grouping order, adding the required
PropTypes import and separating import groups with blank lines. Define PropTypes
for activeFilters and setActiveFilters, and wrap handleChange in useCallback
with its relevant dependencies while preserving the existing filter update
behavior.

Source: Coding guidelines

app/pages/clinicworkspace/FilterBySites.js (2)

11-11: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Replace all placeholder metrics helpers before merging.

  • app/pages/clinicworkspace/FilterBySites.js#L11-L11: import the real trackMetric.
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L33-L34: import the real metric and prefix helpers.
  • app/pages/clinicworkspace/FilterByTags.js#L11-L11: import the real trackMetric.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L33-L34: import the real metric and prefix helpers.

These placeholders silently discard every newly added filter metric.

📍 Affects 4 files
  • app/pages/clinicworkspace/FilterBySites.js#L11-L11 (this comment)
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L33-L34
  • app/pages/clinicworkspace/FilterByTags.js#L11-L11
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L33-L34
🤖 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 `@app/pages/clinicworkspace/FilterBySites.js` at line 11, Replace the
placeholder metrics helpers so filter metrics are emitted through the real
implementations: import and use the real trackMetric in
app/pages/clinicworkspace/FilterBySites.js (line 11) and
app/pages/clinicworkspace/FilterByTags.js (line 11), and import and use the real
metric and prefix helpers in
app/pages/clinicworkspace/components/SiteFilterDropdown.js (lines 33-34) and
app/pages/clinicworkspace/components/TagFilterDropdown.js (lines 33-34). Remove
the noop/TODO substitutions without changing the existing metric call sites.

29-32: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Align the new metrics with the established event convention.

  • app/pages/clinicworkspace/FilterBySites.js#L29-L32: dispatch first, then track with a past-tense event name.
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L188-L202: rename clear/apply events to past tense.
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L239-L283: rename open/close events to past tense.
  • app/pages/clinicworkspace/FilterByTags.js#L29-L32: dispatch first, then track with a past-tense event name.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L184-L198: rename clear/apply events to past tense.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L235-L279: rename open/close events to past tense.

Based on learnings, metric names should be past tense and async initiation metrics should be emitted immediately after dispatch.

📍 Affects 4 files
  • app/pages/clinicworkspace/FilterBySites.js#L29-L32 (this comment)
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L188-L202
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L239-L283
  • app/pages/clinicworkspace/FilterByTags.js#L29-L32
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L184-L198
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L235-L279
🤖 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 `@app/pages/clinicworkspace/FilterBySites.js` around lines 29 - 32, Update
handleClickEditSites and the corresponding tag handler to dispatch the async
fetch before tracking, then use past-tense event names. In SiteFilterDropdown.js
lines 188-202 and 239-283, and TagFilterDropdown.js lines 184-198 and 235-279,
rename clear/apply and open/close metrics to their past-tense equivalents while
preserving their existing behavior; apply the dispatch-order change in
FilterBySites.js lines 29-32 and FilterByTags.js lines 29-32.

Source: Learnings

app/pages/clinicworkspace/FilterBySummaryPeriod.js (1)

1-22: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Apply coding guidelines for imports, PropTypes, and hooks.

As per coding guidelines:

  • Imports must be grouped in the required order with blank lines between groups.
  • Component props must have PropTypes defined.
  • Callback props should be wrapped in useCallback.
♻️ Proposed fixes
-import React from 'react';
-import noop from 'lodash/noop';
+import React, { useCallback } from 'react';
+
+import PropTypes from 'prop-types';
+
+import noop from 'lodash/noop';
 
 import SummaryPeriodFilterDropdown from './components/SummaryPeriodFilterDropdown';
 
 const FilterBySummaryPeriod = ({
   activeSummaryPeriod,
   setActiveSummaryPeriod = noop,
 }) => {
-  const handleChange = (summaryPeriod) => {
+  const handleChange = useCallback((summaryPeriod) => {
     setActiveSummaryPeriod(summaryPeriod);
-  };
+  }, [setActiveSummaryPeriod]);
 
   return (
     <SummaryPeriodFilterDropdown
       onChange={handleChange}
       activeSummaryPeriod={activeSummaryPeriod}
     />
   );
 };
+
+FilterBySummaryPeriod.propTypes = {
+  activeSummaryPeriod: PropTypes.string,
+  setActiveSummaryPeriod: PropTypes.func,
+};
 
 export default FilterBySummaryPeriod;
📝 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.

import React, { useCallback } from 'react';

import PropTypes from 'prop-types';

import noop from 'lodash/noop';

import SummaryPeriodFilterDropdown from './components/SummaryPeriodFilterDropdown';

const FilterBySummaryPeriod = ({
  activeSummaryPeriod,
  setActiveSummaryPeriod = noop,
}) => {
  const handleChange = useCallback((summaryPeriod) => {
    setActiveSummaryPeriod(summaryPeriod);
  }, [setActiveSummaryPeriod]);

  return (
    <SummaryPeriodFilterDropdown
      onChange={handleChange}
      activeSummaryPeriod={activeSummaryPeriod}
    />
  );
};

FilterBySummaryPeriod.propTypes = {
  activeSummaryPeriod: PropTypes.string,
  setActiveSummaryPeriod: PropTypes.func,
};

export default FilterBySummaryPeriod;
🧰 Tools
🪛 ast-grep (0.44.1)

[warning] 10-10: Avoid using the initial state variable in setState
Context: setActiveSummaryPeriod(summaryPeriod)
Note: [CWE-710] Improper Adherence to Coding Standards. Security best practice.

(setstate-same-var)

🤖 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 `@app/pages/clinicworkspace/FilterBySummaryPeriod.js` around lines 1 - 22,
Update FilterBySummaryPeriod imports to follow the project’s required grouping
and spacing, add PropTypes definitions for activeSummaryPeriod and
setActiveSummaryPeriod, and wrap handleChange in useCallback with the
appropriate dependency. Preserve the existing dropdown behavior and default
no-op callback.

Source: Coding guidelines

This was referenced Jul 15, 2026
@henry-tp henry-tp changed the title Web 4654 summary period WEB-4654 - Summary Period Jul 17, 2026
@henry-tp
henry-tp requested a review from clintonium-119 July 21, 2026 21:35
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