Repository navigation
fix(ui): refuse a locked cell's edit before a draft blocks Save (#2945) - #3040
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Protection message contract crates/engine/src/lib.rs, crates/engine/src/tests.rs |
Session::locked_cell_message returns a protection error for a locked cell on a protected sheet. Tests check the message and cases that return no message. |
Editing guards and validation crates/ui-egui/src/app/editing.rs, crates/ui-egui/tests/it/* |
Editing refuses locked cells before opening an editor. If a draft becomes locked, the UI discards it and displays a warning. Tests cover unlocked-cell editing, undo, and saving. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: aiongg
Merge Risk: 
Minimal · up to edcb6
-
The protected-cell behavior is covered at edit start and commit without an identified regression; the change is mergeable.
Security architecture risk: 
Minimal · up to edcb6
-
Protected cells are checked earlier without weakening existing write protections. Drafts that become locked are discarded with a warning instead of blocking Save. The reviewed changes introduce no material security risk.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- observed — The affected write route includes individual cell edits and selection fills within a workbook. Although the UI preflight checks the draft’s anchor cell, the engine’s general commit check still evaluates changed locked cells before accepting the workbook update.
Trust Boundaries and Controls
- observed — UI input remains subject to authoritative engine enforcement. Bypassing the new editor preflight does not remove the existing cell.set guard or the general protection check; authorization responsibility therefore remains in the engine rather than moving into the UI.
Resilience and Maintainability Implications
- inferred — Protection cancellation is idempotent: it removes the editor without issuing a cell write, so subsequent settlement has no draft to retry. Ordinary formula or validation failures still restore the draft and abort settlement, preserving the distinction between retryable input errors and the newly handled protection refusal.
-
Pre-merge checks: 
3 · 
2
-
Failed checks: 2 warnings Passed checks: 3 passed-
Full details: Linked Issues check
-
Explanation
Issue
#2945requires that a protected-cell edit does not leave the file unsavable or the user without a valid undo path. The change checks protection beforebegin_editcreates a draft and cancels a draft that becomes locked. The reported unit, engine, and integration tests cover the warning, unchanged state, Save, undo, and editing of an unlocked cell.
-
Full details: Out of Scope Changes check
-
Explanation
The editing changes and their tests support issue
#2945. The addedcontributors/people.tomlentry forpeople.maxm11does not implement or test protected-cell editing, Save, or undo behavior. It is unrelated to the issue scope.Resolution
Remove the unrelated
contributors/people.tomlchange, or provide a concrete issue-related coding requirement that requires this contributor entry.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 5 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the first hunks: the PR adds the author to contributors/people.toml (sync_github_name = true, matching other entries) and changes the engine so that, per the title (#2945), an edit of a locked cell is refused up front, before a draft is created that then blocks Save. Refusing before the draft exists is right: a draft in a protected cell can neither be committed nor discarded cleanly. The message should name the reason (sheet protection) and how to lift it. I did not read the engine change. Add tests for typing in a locked cell on a protected sheet (refused, no draft), an unlocked cell (accepted), a protected sheet with the option to select locked cells off, and Save afterwards (works). Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
|
Merged in ea1d52f. Thanks! Refusing the locked cell before a draft exists is the right fix for the blocked Save. |
Typing into a locked cell of a protected sheet opened the in-cell editor. On Enter the engine correctly refused
cell.set, but the UI kept the draft open with the warning. That draft could only be closed with Esc, and until then everyfile.*command ransettle_drafts, so Save was refused and there was no undo step to take back (the edit never entered the workbook).Closes #2945.
Cause
SheetApp::begin_editnever checked sheet protection.commit_edit_heretreated every refusal as "fix the draft and retry" — correct for data validation and formula errors, but a protection refusal left a draft that could never be entered.Fix
Session::locked_cell_messageexposes the engine's existing protection check (locked_cell_error+ the cell's locked style + Allow Edit Ranges unlocked in the session) as one query, so the UI asks the same rule the engine enforces.begin_editrefuses before creating an editor, with Excel's warning, so no draft (and no undo/dirty/save side effect) ever exists.commit_edit_herecancels a draft that becomes locked while it is open (sheet protected or cell locked concurrently) instead of keeping a draft that can never be committed.Tests
app::editing): typing in a locked cell opens no editor, adds no undo step, leaves dirty state alone and Save works; an unlocked cell on the same sheet still edits, undoes and saves; a draft that becomes locked is cancelled.tests/it/protected_cell.rs): real typed text into a locked cell shows the warning, Enter dismisses it, Save is not blocked, and an unlocked cell still edits, undoes and saves.locked_cell_messagereports locked vs unlocked cells and an unknown sheet.Validation
cargo xtask ci(withCRAFT_FONTS_DIR): i18n-report, fmt, clippy, test, doctest, assets and layers pass;cargo xtask parity --checkandcargo xtask keytips --checkpass separately.wasm32-unknown-unknowntarget (can't find crate for core). That is environmental; the changed crates are engine and UI and no wasm-only code was touched.CRAFT_FONTS_DIR, two pre-existing integration tests fail on missing glyphs (ẞ,ẻ); both pass with the pinned fonts input.Summary by CodeRabbit