Repository navigation
OpenConceptLab/ocl_online#700 | The new-project form shows a line the API sends about the chosen owner's projects - #133
Conversation
… API sends about the chosen owner's projects Under Project Owner, while the project is new, the form asks the API for GET /capabilities/mapper.projects/note/?owner=<owner url>&lang=<language> and shows the `message` string it sends, again whenever the owner changes. With no such route, a failure or no string, nothing shows. The Mapper holds no wording or numbers of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTJedFKZzhLXoHiTaG
…field's own helper text, and shows only for the owner it was sent for - F1.1: NamespaceDropdown takes helperText, so the line is the field's description (aria-describedby) and its changes are announced politely. - F1.2: each line is kept with the capability, owner and language it was asked for, so a new owner never shows the last one's while its own is on the way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTJedFKZzhLXoHiTaG
…fore the line announces it, and asking again drops the kept line - F2.1: the form keeps a visually hidden status region mounted, so the line is announced when it arrives; the helper text stays the field's description. - F2.2: the hook's state is a reducer (capabilityNoteReducer): every ask drops the kept line, and only a reply to the latest ask is kept, so returning to an owner waits for a fresh reply and a failed one shows nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTJedFKZzhLXoHiTaG
…kept line in the render that brings it F3.1: useKeptCapabilityNote (capabilityNote.js) asks again during the render whose key changed, so no render shows a line kept for another owner, or for this one before it was asked again, whenever the effects run. The fetch stays in useCapabilityNote. A lifecycle test mounts the hook and switches owners away and back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTJedFKZzhLXoHiTaG
…y the line for the latest ask, and the tests don't repeat each other Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTJedFKZzhLXoHiTaG
…n an effect, so a queued reply to it is never dropped FC.1: asking during render was a render-phase update, which React leaves out of the state it replays queued updates from; a reply to the new owner could then be dropped and its line never show. The ask goes back to an effect (as in 628e241), and pass 3's F3.1, one render that can still show the same owner's line from just before, is accepted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTJedFKZzhLXoHiTaG
Codex review, pass 1 (codex-cli 0.169.0, commit 559124f)Verdict: findings: 1 P1, 1 P2
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "full",
"commit": "559124f2cd41ce0dad69bbf71a5d4006717aa506",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "F1.1",
"severity": "P1",
"tag": null,
"file": "src/components/map-projects/ConfigurationForm.jsx",
"line": 171,
"claim": "The Project Owner field does not expose its count as accessible helper text.",
"scenario": "A screen reader user selects an organization and tabs to Name. The count arrives as a standalone paragraph without a live announcement. Returning focus to Project Owner also omits the count from the field description.",
"action": "Pass the note through NamespaceDropdown to the underlying TextField as helper text and announce asynchronous updates politely.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.2",
"severity": "P2",
"tag": null,
"file": "src/components/common/useCapabilityNote.js",
"line": 33,
"claim": "Changing the owner can briefly show the previous owner's count under the new selection.",
"scenario": "After the personal count loads, select an organization whose request is still pending. React commits the organization selection with the personal count still present. The effect clears the count in a later render, so the wrong count can flash even when the organization has no note.",
"action": "Store the request inputs with each result and return a note only when they match the current enabled request. Add an integration test that checks the first committed render after an owner change.",
"lines_delta": null,
"confidence": "high"
}
]
} |
|
Pass 1 answered in 60edfed:
|
Codex review, pass 2 (codex-cli 0.169.0, commit 60edfed)Verdict: findings: 1 P1, 1 P2
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "60edfed7bf6d6fd91d78dd2e197aef2ff93bf672",
"verdict": "findings",
"prior": [
{"id": "F1.1", "status": "unresolved"},
{"id": "F1.2", "status": "regressed"}
],
"findings": [
{
"id": "F2.1",
"severity": "P1",
"tag": null,
"file": "src/components/common/NamespaceDropdown.jsx",
"line": 90,
"claim": "The count is associated with the Owner field, but its live region is created with the count already inside it.",
"scenario": "A user selects an organization and the field blurs. When the API reply arrives, NVDA with Firefox does not announce the newly inserted count. The user can hear the description by refocusing the field. [Screen reader test results](https://patrickhlauke.github.io/aria/tests/live-regions/results.html)",
"action": "Mount an empty polite live region before the reply arrives and update its text on success. Preserve the field's accessible description.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.2",
"severity": "P2",
"tag": null,
"file": "src/components/common/useCapabilityNote.js",
"line": 28,
"claim": "Returning to an owner can restore a previous count and leave it visible after the new request fails.",
"scenario": "The personal count loads. The user selects an organization, then switches back before the organization replies. The old personal count reappears immediately and stays visible if the new personal request times out, violating the requirement to show nothing on failure.",
"action": "Invalidate the stored note when the selection changes so a return to the same owner waits for a fresh response. Add a regression test for a failed request after switching back.",
"lines_delta": null,
"confidence": "high"
}
]
} |
|
Pass 2 answered in 628e241:
|
Codex review, pass 3 (codex-cli 0.169.0, commit 628e241)Verdict: findings: 1 P2
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "628e24116ad2d99b8fd3a2e78fc1efd8e6ac00c7",
"verdict": "findings",
"prior": [
{"id": "F1.1", "status": "resolved"},
{"id": "F1.2", "status": "resolved"},
{"id": "F2.1", "status": "resolved"},
{"id": "F2.2", "status": "unresolved"}
],
"findings": [
{
"id": "F3.1",
"severity": "P2",
"tag": null,
"file": "src/components/common/useCapabilityNote.js",
"line": 21,
"claim": "Rapidly switching back to an owner can briefly restore its stale count before the fresh request completes.",
"scenario": "With the personal count visible, select an organization and switch back before React processes the reset queued by the effect. A React reproduction with the actual dropdown showed the old personal count reappearing in both the field description and the live region. The fresh request failed and the next render cleared the count.",
"action": "Invalidate the previous note during rendering when the request key changes. Add a React lifecycle test that switches away and back before the effect's state update is processed and verifies that the old note never reappears.",
"lines_delta": null,
"confidence": "high"
}
]
} |
|
Pass 3 answered in 72e4c25. No P0 or P1 open after three passes; the simplification review and a Codex check of the commits after 628e241 come next.
Later: the render-time ask was reverted in 4c81ade (see the Codex check below), and F3.1 accepted. |
Simplification review (fresh Claude subagent, commit 72e4c25)Verdict: 3 cuts, all applied in e3ed616 (674 unit + 12 integration tests pass, ESLint clean):
simplify.json{"reviewer":"claude subagent","perspective":"simplify","mode":"full","commit":"72e4c25","verdict":"findings","prior":[],"findings":[{"id":"S1","severity":null,"tag":"dup-test","file":"src/components/common/__integration__/capabilityNote.test.js","line":49,"claim":"The second integration test ('nothing while there is nothing to ask about') repeats the last unit test in __tests__/capabilityNote.test.js ('nothing to ask about while disabled or with no owner'), which already covers a null key dropping kept lines and stray replies at the reducer level. The render-level behaviour adds nothing the F3.1 test does not already pin.","action":"Delete the second integration test; keep only the switch-away-and-back test, which pins the P2 fix.","lines_delta":-11,"confidence":"medium","scenario":null},{"id":"S2","severity":null,"tag":"dup-test","file":"src/components/common/__tests__/capabilityNote.test.js","line":38,"claim":"The 'new owner never shows the last one's line' unit test rebuilds the same run([...asked, ask PERSONAL, reply ORG]) twice and re-checks the stale-reply and switch-back scenario that the integration test now exercises through the real hook (including the dropped late ORG reply).","action":"Compute the state once (const late = run([...])) and drop the final duplicate assertion, or trim the test to the first ORG-after-PERSONAL assertion and leave the switch-back to the integration test.","lines_delta":-4,"confidence":"medium"},{"id":"S3","severity":null,"tag":"shrink","file":"src/components/common/capabilityNote.js","line":38,"claim":"getKeptCapabilityNote re-checks `key &&` and `state.kept.key === key`, but the reducer only stores a reply when key === state.asked and every 'ask' clears kept, and the hook already guards with `state.asked === key`. So kept.key always equals asked and the key comparison is redundant; the exported helper has one caller.","action":"Drop the helper and return `state.asked === key ? state.kept?.note ?? null : null` from useKeptCapabilityNote (adjust the unit tests to use the reducer state or the hook).","lines_delta":-4,"confidence":"low"}]} |
Codex check of commits 628e241..e3ed616 (codex-cli 0.169.0)Verdict: findings: 1 P2
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "e3ed616",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "FC.1",
"severity": "P2",
"tag": null,
"file": "src/components/common/capabilityNote.js",
"line": 43,
"claim": "React can discard the selected owner's successful reply when it replays a pending update.",
"scenario": "Owner A's reply queues an update. The user selects owner B before React processes that update, and B's reply arrives before React drains the queue. React replays both replies against the reducer state for A because the render-time reset to B was not saved for replay. The reducer drops B's reply, so the field stays blank and the status region never announces it. A React 18 check using the request hook reproduced the failure at e3ed616 and showed B's note at 628e241.",
"action": "Track the current request identity separately from queued replies and display only a reply with that identity. Add a lifecycle test that queues A's reply, switches owners with a click, and resolves B's reply before React drains the queue.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Codex check of commits e3ed616..4c81ade (codex-cli 0.169.0)Verdict: clean, no findings
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "4c81ade",
"verdict": "clean",
"prior": [
{"id": "FC.1", "status": "resolved"},
{"id": "F3.1", "status": "unresolved"}
],
"findings": []
} |
Codex check of commits 628e241..e3ed616, and of e3ed616..4c81ade
No P0 or P1 open. One P2 accepted (F3.1, above). |
snyaggarwal
left a comment
There was a problem hiding this comment.
One P2 remains from the earlier review (F3.1). I reproduced the stale note on React 18 at the current head and verified that resetting in a layout effect clears it in the same reproduction. The field description and the mounted status region address the earlier accessibility findings. The public Mapper renders the API-provided message as text and falls back to silence when the route is unavailable.
Verification passed for 674 unit tests, 12 integration tests, and ESLint.
| // when it replays queued ones, and then a reply to the new key would be lost. | ||
| export const useKeptCapabilityNote = key => { | ||
| const [state, dispatch] = React.useReducer(capabilityNoteReducer, {asked: null, note: null}) | ||
| React.useEffect(() => { |
There was a problem hiding this comment.
[P2] Clear the previous note before a quick switch back can reuse it. After A’s note loads, two closely scheduled selection updates from A to B and back to A can commit A’s old note before the fresh request resolves. React can process the second selection before applying the reset queued by the passive effect, so state.asked === key accepts the old note and puts it back into the helper text and status region. I reproduced the committed DOM sequence with two synthetic clicks on React 18. Moving the reducer reset to useLayoutEffect cleared the stale commit in the reproduction and keeps the reset dispatch outside render. Please add a regression test that observes commits before the queued reset is processed, since the two act-wrapped rerenders in the existing test drain the queue between selections.
There was a problem hiding this comment.
Fixed in c07aa9e with your layout-effect reset. useKeptCapabilityNote now asks in useLayoutEffect. React gives an update made in a layout effect the sync lane and processes it at the end of that commit. So once owner B commits, the ask for B is in the state before a second click can render, and a switch back to A finds asked set to B and shows nothing until A's fresh reply arrives.
I kept your fix rather than look for another. The render that switches back needs something written when B committed, and the only place to write it then is a layout effect, whether as this ask or as a ref. A render-phase ask can lose a reply (the earlier FC.1). The request itself stays in the passive effect.
Regression test: a quick switch away and back commits the earlier line in no render in src/components/common/__integration__/capabilityNote.test.js. Inside one act(), it commits each choice with ReactDOM.flushSync, the way a click commits. That leaves the passive effect's ask queued at default priority, which the act scope doesn't run until it ends. The test reads the DOM after each commit. At 4c81ade the second commit shows the old line (['', 'Personal line.']), and at c07aa9e both commits are empty. ESLint, 674 unit tests and 13 integration tests pass locally.
…fect, so a quick switch back never shows the earlier line A passive effect's ask can wait behind a quick switch back to the earlier owner: the switch back commits first and shows the line kept for that owner before its fresh reply. An ask from a layout effect is done as the new owner commits. The new test commits two choices before lower-priority work runs, as two quick clicks do, and fails without this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTBs6TBvnyRdYLAfWG
Codex review, pass 1 (codex-cli 0.169.0, commit c07aa9e)A new round on c07aa9e, the fix for the maintainer's F3.1 (layout-effect ask and a regression test that commits two choices before the queued work runs). The review covered the whole diff from Verdict: clean. No findings. findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "full",
"commit": "c07aa9e",
"verdict": "clean",
"prior": [],
"findings": []
}Simplification review (fresh Claude subagent, commit c07aa9e): clean, nothing to cut. No commits after the reviewed one, so no further check. |
snyaggarwal
left a comment
There was a problem hiding this comment.
F3.1 is resolved at c07aa9e. The layout effect clears the previous note as the owner changes. My React 18 click reproduction now stays blank after switching away and back, and the new regression test fails with the previous implementation and passes with the fix. The integration tests also verify that a late reply from the other owner is discarded and the fresh reply is shown.
No remaining findings. All 674 unit tests, 13 integration tests, and ESLint passed.
snyaggarwal
left a comment
There was a problem hiding this comment.
Approving at c07aa9e. This stays on the open side of the line: the form shows only a non-empty string the API sends, holds no wording or numbers of its own, and shows nothing on a 404, a failure or without a token. So an OCL without the private route works as before.
The details hold:
- the reply is kept only for the latest ask (the reducer and the layout effect), so a late reply for another owner never shows;
- axios is called directly, so a 404 or 401 skips
APIService's sign-out and throttling handling; - the line is the owner field's helper text (
aria-describedby), and a visually hidden status region announces it when it arrives; - the note is asked for only while the project is new.
I haven't run it. CI is green.
The API half, OpenConceptLab/ocl_online_api#80, needs changes before it merges (a conflict with main, and staff and unlimited members' counts after #72). This PR doesn't depend on that: until the route is served, the form shows nothing, so the two can ship in either order.
Partial work on OpenConceptLab/ocl_online#700.
What changes. While a map project is new, the configuration form asks the API for a line about the projects the chosen owner has, and shows it under the Project Owner field:
GET {API_URL}/capabilities/mapper.projects/note/?owner=<owner url>&lang=<language>returns{"message": "<text>"}or{"message": null}. The form asks again whenever the owner changes.messagestring it's sent. With no such route (a 404), a failure, no token or no string, nothing shows. It holds no wording or numbers of its own.aria-describedby), and a visually hiddenrole="status"region announces it when it arrives.Files.
src/components/common/capabilityNote.js: builds the request, accepts only a non-empty string, and keeps the line for the latest ask (capabilityNoteReducer,useKeptCapabilityNote), so a new owner never shows the last one's line and a late reply for another owner is dropped.src/components/common/useCapabilityNote.js: the hook. It uses axios directly, notAPIService, so a 404 or 401 skips its sign-out and throttling handling.NamespaceDropdown.jsxtakeshelperText;ConfigurationForm.jsxpasses the line and mounts the status region.Tests. Unit (
__tests__/capabilityNote.test.js): the request, what's accepted, the key, and the reducer through owner switches and a failed reply. Integration (__integration__/capabilityNote.test.js): the hook mounted, switching away and back../node_modules/eslint/bin/eslint.js src --ext .jsx,.js: clean.npm run test:all: 674 unit and 12 integration tests pass.aria-describedby="owner-helper-text", the status region, and nothing on a 404.Review. Codex, three passes, and checks of the later commits: posted below.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qTJedFKZzhLXoHiTaG