[PR #19027] Display a warning if SUI is unable to write to settings file #31686

Closed
opened 2026-01-31 09:48:50 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/19027

State: closed
Merged: Yes


Summary of the Pull Request

Adds logic to display a warning popup if the settings.json is marked as read-only and we try to write to the settings.json file. Previously, this scenario would crash, which definitely isn't right. However, a simple fix of "not-crashing" wouldn't feel right either.

This leverages the existing infrastructure to display a warning dialog when we failed to write to the settings file. The main annoyance here is that that popup dialog is located in TerminalWindow and is normally triggered from a failed SettingsLoadEventArgs. To get around this, CascadiaSettings::WriteSettingsToDisk() now returns a boolean to signal if the write was successful; whereas if it fails, a warning is added to the settings object. If we fail to write to disk, the function will return false and we'll raise an event with the settings' warnings to TerminalPage which passes it along to TerminalWindow.

Additionally, this uses IVectorView<SettingsLoadWarnings> as opposed to IVector<SettingsLoadWarnings> throughout the relevant code. It's more correct as the list of warnings shouldn't be mutable and the warnings from the CascadiaSettings object are retrieved in that format.

Validation Steps Performed

  • ✅ Using SUI, save settings when the settings.json is set to read-only

Closes #18913

**Original Pull Request:** https://github.com/microsoft/terminal/pull/19027 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Adds logic to display a warning popup if the settings.json is marked as read-only and we try to write to the settings.json file. Previously, this scenario would crash, which definitely isn't right. However, a simple fix of "not-crashing" wouldn't feel right either. This leverages the existing infrastructure to display a warning dialog when we failed to write to the settings file. The main annoyance here is that that popup dialog is located in `TerminalWindow` and is normally triggered from a failed `SettingsLoadEventArgs`. To get around this, `CascadiaSettings::WriteSettingsToDisk()` now returns a boolean to signal if the write was successful; whereas if it fails, a warning is added to the settings object. If we fail to write to disk, the function will return false and we'll raise an event with the settings' warnings to `TerminalPage` which passes it along to `TerminalWindow`. Additionally, this uses `IVectorView<SettingsLoadWarnings>` as opposed to `IVector<SettingsLoadWarnings>` throughout the relevant code. It's more correct as the list of warnings shouldn't be mutable and the warnings from the `CascadiaSettings` object are retrieved in that format. ## Validation Steps Performed - ✅ Using SUI, save settings when the settings.json is set to read-only Closes #18913
claunia added the pull-request label 2026-01-31 09:48:50 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31686