Skip to content

OpenConceptLab/ocl_online#870 | The bridge can be chosen as soon as it has loaded, and runs only for a user who is offered it - #149

Open
paynejd wants to merge 2 commits into
mainfrom
OpenConceptLab/ocl_online#870-bridge-offered
Open

paynejd wants to merge 2 commits into
mainfrom
OpenConceptLab/ocl_online#870-bridge-offered

Conversation

@paynejd

@paynejd paynejd commented Dec 3, 2026

Copy link
Copy Markdown
Member

Two small fixes to the bridge algorithm, for OpenConceptLab/ocl_online#870.

Choosing it on a new project. After picking a target repository, the bridge stayed greyed out in the list of algorithms until another field was changed. The form asked the bridge component whether it can run only once, before the component had loaded, and nothing made it ask again. The answer is now kept in state, so the list updates as soon as the component has loaded.

A bridge saved in a project. Projects keep the algorithms they were set up with, and people share projects. A saved bridge now loads only if the list of algorithms the server offers this user still has it. Otherwise it doesn't run: AutoMatch says that the project's algorithms aren't available, as it does already for other algorithms a user can't run, and a row refreshed by hand skips it. The project's settings keep it.

How to check

  1. Start a new project, upload a file and pick a target that the bridge maps to. Open Advanced settings and the list of algorithms: the bridge can be chosen straight away. On main it's greyed out until you change, say, the name.
  2. Open a project with a saved bridge, as somebody who is offered it: AutoMatch lists it and runs it.
  3. Open the same project as somebody who isn't: AutoMatch doesn't run it, and neither does Refresh Candidates on a row.

I did all three in a browser against a local API, with the match answers mocked. 833 tests pass, 2 of them new, and ESLint is clean.

No words, screens or API calls change. If the list of offered algorithms can't be read, a saved bridge doesn't run until the page is loaded again.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qTEw8c6qZh5C69F1V4

…t has loaded, and a saved one runs only for a user who is still offered it

On a new project the bridge stayed greyed out until another field changed, because its answer was read once, before it had loaded.

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

paynejd commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.171.0, commit 9b25816)

5 findings: 2 P1, 3 P2. None of them is new with this change, so the code stays as it is.

  • F1.1 (P1), a manual refresh drops saved bridge results when the bridge can't run: the same on main. A refresh clears the row first and then asks each algorithm again, and a bridge that can't run (a target it doesn't map to, for one) already loses its results that way. Keeping each algorithm's results until its own refresh succeeds would be a change to every algorithm's refresh, so not here.
  • F1.2 (P1), ScispaCy goes with the bridge: the same on main, where ScispaCy runs only if the bridge can. On a project without a saved bridge it already needs one to be offered. Untying the two is its own change.
  • F1.3 (P2), two saved bridges: accepted. A project can hold one, and on main both would use the same component too.
  • F1.4 (P2), a bridge on the second page of the list: accepted. The list is one page in full, and choosing an algorithm on a new project reads the same page.
  • F1.5 (P2), no React test of the late answer: accepted. This repository has no tests that render components. I checked it in a browser, on this branch and on main: the bridge is greyed out on main until another field changes, and can be chosen straight away here.
findings.json
{
 "reviewer": "codex-cli 0.171.0",
 "perspective": "defects",
 "mode": "full",
 "commit": "9b25816",
 "verdict": "findings",
 "prior": [],
 "findings": [
  {
   "id": "F1.1",
   "severity": "P1",
   "tag": null,
   "file": "src/components/map-projects/MapProject.jsx",
   "line": 3836,
   "claim": "Manual refresh can permanently erase saved bridge candidates when the bridge is skipped.",
   "scenario": "An editor opens a row with saved bridge candidates and clicks Refresh while the algorithm list is still loading, or after the bridge has stopped being offered. Refresh deletes the entire row's candidate state before discovering that the bridge cannot run. The next project save persists the row without its bridge results.",
   "action": "Keep each algorithm's stored results until its refresh succeeds. Preserve bridge results when availability is pending or the bridge is skipped.",
   "lines_delta": null,
   "confidence": "high"
  },
  {
   "id": "F1.2",
   "severity": "P1",
   "tag": null,
   "file": "src/components/map-projects/MapProject.jsx",
   "line": 806,
   "claim": "The saved bridge permission check also disables separately authorized ScispaCy matching.",
   "scenario": "A LOINC project has both CIEL Bridge and ScispaCy saved. The user has the ScispaCy capability and the deployment has ScispaCy enabled, but the server no longer offers that project's bridge. The bridge component never mounts, so `canScispacy` stays false and AutoMatch omits ScispaCy even though it ran before.",
   "action": "Separate ScispaCy's target compatibility and entitlement checks from permission to execute the saved bridge.",
   "lines_delta": null,
   "confidence": "high"
  },
  {
   "id": "F1.3",
   "severity": "P2",
   "tag": null,
   "file": "src/components/map-projects/MapProject.jsx",
   "line": 857,
   "claim": "Checking the first saved bridge lets a second, unoffered bridge entry trigger a duplicate match.",
   "scenario": "A project stores bridge IDs A and B in that order, the server offers only A, and A maps to the target. AutoMatch treats both entries as runnable and manual refresh visits both. Both dispatches use A's mounted handle, sending two one-row `$match` requests when only A is authorized.",
   "action": "Check the ID of each bridge at dispatch and use a handle bound to that ID. Apply the same eligibility check to AutoMatch selection, quota estimates, and manual refresh.",
   "lines_delta": null,
   "confidence": "high"
  },
  {
   "id": "F1.4",
   "severity": "P2",
   "tag": null,
   "file": "src/components/map-projects/MapProject.jsx",
   "line": 870,
   "claim": "A bridge offered on a later page is treated as unavailable.",
   "scenario": "The server offers the user more than 25 algorithms and the project's saved bridge appears on page two. The successful list request supplies only page one's `results` to the permission check, so both AutoMatch and manual refresh skip the authorized bridge.",
   "action": "Follow the algorithm list's pagination or verify the saved bridge through its authenticated detail endpoint.",
   "lines_delta": null,
   "confidence": "high"
  },
  {
   "id": "F1.5",
   "severity": "P2",
   "tag": null,
   "file": "src/components/map-projects/__tests__/autoMatchRows.test.js",
   "line": 415,
   "claim": "The new-project readiness fix lacks the React lifecycle test called for by the repository's integration test conventions.",
   "scenario": "With a compatible target selected, the lazy bridge resolves after the configuration has rendered. Reverting to a plain ref would leave the picker disabled until another edit, while both new helper tests would still pass.",
   "action": "Add an integration test that resolves a deferred bridge with the runtime component's imperative-ref behavior and verifies that the picker enables without another user action.",
   "lines_delta": null,
   "confidence": "high"
  }
 ]
}

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

paynejd commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Simplification review (a fresh Claude subagent, commit 9b25816): two cuts, both made in dae0926.

  • A comment that said the same as the function's own: gone.
  • The function that picks the bridge: an early return in place of a nested condition.

Codex check of commits 9b25816..dae0926 (codex-cli 0.171.0): no findings. 833 tests pass and ESLint is clean.

@paynejd
paynejd marked this pull request as ready for review December 3, 2026 09:01
@paynejd
paynejd requested a review from snyaggarwal December 3, 2026 09:01

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

Approve. Merge order: merge this and release it to production before OpenConceptLab/react-bridge-match#7 is published. Merging the two in either order is fine, but the bridge file goes live everywhere the moment it's uploaded, while this needs a release. If the file goes first, a saved bridge runs for people the server doesn't offer it to, until this is deployed.

Checked

  • "Offered" is the runtime answer from /match-algorithms/ on the OCL Online API. Nothing here works out who gets it. In a build without OCL_ONLINE_API_URL the list stays empty, so a saved bridge doesn't load. Such a build has no BRIDGE_MATCH_URL either, and the stub already answers canBridge() === false, so nothing changes for the open product.
  • The ref callback: BridgeMatch and BridgeMatchStub both call useImperativeHandle without deps. So the callback runs on every commit of the child (null, then the new handle), and canBridge follows prop changes such as the mapped sources arriving. Setting the same value bails out, so there's no render loop. The deps-less effect runs after layout, so it clears canBridge only when the child has really gone (unmounted, or still suspended in the lazy loader).
  • getBridgeToLoad matches on id only, so a core user's edited Bridge Source URL keeps working, as the test says.
  • CI is green.

Notes, not blocking

  1. A saved bridge now waits for /match-algorithms/ before the mapped-sources probe starts. On opening a project, the bridge becomes usable one request later than on main. The AutoMatch dialog reads canBridge from state now, so it picks the bridge up when it's ready. Not running it when the list can't be read is the right call.
  2. user={user} (inline): keep it until react-bridge-match#7 is published, then it can go.

Codex F1.1 to F1.5 are already raised and answered in Jon's comment, so I'm not raising them again.

@@ -6602,7 +6613,7 @@ const MapProject = () => {
bridgeRepoVersion={bridgeProbeAlgo?.target_repo_version}
limit={CANDIDATES_LIMIT}
user={user}

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.

Keep this until OpenConceptLab/react-bridge-match#7 is published: the live file still reads user. After that, nothing reads it and it can be dropped.

@snyaggarwal

Copy link
Copy Markdown
Contributor

Merge-ready only after Jonathan has reviewed it too, as the ticket asks: "@snyaggarwal and Jonathan review it themselves" (https://github.com/OpenConceptLab/ocl_online/issues/870#issuecomment-7373066624).

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.

2 participants