Repository navigation
Improve VoiceOver, and make the view safe to call off the main thread - #39
Merged
Merged
Conversation
Under a line limit, VoiceOver now reads the whole text of the block that the limit cuts. The last element also reads the blocks that the limit leaves out, as a label that is cut short does. A selection that reaches the end of the text shown now also covers the text that the limit leaves out. Select All followed by Copy copies all of the text. The selection highlight still covers only the text shown. selectedRange and selectedText give the same range that Copy uses. The accessibility text now comes from a model without UIKit, so that the tests on macOS cover it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each block now keeps its accessibility element from one layout to the next, by its block id. A new layout updates the label, frame, traits and link actions of the element in place. VoiceOver focus thus stays on its block while text streams in. The view posts a layout-changed notification only after an assistive technology asked for the elements, and only when elements come or go, or when the layout is not an append. Text that streams into the last block posts nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first block of a list item now gives its position in its list and the number of items as its accessibility value, such as "Item 2 of 3". A list ends at a block outside its containers, or at an item with another kind of marker. The count includes items that a line limit leaves out. A table is now a data table container with one element for each cell. VoiceOver reads the row, the column and the column header. A link in a cell is an action of that cell. The new mathAccessibilityLabel closure on TranscriptTextView, and the mathAccessibilityLabel modifier on TranscriptText, give the words for a formula. Without them, VoiceOver reads the LaTeX, as before. The new string "Item %1$ld of %2$ld" comes from the app's Localizable.strings, as the other spoken strings do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the Swift 6 language mode, a main actor method that Objective-C calls from another thread stops the process. VoiceOver, Speak Screen, Voice Control and the text rotor can call accessibility getters and UITextInput methods from another thread. A test that called isAccessibilityElement on the view from a background thread stopped in _checkExpectedExecutor. These methods are now nonisolated: - The view's isAccessibilityElement and accessibilityElements. - Every UITextInput method and property of the view, its tokenizer, its input delegate and writingToolsBehavior. - The getters of the text position, text range and selection rect types. They read values that never change. - The label, value, traits, frame and custom actions of the block and cell elements, which now keep these values in Swift properties. - The data table methods of the table element and the row and column ranges of the cell elements. - The link actions. A method that needs the view's state does its work on the main thread with onMainThread: at once on the main thread, and otherwise with DispatchQueue.main.sync from the thread that called. The main thread never waits for another thread. The new tests call each of these methods from a background thread through the Objective-C runtime. They run in the Mac Catalyst variant, because swift test on macOS does not build the UIKit code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The elements now give their screen frame from a nonisolated getter. UIKit can also use the frame in container coordinates, for example to scroll an element into view. The update on the main thread now sets that frame too: the block's frame in the view, and a cell's frame in its table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An assistive technology can keep an element, such as the element that has VoiceOver focus, and read it again later. An update that only adds text to the last block posts no notification, so the client does not ask the view for its elements again. The element then gave its old text. Each getter of a block, cell or table element now first brings the elements up to date with the layout on screen. When the elements already match that layout, this costs nothing more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A layout that is not an append, such as a layout after new colors for code, posted a layout-changed notification every time. Now such a layout posts only when its items differ from the items that the elements were last made with. An append posts only when its shape changes. The shape now also tells whether the text that a line limit leaves out has an item of its own. Before, a paragraph that streamed in after a table under a line limit added an element and posted nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A table that starts a list item lost the list marker, the task state and the position. Now its first cell reads the marker before its text, and has the position as its value. An element key was the block id with "#" and a count, so the ids "same", "same" and "same#1" gave the same key twice. A key is now a struct of the id and the number of blocks before it with that id. A table cell now brings the elements up to date before it gives its row or column, as its other getters do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With an assistive technology on, the elements were made from the whole document for each new layout. Each block was read again, and the app's formula closure ran again for each formula. Now the view keeps the words of each block with the block layout that they came from. A block whose layout is the same object as before uses its words again. New link definitions or a new mathAccessibilityLabel make all words again. A table cell read all of the spans of its table, so a table cost its spans times its cells. Now each span goes to the cell that holds its start, by binary search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
point(inside:with:), canBecomeFirstResponder, inputView, canPerformAction(_:withSender:), copy(_:) and selectAll(_:) were still main actor overrides. The accessibility hit test reaches point(inside:with:), so an assistive client that hit-tests from another thread stopped the app. These overrides are now nonisolated and do their work on the main thread, as the UITextInput methods do. New tests call these overrides, the inputDelegate setter, writingToolsBehavior and a link action from a background thread. Other new tests check that Select All under a line limit selects and copies all of the text, that the selection grows and is reported again while text streams in after the cut, and that the element reads all of the text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The decision to post a layout change compared a new layout with the items that the elements were last made with. An append that posted nothing did not make the items again, so they grew old. While a code block streamed in, the next color result then found a longer label and posted. Now the view keeps the geometry of each layout that it installs, once an assistive technology has asked for the elements: the blocks, the number of elements of each, their frames, and whether the text that a line limit leaves out has an item. The geometry does not read the text of the blocks. An append posts when elements come or go. Another layout also posts when an element moved or changed its size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The iOS 27.2 SDK makes conversationContext(_:didChange:) a required method of UITextInputDelegate, so the test delegate did not build for iOS. Two calls also used main actor API in a closure that runs off the main thread, which gave warnings. They now go through the Objective-C runtime, as the other calls in the file do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TranscriptText: the view keeps both mathCache and mathAccessibilityLabel, and sets the cache before the renderer. TranscriptTextView: the view keeps mathCache and contentSettled(), and then mathAccessibilityLabel. TranscriptTextView.point(inside:with:): the check runs on the main thread from any thread, and a block that scrolls sideways takes touches. TranscriptTextView: the UITextInput methods run on the main thread, and every geometry call uses the side scroll of the blocks. TranscriptTextView+Accessibility: the elements come from the layout items, and a block element that scrolls sideways answers a three-finger swipe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 9 of a stack of 13 pull requests. The base is #38 (
feature/tags). #31 (part 1) tells how to merge the stack.On this stacked branch,
swift testpasses (330 tests), and the iOS build and build-for-testing pass.Summary
Assistive technologies need all of the text, elements that stay the same while text streams in, and answers on any thread. Before this change, a line limit cut what VoiceOver read and what Copy copied. Each layout made new elements. A call from a background thread stopped the app.
selectedRangeandselectedText.TranscriptTextView.mathAccessibilityLabelandTranscriptText.mathAccessibilityLabel(_:)give the words for a formula. Without them, VoiceOver reads the LaTeX, as before. The new string "Item %1$ld of %2$ld" comes from the app'sLocalizable.strings.UITextInputmembers, the element types,point(inside:with:),canBecomeFirstResponder,inputView,canPerformAction(_:withSender:),copy(_:)andselectAll(_:)are nownonisolated. Their signatures do not change. Off the main thread, they do their work withDispatchQueue.main.sync. The main thread never waits for another thread.Tests
swift teston macOS: 202 tests pass.-only-testing:TranscriptKitTests): 211 tests pass, with the UIKit tests. The first call ofOffMainThreadTestsstops the process on main, in_checkExpectedExecutor.xcodebuild buildandbuild-for-testingwith-scheme TranscriptKit -destination 'generic/platform=iOS'(Xcode 27.2) succeed with no warnings. The last commit makes the test delegate build with the iOS 27.2 SDK.Checked on an iPhone 12 mini
A check screen in a local test app ran with VoiceOver off, at the commit before the last one. The last commit changes only a test file. Each check ran on main first and showed the problem. The cost check is a comparison.
Stand-ins: calls from a background thread take the place of a real client. The check reads the accessibility properties and does not hear them.
Not checked
convertToScreenCoordinatesreturns its input.Known limits
🤖 Generated with Claude Code