Apply MathCAT settings with libmathcat.SetPreference when changed#19613
Apply MathCAT settings with libmathcat.SetPreference when changed#19613seanbudd merged 6 commits intonvaccess:betafrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes NVDA MathCAT settings not being honored at runtime by applying NVDA’s stored MathCAT preferences through libmathcat.SetPreference when MathCAT initializes and when preferences are saved.
Changes:
- Added
applyUserPreferencesto push stored MathCAT preferences into the MathCAT runtime vialibmathcat.SetPreference. - Updated
MathCATUserPreferences.save()to apply runtime preferences before writingmathcat.yaml. - Updated MathCAT initialization to apply all user preferences (not just braille code) after setting the rules dir / TTS mode.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
source/mathPres/MathCAT/preferences.py |
Introduces applyUserPreferences and uses it from MathCATUserPreferences.save() to update MathCAT runtime preferences. |
source/mathPres/MathCAT/MathCAT.py |
Applies stored MathCAT preferences during MathCAT startup via applyUserPreferences(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@GeorgeKerscher - can you confirm testing of this build when it completes? You should be able to find it under an "artifacts" menu under the checks tab for the pull request |
|
I could not find a link to an alpha to test. Can you provide a direct link and I will test. |
|
@GeorgeKerscher honestly it's a little hard to find if you aren't familiar with the UI, but here's a test build. It's unsigned, so you won't be able to use it on secure screens and it'll show a warning when you run it. In the installer, just click "continue running" or create (and run) a portable copy. |
|
I installed pr19613-4581,c4437fbd (2026.1.0.4581) I installed as a portable copy. I found that there are still issues:
|
|
@GeorgeKerscher turns out that I can also reproduce the pause factor bug under 890d2d6, and it's unrelated (the factor wasn't being scaled properly when saved to config). As for relative speech rate, which synthesizer are you using? If you aren't using espeak-ng, can you test under that synth? |
|
I was using Windows Core voices. When I switched to E-Speak, NVDA did change the voice speed. However, when I went outside the MathML, it did not return to the original speed setting; it stayed at the speech rate set in the MathCAT settings. |
Yes, that's been the case with all versions of MathCAT (including the add-on). |
|
I think that is incorrect. Once outside the MathML expression, the speed returns to the setting in NVDA. I just tested with: I am using one core voices, David. Perhaps that is a behavior with E-Speak? |
seanbudd
left a comment
There was a problem hiding this comment.
Approved pending testing confirmation with George
|
Please provide a link to an alpha you want me to test. Probably after the merge. |
|
@GeorgeKerscher - weren't you still having issues with speech speed with the current PR build? |
|
Thanks for confirming - @GeorgeKerscher can you open a separate issue for the speech problems? |
|
I just installed NVDA 2026.1 Beta 3 and my preliminary testing resolves the speed, pause, and bep problems initially reported. Two thumbs up! |
|
Hi @GeorgeKerscher - this PR is not in beta3, can you test alphas or beta4 and confirm? |
|
A few things: I am no using NVDA 2026.1 beta 3 as installed. I find four bugs in beta 3: If you give me a link to another alpha to test, I will be happy to test. Also, Should I create a new issue with these items on beta 3? |
|
As mentioned in my previous comment, beta3 doesn't contain any of the fixes from this PR. Please test with alpha or beta4 and open a new issue with anything remaining |
|
@GeorgeKerscher to clarify, beta4 will not be out until next week, but these changes are in NVDA alpha 54640,2f8b7d4b |
|
I am using alpha-54640,2f8b7d4b (2026.2.0.54640) I am finding: I will submit a new issue. It may be a day or so. |
Follow-up to #18323, #19373 and #19613 ### Summary of the issue: Since the introduction of MathCAT into NVDA in #18323, NVDA has persisted MathCAT settings to a YAML file . This is at odds with current project configuration standards, which use either configobj ini files, or JSON. This also duplicates settings, as they're also saved to `nvda.ini`. Originally, these were stored in `%AppData%\MathCAT\prefs.yaml`, but as of #19373, they are saved to `mathcat.yaml` in NVDA's config directory. In neither case was `shouldWriteToDisk` checked before saving the preferences. Additionaly, [NV Access's Corporate & Government page](https://www.nvaccess.org/corporate-government/) states "To prevent NVDA users from modifying their configuration or add-ons directly, user write access to [`%APPDATA%\nvda`] must also be restricted". If implemented, this would have stopped users from changing their MathCAT settings in memory, as they had to be saved to YAML to be loaded by MathCAT. In #19613, the logic was changed to programmatically apply these settings with `libmathcat.SetPreference`, which should solve the problem of users without write access to their NVDA config directory being able to change their MathCAT preferences. However, the code that wrote the settings to the YAML file was not removed, nor did it contain any error handling. ### Description of user facing changes: None, but may avoid some errors in the logs. ### Description of developer facing changes: Pyyaml is no-longer a dependency. `mathPres.MathCAT.preferences.MathCATUserPreferences.save` has been renamed to `apply`, and no longer saves the settings to YAML. Settings persistance is handled by NVDA's configuration system. ### Description of development approach: Removed the code that wrote MathCAT preferences to YAML, and any code that only it depended on. Renamed `save` to `apply` using VS Code's refactoring tool. Searched the repo for `yaml` and after confirming that we don't rely on `pyyaml` anywhere else, ran `uv remove pyyaml`. ### Testing strategy: Tested by loading the [Wikipedia page on the quadratic formula](https://en.wikipedia.org/wiki/Quadratic_formula) in firefox. Located some math and read it. Changed settings one at a time and tested that they were applied correctly. Restarted NVDA and ensured that the new settings were still present. ### Known issues with pull request: None known
Link to issue number:
Closes #19597.
Summary of the issue:
After #19373, NVDA math preferences were not honoured by MathCAT.
Description of how this pull request fixes the issue:
Per #19373 (comment), use
libmathcat.SetPreferenceto apply settings changes when they are saved to the NVDA configuration.Testing strategy:
Confirmed that I could reproduce #19597 before this PR and not after. Verified that preferences persist across NVDA restarts.
Known issues with pull request:
None known
Code Review Checklist: