uttrflow / uttrflow/uttrflow-swift
A long AI suggestion runs past the field and off the screen: no maximum width, and the clamp keeps the full size
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
Seen in the released build 2026.9.14: a long AI suggestion runs past the end of the field and past the edge of the screen.
## Root cause
- **No maximum width and no truncation.** `Sources/Uttrflow/Suggestion/SuggestionView.swift:12` sizes the ghost with `.fixedSize()`, so a line is always as wide as its whole text, whatever room there is.
- **The clamp keeps the size and moves the origin.** `SuggestionGeometry.clamped` (`Sources/UttrflowContext/SuggestionGeometry.swift:56-60`) pins the origin at `screen.minX` when the panel is wider than the room, but the frame keeps its full width, so it still extends past `visibleFrame.maxX`. When the panel is narrower than the screen but wider than the room after the caret, the clamp pulls it left, over the characters already typed.
- **The field's own frame is never read.** `FocusedFieldSnapshot` (`Sources/UttrflowContext/FocusedFieldSnapshot.swift`) carries the caret and the window but not the field, so nothing can stop a ghost at the right edge of a single-line field.
The existing test `surfaceLargerThanTheScreen` in `Tests/UttrflowContextTests/SuggestionGeometryTests.swift` asserts the pinned origin but never that the frame is inside the screen, which it is not.
## Expected
The ghost never extends past the screen's `visibleFrame`, nor past the field's frame when it is known; what does not fit is cut with an ellipsis, and a caret with almost no room draws nothing rather than covering the typed text. Tab keeps inserting the whole suggestion.
Contributor guide
Assessment
This issue has not been assessed yet.