Skip to content

feat(history): batch delete for recognition history + test alignment#121

Open
MangoWAY wants to merge 1 commit intojoewongjc:mainfrom
MangoWAY:feat/history-batch-delete
Open

feat(history): batch delete for recognition history + test alignment#121
MangoWAY wants to merge 1 commit intojoewongjc:mainfrom
MangoWAY:feat/history-batch-delete

Conversation

@MangoWAY
Copy link
Copy Markdown

Summary

This PR adds batch delete for Settings → History (recognition history), refactors selection logic into a small testable helper, extends HistoryStore with a transactional multi-row delete, and aligns several XCTest suites with the current production behavior (AssemblyAI, Soniox, Volcano, AppState, ModeStorage).


Features (user-visible)

Batch delete in History tab

  • Select button enters selection mode; Done exits and clears selection.
  • In selection mode, each row shows a checkbox; clicking the row or the checkbox toggles selection.
  • Toolbar: N selected, Select all in list / Deselect all when the current filtered list is fully selected, and Delete (disabled when nothing is selected).
  • Select all applies only to the currently loaded + filtered rows (same semantics as infinite scroll elsewhere).
  • Delete shows a confirmation alert (destructive).
  • Search clears the current selection; leaving the History tab clears selection mode.
  • Per-row actions (Correct / Copy / single Delete) are hidden in selection mode to reduce mis-taps.
  • Export is disabled while in selection mode.

Data layer

  • HistoryStore.delete(ids: [String]): runs in a single SQLite transaction, deletes in chunks of up to 500 IDs (SQLite variable limit), posts historyStoreDidChange once on success.

Testability

  • HistorySelectionHelpers: pure functions for “all filtered selected?” and toggle select-all / deselect-all; covered by HistorySelectionHelpersTests.
  • HistoryStoreTests: batch delete, empty-ID no-op, notification expectation; HistoryRecord initializers updated with asrProvider: nil where needed.

Test suite fixes (why they changed)

These are not behavioral changes to those subsystems in this PR; tests were outdated vs current code:

Area Change
AppState finalize only runs when barPhase == .processing; test sets phase before calling.
AssemblyAI Keyterms moved off the WebSocket URL to UpdateConfiguration after connect; URL tests assert absence of keyterms_prompt and validate updateConfigurationMessage.
Soniox Start payload context is only { "terms": [...] } (no general block).
Volcano When boostingTableID is set, inline hotwords context is omitted (table wins); split expectations + new test for hotwords-only.
ModeStorage Legacy formal-writing migration resets processingLabel to the current default; assertion compares to ProcessingMode.formalWriting.processingLabel.

Risks & limitations

  1. Batch delete scope: Deletes only selected rows that are already loaded in the UI. Users who need to delete “everything in DB” without scrolling must still rely on multiple loads or a future “clear all” (out of scope here).
  2. Search + selection: Changing the search text clears selection (intentional, avoids deleting stale IDs).
  3. Double notification: After batch delete, historyStoreDidChange triggers a full reload of the first page; acceptable and consistent with single-row delete.
  4. Test alignment: Owners should be aware that test updates encode current AssemblyAI/Soniox/Volc/AppState contracts; if upstream intentionally diverges, those tests may need revisiting.

How to verify

swift build -c release
swift test

Manually: Settings → History → Select → select rows → Delete → confirm.


Checklist

  • Builds (swift build -c release)
  • Tests pass (swift test)
  • New strings use existing L(zh, en) pattern where applicable

- Add HistoryStore.delete(ids:) transactional batch delete
- HistoryTab: selection mode, select/deselect all, confirmation alert
- Extract HistorySelectionHelpers + unit tests
- Align XCTest with AssemblyAI, Soniox, Volc, AppState, ModeStorage

Made-with: Cursor
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