Skip to content

feat(trees): sort Chronostrat tree by period instead of name, add ranges#8254

Merged
CarolineDenis merged 37 commits into
mainfrom
issue-6049
Jul 8, 2026
Merged

feat(trees): sort Chronostrat tree by period instead of name, add ranges#8254
CarolineDenis merged 37 commits into
mainfrom
issue-6049

Conversation

@grantfitzsimmons

@grantfitzsimmons grantfitzsimmons commented Jul 3, 2026

Copy link
Copy Markdown
Member

Fixes #6049

This PR hardcodes the Chronostratigraphy (GeologicTimePeriod) tree to always sort nodes by startPeriod, independent of the user's orderByField preference under User Preferences → Tree Editor → Behavior. This a pretty big QoL update for paleo and geo users.

Currently, the orderByField preference controls sorting for all tree types. However, Chronostratigraphy should be using chronological ordering by startPeriod, which should take precedence over user-configurable sort fields.

OrderChronostratByPeriod

This also adds a new Show start and end periods toggle preference has been added under User Preferences → Tree Editor → Chronostratigraphy (enabled by default). When enabled, each node displays its geologic time range in ICS format: (298.9 ± 0.15 – 251.902 ± 0.024). Trailing zeros are trimmed. Hovering over the range shows a tooltip with full details using schema field labels.

image image Screenshot 2026-07-03 at 5 59 52 PM

Testing instructions

Compare against the Chronostrat chart: https://stratigraphy.org/ICSchart/ChronostratChart2026-06.pdf

  • Open the Chronostratigraphy tree
  • Expand nodes at various levels and verify that children are ordered by startPeriod (ascending geologic time).
  • Verify the displayed time ranges match the chart (e.g., Campanian (83.6 ± 0.2 – 72.2 ± 0.2)).
  • Hover over a time range and verify the tooltip shows the schema field labels with values.
  • Toggle the Show start and end periods preference off and verify the ranges disappear.
  • Change the Tree Editor → Behavior → Sort by field preference to different values (name, fullName, rankId, nodeNumber).
  • Verify that the Chronostrat tree is unaffected by this preference change since it always sorts by startPeriod.
  • Open a different tree (Taxon, Storage, Geography, etc.) and verify the orderByField preference still works correctly there

Summary by CodeRabbit

  • Bug Fixes
    • Improved geologic time tree row loading to preserve server-provided ordering for geologic time periods.
    • Refreshed tree row fetching URLs and results for geologic time period display options.
  • New Features
    • Added biostratification filtering for geologic time periods (all/bio/chrono) with updated visibility and emphasis in the tree.
    • Added optional display of start/end periods with richer tooltips.
  • Preferences
    • Introduced a “Show start and end periods” preference for geologic time period rows.
  • Localization
    • Added localized tooltip and preference text, and corrected “BioStratigraphy” → “Biostratigraphy” capitalization.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes add GeologicTimePeriod start/end period data and biostrat filtering through the backend tree API, frontend tree rendering, and search controls. A new preference and localization strings control chrono-period display, and QueryComboBox adds BioStrat-specific filtering plus text normalization.

Changes

GeologicTimePeriod tree view

Layer / File(s) Summary
Backend period fields and tests
specifyweb/backend/trees/views.py, specifyweb/backend/trees/tests/test_trees.py
tree_view forwards GeologicTimePeriod-specific period and biostrat query flags into get_tree_rows, and get_tree_rows conditionally projects start/end period fields and descendant counts. The tree view test call sites are updated for the new function signature.
TreeView row payload and request flow
specifyweb/frontend/js_src/lib/components/TreeView/helpers.ts, specifyweb/frontend/js_src/lib/components/TreeView/index.tsx, specifyweb/frontend/js_src/lib/utils/cache/definitions.ts
fetchRows maps the extra period and biostrat fields into row objects, and TreeView reads user preferences, tracks biostratFilter, updates row fetching URLs, and passes the filter into Tree and TreeViewSearch.
Tree row chrono and biostrat rendering
specifyweb/frontend/js_src/lib/components/TreeView/Row.tsx, specifyweb/frontend/js_src/lib/components/TreeView/Tree.tsx, specifyweb/frontend/js_src/lib/components/TreeView/Search.tsx, specifyweb/frontend/js_src/lib/components/TreeView/__tests__/biostratFilter.test.ts
TreeRow adds the biostratFilter prop, skips client-side sorting for GeologicTimePeriod, reads the chrono-period preference, filters and dims GeologicTimePeriod rows by biostrat state, renders chrono-period labels, and passes the filter to child rows. Tree and TreeViewSearch thread the filter through, and the new test suite covers search filtering behavior.
Preference and tree text strings
specifyweb/frontend/js_src/lib/components/Preferences/UserDefinitions.tsx, specifyweb/frontend/js_src/lib/localization/preferences.ts, specifyweb/frontend/js_src/lib/localization/tree.ts
displayChronoPeriods is added to user preference definitions and localization, and tree localization gains chrono-period tooltip text and unit text.

BioStrat query combo filtering

Layer / File(s) Summary
BioStrat condition plumbing
specifyweb/frontend/js_src/lib/components/QueryComboBox/helpers.ts, specifyweb/frontend/js_src/lib/components/QueryComboBox/index.tsx, specifyweb/frontend/js_src/lib/components/QueryComboBox/__tests__/biostratConditions.test.ts
getQueryComboBoxConditions accepts typeSearchName, QueryComboBox passes that name through, and the helper emits an isBioStrat condition for GeologicTimePeriod BioStrat searches. The new tests cover the accepted and rejected cases, and the filter mapper handles isBioStrat.
Biostratigraphy text updates
config/common/schema_localization_en.json, specifyweb/frontend/js_src/lib/tests/ajax/static/context/schema_localization.json/lang=en.json, specifyweb/specify/fixtures/empty_db.json
The schema localization fixture and export data change the displayed wording from BioStratigraphy to Biostratigraphy.

Compact metadata

  • Related issues: #6049 — Add support for sorting by time period in the Chronostrat tree
  • Suggested labels: frontend, backend, tree-view, localization
  • Suggested reviewers: CarolineDenis, acwhite211
🚥 Pre-merge checks | ✅ 3 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Biostrat filtering, search, query, and preference changes appear unrelated to #6049's Chronostrat sorting/range scope. Move the biostrat-related UI, query, and test changes to a separate PR unless they are required for #6049.
Automatic Tests ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Testing Instructions ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main Chronostrat tree sorting and range-display change.
Linked Issues check ✅ Passed The Chronostrat tree now sorts by startPeriod, which satisfies #6049's time-based ordering requirement.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-6049

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
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
specifyweb/frontend/js_src/lib/components/TreeView/index.tsx (1)

158-174: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Update stale comment to reflect the new conditional sort logic.

The comment still says name is unconditionally hard-coded, but the code below now branches to startPeriod for GeologicTimePeriod. Worth a quick update so future readers aren't misled.

🤖 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 `@specifyweb/frontend/js_src/lib/components/TreeView/index.tsx` around lines
158 - 174, The comment in TreeView index.tsx is stale and still describes the
sort field as always hard-coded to name, but the nearby sorting logic now
conditionally uses startPeriod for GeologicTimePeriod. Update the comment around
the tree row fetch/sort handling to match the actual behavior in the relevant
TreeView code path, and keep the reference to userPreferences.get if you mention
the preference fallback so future readers aren’t misled.
🤖 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.

Nitpick comments:
In `@specifyweb/frontend/js_src/lib/components/TreeView/index.tsx`:
- Around line 158-174: The comment in TreeView index.tsx is stale and still
describes the sort field as always hard-coded to name, but the nearby sorting
logic now conditionally uses startPeriod for GeologicTimePeriod. Update the
comment around the tree row fetch/sort handling to match the actual behavior in
the relevant TreeView code path, and keep the reference to userPreferences.get
if you mention the preference fallback so future readers aren’t misled.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 39f17028-fb57-49b5-ad16-7236ba31ad2e

📥 Commits

Reviewing files that changed from the base of the PR and between f3d4fec and f6cd2cf.

📒 Files selected for processing (2)
  • specifyweb/frontend/js_src/lib/components/TreeView/Row.tsx
  • specifyweb/frontend/js_src/lib/components/TreeView/index.tsx

@grantfitzsimmons grantfitzsimmons changed the title feat(trees): sort Chronostrat tree by period instead of name feat(trees): sort Chronostrat tree by period instead of name, add ranges Jul 3, 2026
Triggered by 0c5d1b4 on branch refs/heads/issue-6049

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@specifyweb/backend/trees/views.py`:
- Line 168: The query flag handling in the tree view is treating a present
string value as truthy, so the `include_start_end_periods` path in
`trees/views.py` is enabled even when the request sends `"false"`. Update the
`include_start_end_periods` assignment in the view logic to explicitly parse the
GET parameter value into a real boolean before combining it with the `tree ==
'geologictimeperiod'` check, using the same pattern as other request-flag
handling in this view so `fetchRows` can actually disable the option.

In `@specifyweb/frontend/js_src/lib/components/TreeView/Row.tsx`:
- Around line 289-348: The visible label in Row’s GeologicTimePeriod rendering
always prints the range separator even when `row.endPeriod` is missing, causing
malformed text like a dangling dash. Update the JSX in `Row.tsx` so the span
content branches the same way as the `title` logic: use the range format only
when `typeof row.endPeriod === 'string'`, otherwise render a single-period label
with no separator or empty end value. Keep the `trimDecimal`,
`treeText.geologicTimePeriodRange`, and `treeText.geologicTimePeriodSingle`
usage aligned with that check.
🪄 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: 91121783-ea90-4997-8e25-a8a70222d748

📥 Commits

Reviewing files that changed from the base of the PR and between f6cd2cf and 0c5d1b4.

📒 Files selected for processing (7)
  • specifyweb/backend/trees/views.py
  • specifyweb/frontend/js_src/lib/components/Preferences/UserDefinitions.tsx
  • specifyweb/frontend/js_src/lib/components/TreeView/Row.tsx
  • specifyweb/frontend/js_src/lib/components/TreeView/helpers.ts
  • specifyweb/frontend/js_src/lib/components/TreeView/index.tsx
  • specifyweb/frontend/js_src/lib/localization/preferences.ts
  • specifyweb/frontend/js_src/lib/localization/tree.ts
✅ Files skipped from review due to trivial changes (2)
  • specifyweb/frontend/js_src/lib/localization/tree.ts
  • specifyweb/frontend/js_src/lib/localization/preferences.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • specifyweb/frontend/js_src/lib/components/TreeView/index.tsx

Comment thread specifyweb/backend/trees/views.py
Comment thread specifyweb/frontend/js_src/lib/components/TreeView/Row.tsx
@github-project-automation github-project-automation Bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Jul 3, 2026
@grantfitzsimmons grantfitzsimmons marked this pull request as draft July 3, 2026 22:23
@grantfitzsimmons grantfitzsimmons requested a review from emenslin July 3, 2026 23:00
@grantfitzsimmons grantfitzsimmons marked this pull request as ready for review July 4, 2026 00:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
specifyweb/backend/trees/tests/test_trees.py (1)

340-403: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

LGTM on signature update, but consider testing the new flag's actual effect.

Both get_tree_rows calls correctly add the new include_start_end_periods positional argument to match the updated signature in views.py. However, both calls pass False, so there's no test coverage confirming that start_period/end_period/etc. are actually populated (vs. "NULL") when the flag is True for a GeologicTimePeriod tree — which is the actual feature this PR introduces.

Consider adding a test case using a GeologicTimePeriod tree with include_start_end_periods=True to verify the projected columns contain real values.

🤖 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 `@specifyweb/backend/trees/tests/test_trees.py` around lines 340 - 403, The
updated get_tree_rows signature is covered, but the new
include_start_end_periods behavior is not verified because both existing calls
pass False. Add a test in test_trees using a GeologicTimePeriod tree and call
get_tree_rows with include_start_end_periods=True, then assert the returned rows
populate start_period/end_period and related fields with real values instead of
"NULL". Use the existing get_tree_rows helper and the tree setup patterns in
this test module to locate the new case.
🤖 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.

Nitpick comments:
In `@specifyweb/backend/trees/tests/test_trees.py`:
- Around line 340-403: The updated get_tree_rows signature is covered, but the
new include_start_end_periods behavior is not verified because both existing
calls pass False. Add a test in test_trees using a GeologicTimePeriod tree and
call get_tree_rows with include_start_end_periods=True, then assert the returned
rows populate start_period/end_period and related fields with real values
instead of "NULL". Use the existing get_tree_rows helper and the tree setup
patterns in this test module to locate the new case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e6bb22da-ad2a-457b-a410-4c6746d5f887

📥 Commits

Reviewing files that changed from the base of the PR and between 32b81ac and 137f7a5.

📒 Files selected for processing (3)
  • specifyweb/backend/trees/tests/test_trees.py
  • specifyweb/frontend/js_src/lib/components/TreeView/Row.tsx
  • specifyweb/frontend/js_src/lib/localization/tree.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • specifyweb/frontend/js_src/lib/components/TreeView/Row.tsx

@emenslin emenslin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Open the Chronostratigraphy tree
  • Expand nodes at various levels and verify that children are ordered by startPeriod (ascending geologic time).
  • Verify the displayed time ranges match the chart (e.g., Campanian (83.6 ± 0.2 – 72.2 ± 0.2)).
  • Hover over a time range and verify the tooltip shows the schema field labels with values.
  • Toggle the Show start and end periods preference off and verify the ranges disappear.
  • Change the Tree Editor → Behavior → Sort by field preference to different values (name, fullName, rankId, nodeNumber).
  • Verify that the Chronostrat tree is unaffected by this preference change since it always sorts by startPeriod.
  • Open a different tree (Taxon, Storage, Geography, etc.) and verify the orderByField preference still works correctly there

Looks good, I didn't run into any issues!

@emenslin emenslin requested a review from a team July 6, 2026 17:50
feat(trees): add biostrat filter to chronostrat
@grantfitzsimmons

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

(let's see how this goes)

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

(let's see how this goes)

Resolved. I merged origin/main into this branch and fixed the conflict in specifyweb/backend/trees/views.py in commit f87e791.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
specifyweb/backend/trees/views.py (1)

155-186: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Sort-by-period guarantee for GeologicTimePeriod is enforced only on the client.

The fix for #6049 (always sort chrono tree by startPeriod) is implemented solely by the frontend passing sortfield='startPeriod' in the URL (see TreeView/index.tsx). get_tree_rows/tree_view still blindly trust the sortfield query parameter for every tree, including geologictimeperiod. Any other API consumer (or a future frontend regression) could pass sortfield=name and silently reintroduce the original bug. Consider forcing sortfield to 'startPeriod' server-side whenever tree == 'geologictimeperiod', so the ordering guarantee doesn't depend on client cooperation.

🤖 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 `@specifyweb/backend/trees/views.py` around lines 155 - 186, The sort-order fix
for geologictimeperiod is only enforced by the client, while
tree_view/get_tree_rows still accept any sortfield from the request. Update
tree_view (or get_tree_rows) to override sortfield to startPeriod whenever tree
is geologictimeperiod, so the ordering guarantee cannot be bypassed by other
callers. Keep the change localized around tree_view, get_tree_rows, and the
orderby lookup.
♻️ Duplicate comments (1)
specifyweb/backend/trees/views.py (1)

167-169: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Truthiness bug still present: includestartendperiods param is always truthy.

request.GET.get('includestartendperiods', False) returns the raw string when present, so "false" (or any non-empty string) is still truthy. This means include_start_end_periods is effectively always True for tree == 'geologictimeperiod', defeating the point of toggling displayChronoPeriods off — this was already flagged on a prior commit and remains unfixed.

🐛 Proposed fix
-    include_start_end_periods = request.GET.get('includestartendperiods', False) and tree == 'geologictimeperiod'
+    include_start_end_periods = request.GET.get('includestartendperiods', 'false').lower() == 'true' and tree == 'geologictimeperiod'
🤖 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 `@specifyweb/backend/trees/views.py` around lines 167 - 169,
`include_start_end_periods` in `trees.views` is still using the raw
`request.GET.get('includestartendperiods', False)` value, so any non-empty
string like "false" evaluates truthy. Update the parsing in the view logic
around `include_author` and `include_start_end_periods` to explicitly interpret
the query param as a boolean (for example, by checking for an allowed true
value) before combining it with `tree == 'geologictimeperiod'`. This should be
fixed in the same request-handling block where `biostrat` is read.
🧹 Nitpick comments (2)
specifyweb/frontend/js_src/lib/components/TreeView/__tests__/biostratFilter.test.ts (1)

14-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test duplicates logic instead of exercising the real implementation.

filterBio/filterChrono/filterAll are reimplemented locally rather than imported from Search.tsx, so this test provides no protection against the actual filter logic regressing. Consider extracting the predicate into a small exported helper used by both Search.tsx and this test.

🤖 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
`@specifyweb/frontend/js_src/lib/components/TreeView/__tests__/biostratFilter.test.ts`
around lines 14 - 20, The biostrat filter test is duplicating predicate logic
locally instead of validating the real implementation. Extract the filter
predicate(s) from Search.tsx into a small exported helper and use that helper in
both Search.tsx and biostratFilter.test.ts so the test exercises the actual
shared logic. Update the test to import the helper instead of defining
filterBio, filterChrono, and filterAll inline.
specifyweb/frontend/js_src/lib/components/QueryComboBox/index.tsx (1)

595-609: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Hardcoded '1' discards the condition's actual startValue.

Every sibling branch in this mapper (rankId, nodeNumber, collectionRelTypeId, taxonTreeDefId/definitionId) forwards the real startValue from the serialized condition. This new branch instead hardcodes value: '1', silently ignoring whatever helpers.ts actually computed ('true'). It works today only because helpers.ts never emits anything else for isBioStrat, but the coupling is implicit and would break silently if that ever changes.

♻️ Suggested fix: reuse startValue for consistency
                                           : fieldName === 'isBioStrat'
                                             ? {
                                                 field: 'isBioStrat',
                                                 isRelationship: false,
                                                 operation: 'in',
                                                 isNot: false,
-                                                value: '1',
+                                                value: startValue === 'true' ? '1' : '0',
                                               }

Also worth confirming the backend/extraFilters consumer actually expects '1'/'0' (vs 'true'/'false') for boolean in filters, since that contract lives outside this file.

🤖 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 `@specifyweb/frontend/js_src/lib/components/QueryComboBox/index.tsx` around
lines 595 - 609, The isBioStrat branch in QueryComboBox’s extended filter mapper
is hardcoding a value instead of using the serialized condition’s startValue.
Update the isBioStrat case to follow the same pattern as the sibling branches
(rankId, nodeNumber, collectionRelTypeId, taxonTreeDefId/definitionId) by
forwarding startValue into the returned filter object, and verify the
extraFilters/backend contract for boolean in values while keeping the mapping
consistent in the QueryComboBox logic.
🤖 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 `@specifyweb/frontend/js_src/lib/components/TreeView/index.tsx`:
- Around line 429-436: The new biostrat filter Select in TreeView is missing the
same accessibility attributes used by the other Select controls. Update the
Select component in TreeView to include a descriptive aria-label and title,
matching the pattern used by the existing Select around the other filter
controls, so screen readers can identify it consistently.

---

Outside diff comments:
In `@specifyweb/backend/trees/views.py`:
- Around line 155-186: The sort-order fix for geologictimeperiod is only
enforced by the client, while tree_view/get_tree_rows still accept any sortfield
from the request. Update tree_view (or get_tree_rows) to override sortfield to
startPeriod whenever tree is geologictimeperiod, so the ordering guarantee
cannot be bypassed by other callers. Keep the change localized around tree_view,
get_tree_rows, and the orderby lookup.

---

Duplicate comments:
In `@specifyweb/backend/trees/views.py`:
- Around line 167-169: `include_start_end_periods` in `trees.views` is still
using the raw `request.GET.get('includestartendperiods', False)` value, so any
non-empty string like "false" evaluates truthy. Update the parsing in the view
logic around `include_author` and `include_start_end_periods` to explicitly
interpret the query param as a boolean (for example, by checking for an allowed
true value) before combining it with `tree == 'geologictimeperiod'`. This should
be fixed in the same request-handling block where `biostrat` is read.

---

Nitpick comments:
In `@specifyweb/frontend/js_src/lib/components/QueryComboBox/index.tsx`:
- Around line 595-609: The isBioStrat branch in QueryComboBox’s extended filter
mapper is hardcoding a value instead of using the serialized condition’s
startValue. Update the isBioStrat case to follow the same pattern as the sibling
branches (rankId, nodeNumber, collectionRelTypeId, taxonTreeDefId/definitionId)
by forwarding startValue into the returned filter object, and verify the
extraFilters/backend contract for boolean in values while keeping the mapping
consistent in the QueryComboBox logic.

In
`@specifyweb/frontend/js_src/lib/components/TreeView/__tests__/biostratFilter.test.ts`:
- Around line 14-20: The biostrat filter test is duplicating predicate logic
locally instead of validating the real implementation. Extract the filter
predicate(s) from Search.tsx into a small exported helper and use that helper in
both Search.tsx and biostratFilter.test.ts so the test exercises the actual
shared logic. Update the test to import the helper instead of defining
filterBio, filterChrono, and filterAll inline.
🪄 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: 6bb85ccc-f91c-45ea-a2f4-6ee7bec57ee3

📥 Commits

Reviewing files that changed from the base of the PR and between 137f7a5 and 2552c74.

📒 Files selected for processing (17)
  • config/common/schema_localization_en.json
  • specifyweb/backend/context/data/schemalocalization.json
  • specifyweb/backend/trees/tests/test_trees.py
  • specifyweb/backend/trees/views.py
  • specifyweb/frontend/js_src/lib/components/QueryComboBox/__tests__/biostratConditions.test.ts
  • specifyweb/frontend/js_src/lib/components/QueryComboBox/helpers.ts
  • specifyweb/frontend/js_src/lib/components/QueryComboBox/index.tsx
  • specifyweb/frontend/js_src/lib/components/TreeView/Row.tsx
  • specifyweb/frontend/js_src/lib/components/TreeView/Search.tsx
  • specifyweb/frontend/js_src/lib/components/TreeView/Tree.tsx
  • specifyweb/frontend/js_src/lib/components/TreeView/__tests__/biostratFilter.test.ts
  • specifyweb/frontend/js_src/lib/components/TreeView/helpers.ts
  • specifyweb/frontend/js_src/lib/components/TreeView/index.tsx
  • specifyweb/frontend/js_src/lib/localization/tree.ts
  • specifyweb/frontend/js_src/lib/tests/ajax/static/context/schema_localization.json/lang=en.json
  • specifyweb/frontend/js_src/lib/utils/cache/definitions.ts
  • specifyweb/specify/fixtures/empty_db.json
✅ Files skipped from review due to trivial changes (3)
  • specifyweb/specify/fixtures/empty_db.json
  • specifyweb/frontend/js_src/lib/tests/ajax/static/context/schema_localization.json/lang=en.json
  • config/common/schema_localization_en.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • specifyweb/frontend/js_src/lib/localization/tree.ts
  • specifyweb/frontend/js_src/lib/components/TreeView/Row.tsx
  • specifyweb/frontend/js_src/lib/components/TreeView/helpers.ts

Comment thread specifyweb/frontend/js_src/lib/components/TreeView/index.tsx
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Comment thread specifyweb/backend/trees/views.py Fixed
Comment thread specifyweb/backend/trees/views.py Fixed

@g1rly-c0d3r g1rly-c0d3r left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Open the Chronostratigraphy tree
  • Expand nodes at various levels and verify that children are ordered by startPeriod (ascending geologic time).
  • Verify the displayed time ranges match the chart (e.g., Campanian (83.6 ± 0.2 – 72.2 ± 0.2)).
  • Hover over a time range and verify the tooltip shows the schema field labels with values.
  • Toggle the Show start and end periods preference off and verify the ranges disappear.
  • Change the Tree Editor → Behavior → Sort by field preference to different values (name, fullName, rankId, nodeNumber).
  • Verify that the Chronostrat tree is unaffected by this preference change since it always sorts by startPeriod.
  • Open a different tree (Taxon, Storage, Geography, etc.) and verify the orderByField preference still works correctly there

All good! Timestamps appear correctly.

@rijulpoudel

rijulpoudel commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator
  • Open the Chronostratigraphy tree
  • Expand nodes at various levels and verify that children are ordered by startPeriod (ascending geologic time).
  • Verify the displayed time ranges match the chart (e.g., Campanian (83.6 ± 0.2 – 72.2 ± 0.2)).
  • Hover over a time range and verify the tooltip shows the schema field labels with values.
  • Toggle the Show start and end periods preference off and verify the ranges disappear.
  • Change the Tree Editor → Behavior → Sort by field preference to different values (name, fullName, rankId, nodeNumber).
  • Verify that the Chronostrat tree is unaffected by this preference change since it always sorts by startPeriod.
  • Open a different tree (Taxon, Storage, Geography, etc.) and verify the orderByField preference still works correctly there

Updated: Everything looks good. Didn't run into any issues!

@rijulpoudel rijulpoudel self-requested a review July 7, 2026 17:51
grantfitzsimmons and others added 5 commits July 7, 2026 13:58
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…None'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@CarolineDenis CarolineDenis merged commit 98bf324 into main Jul 8, 2026
18 checks passed
@CarolineDenis CarolineDenis deleted the issue-6049 branch July 8, 2026 10:57
@github-project-automation github-project-automation Bot moved this from Dev Attention Needed to ✅Done in General Tester Board Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅Done

Development

Successfully merging this pull request may close these issues.

Add support for sorting by time period in the Chronostrat tree

7 participants