Skip to content

core: send selection_changed notification - #12902

Merged
mitchellh merged 1 commit into
ghostty-org:mainfrom
jparise:ax-selection-changed
Jun 4, 2026
Merged

mitchellh merged 1 commit into
ghostty-org:mainfrom
jparise:ax-selection-changed

Conversation

@jparise

@jparise jparise commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

The core had no signal to the apprt when the active selection changed, so a consumer (e.g. a screen reader) kept reading a stale selection until some unrelated query refreshed it.

This change adds a payload-less selection_changed action that's fired on a selection state transition. The apprt reads the current selection through the normal read path.

This consolidates selection state changes so the notification fires consistently: all sites route through setSelection rather than calling screen.select directly, including the mouse paths that previously bypassed it for clipboard timing.

The new setSelectionAndCopy extends setSelection with the additional 'copy_on_select' behavior.

On macOS, this posts .ghosttySelectionDidChange, which is debounced before posting a NSAccessibility .selectedTextChanged notification.

GTK has no consumer yet and no-ops the action.

See: #9932

@jparise
jparise requested review from a team as code owners June 2, 2026 23:29
The core had no signal to the apprt when the active selection changed,
so a consumer (e.g. a screen reader) kept reading a stale selection
until some unrelated query refreshed it.

This change adds a payload-less selection_changed action that's fired on
a selection state transition. The apprt reads the current selection
through the normal read path.

This consolidates selection state changes so the notification fires
consistently: all sites route through setSelection rather than calling
screen.select directly, including the mouse paths that previously
bypassed it for clipboard timing.

The new setSelectionAndCopy extends setSelection with the additional
'copy_on_select' behavior.

On macOS, this posts .ghosttySelectionDidChange, which is debounced
before posting a NSAccessibility .selectedTextChanged notification.

GTK has no consumer yet and no-ops the action.
@jparise
jparise force-pushed the ax-selection-changed branch from c67f2ca to c4e1ab8 Compare June 2, 2026 23:38
@jparise jparise added this to the 1.4.0 milestone Jun 2, 2026
@jparise jparise added a11y Issues related to accessibility and accessible APIs os/macos labels Jun 2, 2026

@jcollie jcollie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bo2themax bo2themax left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread macos/Sources/Ghostty/Ghostty.App.swift
@bo2themax
bo2themax dismissed their stale review June 3, 2026 13:12

I was wrong

@mitchellh

Copy link
Copy Markdown
Contributor

Appreciate the smaller PRs towards a11y improvements. Thank you.

@mitchellh
mitchellh merged commit 52368cb into ghostty-org:main Jun 4, 2026
93 checks passed
@jparise
jparise deleted the ax-selection-changed branch June 11, 2026 00:50
deblasis added a commit to deblasis/wintty that referenced this pull request Jun 26, 2026
Upstream ghostty-org#12902 added a payload-less GHOSTTY_ACTION_SELECTION_CHANGED,
fired on a selection state transition; the apprt is expected to read the
current selection and notify accessibility. macOS posts NSAccessibility
.selectedTextChanged -- this wires the Windows equivalent.

Add SelectionChanged (51) to the dispatched GhosttyActionTag subset and
route it through GhosttyHost.OnAction to the surface's TerminalControl,
which forwards to its UIA TerminalAutomationPeer. The peer raises
TextPatternOnTextSelectionChanged, guarded by ListenerExists so it is
inert without an attached AT client; the control no-ops when no peer has
been created (no AT client). Pins the new ordinal in
GhosttyActionsLayoutTests.

Closes #550.

Not built locally: the C# app only compiles on Windows (CsWin32). Needs
a Windows build plus a screen-reader/automation-client smoke test, and
confirmation that AutomationEvents.TextPatternOnTextSelectionChanged is
the correct WinUI 3 event id.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a11y Issues related to accessibility and accessible APIs os/macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants