Skip to content

Minor changes #809

Merged
ypriverol merged 14 commits intomasterfrom
dev
Mar 11, 2026
Merged

Minor changes #809
ypriverol merged 14 commits intomasterfrom
dev

Conversation

@ypriverol
Copy link
Member

@ypriverol ypriverol commented Mar 9, 2026

Summary by CodeRabbit

  • New Features

    • Improved SDRF Builder column management: explicitly remove/re-add recommended columns and see them moved to optional or included lists.
    • Editor/download flow now passes actual TSV content so editor opens with current data and downloads produce TSV.
  • Chores

    • Removed "Dev Version" navigation links across site pages.
    • Adjusted version-link injection for dev builds.
    • Updated SDRF dataset ordering and canonicalized some entries.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

Caution

Review failed

The head commit changed during the review from c9ca04c to c652716.

📝 Walkthrough

Walkthrough

The PR refactors the version-link injection in the build script, removes Dev Version navigation links from multiple static pages, adds removed-column state and TSV export flow to the SDRF builder, and updates site SDRF data with reordered entries and a new timestamp.

Changes

Cohort / File(s) Summary
Header Injection Refactoring
scripts/inject-headers.py
Renamed rewrite_version_linksinject_version_link_into_static; docstring updated. In dev builds, injects a "Stable Version" link if missing (placed before GitHub link); no-op for non-dev builds. Main flow now calls the new function; log messages adjusted.
SDRF Builder Logic & Export
site/js/sdrf-builder.js
Added state.removedColumns to track user-removed recommended columns. Column-resolution and picker logic updated to treat removed recommended columns as optional and to clear removed state when re-added. Editor/download actions now build headers+values into TSV and pass TSV via content (base64 for editor) or direct TSV for download.
Navigation Link Cleanup
site/quickstart.html, site/sdrf-builder.html, site/sdrf-explorer.html, site/sdrf-terms.html
Removed the Dev Version navigation link from the header/navigation in four static pages.
SDRF Data Reorganization
site/sdrf-data.json
Updated generated_at timestamp and reordered many array entries (organisms, diseases, instruments, etc.) across SDRF records; no schema additions or removals, primarily element reordering.

Sequence Diagram(s)

(omitted — changes are multiple but do not introduce a new multi-component sequential feature warranting a sequence diagram)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 I hopped through headers, tidy and spry,
I nudged version links where they’d lie,
I nudged columns out, then let them back in,
I shuffled the data with a mischievous grin,
Cheers — a rabbit’s wink for the new build win!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Minor changes' is vague and generic, failing to describe the specific nature of the changeset which includes function renaming, state management updates, UI element removal, and data reorganization. Revise the title to specifically describe the main changes, such as 'Refactor version link injection and update SDRF builder state management' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (1)
site/js/sdrf-builder.js (1)

855-870: ⚠️ Potential issue | 🟠 Major

Prune factor selections when the backing characteristic is removed.

This handler removes the column from the picker state, but it never clears state.factorValues. If the removed column was selected as a factor, resolveColumns() still emits factor value[...] without the matching characteristics[...] column, so the generated SDRF becomes inconsistent.

Suggested fix
         if (!isHardLocked) {
             var colName = col.name;
             item.addEventListener('click', function () {
+                var factorIdx = state.factorValues.indexOf(colName);
+                if (factorIdx !== -1) {
+                    state.factorValues.splice(factorIdx, 1);
+                }
+
                 if (isExtra) {
                     // Remove from extra
                     var idx = state.extraColumns.indexOf(colName);
                     if (idx !== -1) state.extraColumns.splice(idx, 1);
                 } else if (col.requirement === 'recommended') {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@site/js/sdrf-builder.js` around lines 855 - 870, When removing a column
inside the click handler (the block that mutates state.extraColumns,
state.removedColumns, or state.addedOptionals), also remove any factor
selections that reference that column from state.factorValues so
resolveColumns() won't emit factor value[...] without a matching
characteristics[...] entry; locate the handler around the
item.addEventListener('click', ...) and after splicing the column out, delete or
filter out entries in state.factorValues keyed by or containing colName (or
remove colName from any arrays stored there), then call updatePreview() as is so
the preview/resolution is consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/inject-headers.py`:
- Around line 41-46: The Stable Version link is hard-coded to "/" which breaks
docs served from subpaths; replace that literal with a computed stable target
derived from the deployment base or page depth (e.g., compute a relative base
like "../" repeated page_depth or use an existing deployment_base variable if
present) and use that value when building version_link instead of "/". Update
the block that sets version_link (refer to is_dev, VERSION_LINK_PLACEHOLDER,
header_html, resolved_header) to compute stable_target = computed_base + maybe
"index.html" or root of the docs site and then set version_link = f'<a
href="{stable_target}" class="version-link">Stable Version</a>'; apply the same
change to the analogous footer/footer injection code around lines 71-76 so both
injections derive the stable URL the same way.

In `@site/sdrf-data.json`:
- Around line 358-359: The organism labels in the serialized JSON are not
canonicalized, causing duplicates like "mus musculus"/"Mus musculus" to appear;
normalize organism names before writing sdrf-data.json by converting them to a
consistent canonical form (e.g., Title Case "Mus musculus" or a chosen lowercase
canonical form) at the place where the organisms list is assembled (the code
path that populates statistics.organisms / the array that currently contains
"mus musculus" and "homo sapiens"); update the normalization logic to apply to
all occurrences (including the entries around the shown rows and the other
reported ranges 2057-2058 and 3955-3957) so serialization only emits the
canonical label.
- Around line 1871-1875: The disease labels in the generator are not normalized,
causing duplicate keys in statistics.diseases (e.g., "Mlignant Melanoma",
"squamous  cell carcinoma", "'Crohn''s Disease'"); update the code that
emits/aggregates the disease field (the part that populates statistics.diseases)
to normalize labels by trimming whitespace, collapsing multiple spaces to one,
un-escaping doubled single quotes, and applying small canonicalization fixes
(e.g., "Mlignant" -> "Malignant") or a short mapping table for common typos;
ensure the normalization runs before using the string as the key so "Breast
Cancer" and "Breast   Cancer" or variants map to the same canonical bucket.

---

Outside diff comments:
In `@site/js/sdrf-builder.js`:
- Around line 855-870: When removing a column inside the click handler (the
block that mutates state.extraColumns, state.removedColumns, or
state.addedOptionals), also remove any factor selections that reference that
column from state.factorValues so resolveColumns() won't emit factor value[...]
without a matching characteristics[...] entry; locate the handler around the
item.addEventListener('click', ...) and after splicing the column out, delete or
filter out entries in state.factorValues keyed by or containing colName (or
remove colName from any arrays stored there), then call updatePreview() as is so
the preview/resolution is consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d821bb71-f2d5-49b9-8eae-0118f3a48dbd

📥 Commits

Reviewing files that changed from the base of the PR and between 918933e and c6dfaa8.

⛔ Files ignored due to path filters (1)
  • psi-document/sdrf-proteomics-specification-v1.1.0-dev.pdf is excluded by !**/*.pdf
📒 Files selected for processing (7)
  • scripts/inject-headers.py
  • site/js/sdrf-builder.js
  • site/quickstart.html
  • site/sdrf-builder.html
  • site/sdrf-data.json
  • site/sdrf-explorer.html
  • site/sdrf-terms.html
💤 Files with no reviewable changes (4)
  • site/sdrf-terms.html
  • site/quickstart.html
  • site/sdrf-explorer.html
  • site/sdrf-builder.html

Comment on lines +41 to 46
# Resolve version link: only show in dev builds (link back to stable)
if is_dev:
version_link = '<a href="/" class="version-link">Stable Version</a>'
else:
version_link = '<a href="/dev/" class="version-link">Dev Version</a>'
version_link = ''
resolved_header = header_html.replace(VERSION_LINK_PLACEHOLDER, version_link)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid hard-coding the Stable Version link to "/".

Every other nav URL in this script is relative, but these two injections jump to the domain root. That breaks the version switch when the docs are served from a project subpath or opened from a generated local build. Please derive the stable target from the deployment base/page depth instead of baking in "/".

Also applies to: 71-76

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

In `@scripts/inject-headers.py` around lines 41 - 46, The Stable Version link is
hard-coded to "/" which breaks docs served from subpaths; replace that literal
with a computed stable target derived from the deployment base or page depth
(e.g., compute a relative base like "../" repeated page_depth or use an existing
deployment_base variable if present) and use that value when building
version_link instead of "/". Update the block that sets version_link (refer to
is_dev, VERSION_LINK_PLACEHOLDER, header_html, resolved_header) to compute
stable_target = computed_base + maybe "index.html" or root of the docs site and
then set version_link = f'<a href="{stable_target}" class="version-link">Stable
Version</a>'; apply the same change to the analogous footer/footer injection
code around lines 71-76 so both injections derive the stable URL the same way.

Comment on lines +358 to +359
"mus musculus",
"homo sapiens"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Canonicalize organism labels before serializing.

These touched rows still mix mus musculus/homo sapiens with Mus musculus/Homo sapiens. statistics.organisms already shows the fallout in Lines 7-10, where the same species is split across multiple exact-string buckets.

Also applies to: 2057-2058, 3955-3957

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

In `@site/sdrf-data.json` around lines 358 - 359, The organism labels in the
serialized JSON are not canonicalized, causing duplicates like "mus
musculus"/"Mus musculus" to appear; normalize organism names before writing
sdrf-data.json by converting them to a consistent canonical form (e.g., Title
Case "Mus musculus" or a chosen lowercase canonical form) at the place where the
organisms list is assembled (the code path that populates statistics.organisms /
the array that currently contains "mus musculus" and "homo sapiens"); update the
normalization logic to apply to all occurrences (including the entries around
the shown rows and the other reported ranges 2057-2058 and 3955-3957) so
serialization only emits the canonical label.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
site/js/sdrf-builder.js (1)

917-926: Replace deprecated unescape() and address URL length limits.

The current implementation has two concerns:

  1. Deprecated function: unescape() is deprecated and should be avoided.
  2. URL length limits: Base64 encoding adds ~33% overhead. Templates with 30+ columns will likely exceed browser URL limits (2,000–8,000 characters), potentially breaking the editor link.

Consider using sessionStorage for larger payloads:

♻️ Alternative using sessionStorage
 function openInEditor() {
     var columns = resolveColumns();
     if (!columns.length) return;

     var headers = [];
     var values = [];
     for (var i = 0; i < columns.length; i++) {
         headers.push(columns[i].name);
         values.push(columns[i].example_value || '');
     }

     var tsv = headers.join('\t') + '\n' + values.join('\t') + '\n';
-    var encoded = btoa(unescape(encodeURIComponent(tsv)));
-    window.open('sdrf-editor.html?content=' + encodeURIComponent(encoded));
+    var storageKey = 'sdrf-builder-content-' + Date.now();
+    try {
+        sessionStorage.setItem(storageKey, tsv);
+        window.open('sdrf-editor.html?storageKey=' + encodeURIComponent(storageKey));
+    } catch (e) {
+        var encoded = btoa(unescape(encodeURIComponent(tsv)));
+        window.open('sdrf-editor.html?content=' + encodeURIComponent(encoded));
+    }
 }

Note: The editor will need to check for and handle the storageKey parameter in addition to the current content parameter.

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

In `@site/js/sdrf-builder.js` around lines 917 - 926, Replace the deprecated
unescape-based base64 encoding and avoid long URLs by encoding TSV safely and
falling back to sessionStorage: build headers/values and tsv as before, then
create a safe base64 string for tsv using a TextEncoder + a base64 encoder
(replace the unescape(encodeURIComponent(...)) pattern used when creating
encoded), check the encoded length and if it exceeds a chosen threshold (e.g.,
~2000 chars) write the raw TSV or base64 to sessionStorage under a generated key
(storageKey) and call window.open('sdrf-editor.html?storageKey=' + storageKey),
otherwise call window.open('sdrf-editor.html?content=' +
encodeURIComponent(encoded)); update the editor to accept storageKey (it will
read sessionStorage[storageKey]) and keep references to the existing
variables/functionality: columns, headers, values, tsv, encoded, and the
window.open call so the change is localized.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@site/js/sdrf-builder.js`:
- Around line 917-926: Replace the deprecated unescape-based base64 encoding and
avoid long URLs by encoding TSV safely and falling back to sessionStorage: build
headers/values and tsv as before, then create a safe base64 string for tsv using
a TextEncoder + a base64 encoder (replace the unescape(encodeURIComponent(...))
pattern used when creating encoded), check the encoded length and if it exceeds
a chosen threshold (e.g., ~2000 chars) write the raw TSV or base64 to
sessionStorage under a generated key (storageKey) and call
window.open('sdrf-editor.html?storageKey=' + storageKey), otherwise call
window.open('sdrf-editor.html?content=' + encodeURIComponent(encoded)); update
the editor to accept storageKey (it will read sessionStorage[storageKey]) and
keep references to the existing variables/functionality: columns, headers,
values, tsv, encoded, and the window.open call so the change is localized.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07bfb38e-0ff3-466c-9f9e-f9ace268a501

📥 Commits

Reviewing files that changed from the base of the PR and between c6dfaa8 and 5241654.

⛔ Files ignored due to path filters (1)
  • psi-document/sdrf-proteomics-specification-v1.1.0-dev.pdf is excluded by !**/*.pdf
📒 Files selected for processing (1)
  • site/js/sdrf-builder.js

@ypriverol ypriverol merged commit 73c9b55 into master Mar 11, 2026
1 check passed
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