Skip to content

Refactor anonymiser UI to handle latest BSA version#86

Merged
boscorat merged 1 commit into
masterfrom
79-refactor-to-handle-latest-version-of-bank-statement-anonymiser
Jul 7, 2026
Merged

Refactor anonymiser UI to handle latest BSA version#86
boscorat merged 1 commit into
masterfrom
79-refactor-to-handle-latest-version-of-bank-statement-anonymiser

Conversation

@boscorat

@boscorat boscorat commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

This PR refactors the anonymisation functionality to replace raw TOML text editors with intuitive form-based table inputs, addressing the breaking changes in the latest bank_statement_anonymiser package.

Changes

UI Improvements

  • Never Anonymise tab: Single-column table for excluded phrases with Add Row / Remove Selected buttons
  • Always Anonymise tab: Two-column table (Original Text | Replacement) with Add Row / Remove Selected buttons
  • Auto-save behavior: Configs now save automatically on dialog close or "Run Anonymisation" button press (with 3-retry logic)
  • Removed manual "Save Config" button
  • Always show one empty row at bottom of tables for convenience

Code Refactoring

  • Added NeverAnonymiseConfig data model for excluded phrases
  • Added AlwaysAnonymiseConfig data model for forced replacements
  • Both models support full TOML round-trip serialization
  • Implemented retry logic: 3 attempts with 1-second delays between failures
  • Removed ~40 lines of legacy migration code
  • Removed dirty-state tracking and related signal wiring
  • Simplified presenter logic significantly
  • Improved docstrings for _run_anonymisation() and _on_dialog_finished()

Documentation Updates

  • Rewrote "Configuring Anonymisation" section with table-based explanations
  • Removed obsolete "Saving the config" section
  • Updated "Config File Locations" to clarify two separate TOML files
  • Improved feature overview to reflect new two-table model
  • Added examples showing how each tab works

Testing

✅ All 129 tests pass
✅ Type check: 0 errors (pyrefly)
✅ Lint: All checks pass (ruff)
✅ Format: All files correctly formatted
✅ TOML round-trip: Verified with BSA system config files (155 phrases load correctly)

Files Changed

  • docs/screens/anonymise.md — Documentation rewrite
  • src/openstan/presenters/anonymise_presenter.py — Data models + presenter logic
  • src/openstan/views/anonymise_dialog.py — Table-based UI

Architecture

  • MVP separation maintained: View (tables) ↔ Presenter (auto-save) ↔ Data models (TOML)
  • All widgets use Stan-prefixed subclasses
  • Background worker thread for anonymisation (unchanged)
  • Non-blocking UI with proper error handling

Resolves #79

Replace raw TOML text editors with intuitive form-based table inputs:

**UI Changes:**
- 'Never Anonymise' tab: Single-column table for excluded phrases
- 'Always Anonymise' tab: Two-column table (Original Text | Replacement)
- Add Row / Remove Selected buttons for both tabs
- Auto-save on exit or 'Run Anonymisation' (3-retry logic with 1s delays)

**Code Changes:**
- New data models: NeverAnonymiseConfig, AlwaysAnonymiseConfig
- TOML round-trip serialization for both configs
- Simplified presenter logic (removed legacy migration code)
- Removed dirty-state tracking and manual save button
- Improved docstrings for clarity

**Documentation:**
- Rewrote 'Configuring Anonymisation' section
- Removed obsolete 'Saving the config' section
- Updated 'Config File Locations' to clarify two separate TOML files
- Improved feature overview and workflow explanation

**Testing:**
- All 129 tests pass
- Type check: 0 errors
- Lint and format: all checks pass
- TOML round-trip: verified with BSA system config files

Resolves #79
@boscorat boscorat linked an issue Jul 7, 2026 that may be closed by this pull request
@boscorat boscorat merged commit d29e6d1 into master Jul 7, 2026
@boscorat boscorat deleted the 79-refactor-to-handle-latest-version-of-bank-statement-anonymiser branch July 7, 2026 09:07
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.

Refactor to handle latest version of Bank Statement Anonymiser

1 participant