Skip to content

OpenConceptLab/ocl_issues#3057 | Include retired switch; counts agree with results - #110

Draft
paynejd wants to merge 7 commits into
mainfrom
issues#3057
Draft

paynejd wants to merge 7 commits into
mainfrom
issues#3057

Conversation

@paynejd

@paynejd paynejd commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

The TBv3 half of OpenConceptLab/ocl_issues#3057. Filter counts in TBv3 included retired concepts while the result list hid them (CIEL v2026-10-23, Class = Drug: 8,765 in the panel, 8,289 in the list). One "Include Retired" switch in the results toolbar now drives the results, the filter values and the filter counts together, and "active" always means not retired.

Draft for a look at the visuals first.

What changes

The switch (concept and mapping searches: global search, source pages, collection pages)

  • Sits in the results toolbar next to Sort By. It shows how many results are retired when the API gives that count: "Include Retired (476)".
  • Off by default in sources and global search; on by default in collections, whose retired members are there on purpose.
  • Kept in the URL as includeRetired=true|false, written only when it differs from the page's default, so it survives reload and Back. Changing it starts again from page 1 and refetches results and filter counts together.
  • Stays clickable when a search finds nothing, since turning it on may be what brings results back.
  • Not shown in $match (Matched Candidates) or in the hierarchy view, which send no filters; both behave as before.

Request contract (shared with OpenConceptLab/oclapi2#1019)

Switch Sources, global search Collections
off no retired param retired=false
on includeRetired=true includeRetired=true

The list request and the filter (facet, facetsOnly=true) request send the same. With the switch off, sources and global search send nothing because the API already leaves retired ones out of their results, and a plain listing stays off the search index, so paging past 10,000 results keeps working.

Deploy order: OpenConceptLab/oclapi2#1019 first, then this.

  • Collections: results and filter counts agree on today's API (retired=false filters both).
  • Sources and global search: with the switch on they agree today. With it off, the list leaves retired ones out but today's filter counts still include them (CIEL, Class = Drug: list 8,289, Drug 8,765). They agree once the oclapi2 PR makes filter counts follow the default retired rule.
  • The count on the switch comes from the facet response's retired field, true value, and shows only when that value is there (never "(0)" for a missing one). Today it shows in sources and global search in both states, and in collections only when on: with retired=false the API leaves the true value out. Once the oclapi2 PR returns both values of the Retired facet, it shows in every state.

The Retired filter leaves the filter panel for concept and mapping searches.

  • A Retired filter in an old URL sets the switch instead: true,false → on, false → off. A retired-only filter (true) can't be expressed with the switch, so it turns the switch on (active and retired, each retired one marked Retired). The URL's own includeRetired wins.
  • Saved default filters never set the switch: a retired entry in them is left out, and new saved defaults never include it. (No repository on production has retired in its saved default filters.)
  • Repository searches (the Repositories tab, organization and user pages) keep their Retired filter: no repository on production is retired (13,517, all retired=false), so a switch there would have nothing to show.

Counts and wording ("active" = not retired)

  • Repository summary panel: collections show "8,765 concepts (476 retired)" (all members); sources keep "55,561 active concepts (3,335 retired)". Same for mappings.
  • Collection versions tab and expansion rows: an expansion counts all its members. They show the total, and "8,765 concepts (476 retired)" once the API adds retired_concepts / retired_mappings to expansion summaries (total = active + retired). On today's API, where the expansion's active_concepts is already the total, they show that number as "8,765 concepts". A version with no expansion falls back to its own summary, labelled "Active Concepts".
  • Compact counts that show summary.active_* say so: the tooltips in repository search rows and source version rows, the repository hover card, the version picker table and the version comparison rows now read "Active Concepts" / "Active Mappings".
  • New strings are in en, es, pt-BR and zh, built from each locale's existing wording for "retired" and "active".

Checked in the app

Local build against the production API, signed in as a test account.

Page Switch off Switch on
CIEL v2026-10-23 concepts list 55,561, last-page button shown, "Include Retired (3,335)" list 58,896
CIEL v2026-10-23 concepts, Class = Drug list 8,289; Drug 8,765 until the oclapi2 PR deploys list 8,765, Drug 8,765, "Include Retired (476)"
Test collection (8,765 members, 476 retired), HEAD and v1 list 8,289, Concept Class Drug 8,289 default: 8,765 and 8,765, "Include Retired (476)"
Global search "malaria" list 986, "Include Retired (54)"; filter counts include retired until the oclapi2 PR deploys 1,040

The test collection's summary panel reads "8,765 concepts (476 retired)" at HEAD and at v1. Reload keeps the setting; Back returns to the previous one. An old filters={"retired":"true,false"} URL opens with the switch on; {"retired":"false", ...} with it off and the other filters kept.

CIEL, switch off: all pages reachable
CIEL, Class = Drug, switch off (filter counts agree once the oclapi2 PR deploys)
CIEL, Class = Drug, switch on
Collection HEAD, switch off
Collection v1, switch on by default, summary panel
Collection versions tab, count tooltip
Collection expansions and HEAD summary
Global search, switch off
Global search, switch on

The issues#3057-screenshots branch holds only these images and can be deleted after review.

Worth knowing

  • In a collection, the switch turned off sends retired=false, a filter, so a collection of more than 10,000 members gets the 10,000-result paging window the UI already applies to filtered searches.

Design system

The switch reuses the existing "Include Retired" chip on a concept's associations (Associations.jsx: MUI Chip, tick icon and filled primary.90 when on, outlined when off). The OCL v3 design system has no on/off toggle for a filter or results toolbar; this is a gap to fill there, with this chip as the candidate pattern. The label reads "Include Retired", as that chip and the other toolbar buttons do (es, pt-BR and zh use their chip's wording).

Tests

  • npm test: 179 pass, 0 fail. New: src/components/search/__tests__/retiredSwitch.test.js (defaults, request params, old-URL mapping, URL precedence, Searchlight URLs, retired count) and src/components/repos/__tests__/expansionCounts.test.js (expansion and version counts before and after the API change, labels).
  • ./node_modules/eslint/bin/eslint.js src --ext .jsx,.js: clean.

Review

Three Codex defect passes, posted below with responses. Fixed: answers to an earlier search no longer overwrite the current list or counts (including a page change that overtakes a switch change), Searchlight and clearing the keyword keep the switch, an includeRetired URL opens a saved Hierarchy display as a list, and an applied filter value with no matches left shows 0. Two P2s accepted as behaviour that predates this PR (see the pass 3 reply). Since then the "off" request changed per context and the label casing changed (21c130b); the simplification review then removed the saved-default mapping and an alias (50e6355). A Codex check of a065958..HEAD follows below.

closes OpenConceptLab/ocl_issues#3057

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qVNufohRXPK1DHpx7i

paynejd and others added 2 commits November 20, 2026 13:54
… with results

One "Include retired" switch in the results toolbar of concept and mapping
searches (global search, source and collection pages) sets the results, the
filter values and the filter counts together. Off by default in sources and
global search, on in collections. Off sends retired=false and on sends
includeRetired=true, on the list request and the facet request alike. The
setting is kept in the URL (includeRetired, written only when it differs
from the page's default); changing it starts again from page 1. The label
shows the retired count when the facet response gives one.

The Retired filter leaves the filter panel for these searches. A Retired
filter in an old URL or a repository's saved default filters sets the switch
instead (true,false or true alone: on; false: off), and new default filters
don't save it. Repository searches keep their Retired filter.

"Active" now always means not retired: a collection's summary shows all its
concepts and how many are retired, a source's keeps its active count;
collection version and expansion rows show all members, with the retired
count once the API gives retired_concepts / retired_mappings; compact counts
of summary.active_* say "Active Concepts" / "Active Mappings".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVNufohRXPK1DHpx7i
…pped; Searchlight keeps the switch

From the first Codex pass on #110:
- a slow list or filter-count answer for the switch's previous setting no
  longer overwrites the current one (each keeps only its latest request);
- an applied filter value that loses all its matches shows 0, not its old count;
- applying a Class or Map Type in Searchlight keeps includeRetired;
- a Retired filter in a repository's saved defaults sets the switch's default
  there, so turning it back to the page default survives a reload, and saved
  defaults that held only that filter no longer leave the table on hierarchy roots;
- returning from Matched Candidates keeps the retired count;
- only an owner's /collections/ path segment makes a page a collection;
- the count label test no longer depends on the machine's number format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVNufohRXPK1DHpx7i
@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.169.0, commit a833560)

Verdict: findings (8: 4 P1, 4 P2)

  • F1.1 (P1) src/components/search/Search.jsx:516: An older facet response can overwrite the counts for the current switch setting.
  • F1.2 (P1) src/components/search/Search.jsx:544: An applied facet retains its old positive count when switching off retired results removes its last match.
  • F1.3 (P1) src/components/search/SearchInputDrawer.jsx:140: Applying a Searchlight Class or Map Type filter drops the Include retired setting.
  • F1.4 (P1) src/components/search/Search.jsx:185: A legacy saved Retired filter can override the user's switch choice on reload.
  • F1.5 (P2) src/components/search/Search.jsx:147: Leaving Hierarchy can leave the table showing only hierarchy roots.
  • F1.6 (P2) src/components/search/Search.jsx:502: Returning from semantic match can leave the retired count missing.
  • F1.7 (P2) src/components/search/retiredSwitch.js:13: A source named collections gets the collection default.
  • F1.8 (P2) src/components/repos/__tests__/expansionCounts.test.js:32: The new count-label test fails under locales that use a different grouping separator.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "a833560c",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "F1.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 516,
      "claim": "An older facet response can overwrite the counts for the current switch setting.",
      "scenario": "Turn Include retired off while the facets request for the on setting is pending. If the older request finishes last, the list stays active-only but the filter panel shows counts that include retired concepts.",
      "action": "Give each search a request identifier shared by its list and facet requests. Discard responses for superseded searches and show counts only when they match the displayed results.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.2",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 544,
      "claim": "An applied facet retains its old positive count when switching off retired results removes its last match.",
      "scenario": "In a collection, apply the Drug class filter without a keyword when every matching drug is retired. Turn Include retired off. The list reports zero concepts and the API returns no Drug bucket, but the panel still shows the previous Drug count.",
      "action": "Keep the applied value available to remove, but show a count of zero when its bucket is absent from the new response. Treat a missing facet field as an empty bucket list.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.3",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/SearchInputDrawer.jsx",
      "line": 140,
      "claim": "Applying a Searchlight Class or Map Type filter drops the Include retired setting.",
      "scenario": "Turn Include retired on in global concept search, then apply Class=Drug through Searchlight. The new URL keeps the class filter and drops includeRetired=true, so retired drugs disappear from the results.",
      "action": "Carry the existing Include retired setting into Searchlight URLs for the same concept or mapping search while resetting pagination.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.4",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 185,
      "claim": "A legacy saved Retired filter can override the user's switch choice on reload.",
      "scenario": "Open a source whose only saved filter is retired=true,false. It opens with Include retired on. Turn the switch off and reload. The URL dropped the switch parameter because off is the source default, so the saved filter turns the switch back on.",
      "action": "Preserve enough URL state to distinguish an intentional return to the page default from a fresh visit that should apply the legacy saved filter.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.5",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 147,
      "claim": "Leaving Hierarchy can leave the table showing only hierarchy roots.",
      "scenario": "Open a source with Hierarchy as its saved display and retired=false as its only saved filter. Switch to Table. Converting that filter leaves the URL unchanged, so no list or facet request runs and the table keeps the hierarchy response.",
      "action": "When applying deferred defaults leaves the query string unchanged, fetch the page-one list and facets directly.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.6",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 502,
      "claim": "Returning from semantic match can leave the retired count missing.",
      "scenario": "On a source version, run a keyword search with Include retired on and a visible retired count. Run semantic match for the same keyword, let it finish, then go Back. The match response discarded the stored count, and returning to the same keyword skips the facet request that would restore it.",
      "action": "Refresh facets when leaving match mode so the restored results bar gets the retired count for that search.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.7",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/retiredSwitch.js",
      "line": 13,
      "claim": "A source named collections gets the collection default.",
      "scenario": "Open /orgs/MyOrg/sources/collections/HEAD/concepts/ without an override. The substring match turns Include retired on, so the source shows retired concepts by default.",
      "action": "Determine repository type from the route's repository-type segment.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.8",
      "severity": "P2",
      "tag": null,
      "file": "src/components/repos/__tests__/expansionCounts.test.js",
      "line": 32,
      "claim": "The new count-label test fails under locales that use a different grouping separator.",
      "scenario": "Run the expansion count tests with LC_ALL=de_DE.UTF-8. The implementation correctly formats the total as 8.765, but the test requires 8,765 and fails.",
      "action": "Build the expected interpolated value using the process locale, or use a fixture that does not require digit grouping.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Responses to pass 1 (fixes in 2f2743b)

  • F1.1 fixed: the list and the filter-count requests each keep only their latest answer (latestListRequest / latestFacetRequest); a stale list answer also never asks for its counts. Three quick clicks on the switch end with list and counts in agreement.
  • F1.2 fixed: an applied value missing from the new counts stays listed (so it can be taken off) with 0; a field missing from the new answer is treated as empty.
  • F1.3 fixed: Searchlight's filter URLs carry the current includeRetired (withIncludeRetiredFrom, tested).
  • F1.4 fixed: a saved Retired default filter now sets the switch's default for that repository, so the URL records any departure from it and a reload keeps the user's choice. (No repository on production has retired in its saved defaults today.)
  • F1.5 fixed with F1.4: saved defaults that held only a Retired filter leave no filters to write, so leaving Hierarchy fetches the list directly.
  • F1.6 fixed: Matched Candidates keeps the stored retired count, and its own answer is subject to the same latest-request check.
  • F1.7 fixed: only an owner's /collections/ path segment makes a page a collection (test added for a source named "collections").
  • F1.8 fixed: the test builds the expected number with the machine's own format.

… page change overtakes

From the second Codex pass on #110:
- when a page or page-size change replaces a list request that was to refresh
  the filter counts, the newer request refreshes them; a list answer keeps the
  latest counts rather than the ones from when it was sent;
- clearing the keyword in the search bar keeps includeRetired;
- coming back from Matched Candidates refreshes the filter counts;
- an includeRetired URL opens a saved Hierarchy display as a list, as filters do;
- the active-count stand-in for 10,000-result totals isn't extended to retired=false;
- the count label test formats both numbers the machine's way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVNufohRXPK1DHpx7i
@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 2 (codex-cli 0.169.0, commit 2f2743b)

Verdict: findings (6: 2 P1, 4 P2). Earlier: F1.1 regressed, F1.2 resolved, F1.3 resolved, F1.4 resolved, F1.5 resolved, F1.6 resolved, F1.7 resolved, F1.8 unresolved.

  • F2.1 (P1) src/components/search/Search.jsx:458: Changing the page size during a retirement refresh can leave the filter counts on the previous switch setting.
  • F2.2 (P1) src/components/search/SearchInput.jsx:159: Submitting an empty Searchlight query drops the Include retired override.
  • F2.3 (P2) src/components/search/Search.jsx:286: Leaving semantic match can carry facet counts from a different keyword into the regular results.
  • F2.4 (P2) src/components/search/Search.jsx:78: A saved Hierarchy display can prevent a shared URL from applying its retirement override.
  • F2.5 (P2) src/components/search/Search.jsx:468: The results bar can use the default expansion's count for a different expansion.
  • F2.6 (P2) src/components/repos/__tests__/expansionCounts.test.js:32: The count-label test still fails under locales that use non-Latin digits.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "2f2743be",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "regressed"
    },
    {
      "id": "F1.2",
      "status": "resolved"
    },
    {
      "id": "F1.3",
      "status": "resolved"
    },
    {
      "id": "F1.4",
      "status": "resolved"
    },
    {
      "id": "F1.5",
      "status": "resolved"
    },
    {
      "id": "F1.6",
      "status": "resolved"
    },
    {
      "id": "F1.7",
      "status": "resolved"
    },
    {
      "id": "F1.8",
      "status": "unresolved"
    }
  ],
  "findings": [
    {
      "id": "F2.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 458,
      "claim": "Changing the page size during a retirement refresh can leave the filter counts on the previous switch setting.",
      "scenario": "In an unfiltered concept listing with Include retired on, turn it off and change the page size before the list returns. The page-size request supersedes the switch request and skips facets, so the active-only rows retain counts that include retired concepts. If the switch request already started its facet fetch, the page-size response can still overwrite the new counts with its older snapshot.",
      "action": "Refresh facets independently of pagination when the search criteria change, and preserve the latest facet state when a list response arrives.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.2",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/SearchInput.jsx",
      "line": 159,
      "claim": "Submitting an empty Searchlight query drops the Include retired override.",
      "scenario": "Turn Include retired on in global concept search, clear the keyword in Searchlight, and press Enter. The resulting URL keeps only the resource type, so the unfiltered list hides retired concepts.",
      "action": "When clearing the keyword, preserve the current Include retired override on the same search page.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.3",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 286,
      "claim": "Leaving semantic match can carry facet counts from a different keyword into the regular results.",
      "scenario": "On a source version with Include retired on, run a regular search for malaria, run semantic match for insulin, then submit insulin as a regular search. The list updates to insulin, but the filter panel and retired count still describe malaria because leaving match mode suppresses the facet request.",
      "action": "On return to regular search, refresh facets unless the stored counts match the current keyword, filters, and retirement setting.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.4",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 78,
      "claim": "A saved Hierarchy display can prevent a shared URL from applying its retirement override.",
      "scenario": "Open a source whose saved display is Hierarchy, switch to Table, turn Include retired on, and reload. The URL still has includeRetired=true, but the page opens in Hierarchy, hides the switch, and sends onlyHierarchyRoot without the retirement setting.",
      "action": "Treat an explicit retirement override as a list filter when choosing the initial display, just as the code treats the filters parameter.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.5",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 468,
      "claim": "The results bar can use the default expansion's count for a different expansion.",
      "scenario": "A collection version's default expansion has 23,000 active concepts. Select an alternate expansion with exactly 10,000 active concepts and turn Include retired off. When the API reports 10,000, the results bar substitutes 23,000 from the collection version's summary.",
      "action": "Use a summary as a fallback only when it describes the exact expansion being queried.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.6",
      "severity": "P2",
      "tag": null,
      "file": "src/components/repos/__tests__/expansionCounts.test.js",
      "line": 32,
      "claim": "The count-label test still fails under locales that use non-Latin digits.",
      "scenario": "Run the expansion count tests with LC_ALL=ar_EG.UTF-8. The implementation formats the retired count as ٤٧٦, but the assertion still expects the literal 476.",
      "action": "Format both expected counts with toLocaleString().",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Responses to pass 2 (fixes in a065958)

  • F1.1 regressed / F2.1 fixed: a list request that should refresh the filter counts marks them due; if a page or page-size change replaces it before it answers, the newer request refreshes them. A list answer now keeps the latest counts (prev) instead of the ones from when it was sent. Checked in the browser with the switch's list answer held back 3 s and a page change sent meanwhile: the counts follow the switch.
  • F2.2 fixed: clearing the keyword in the search bar keeps includeRetired, as a keyword search already did.
  • F2.3 fixed: coming back from Matched Candidates refreshes the filter counts.
  • F2.4 fixed: an includeRetired in the URL opens a saved Hierarchy display as a list, as filters does.
  • F2.5 fixed by not extending it: the summary stand-in for 10,000-result totals is back to its original parameter list, so retired=false never uses it (the search index returns exact totals there).
  • F1.8 / F2.6 fixed: both numbers in the label test use the machine's number format.

…h; a new search drops counts on their way for the last

From the third Codex pass on #110:
- clearing the keyword keeps includeRetired on every search page, including
  /search/ with no type in the URL;
- a search that changes the filter counts drops a counts answer still on its
  way for the previous one, so active-only rows never show beside counts that
  include retired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVNufohRXPK1DHpx7i
@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 3 (codex-cli 0.169.0, commit a065958)

Verdict: findings (4: 1 P1, 3 P2). Earlier: F1.1 resolved, F1.2 resolved, F1.3 resolved, F1.4 resolved, F1.5 resolved, F1.6 resolved, F1.7 resolved, F1.8 resolved, F2.1 resolved, F2.2 unresolved, F2.3 resolved, F2.4 resolved, F2.5 resolved, F2.6 resolved.

  • F3.1 (P1) src/components/search/SearchInput.jsx:160: Clearing a concept keyword still drops the retirement override when the URL omits type.
  • F3.2 (P2) src/components/search/Search.jsx:544: Reloading a filtered URL can hide applied filters whose only matches are retired.
  • F3.3 (P2) src/components/search/Search.jsx:478: Newly loaded rows can appear alongside counts from the opposite switch setting.
  • F3.4 (P2) src/components/search/Search.jsx:746: A completed collection removal can reload results using a superseded retirement setting.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "a0659581",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "resolved"
    },
    {
      "id": "F1.2",
      "status": "resolved"
    },
    {
      "id": "F1.3",
      "status": "resolved"
    },
    {
      "id": "F1.4",
      "status": "resolved"
    },
    {
      "id": "F1.5",
      "status": "resolved"
    },
    {
      "id": "F1.6",
      "status": "resolved"
    },
    {
      "id": "F1.7",
      "status": "resolved"
    },
    {
      "id": "F1.8",
      "status": "resolved"
    },
    {
      "id": "F2.1",
      "status": "resolved"
    },
    {
      "id": "F2.2",
      "status": "unresolved"
    },
    {
      "id": "F2.3",
      "status": "resolved"
    },
    {
      "id": "F2.4",
      "status": "resolved"
    },
    {
      "id": "F2.5",
      "status": "resolved"
    },
    {
      "id": "F2.6",
      "status": "resolved"
    }
  ],
  "findings": [
    {
      "id": "F3.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/SearchInput.jsx",
      "line": 160,
      "claim": "Clearing a concept keyword still drops the retirement override when the URL omits type.",
      "scenario": "Search globally for malaria and turn Include retired on. The toolbar writes /search/?q=malaria&includeRetired=true. Clear the keyword in Searchlight and press Enter. The URL becomes /search/ and retired concepts disappear.",
      "action": "Preserve includeRetired on empty submissions even when the destination relies on the default concept type.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.2",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 544,
      "claim": "Reloading a filtered URL can hide applied filters whose only matches are retired.",
      "scenario": "In a collection, apply Datatype=Coded and Locale=en when every concept matching both filters is retired. Turn Include retired off and reload. The first facet response has no matching buckets, so the panel hides both selections and offers no way to remove just one.",
      "action": "Keep applied facet values visible with zero counts using the URL's selections, even when there are no earlier facet results.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.3",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 478,
      "claim": "Newly loaded rows can appear alongside counts from the opposite switch setting.",
      "scenario": "Turn Include retired off while the previous facet request is pending. If the old facets arrive before the active-only list, that list preserves the old counts. The active-only rows then appear alongside counts that still include retired concepts until the new facet request completes.",
      "action": "Invalidate facet responses when the retirement setting changes and withhold counts until they match the displayed results.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.4",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 746,
      "claim": "A completed collection removal can reload results using a superseded retirement setting.",
      "scenario": "On a collection HEAD, turn Include retired off and confirm a bulk removal. While the delete is pending, use browser Back to restore Include retired on. When the delete succeeds, its refresh sends retired=false. The checked switch then stays above active-only rows and counts until another search.",
      "action": "Refresh the current URL-derived search after removal instead of reusing the search state captured at confirmation.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Responses to pass 3 (fixes in a84ecad; this was the third and last defect pass)

  • F2.2 unresolved / F3.1 fixed: clearing the keyword keeps includeRetired on every search page, including /search/ with no type (checked in the browser: /search/?q=malaria&includeRetired=true → /search/?includeRetired=true).
  • F3.2 accepted (P2): a first load whose applied filters match nothing doesn't list those values; that's how the panel's first load already behaves for any filter set with no matches, and the clear button removes them. Not specific to the switch.
  • F3.3 fixed: a search that changes the counts also drops a counts answer still on its way for the previous one, so active-only rows never sit beside counts that include retired.
  • F3.4 accepted (P2): the refresh after a collection removal reuses the search captured when it was confirmed, as it already does for filters, page and sort; it needs Back pressed while the removal is pending. Not specific to the switch.

No P0 or P1 open. Commits after a065958 still need the final check of that range.

paynejd and others added 2 commits November 20, 2026 14:25
…ollections; label reads Include Retired

With the switch off, sources and global search now send no retired param:
the API already leaves retired ones out there, and a plain listing stays off
the search index, so paging past 10,000 results works as before. Collections
keep sending retired=false when off, and on is includeRetired=true everywhere.
In sources and global search the filter counts follow the list once the
oclapi2 change for this ticket makes facets use the default retired rule.

The switch reads "Include Retired", as the concept page's chip does; the other
locales already use their chip's wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVNufohRXPK1DHpx7i
…saved Retired defaults ignored

- The switch's default is isCollectionSearchURL itself (renamed from isCollectionURL, which
  versionsTab.styles.js also exports with a looser match).
- A saved Retired default filter no longer sets the switch: getRepoDefaultFilters already leaves
  it out, and no repository on production has one.
- hasRetiredSwitch compares the two resources directly; Number.isFinite replaces lodash isNumber.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVNufohRXPK1DHpx7i
@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Simplification review (Claude subagent, commit 21c130b). Responses; applied in 50e6355:

  • S1 getDefaultIncludeRetired alias: applied. Search.jsx uses isCollectionSearchURL directly, renamed so it doesn't share a name with the looser isCollectionURL in versionsTab.styles.js.
  • S2 SWITCH_RESOURCES array: applied. The local _hasRetiredSwitch stays, because it's used in four places in one function.
  • S3 build the i18n keys from a pattern: not applied. Spelled-out keys stay searchable.
  • S4 compute version counts once per row: not applied. They're cheap pure lookups, and restructuring the memoized summary isn't worth about 4 lines.
  • S5 saved Retired default sets the switch: applied. It's removed, and saved defaults never carry retired. No production repository has one, and Codex F1.4's precedence concern goes with it.
  • S6 overlapping tests: applied. The saved-defaults test is removed and the duplicate (true, true) request-param case dropped.
  • S7 lodash isNumber: applied. It's now Number.isFinite.

npm test 179 pass, 0 fail; ESLint clean.

…keep the 10,000-result paging cap

The API runs them on the search index with or without a keyword, so Last Page past 10,000
results returned 400 (also on main; a065958's retired=false had hidden it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVNufohRXPK1DHpx7i
@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits a065958..50e6355 (codex-cli 0.169.0, commit 50e6355)

Verdict: 1 P1, 1 P2.

  • FC.1 P1 src/components/search/Search.jsx:407: A keyword-free global search exposes pagination beyond the API's 10,000-result window.
  • FC.2 P2 src/components/search/Search.jsx:100: Upgrading discards an existing source's saved preference to include retired concepts.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "50e63553",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "FC.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 407,
      "claim": "A keyword-free global search exposes pagination beyond the API's 10,000-result window.",
      "scenario": "Open /search/ with Include Retired off and more than 10,000 active concepts, then click Last Page. Removing retired=false makes the UI treat the request as a database listing. Axios still sends q= and APIService sends INCLUDESEARCHLATEST, so the API uses Elasticsearch and rejects the page. At a0659581, the UI capped pagination and hid Last Page.",
      "action": "Keep the pagination cap for global concept and mapping requests that send q with INCLUDESEARCHLATEST, including when q is empty. Cover that request shape in a pagination test.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "FC.2",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 100,
      "claim": "Upgrading discards an existing source's saved preference to include retired concepts.",
      "scenario": "On a self-hosted instance, open a source whose saved concept filters contain retired: \"true,false\", with no URL override. At a0659581 the switch opened on and showed both active and retired concepts. Now it opens off and hides the retired concepts because the saved filter is discarded.",
      "action": "Restore the translation from a saved Retired filter to the switch default. Keep an explicit URL setting authoritative.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

Responses

  • FC.1 P1: fixed in 35ede39. Global concept and mapping searches now always count as search-index queries, so Last Page stays hidden past 10,000. Confirmed on production: keyword-free global /concepts/ reports 1,286,926 and its last page returns 400. That also happens on main today; a065958's retired=false had hidden it. No component-level test, because the repo's tests cover pure helpers only.
  • FC.2 P2: accepted. The switch replaces the Retired filter, and a saved Retired default now falls back to each context's documented default, with an explicit URL setting still winning. No repository on production has retired in its saved defaults; a self-hosted one would open with retired hidden in a source and could turn it on.

@paynejd

paynejd commented Nov 21, 2026 •

Copy link
Copy Markdown
Member Author

Independent review (Claude, with Codex second opinion)

Reviewed at 35ede39 against main (9ece1ba), with OpenConceptLab/oclapi2#1019 at 8ccc62c2 as its pair. I wrote my findings before reading this PR's earlier review threads. Codex (codex-cli 0.169.0, xhigh, read-only) then ran a blind defect pass and a second pass that tried to refute each of my findings. The findings on the pair, covering the contract, deploy order, the 10,000-result paging in collections and the zero-retired count, are in the review comment on OpenConceptLab/oclapi2#1019. The two PRs agree on the request contract.

Verdict: not ready to merge. Two items come first:

  • P1: the filter panel shows 0 for every other value of an applied filter.
  • P2: Matched Candidates can no longer include retired candidates.

Codex refuted none of my findings. Where we differ on severity is listed at the end.

P1

1. prepareFacets zeroes every other value of an applied filter field. src/components/search/Search.jsx:568

  • Example: on CIEL, apply Class = Drug. The API applies every filter to the facet search, so conceptClass comes back with Drug only.
  • Every other class (Diagnosis, Test, …) now reads 0. They stay clickable (no disabledZero), and adding one brings results back. main kept their earlier counts.
  • It hits every filter field on concept, mapping and repository searches, not just the switch.
  • It came in with the fix for Codex pass 1 F1.2. That fix's comment says "an applied value", but the code doesn't check whether the value is applied.
  • Fix: zero only values that are applied (appliedFacets[field]?.[value]). For the others, either keep main's earlier count or, as Codex prefers, show no count, since an earlier count goes stale once the keyword or another filter changes.
  • A test would pin it: prepareFacets can move into a helper like retiredSwitch.js and get a test there.
  • Codex: partly confirmed, P1. It confirmed the scenario; its objection is only to bringing stale counts back.

P2

2. Matched Candidates ($match) can no longer include retired candidates. src/components/search/Search.jsx:259, :320, :883

  • On main, getFacetQueryParam turned a Retired filter with both values into includeRetired=true on the $match request, and the filter panel stays usable in $match.
  • This PR removes the Retired filter from the URL state, doesn't add the switch's params in fetchMatchResults, and hides the switch in $match. A $match search now always leaves retired candidates out, and an old $match URL that selected both Retired values loses them.
  • The PR body says $match "sends no filters"; on main it does.
  • Fix: send includeRetired=true with $match when the switch is on, and show the switch there. Or decide $match is out of scope and say so on the ticket.
  • Codex: found by its blind pass (F1.5, P1); I confirmed it against main. I rate it P2 because retired candidates in $match are an uncommon need.

3 (pair). With the switch off, a collection can't page past 10,000 results. src/components/search/retiredSwitch.js:23. See item 8 in the oclapi2#1019 comment. With the API deployed first, includeRetired=false keeps the database path. Codex: confirmed (P2).

P3

  1. Repository searches keep the Retired filter in the panel (src/components/search/ResultConstants.js:141). The AC "The Retired filter leaves the filter panel" isn't limited to concepts and mappings. The reason given, that no repository on production is retired, is sound, but the scope call should be recorded on the ticket. Codex: confirmed as a scope question; its blind pass rated it P1 as an unmet AC.
  2. The filter panel can stay in its loading state after a failed list request (src/components/search/Search.jsx:534, :472).
    • fetchResults invalidates the pending facet answer, which then returns without calling setLoadingFacets(false), and the error branch never calls fetchFacets.
    • It's visible only when the panel is open with nothing to show.
    • Fix: clear facet loading in the error branch.
    • Codex: partly (P2).
  3. For a moment after the switch changes, the new rows sit beside the previous counts until the facet answer arrives. Codex's blind pass raised this as F1.6 and rated it P1. Every filter change in TBv3 already works this way, so I rate it P3. Dimming or clearing the counts while loadingFacets is set would close it.
  4. No retired results gives no count instead of "(0)" (pair, item 9 on oclapi2#1019).
  5. The tests cover the pure helpers only. prepareFacets, the request ordering (latestListRequest, latestFacetRequest, facetsDue) and the old-URL mapping in setQueryParamsInState have none. The repo has no component harness, but moving prepareFacets into a helper would make the test in item 1 possible, and that test would have caught it. Codex: confirmed.
  6. nit: getIncludeRetired reads only the literal 'true', so a hand-built includeRetired=1 or True reads as off, and in a collection that turns the switch off (src/components/search/retiredSwitch.js:54). Codex: confirmed.

Earlier acceptances I agree with.

  • FC.2: a saved Retired default falls back to the context's default. Codex's blind pass raised it again as F1.4; no production repository has one.
  • F3.2 and F3.4: both behaviours predate this PR.

Where Codex and I differ on severity:

Item Codex Me Why
2, $match P1 P2 retired candidates in $match are an uncommon need
4, repository filter P1 P3 scope call, not a code defect
6, counts during the switch change P1 P3 matches how every filter change already behaves
F1.1, TBv3 shipped first P1 P3 documented; nothing worse than today
F1.2, today's TBv3 after the API deploy P1 covered by deploying back to back see item 3 on oclapi2#1019
Codex blind defect pass on this PR (codex-cli 0.169.0, xhigh, commit 35ede39): 9 findings (F1.1 and F1.2 are pair findings on oclapi2#1019; F1.3 = 4, F1.4 = FC.2 accepted earlier, F1.5 = 2, F1.6 = 6, F1.7 = 3, F1.8 = 7, F1.9 = the facet cache, item 4 on oclapi2#1019)
  • F1.1 P1 src/components/search/retiredSwitch.js:23: Deploying TBv3 first or rolling back the API brings back the count mismatch the ticket fixes.
  • F1.2 P1 src/components/repos/ExpansionRowList.jsx:83: The stated API-first deployment makes the current TBv3 undercount collection and expansion members.
  • F1.3 P1 src/components/search/ResultConstants.js:141: Repository search keeps the Retired filter in the panel and has no results-bar switch.
  • F1.4 P1 src/components/search/Search.jsx:329: The migration silently discards saved repository defaults that include retired concepts.
  • F1.5 P1 src/components/search/Search.jsx:320: Matched Candidates loses the ability to include retired concepts.
  • F1.6 P1 src/components/search/Search.jsx:484: The switch publishes new results while the filter panel still shows selectable counts from the previous setting.
  • F1.7 P2 src/components/search/retiredSwitch.js:23: Turning the switch off limits unfiltered collection browsing to the first 10,000 active members.
  • F1.8 P2 src/components/search/retiredSwitch.js:62: The switch omits the count when a successful search has zero retired matches.
  • F1.9 P2 src/components/search/Search.jsx:533: A cached pre-deploy facet response can keep the old counts visible after the API-first rollout.
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "35ede39fed87f9d32e1ba7ba1d9600a49a6e6c19",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "F1.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/retiredSwitch.js",
      "line": 23,
      "claim": "Deploying TBv3 first or rolling back the API brings back the count mismatch the ticket fixes.",
      "scenario": "With the new TBv3 and the old API, the switch is off in CIEL v2026-10-23. The list excludes retired drugs, but the Class facet still includes them because the request sends no retired filter and the old API skips the default retired rule for facets. In a collection, switching off sends retired=false, which makes the old API omit the retired bucket, so the switch loses its count.",
      "action": "Gate the switch on an API capability or provide compatible facet and retired-count requests for the old API. Cover API rollback in the rollout check.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.2",
      "severity": "P1",
      "tag": null,
      "file": "src/components/repos/ExpansionRowList.jsx",
      "line": 83,
      "claim": "The stated API-first deployment makes the current TBv3 undercount collection and expansion members.",
      "scenario": "An expansion has 8,289 active concepts and 476 retired concepts. After the API deploy, a browser still running the current TBv3 bundle reads active_concepts as the total in both the expansion row and its collection version row. Those rows drop from 8,765 to 8,289 while the collection still contains 8,765 concepts.",
      "action": "Stage the expansion count change additively, or ship a compatible reader before changing the meaning of the existing fields.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.3",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/ResultConstants.js",
      "line": 141,
      "claim": "Repository search keeps the Retired filter in the panel and has no results-bar switch.",
      "scenario": "Open the global Repositories tab for a search with active and retired repositories. The panel still shows Retired, and the results bar offers neither the switch nor the retired repository count, even though the paired API returns the retired bucket.",
      "action": "Apply the URL-backed switch and facet-panel removal to repository searches as well.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.4",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 329,
      "claim": "The migration silently discards saved repository defaults that include retired concepts.",
      "scenario": "A source owner saved both Retired values as the default filter. Opening the source without query parameters previously included retired concepts for all visitors. The new code strips the saved Retired field and initializes the switch from the source default, so those concepts disappear until each visitor turns the switch on.",
      "action": "Use the saved setting when initializing or resetting the switch, give explicit URL settings precedence, and preserve the switch setting when saving defaults.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.5",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 320,
      "claim": "Matched Candidates loses the ability to include retired concepts.",
      "scenario": "Open an existing $match URL whose Retired filter selects both values. The base frontend converted that filter to includeRetired=true for the match request. The PR strips the filter, skips the new request parameters for $match, and hides the switch in Matched Candidates. The API then excludes retired candidates and the user cannot bring them back from that screen.",
      "action": "Pass the retired setting to $match and retain a way to change it in Matched Candidates.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.6",
      "severity": "P1",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 484,
      "claim": "The switch publishes new results while the filter panel still shows selectable counts from the previous setting.",
      "scenario": "Turn the switch off in a source while a class contains only retired concepts. The list completes before the facet request starts and replaces the rows while retaining the previous facets. During that request, the panel still offers the retired-only class with its old positive count, and applying it leads to an empty result set.",
      "action": "Clear or disable stale facets when the switch changes, or publish the new rows and facets together. Test with a delayed facet response.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.7",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/retiredSwitch.js",
      "line": 23,
      "claim": "Turning the switch off limits unfiltered collection browsing to the first 10,000 active members.",
      "scenario": "Open an expansion with 12,000 active concepts and no keyword or other filters. The default list can page through all members. Switching off sends retired=false, which forces Elasticsearch and stops pagination at its 10,000-result window.",
      "action": "Use includeRetired=false with the paired API so an otherwise unfiltered collection list keeps database pagination. Use the legacy facet filter only where compatibility requires it.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.8",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/retiredSwitch.js",
      "line": 62,
      "claim": "The switch omits the count when a successful search has zero retired matches.",
      "scenario": "Search for a term that matches active concepts only. The paired API returns a false bucket with no true bucket, as its integration test expects. The frontend renders Include Retired without a number. The frontend test reaches the zero display state only by supplying a true bucket with a zero count.",
      "action": "Represent zero explicitly in the API response or infer it after confirming the backend supports the new facet contract. Test the response shape the paired API actually returns.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.9",
      "severity": "P2",
      "tag": null,
      "file": "src/components/search/Search.jsx",
      "line": 533,
      "claim": "A cached pre-deploy facet response can keep the old counts visible after the API-first rollout.",
      "scenario": "A user opens the unfiltered first page of a source's latest version before deploy, warming the Redis facet cache. The new frontend sends the same switch-off facet query, and the paired API can serve the old cached payload for up to 24 hours without running its new retired rule.",
      "action": "Version or invalidate the affected source facet cache entries as part of the API rollout.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

This branch has not been deployed

No deployments
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.

Retired concepts and mappings: counts that agree, and one Include retired switch

1 participant