Skip to content

OpenConceptLab/ocl_online#786 | Proposal edits and column-mapping changes are seen as unsaved - #140

Merged
snyaggarwal merged 2 commits into
mainfrom
ocl_online-786-unsaved-edits
Nov 25, 2026
Merged

snyaggarwal merged 2 commits into
mainfrom
ocl_online-786-unsaved-edits

Conversation

@snyaggarwal

@snyaggarwal snyaggarwal commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes OpenConceptLab/ocl_online#786 (the two items in its body; #139 fixed the follow-up from its comment).

Problem

  1. Editing a saved proposal's fields only set state (onProposedUpdate). No autosave was scheduled, so the save on leave and the beforeunload prompt both missed it, and leaving right after the edit dropped it.
  2. Configure's snapshot compared each column's mapped, which nothing sets. The mapping controls write label, targetSource and unmapped. So a mapping-only change didn't save when Configure closed, and hasUnsavedConfiguration returned false.

Change

  • onProposedUpdate goes through editProposed, which sets the row's proposal and schedules an autosave (proposal_change), as a review note edit already does.
  • getConfigurationSnapshot uses getColumnsSnapshot, which compares each column's label, targetSource and unmapped, plus visibility, width and AI Assistant columns as before.
  • Both helpers are in unsavedEdits.js.
  • Propose copies the attribute being edited instead of changing the one the saved proposal holds. This also stops a throw when typing into a newly added attribute row.

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 in unsavedEdits.test.js). The new tests use the real autosave scheduler, saveOnLeave and shouldWarnBeforeUnload, so leaving before the autosave runs is shown to be caught.
  • ESLint clean on the changed files.
  • Not checked in the browser.

🤖 Generated with Claude Code

…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', () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 snyaggarwal left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 the beforeunload check. Propose calls onChange only on user input, and scheduleAutoSave does nothing after unmount, so loading or switching rows schedules nothing.
  • Configure snapshot. It now compares each column's label, targetSource and unmapped, which is everything the mapping controls save. The old mapped field was never set. auto and suggested are left out; they're stripped on load, so they don't change saved data.
  • Tests. npm test passes (775, 9 new) and CI is green.

Non-blocking:

  1. 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.
  2. The tests cover the helpers, not the wiring. Nothing checks that getConfigurationSnapshot uses getColumnsSnapshot, that open-then-close with no edit stays unchanged, or the Propose attribute copy.
  3. 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.
  4. Pre-existing. Propose's [row] effect still writes legacy attributes.N.x keys 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.

@snyaggarwal
snyaggarwal merged commit 33bcd1e into main Nov 25, 2026
2 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-786-unsaved-edits branch November 25, 2026 02:13
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