Skip to content

show unread dictionary lines in settings - #522

Open
mvanhorn wants to merge 3 commits into
mtgto:mainfrom
mvanhorn:fix/503-dict-load-failures
Open

mvanhorn wants to merge 3 commits into
mtgto:mainfrom
mvanhorn:fix/503-dict-load-failures

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Oct 4, 2026

Copy link
Copy Markdown

Entry.parse now returns a Result that distinguishes those three failures. MemoryDict stores each one as a DictReadFailure (line number, raw text, and reason), and DictLoadStatus.loaded carries that array on both the initial load and later edit notifications; failedEntryCount is the array length, which the existing user-dictionary notification still uses. When a dictionary file contains lines the loader skips, Settings only shows how many lines failed. The log records the line number, so the user still has to open the file to see the text and figure out why that line was skipped.

The Swift test command did not run the new dictionary tests.

Fixes #503

Entry.parse now returns a Result that distinguishes those three
failures. MemoryDict stores each one as a DictReadFailure (line number,
raw text, and reason), and DictLoadStatus.loaded carries that array on
both the initial load and later edit notifications; failedEntryCount is
the array length, which the existing user-dictionary notification still
uses. In dictionary settings, a loaded dictionary with failures shows a
button that opens a sheet listing the line number, a localized reason,
and the selectable raw line, with English and Japanese strings.

Fixes mtgto#503
Resolve conflicts with the ReadonlyMemoryDict split. SearchableDict now
exposes readFailures, with failedEntryCount derived from it, and
ReadonlyMemoryDict records each unread line the same way MemoryDict does.
Adopt FileDict.Status and FileDict.StatusEvent from main and carry the
unread lines in Status.loaded. Edit notifications now come from
UserDict.postEditEvent, so it passes readFailures too.
@mvanhorn

Copy link
Copy Markdown
Author

Merged main again (084089b) to clear the conflict with the FileDict.Status move: the load failures now ride on Status.loaded as failures, and edit notifications go through main's UserDict.postEditEvent with dict.readFailures instead of the PR's own posts from FileDict.add and delete.

@mtgto

mtgto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

@mvanhorn Sorry for the late reply, and thank you for working on #503.

Before I review this in detail, could you verify it on a real environment?
This change affects the Settings UI and the dictionary loading path, and the
PR description notes that the tests were not run. Specifically:

  • Build and run it locally with ./build_restart.sh (see CONTRIBUTING.md)
  • Add a SKK dictionary (or edit the user dictionary) so that it contains some invalid lines
  • Attach screenshots of the Dictionaries settings and the "unread lines" sheet
  • Confirm that the unit tests pass

If that's difficult on your side, no problem at all — just let me know and I'll implement it myself, using this PR as a reference.

@mvanhorn

Copy link
Copy Markdown
Author

Thanks for taking a look. I ran the unit tests on the PR head (084089b) with the CI command, xcodebuild -scheme macSKK -destination 'platform=macOS' DEVELOPMENT_TEAM= test, on Xcode 27.2 and macOS 27.2: 545 passed, 18 skipped, 10 failed. The 10 failures are segfaults in the CloudKit sync tests (UserDictSyncRecordTests, UserDictSyncOutboxTests.testHasPendingPlaceholder, UserDictTests.testApplySyncRecordsSkipping), and the same 10 crash the same way when I run current main (542 passed, 18 skipped, 10 failed), so they don't come from this change.

Running only FileDictTests, MemoryDictTests, ReadonlyMemoryDictTests and EntryTests, all 57 pass. That includes the new FileDictTests.testLoadBadLineSurvivesEdit, which loads a file with an invalid line (い/胃/), checks that Status.loaded carries it as a failure with its line number and reason, and checks it is still there after an edit.

I can't run ./build_restart.sh on a real install or take the Settings screenshots from my setup right now, so the UI side is still unverified on my end.

This branch has not been deployed

No deployments
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.

辞書の読み込みできなかった行を設定画面から確認できる

2 participants