Skip to content

The agent that grows with you

fix(desktop): honor every documented renderer_accessibility off value (#122080 review)

Brooklyn Nicholsona2587b8c9f7e
diff --git a/apps/desktop/electron/renderer-accessibility.test.ts b/apps/desktop/electron/renderer-accessibility.test.ts
index c29975b21a5..f8ad5be4fef 100644
--- a/apps/desktop/electron/renderer-accessibility.test.ts
+++ b/apps/desktop/electron/renderer-accessibility.test.ts
@@ -16,7 +16,7 @@ test('shouldEnableRendererAccessibility never enables on platforms without the t
})
test('shouldEnableRendererAccessibility honors the opt-out env bridge', () => {
- for (const off of ['0', 'false', 'no', 'off', 'OFF', ' 0 ']) {
+ for (const off of ['0', 'false', 'no', 'off', 'OFF', ' 0 ', 'disabled', ' Disabled ']) {
assert.equal(shouldEnableRendererAccessibility({ HERMES_DESKTOP_RENDERER_ACCESSIBILITY: off }, 'darwin'), false)
assert.equal(shouldEnableRendererAccessibility({ HERMES_DESKTOP_RENDERER_ACCESSIBILITY: off }, 'win32'), false)
}
diff --git a/apps/desktop/electron/renderer-accessibility.ts b/apps/desktop/electron/renderer-accessibility.ts
index 34580499993..e9e922d8b16 100644
--- a/apps/desktop/electron/renderer-accessibility.ts
+++ b/apps/desktop/electron/renderer-accessibility.ts
@@ -25,7 +25,7 @@
/** Values that turn the feature OFF when HERMES_DESKTOP_RENDERER_ACCESSIBILITY
* carries them (same words the launcher accepts for false). */
-const RENDERER_ACCESSIBILITY_OFF_WORDS = new Set(['0', 'false', 'no', 'off'])
+const RENDERER_ACCESSIBILITY_OFF_WORDS = new Set(['0', 'false', 'no', 'off', 'disabled'])
/** Whether this boot must expose the renderer's accessibility tree to the OS.
*
diff --git a/apps/desktop/electron/renderer-heap-flags.test.ts b/apps/desktop/electron/renderer-heap-flags.test.ts
index ac4cda011ff..b942ad49465 100644
--- a/apps/desktop/electron/renderer-heap-flags.test.ts
+++ b/apps/desktop/electron/renderer-heap-flags.test.ts
@@ -58,6 +58,16 @@ describe('renderer heap flags', () => {
false
)
expect(readDesktopLaunchConfig('desktop:\n renderer_accessibility: true\n').rendererAccessibility).toBe(true)
+ // Bare `0` is the string '0' to this reader (no YAML parser), but the
+ // unquoted form a user actually writes must opt out like the quoted one.
+ expect(readDesktopLaunchConfig('desktop:\n renderer_accessibility: 0\n').rendererAccessibility).toBe(false)
+ // `disabled`/`enabled` mirror the launcher's word list so both launch
+ // paths accept the same vocabulary (#118271 review).
+ expect(readDesktopLaunchConfig('desktop:\n renderer_accessibility: disabled\n').rendererAccessibility).toBe(false)
+ expect(readDesktopLaunchConfig('desktop:\n renderer_accessibility: "Disabled"\n').rendererAccessibility).toBe(
+ false
+ )
+ expect(readDesktopLaunchConfig('desktop:\n renderer_accessibility: enabled\n').rendererAccessibility).toBe(true)
// Absent or unreadable: unset, so the app keeps its own default.
expect(readDesktopLaunchConfig('desktop:\n font_family: ""\n').rendererAccessibility).toBeUndefined()
expect(readDesktopLaunchConfig('desktop:\n renderer_accessibility: maybe\n').rendererAccessibility).toBeUndefined()
diff --git a/apps/desktop/electron/renderer-heap-flags.ts b/apps/desktop/electron/renderer-heap-flags.ts
index 4afe3072f2f..fa0b0a17682 100644
--- a/apps/desktop/electron/renderer-heap-flags.ts
+++ b/apps/desktop/electron/renderer-heap-flags.ts
@@ -67,9 +67,9 @@ export function readDesktopLaunchConfig(yamlText: string): DesktopLaunchConfig {
if (key === 'renderer_accessibility') {
const word = unquote(value).toLowerCase()
- if (['0', 'false', 'no', 'off'].includes(word)) {
+ if (['0', 'false', 'no', 'off', 'disabled'].includes(word)) {
out.rendererAccessibility = false
- } else if (['1', 'true', 'yes', 'on'].includes(word)) {
+ } else if (['1', 'true', 'yes', 'on', 'enabled'].includes(word)) {
out.rendererAccessibility = true
}
} else if (key === 'renderer_max_old_space_mb') {
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.py
index 198b8fb231c..c53d5b8ec49 100644
--- a/hermes_cli/main_desktop.py
+++ b/hermes_cli/main_desktop.py
@@ -1197,7 +1197,7 @@ def _detect_linux_password_store() -> str | None:
return None
-_A11Y_OFF_WORDS = frozenset(("0", "false", "no", "off"))
+_A11Y_OFF_WORDS = frozenset(("0", "false", "no", "off", "disabled"))
def _desktop_launch_options() -> tuple[list[str], str, str, str, bool]:
@@ -1234,6 +1234,11 @@ def _desktop_launch_options() -> tuple[list[str], str, str, str, bool]:
raw_a11y = desktop_cfg.get("renderer_accessibility", True)
if isinstance(raw_a11y, bool):
renderer_accessibility = raw_a11y
+ elif isinstance(raw_a11y, (int, float)):
+ # YAML resolves a bare `0`/`0.0` to int/float, not str — the unquoted
+ # off-switch a user actually writes must not silently keep the ON
+ # default. Checked after bool: bool is an int subclass in Python.
+ renderer_accessibility = bool(raw_a11y)
elif isinstance(raw_a11y, str):
renderer_accessibility = raw_a11y.strip().lower() not in _A11Y_OFF_WORDS
return flags, disable_gpu, password_store, ozone_hint, renderer_accessibility
diff --git a/tests/hermes_cli/test_gui_command.py b/tests/hermes_cli/test_gui_command.py
index 5437ddd3c35..66466edbdf5 100644
--- a/tests/hermes_cli/test_gui_command.py
+++ b/tests/hermes_cli/test_gui_command.py
@@ -907,6 +907,18 @@ def test_desktop_launch_options_normalizes_ozone_hint(raw, expected):
("false", False),
("OFF", False),
(" no ", False),
+ # `disabled` is a natural spelling of the opt-out; both word lists
+ # (launcher + packaged-launch yaml reader) accept it, so the two
+ # entry points stay in lockstep.
+ ("disabled", False),
+ ("Disabled", False),
+ ("enabled", True),
+ # YAML parses a bare `0` as int and `0.0` as float — neither is a
+ # str, so the normalization must cover numeric scalars too, not just
+ # the quoted forms above.
+ (0, False),
+ (1, True),
+ (0.0, False),
# Unknown strings don't disable the feature (fail-open, like the
# other desktop launch options fail to "auto").
("wibble", True),