Skip to content

Undo/redo, frictionless delete/merge, exclusive tools, dataset-splitter fixes (#80, #81)#26

Merged
cofade merged 3 commits into
masterfrom
feature/undo-redo-tool-mode-splitter
Jun 25, 2026
Merged

Undo/redo, frictionless delete/merge, exclusive tools, dataset-splitter fixes (#80, #81)#26
cofade merged 3 commits into
masterfrom
feature/undo-redo-tool-mode-splitter

Conversation

@cofade

@cofade cofade commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Merges the feature branch into the fork's master so it's usable locally. Full details and upstream submission: bnsreenu#82.

Summary: snapshot-based undo/redo for all annotation edits (Ctrl+Z/Y), frictionless delete & merge (no confirm/success dialogs), mutually-exclusive tools, Esc → selection mode, and dataset-splitter fixes (bnsreenu#80 auto-balance, bnsreenu#81 test=0% → 0 images). 380 tests pass; senior-reviewer clean.

🤖 Generated with Claude Code

cofade and others added 3 commits June 25, 2026 21:31
… fixes

Bundles seven related changes:

Dataset splitter (dialogs/dataset_splitter.py)
- bnsreenu#81: compute_split_counts() + bounded slices so a 0% subset yields
  exactly 0 images (was leaking the flooring remainder into test).
- bnsreenu#80: auto-balance the train/val/test spin boxes so they always sum
  to 100 (val absorbs train; test→train absorb val; etc.).

Frictionless destructive ops (annotation_controller.py)
- Delete: removed the confirmation AND success dialogs — instant.
- Merge: removed the keep/delete prompt (always replaces originals
  with the union) and the success dialog.

Undo/redo for annotation edits (ADR-026)
- New controllers/annotation_history.py: snapshot-based, per-image-key
  undo/redo stacks with deep-equal dedup and a depth cap.
- record_history() choke-point before every synchronous mutation
  (finish poly/rect, delete, merge, change-class, eraser, SAM/DINO
  accept); deferred bbox/paint/temp gestures capture a baseline at
  start (editBaselineRequested) and push it at commit.
- Detail-% drags coalesce to one undo entry.
- Ctrl+Z / Ctrl+Y / Ctrl+Shift+Z as ApplicationShortcuts; undo/redo
  no-op during load, modal, text focus, or an in-flight gesture.

Tool mode (annotator_window.py, sam_controller.py, image_label.py)
- F: single activate_tool() choke-point makes all six tools (incl.
  SAM) mutually exclusive — a SAM tool can no longer be active
  alongside a manual tool.
- G: Esc cancels the in-progress shape AND returns to selection mode
  (selectModeRequested -> activate_tool(None)).

Docs: ADR-026, crosscutting concepts (tool activation, Esc), runtime
view, CLAUDE.md shortcuts + patterns table.

Tests: +114 (splitter math/balance, AnnotationHistory unit, history
integration incl. mid-paint-undo + number-parity guards, tool mode).
378 passed, 3 skipped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Vertex edits (double-click polygon edit) were the one annotation edit
Ctrl+Z couldn't reverse. Their Enter-commit only refreshed the list and
relied on a later save to persist, and Esc silently kept the in-place
vertex drags instead of reverting them.

- start_polygon_edit captures the segmentation + emits editBaselineRequested
  (undo baseline) on entry.
- New polygonEditCommitted signal -> commit_polygon_edit syncs
  all_annotations (save_current_annotations) + pushes the baseline +
  refreshes the list. Gated on an actual geometry change.
- Esc now reverts the drags from the captured original; _editing_polygon_orig
  is cleared on commit/cancel/delete/exit/clear.

Tests: vertex-edit commit->undo and Esc-reverts-without-history.
380 passed, 3 skipped. ADR-026 + CLAUDE.md updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
switch_slice didn't call exit_editing_mode the way switch_image does, so
editing a polygon then switching slice left editing_polygon and the new
_editing_polygon_orig pointing at the previous slice's object (stale
overlay). One-line parity fix; closes the leak for multi-dim stacks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cofade cofade merged commit da054fc into master Jun 25, 2026
12 checks passed
@cofade cofade deleted the feature/undo-redo-tool-mode-splitter branch June 26, 2026 08:25
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