Repository navigation
OpenConceptLab/ocl_online#786 | Proposal edits and column-mapping changes are seen as unsaved - #140
Conversation
…save; Configure's snapshot compares each column's label, target source and cleared mapping Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| assert.deepEqual(saved, [[PROPOSAL_CHANGE]]) | ||
| }) | ||
|
|
||
| test('editProposed: keeps a copy, not the editor\'s object', () => { |
There was a problem hiding this comment.
Nit (optional): This test only checks a top-level field. editProposed copies one level, and Propose's _onChange (Propose.jsx:44) writes attribute edits into the existing attribute objects, which proposed[rowIndex].attributes shares, so the previous state is changed in place. Fix: have Propose copy the edited attribute (newAttributes[i] = {...newAttributes[i], [type]: value}) and cover attributes here.
There was a problem hiding this comment.
Fixed: Propose copies the edited attribute, which also stops a throw when typing into a newly added attribute row. The test is renamed to what it covers.
…ribute instead of changing the one the saved proposal holds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
snyaggarwal
left a comment
There was a problem hiding this comment.
Verdict: ready to merge. Nothing blocking. The notes below are optional.
This meets the acceptance criteria of OpenConceptLab/ocl_online#786:
- Proposal edits. Editing a proposal's fields schedules an autosave (
proposal_change). Leaving before it runs is caught by the save on leave and thebeforeunloadcheck. Propose callsonChangeonly on user input, andscheduleAutoSavedoes nothing after unmount, so loading or switching rows schedules nothing. - Configure snapshot. It now compares each column's
label,targetSourceandunmapped, which is everything the mapping controls save. The oldmappedfield was never set.autoandsuggestedare left out; they're stripped on load, so they don't change saved data. - Tests.
npm testpasses (775, 9 new) and CI is green.
Non-blocking:
- Opening and closing Configure can look changed. If a saved project has a "Mapping: Code" or "Mapping: List" column with no target source, the picker fills one in when Configure opens (
ColumnMapTable.jsx:72). That happens after the snapshot is taken. Closing Configure then saves it, and reloading with Configure open prompts. The filled value is the one the run uses, so the save is real. But a source the user cleared comes back, and the prompt isn't one they caused. A fix would take the snapshot after the pickers' fill has applied. - The tests cover the helpers, not the wiring. Nothing checks that
getConfigurationSnapshotusesgetColumnsSnapshot, that open-then-close with no edit stays unchanged, or the Propose attribute copy. - Attribute copy. Typing into a newly added attribute row no longer throws. Typing into a row past the end of the list leaves gaps, which save as
null; the readers handle that. - Pre-existing. Propose's
[row]effect still writes legacyattributes.N.xkeys into the saved proposal's attribute objects (Propose.jsx:56-66), and it throws when element N doesn't exist. This PR doesn't make it worse.
Fixes OpenConceptLab/ocl_online#786 (the two items in its body; #139 fixed the follow-up from its comment).
Problem
onProposedUpdate). No autosave was scheduled, so the save on leave and thebeforeunloadprompt both missed it, and leaving right after the edit dropped it.mapped, which nothing sets. The mapping controls writelabel,targetSourceandunmapped. So a mapping-only change didn't save when Configure closed, andhasUnsavedConfigurationreturned false.Change
onProposedUpdategoes througheditProposed, which sets the row's proposal and schedules an autosave (proposal_change), as a review note edit already does.getConfigurationSnapshotusesgetColumnsSnapshot, which compares each column'slabel,targetSourceandunmapped, plus visibility, width and AI Assistant columns as before.unsavedEdits.js.The target source picker fills in a source when the column has none and one matches. If that happens when Configure opens on a saved project, closing Configure now saves it. It happens at most once per column, and it's the source the run uses anyway.
Testing
npm test: 775 pass (9 new inunsavedEdits.test.js). The new tests use the real autosave scheduler,saveOnLeaveandshouldWarnBeforeUnload, so leaving before the autosave runs is shown to be caught.🤖 Generated with Claude Code