Toggle Remote Access, rather than connecting or disconnecting explicitly (#17853)
Closes #17789
Closes #17790
Summary of the issue:
Currently, Remote Access uses separate gestures for connecting and
disconnecting. However, these actions are mutually exclusive, so only
one gesture is strictly necessary.
Likewise, connect and disconnect are both always shown in the Remote
menu, though one is always disabled.
Description of user facing changes
A new gesture has been added, which creates a new, or disconnects from
the existing, Remote connection. This gesture has been bound to
`NVDA+alt+r` in all layouts.
The `NVDA+alt+pageUp` and `NVDA+alt+pageDown` gesture bindings for
connecting and disconnecting remote, respectively, have been removed,
though the underlying gestures remain.
The Remote menu (NVDA menu -> Tools -> Remote) now only ever shows the
"Conect..." or "Disconnect" items at any given time.
Description of development approach
Created a new gesture,
`globalCommands.GlobalCommands.script_toggleRemoteConnection`, which
queries whether remote is connected. If it is, this calls
`script_disconnectFromRemote`, otherwise it calls
`script_connectToRemote`.
Instead of enabling/disabling `remoteClient._client.menu.connectItem`
and `disconnectItem`, switch the label, help text, and actions as appropriate.
### Testing strategy:
Tested the existing and new gestures in a range of situations to ensure
that the behaviour of the toggle was the same as that of the expected
single-purpose command.
Tested connecting and disconnecting from remote using nvdaremote.com and
a local relay server, as both leader and follower, checking the menu at
each stage to ensure the correct items were present.
Known issues with pull request:
While this approach means that connecting and disconnecting via the
toggle or the single-use commands have the same restrictions, it does
mean the messages may be misleading: the message will always be "Action
unavailable while X", but the precise action performed, and the
restrictions, vary:
* Disconnecting is disallowed when in secure mode.
* Connecting is disallowed when in secure mode, or when a modal dialog
is open.
This inconsistency may confuse users. Perhaps a clearer way of
communicating the block would be "connecting unavailable when X" or
"disconnecting unavailable when X", but this is not currently possible.
Of course, it is always possible to implement functions to consistently
handle all of this, but I'm not sure if the slight increase in clarity
is worth the effort.
Code Review Checklist:
- [x] Documentation:
- Change log entry
- User Documentation
- Developer / Technical Documentation
- Context sensitive help for GUI changes
- [x] Testing:
- Unit tests
- System (end to end) tests
- Manual testing
- [x] UX of all users considered:
- Speech
- Braille
- Low Vision
- Different web browsers
- Localization in other languages / culture than English
- [x] API is compatible with existing add-ons.
- [x] Security precautions taken.
<!-- Please keep the following -->
@coderabbitai summary
---------
Co-authored-by: Sean Budd <sean@nvaccess.org>