uttrflow / uttrflow/uttrflow-swift
Surroundings deletes line breaks and tabs between words before passing screen text to suggestions
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## Problem
On main `8d93f5b8574f3c7b8c30086d9c817bf7f5d4827d`, `Surroundings.cleaned` removes every Unicode scalar in the control category. This includes ordinary whitespace separators: LF, CR and tab. An element whose text is `Please review\nthe report` becomes `Please reviewthe report`.
`Surroundings.trimmed` calls this cleaner before collection. `FocusedFieldReader.AXElementTree` supplies element values/descriptions to the collector, and `SuggestionCoordinator.situation` passes the collected text unchanged into `GenerationSituation.surroundings` (Sources/Uttrflow/Suggestion/SuggestionCoordinator.swift:559-573). A multiline message or tab-separated text therefore contributes fused words to suggestion context. This is verified context corruption; no specific change in model output or accuracy percentage is claimed.
## Reproduction
Add this test beside the existing `FakeElementTree.swift` fixture and run it against the unchanged Context module:
```swift
@Test(arguments: ["\n", "\r\n", "\t"])
func preservesWordBoundaries(separator: String) {
let focused = Node(id: 1, role: "AXTextArea", text: "Reply")
let message = Node(
id: 2, role: "AXTextArea",
text: "Please review" + separator + "the report")
let window = Node(id: 0, role: "AXWindow", children: [message, focused])
let result = Surroundings.collect(
around: focused, in: FakeTree(root: window),
windowTitle: nil, deadline: unhurried)
#expect(result.text?.split(whereSeparator: \.isWhitespace).map(String.init)
== ["Please", "review", "the", "report"])
}
```
All three cases fail: actual words are `["Please", "reviewthe", "report"]`. The existing 186 Context tests pass. `SurroundingsPropertyTests.Oracle.cleaned` repeats the same category filter as production and therefore agrees with the loss of whitespace rather than detecting it.
## Acceptance criteria
- Keep a word separator when normalizing line breaks and tabs, either by retaining appropriate whitespace or replacing it with a space.
- Continue removing non-text control/direction marks without inserting spaces inside otherwise intact words.
- Add LF, CRLF and tab cases through `Surroundings.collect`; assert word boundaries independently of the production cleaning algorithm.
- Preserve the character caps, ordering and existing mark-removal behavior. Update the property oracle to express the corrected whitespace policy.
Checked open and closed issues and current open PRs. #434 covers test deadlines; #545 covers the disclosure of screen context. Neither addresses separator deletion.
Contributor guide
Research direction
Start with Surroundings.cleaned and Surroundings.trimmed, then inspect the existing FakeElementTree fixture and SurroundingsPropertyTests. Run the supplied Surroundings.collect reproduction and the Context test suite before changing behavior. Done means LF, CRLF, and tab preserve word boundaries, while caps, ordering, mark removal, and the corrected property oracle remain covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, swift
- Domain
- accessibility, desktop-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100