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

Open
#548 0 comments 0 reactions 1 assignee Claimed by @naveen-bhatt View on GitHub
area:ai-suggestions bug P1
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.