[Bug] Single-line normalization loses the word boundary after a leading newline
Category
Output normalization / word spacing. Reproduced without host-app input or Accessibility.
Summary
Single-line normalization removes a leading newline from a completion without preserving its word boundary. For example, Hello followed by \nworld becomes Helloworld when the normalized continuation is appended.
Environment
- macOS version: 26.6.2
- Cotabby revision: upstream main
8cdbea2d2619b0f89a73d46eb0bb856504d07343 - Host app: XCTest; no external editor required for the reproduction
- Cotabby engine: shared output normalizer used by Apple Intelligence, Open Source, and OpenAI-compatible backends
- Model: not required; the test supplies raw model output directly
- Accessibility, Input Monitoring, Screen Recording: not required for this deterministic reproduction
Steps to reproduce
- Create a suggestion request with preceding/prefix text
HelloandisMultiLineEnabled: false. - Pass raw output
"\nworld"toSuggestionTextNormalizer.normalizeDetailed(_:for:). - Append the returned
.textto the preceding text. Repeat with cumulative partials"\nw","\nwor", and"\nworld"to exercise streaming normalization.
Expected behavior
Return " world", preserving a separator where the spacing rules require it. Existing whitespace, punctuation attachment, spaceless scripts, and ordinary mid-word suffixes should retain their behavior. Multiline handling should remain unchanged.
Actual behavior
Returns "world", so appending it yields Helloworld. Cumulative partials likewise lose the separator. A leading CRLF reproduces the same problem.
Notes
Reproduced against the revision above using regression tests: five assertions fail across two new tests before applying the fix. A focused fix with tests is prepared. No live host-app recording or model-backed evaluation was used; this report establishes the deterministic normalization failure.