Teleprompter text starts at the top of the floating window instead of vertically centered (word-tracking mode)

Open Beginner friendly
#92 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
swift
Domain
desktop

Research direction

Start in MarqueeTextView.swift, in SpeechScrollView’s isListening change handler and the existing geo.size.height handler. Compare their initial-state behavior, then verify in Floating Window + Word Tracking and Silence-Paused modes that the first line remains vertically centered when recognition starts without changing Classic mode behavior.

Written by the indexing model from the issue text.

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):

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:

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.

Dominant language
Swift
Stars
3.8k
Forks
265
Avg merge
3d 10h
Merged PRs (30d)
6

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from f/textream

All issues in f/textream

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.