f / f/textream
Teleprompter text starts at the top of the floating window instead of vertically centered (word-tracking mode)
- Dominant language
- Swift
- Stars
- 3.7k
- Forks
- 266
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
**Version:** 1.6.5 (reproduced on `master`, commit `1b2f26d`)
**Mode:** Floating Window + Word Tracking
### Summary
When the teleprompter opens, the first line is supposed to sit roughly halfway down the window, leaving blank space above it that fills in as the text scrolls up. In **Word Tracking** mode this doesn't happen — the first line is pinned to the very top of the window, partly clipped by the fade at the top inner edge, and it never moves down.
The offset is computed correctly when the view appears, then gets overwritten ~400ms later when speech recognition starts.
### Steps to reproduce
1. Settings → Overlay Mode → **Floating Window** (leave "Follow cursor when undocked" off)
2. Settings → Listening Mode → **Word Tracking**
3. Start the teleprompter
### Expected
First line of text roughly vertically centered, with blank space above it.
### Actual
First line sits flush at the top of the window and stays there.
### Mode dependency
This only reproduces in **Word Tracking** (and should apply to Silence-Paused for the same reason). In **Classic** mode it does not occur.
The difference is `isEffectivelyListening` (`NotchOverlayController.swift`):
```swift
case .wordTracking, .silencePaused:
return speechRecognizer.isListening // starts false, flips true when recognition starts
case .classic:
return !isPaused // already true on first render, never changes
```
In Classic the value never *changes*, so the `onChange` handler below never fires. In Word Tracking it flips `false → true` shortly after the window opens, and that's what triggers the bug.
### Root cause
`MarqueeTextView.swift`, `SpeechScrollView`:
- `.onAppear` (line 172) correctly sets the initial offset: `scrollOffset = containerHeight * 0.5 - lineHeight * 0.5`
- `.onChange(of: isListening)` (line 159) then calls `recalcCenter(containerHeight:)` when recognition starts
- `recalcCenter` (line 249) computes `target = center - wordY` — the formula for keeping the *active* word centered mid-scroll. In the initial state, with `highlightedCharCount == 0`, this produces a value that collapses the offset to ~0.
Note that `.onChange(of: geo.size.height)` (line 137) already guards this exact situation:
```swift
if highlightedCharCount == 0 && smoothWordProgress == 0 {
// Initial state: center first line on screen
let lineHeight = font.pointSize * 1.4
scrollOffset = newHeight * 0.5 - lineHeight * 0.5
} else if isListening {
recalcCenter(containerHeight: newHeight)
}
```
The `isListening` handler has no equivalent guard, so it calls `recalcCenter` unconditionally.
### Trace
Instrumented run, 480×360 floating window, XL font, Word Tracking:
```
prefChange wasEmpty=true count=113 h=0.0 offset=0.0
recalcCenter h=0.0 smooth=false idx=0 yPos=113 offset=0.0
onAppear h=312.0 words=113
prefChange wasEmpty=false count=98 h=312.0 offset=139.2 <- correct
onChange(isListening)=true h=312.0 offset=139.2
recalcCenter h=312.0 smooth=false idx=0 yPos=98 offset=139.2
prefChange wasEmpty=false count=113 h=312.0 offset=2.8 <- collapsed to top
```
`onAppear` sets 139.2 (correct: `312/2 - 33.6/2`). Roughly 390ms later `isListening` flips true, `recalcCenter` runs, and the offset drops to 2.8 — the text jumps to the top and stays there.
### Note
Resizing the window afterwards fixes it, because that fires `.onChange(of: geo.size.height)`, which *does* have the initial-state guard and restores the correct offset. That's a useful confirmation of the diagnosis, and also why the bug can look intermittent.
### Suggested direction
Apply the same initial-state guard already used in the `geo.size.height` handler, so `recalcCenter` isn't called before any text has been spoken. Happy to open a PR if that approach sounds right.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.