Skip to content

Move the autosave logic from Controller into AutosaveController - #228

Merged
mfl28 merged 1 commit into
masterfrom
refactor/autosave-controller
Oct 11, 2026
Merged

mfl28 merged 1 commit into
masterfrom
refactor/autosave-controller

Conversation

@mfl28

@mfl28 mfl28 commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Moves the autosave logic (#226) out of Controller into a package-private AutosaveController, following the pattern of the other controller collaborators (ImageFolderController, AnnotationIoController, …). Behavior is unchanged.

Structure

  • AutosaveController gets what it acts on: Model, DialogService, the stage, RecentImageFolders and the AutosaveStore. It builds its AutosaveWriter from an executor.
  • Its Operations interface covers what stays in Controller: storing the view's shapes in the model, checking whether a shape is being drawn, starting the restore import, opening a folder, running on the JavaFX thread, and the status bar (autosave time, failure message).
  • The 5 s delay is a small Timer interface. The app uses a PauseTransition, and the unit tests use a fake one they fire by hand, so no JavaFX toolkit is needed.
  • Controller calls it at each point where autosave is involved: after edit checkpoints, when a folder is opened or closed, after the restore import, on exit, and when the window is hidden. Controller goes from 1,733 to 1,558 lines.

Tests

  • New AutosaveControllerTest (15 unit tests, real Model, mocked DialogService):
    • saving after the delay, and restarting the delay on further edits;
    • waiting while a shape is being drawn;
    • deleting after export or "quit without saving";
    • restoring or declining when a folder is opened, and a failed restore;
    • the startup offer (accepted, declined, no autosave);
    • stopping, closing the folder, and a failed save.
  • AutosaveTests (UI) now go through controller.getAutosaveController().
  • The full suite (306 tests) passes locally.

Like the other controller collaborators, AutosaveController gets what it
acts on (Model, DialogService, the recent folders, the store) plus an
Operations interface for the view, the restore import and the JavaFX
thread. The 5 s delay is a Timer that unit tests replace, so the autosave
behavior is now covered by unit tests with a mocked DialogService.
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.76316% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.23%. Comparing base (509e580) to head (b581538).

Files with missing lines Patch % Lines
...undingboxeditor/controller/AutosaveController.java 95.16% 1 Missing and 5 partials ⚠️
...mfl28/boundingboxeditor/controller/Controller.java 81.48% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #228      +/-   ##
============================================
+ Coverage     90.05%   90.23%   +0.17%     
- Complexity     2374     2398      +24     
============================================
  Files           135      136       +1     
  Lines          8901     8939      +38     
  Branches        865      866       +1     
============================================
+ Hits           8016     8066      +50     
+ Misses          462      455       -7     
+ Partials        423      418       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mfl28
mfl28 merged commit d7763f0 into master Oct 11, 2026
19 checks passed
@mfl28
mfl28 deleted the refactor/autosave-controller branch October 11, 2026 07:57
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