uttrflow / uttrflow/uttrflow-swift
The AI suggestion field read asks for the window up to three times per keystroke
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
Each AI suggestion field read asks the other application for the field's window up to three times, and for the window's position and size as two more round trips.
In `FocusedFieldReader.snapshot` (`Sources/UttrflowContext/FocusedFieldReader+System.swift:117-161`):
- `document(of:)` fetches `kAXWindowAttribute` whenever the field has no document of its own (`:174-178`)
- `windowFrame(of:)` fetches `kAXWindowAttribute` again, then `kAXPositionAttribute` and `kAXSizeAttribute` separately (`:187-193`)
- `windowTitle(of:)` fetches `kAXWindowAttribute` a third time, then `kAXTitleAttribute` (`:181-184`)
Every one of these is a synchronous cross-process call into the frontmost application, on every keystroke turn. The same file already has `AXNode`/`Answers`, which fetches role, position, size, value, title, description, children and parent in one `AXUIElementCopyMultipleAttributeValues` message (`:248-271`).
## Why it matters
Browsers and Electron apps answer Accessibility slowly, and this read runs per keystroke. Up to 7 window round trips can become 2 (one for the window element, one batched read of its title, position, size and document). That cuts latency and the other application's CPU on the path every suggestion depends on.
## Acceptance criteria
- `snapshot` fetches the window element once and reads its title, frame and document with one batched call (reuse `AXNode(window).answers`, adding `kAXDocumentAttribute` to `Answers.attributes` if needed).
- The resulting `FocusedFieldSnapshot` is unchanged for the same field.
- `readMicroseconds` (already logged by `uttrflow-dev probe surface`) is compared before and after on one browser and one native field, and the numbers go in the PR.
## Where to start
- `Sources/UttrflowContext/FocusedFieldReader+System.swift`: `snapshot`, `document(of:)`, `windowTitle(of:)`, `windowFrame(of:)`, `Answers`
- There is no unit seam for live AX calls. Keep the change mechanical and cover any new pure helper in `Tests/UttrflowContextTests`.
- Run `make verify`; see `CONTRIBUTING.md`.
Size: small (under 60 lines).
Contributor guide
Research direction
Start in Sources/UttrflowContext/FocusedFieldReader+System.swift at snapshot, document(of:), windowTitle(of:), windowFrame(of:), and AXNode/Answers. Reuse the existing batched accessibility read, adding kAXDocumentAttribute if needed, and keep the snapshot unchanged. Run make verify, cover any pure helper in Tests/UttrflowContextTests, and compare readMicroseconds on one browser and one native field for the PR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- accessibility, desktop, performance
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100