Screen reader-friendly errors#10122
Conversation
1af5181 to
a377e5f
Compare
amtoine
left a comment
There was a problem hiding this comment.
thanks a lot @JoaquinTrinanes for implementing this, it's a great step in the right direction for accessibility 🙏
i propose we simply wait for some feedback from @edhowland to make sure it's easier to read for them, and then it looks like we can land this 💪
| } | ||
|
|
||
| errors: { | ||
| style: "fancy" # "fancy" or "narratable" for screen reader-friendly error messages |
There was a problem hiding this comment.
Unless we have more error configs, I would not nest and instead use error_style: "fancy".
There was a problem hiding this comment.
Just moved it outside to a single option in 281c1af.
I noticed that some config options are reconstructed after failing validation, while others (specially more simple fields like strings) aren't. I still do the reconstruction for this option according to the rules™️
// Config record (self) mutation rules:
// * When parsing a config Record, if a config key error occurs, remove the key.
// * When parsing a config Record, if a config value error occurs, replace the value
// with a reconstructed Nu value for the current (unaltered) configuration for that setting.
// For instance:
// $env.config.ls.use_ls_colors = 2 results in an error, so
// the current use_ls_colors config setting is converted to a Value::Boolean and inserted in the
// record in place of the 2.Happy to change it if I misunderstood :)
|
Great, thanks! Looks good to me as well. |
| header_on_separator: false # show header text on separator/border line | ||
| } | ||
|
|
||
| error_style: "fancy" |
There was a problem hiding this comment.
- There should be comments showing the available options for
error_styleso people know what the options are. - I'm fine with
fancyas our default, but I don't really like the termnarratable. Maybe one of these is better. I kind of lean toward "simple".
plainwithout_bordersscreen_readersimplebare
There was a problem hiding this comment.
The term "narratable" might seem strange (not a native speaker), but I like that it conveys the purpose of the setting: to be narratable by screen readers. We could have simple or similar instead, but then it should be noted in the comment that it's mean to be screen reader--friendly.
There was a problem hiding this comment.
- I just added the comment back. It was there before but I accidentally deleted it in the last commit 😅
fancyrefers to howmietteitself calls this style, andnarratablefollows the same "logic" (they call the report handlerNarratableReportHandler). Agree, it sounds weird 😬 I'll set it to simple for now if that's ok? I'm not sure about how these kind of decisions should be made
There was a problem hiding this comment.
I'd sign off on it if edhowland agrees it's good. Since he's blind and uses nushell, I'd like to get his input before finalizing the name. I'll ask him in Discord #general https://discord.com/channels/601130461678272522/601130461678272524/1144979237707722752.
There was a problem hiding this comment.
For those not following Discord, this is what edhowland said, "I read the PR and the comments and suggestions. I like either simple or plain. Prefer plain over simple. Reason: No truly hard and fast reason, but the 'bat' command (a replacement for 'cat' written in Rust) also implemented the default behaviour of using box drawing characters for the output for border decorations. To suppress this they added the [-p, --plain] option. So, screen reader users already have at least that one firmly planted in their memories. But I am only 1 dude. Also: plain <=> fancy seems like their are natural antonyms of each other. Thoughts?"
So, since there is a precedent with bat, I move that we maintain that precedent and name the two options fancy and plain for key error_style.
Are there further thoughts?
There was a problem hiding this comment.
I like it. It seems to work as expected. Except for the "plain" text. That doesn't seem right. "entry #6" is probably right, which you can see with view files, but seems like it should say something other than that because that won't be super helpful.
💡 When you do view files you get a list of file names, a span, and size. If you want to view the contents of one of these "file names" like "entry #6", you can use view span like this.
❯ view span 336112 336125
force_error 1But now that I look at it, it doesn't say force_error anywhere. I wonder why?
|
@fdncred I'm confused 🥲
It looks like this when split in 2 lines: I don't know what could be done about the nushell/crates/nu-cli/src/repl.rs Line 590 in 5ac5b90 That will show the name of the file that errors when evaluating a file. I did a quick experiment replacing the filename type with |
|
ya, you're right. maybe it's ok. thanks for looking into it. it just seems not as helpful. maybe it's as good as we can get with miette? |
Not necessarily, it would be a matter of removing the default However, I briefly tried and couldn't find an easy way to do it without the need to change the parser quite a bit. I'll be happy to further look into this but I think something of that scope should be another PR 😄 And there's always the option of creating our own report handler of course 😌 |
|
ok, let's move forward with this. It's not perfect but provides a feature that's better than we had before for our screen reader community. Thanks! |
- Hopefully closes nushell#10120 # Description This PR adds a new config item, `error_style`. It will render errors in a screen reader friendly mode when set to `"simple"`. This is done using `miette`'s own `NarratableReportHandler`, which seamlessly replaces the default one when needed. Before: ``` Error: nu::shell::external_command × External command failed ╭─[entry nushell#2:1:1] 1 │ doesnt exist · ───┬── · ╰── executable was not found ╰──── help: No such file or directory (os error 2) ``` After: ``` Error: External command failed Diagnostic severity: error Begin snippet for entry nushell#4 starting at line 1, column 1 snippet line 1: doesnt exist label at line 1, columns 1 to 6: executable was not found diagnostic help: No such file or directory (os error 2) diagnostic code: nu::shell::external_command ``` ## Things to be determined - ~Review naming. `errors.style` is not _that_ consistent with the rest of the code. Menus use a `style` record, but table rendering mode is set via `mode`.~ As it's a single config, we're using `error_style` for now. - Should this kind of setting be toggable with one single parameter? `accessibility.no_decorations` or similar, which would adjust the style of both errors and tables accordingly. # User-Facing Changes No changes by default, errors will be rendered differently if `error_style` is set to `simple`. # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting There's a PR updating the docs over here nushell/nushell.github.io#1026

Description
This PR adds a new config item,
error_style. It will render errors in a screen reader friendly mode when set to"plain". This is done usingmiette's ownNarratableReportHandler, which seamlessly replaces the default one when needed.Before:
After:
Things to be determined
Review naming.As it's a single config, we're usingerrors.styleis not that consistent with the rest of the code. Menus use astylerecord, but table rendering mode is set viamode.error_stylefor now.accessibility.no_decorationsor similar, which would adjust the style of both errors and tables accordingly.User-Facing Changes
No changes by default, errors will be rendered differently if
error_styleis set tosimple.Tests + Formatting
After Submitting
There's a PR updating the docs over here nushell/nushell.github.io#1026