Speak relation-only labels for unnamed edit fields

Irctest exposes its settings-field labels through AT-SPI LABELLED_BY
relations while leaving the fields' accessible names empty. Cthulhu
previously captured only the name, so focus speech announced the text
role and contents without Nickname, Username, or Real name.

Resolve direct label targets in the shared native snapshot capture for
unnamed text, entry, and password-text objects. Preserve explicit names,
combine multiple label targets in relation order, and use label/static
text only when a target has no accessible name. Bound relation scans,
target queries, and UTF-8 output; release all native references and avoid
reading password targets. No application-specific handling is required.

Add an isolated GTK fixture and native regression test exercising capture
and speech formatting for single labels, multiple labels, explicit names,
unlabelled fields, and labelled password fields without password contents.
Expose the probe through CTHULHU_NATIVE_EDIT_LABELS=1 in native_atspi.py.
Record verification and installed-reader acceptance in the parity ledger.

Validation:
- go test ./... -count=1
- CTHULHU_NATIVE_EDIT_LABELS=1 python3 tests/native_atspi.py
- go vet ./...
- Build the reader and the brlapi-tagged Braille helper.
- Validate configuration and testdata/parity-ledger.csv.
- Read-only live irctest capture includes all three settings-field labels
  in formatted speech.
- Install both tested binaries and replace the reader in its original
  desktop session; verify service ownership and installed build hashes.
- Maintainer confirms the installed reader now speaks the field labels.

The full suite passes outside the sandbox; its socket and process checks
require access unavailable inside the sandbox. Physical Braille acceptance
remains pending. Preserve cthulhu.log outside the commit.
This commit is contained in:
deedra committed 2026-10-20 09:29:24 -07:00
1 parent 538ff88028
commit 8ef838e16e
5 files changed
+200

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
"""Edit fields whose labels are exposed only through AT-SPI relations."""
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Atk", "1.0")
from gi.repository import Atk, Gtk
window = Gtk.Window(title="Edit label probe")
window.connect("destroy", Gtk.main_quit)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
window.add(box)
def field(identifier, labels, name="", password=False):
entry = Gtk.Entry()
entry.set_text("secret value" if password else "sample value")
entry.set_visibility(not password)
accessible = entry.get_accessible()
accessible.set_name(name)
accessible.set_description(identifier)
for text in labels:
label = Gtk.Label(label=text)
box.pack_start(label, False, False, 0)
accessible.add_relationship(Atk.RelationType.LABELLED_BY, label.get_accessible())
box.pack_start(entry, False, False, 0)
field("related", ["Nickname"])
field("multiple", ["Account", "identifier"])
field("named", ["Other label"], name="Explicit name")
field("unlabelled", [])
field("protected", ["Password"], password=True)
window.show_all()
Gtk.main()
+24
View File
@@ -19,6 +19,9 @@ def wait_for(check, message, timeout=15):
def run_inside():
if os.environ.get("CTHULHU_NATIVE_EDIT_LABELS") == "1":
run_edit_label_probe()
return
if os.environ.get("CTHULHU_MOUSE_REVIEW") == "1":
run_probe("list")
return
@@ -38,6 +41,27 @@ def run_inside():
run_thunar_probe()
def run_edit_label_probe():
fixture = subprocess.Popen([sys.executable, str(Path(__file__).with_name("gtk_edit_labels.py"))])
try:
import pyatspi
def find_window():
return any(window.name == "Edit label probe"
for app in pyatspi.Registry.getDesktop(0) for window in app)
wait_for(find_window, "edit label probe missing")
environment = dict(os.environ, GOCACHE="/tmp/cthulhu-go-cache", GOPROXY="off")
subprocess.run(
["go", "test", "./internal/atspi", "-run", "^TestNativeEditFieldLabels$",
"-count=1", "-timeout=25s", "-v"],
cwd=Path(__file__).resolve().parents[1], env=environment, check=True,
)
finally:
fixture.terminate()
fixture.wait(timeout=3)
def run_thunar_probe():
with tempfile.TemporaryDirectory(prefix="cthulhu-thunar-") as temporary:
home = Path(temporary)