Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ to the same release.
of "Copied". The console buttons fit on one row in Lithuanian too.

### Operator console
- **Projector and OBS show only the verses on screen:** when a passage is longer
than the verse limit, the citation names just the verses shown (John 3:16-18)
and the “+N more verses” note is gone from audience screens. The operator's
On display preview still shows it.
- **“+1 verse” button is on by default**, so the verses a limit cut are one press
away. A console that turned it off keeps it off.
- **Auto-clear timer** in Settings → Display clears a passage after 5–600 seconds
on air. It starts Off. The console shows the selected duration beside Clear
while an on-air passage is timed. Showing a passage, including through
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,10 @@ reading automatically" switch under Settings → Auto-approve (off by default, s
every console, saved with the auto-approve mode) does it for a verse that starts at
most 3 verses past the passage on screen; a bigger jump stays a suggestion.

To advance the displayed passage by one verse yourself, enable the **“+1 verse”
button** under Settings → This console. The button appears in On display and
keeps up to three verses, ending on the verse you just added.
To advance the displayed passage by one verse yourself, use the **“+1 verse”
button** in On display (on by default; turn it off under Settings → This console).
It keeps up to three verses, ending on the verse you just added, so it is also how
you show the verses a longer passage had cut by the verse limit.

A whole utterance can end several seconds after the verse began, so the pipeline
also transcribes the utterance still being spoken: every `--partial-interval-s`
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/display/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ describe('display verses', () => {
await waitFor(() => expect(screen.getByText('Jono evangelija 1:1-3')).toBeInTheDocument())
expect(screen.queryByText('John 1:1-3')).not.toBeInTheDocument()
})

it('cites only the verses the limit lets on screen, with no "more verses" note', async () => {
render(<App />)
push(socket, { type: 'display_settings', data: { verse_limit: 3, theme: 'dark' } })
const passage = reference()
passage.verse_end = 4
passage.verses.push({ verse: 4, text: 'In him was life.' })
push(socket, { type: 'reference', data: passage })

await waitFor(() => expect(screen.getByText('John 1:1-3')).toBeInTheDocument())
expect(screen.queryByText('In him was life.')).not.toBeInTheDocument()
expect(document.body.textContent).not.toMatch(/more verse/)
})
})

/**
Expand Down
17 changes: 4 additions & 13 deletions frontend/src/display/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { formatReference } from '../shared/reference'
import {
coerceDisplayTheme,
coerceVerseLimit,
hiddenVerseCount,
readStoredVerseLimit,
selectVerses,
shownReference,
writeStoredDisplayTheme,
} from '../shared/verseText'
import type { DisplayTheme, VerseLimit } from '../shared/verseText'
Expand Down Expand Up @@ -260,7 +260,6 @@ export default function App() {
}, [])

const visibleVerses = selectVerses(reference, verseLimit)
const hiddenCount = hiddenVerseCount(reference, verseLimit)

// Shrink the font until the visible verses fit the viewport, and re-fit on
// resize. Projectors have no scrollbar, so overflow is never acceptable.
Expand Down Expand Up @@ -320,7 +319,6 @@ export default function App() {
<PassageBody
reference={reference}
verses={visibleVerses}
hiddenCount={hiddenCount}
fontSize={fontSize}
versesRef={versesRef}
/>
Expand Down Expand Up @@ -370,14 +368,12 @@ export default function App() {
interface PassageBodyProps {
reference: BibleReference
verses: VerseText[]
hiddenCount: number
fontSize: number
versesRef: RefObject<HTMLDivElement>
}

/** The verses, the citation and the "+N more" note of one passage. */
function PassageBody({ reference, verses, hiddenCount, fontSize, versesRef }: PassageBodyProps) {
const { t } = useI18n()
/** The verses and the citation of one passage; the citation names only the verses shown. */
function PassageBody({ reference, verses, fontSize, versesRef }: PassageBodyProps) {
return (
<>
{/* Verse text - primary focus, bounded to the chosen limit */}
Expand All @@ -400,12 +396,7 @@ function PassageBody({ reference, verses, hiddenCount, fontSize, versesRef }: Pa
</div>

{/* Reference - secondary, elegant label below */}
<div className="display-reference">{formatReference(reference)}</div>

{/* Tell the audience when a range was only partly shown */}
{hiddenCount > 0 && (
<div className="display-range-note">{t('stage.moreVerses', { count: hiddenCount })}</div>
)}
<div className="display-reference">{formatReference(shownReference(reference, verses))}</div>
</>
)
}
13 changes: 4 additions & 9 deletions frontend/src/display/StreamBand.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
import { formatReference } from '../shared/reference'
import { useI18n } from '../shared/i18nContext'
import { hiddenVerseCount, selectVerses } from '../shared/verseText'
import { selectVerses, shownReference } from '../shared/verseText'
import type { VerseLimit } from '../shared/verseText'
import type { BibleReference, StreamOverlaySettings } from '../shared/types'
import { computeFitFontSize, fitFontSizeByMeasurement } from './fitText'
Expand Down Expand Up @@ -35,7 +34,6 @@ export function StreamBand({
verseLimit,
options,
}: StreamBandProps) {
const { t } = useI18n()
const [shownCount, setShownCount] = useState(0)
const versesRef = useRef<HTMLDivElement>(null)

Expand All @@ -55,7 +53,6 @@ export function StreamBand({
}, [])

const verses = selectVerses(reference, verseLimit)
const limitHidden = hiddenVerseCount(reference, verseLimit)

// Fit the verses into the band: shrink the text down to a size a stream viewer
// can still read, and past that drop verses from the end rather than overflow.
Expand Down Expand Up @@ -109,7 +106,8 @@ export function StreamBand({
// The font and alignment change how much text fits, so they refit too.
}, [verses, options.font, options.align])

const droppedCount = limitHidden + Math.max(0, verses.length - (shownCount || verses.length))
// Before the first fit every verse counts as shown.
const onScreen = verses.slice(0, shownCount || verses.length)
const bandClass = [
'stream-band',
`stream-band--${options.position}`,
Expand All @@ -128,10 +126,7 @@ export function StreamBand({
data-testid="stream-band"
>
<div className="stream-reference">
{formatReference(reference)}
{droppedCount > 0 && (
<span className="stream-more"> {t('stage.moreVerses', { count: droppedCount })}</span>
)}
{formatReference(shownReference(reference, onScreen))}
</div>
<div className="stream-verses" ref={versesRef} data-testid="stream-verses">
<div className="stream-verses-inner">
Expand Down
19 changes: 10 additions & 9 deletions frontend/src/display/StreamOverlay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('stream overlay', () => {
try {
push(socket, { type: 'reference', data: reference() })
act(() => vi.advanceTimersByTime(400))
expect(screen.getByText('John 1:1-4')).toBeInTheDocument()
expect(screen.getByText('John 1:1-3')).toBeInTheDocument()

if (state === 'swapping') {
push(socket, { type: 'reference', data: { ...reference(), id: 'ref-2', book: 'Luke' } })
Expand All @@ -73,11 +73,11 @@ describe('stream overlay', () => {
push(socket, { type: 'ping', data: {} } as unknown as DisplayMessage)
).not.toThrow()
expect(screen.getByTestId('stream-band').className).toBe(bandClass)
expect(screen.getByText('John 1:1-4')).toBeInTheDocument()
expect(screen.getByText('John 1:1-3')).toBeInTheDocument()

act(() => vi.advanceTimersByTime(state === 'swapping' ? 50 : 400))
expect(
screen.getByText(state === 'swapping' ? 'Luke 1:1-4' : 'John 1:1-4')
screen.getByText(state === 'swapping' ? 'Luke 1:1-3' : 'John 1:1-3')
).toBeInTheDocument()
expect(screen.getByTestId('stream-band')).toHaveClass('stream-band--visible')
expect(errors).not.toHaveBeenCalled()
Expand Down Expand Up @@ -147,14 +147,15 @@ describe('stream overlay', () => {
expect(screen.getByText('In him was life.')).toBeInTheDocument()
})

it("follows the projector's verse limit and says how many are left out", async () => {
it("follows the projector's verse limit and cites only the verses shown", async () => {
render(<StreamOverlay />)
push(socket, { type: 'display_settings', data: { verse_limit: 3, theme: 'dark' } })
push(socket, { type: 'reference', data: reference() })

await screen.findByText('All things were made by him.')
expect(screen.queryByText('In him was life.')).toBeNull()
expect(screen.getByText(/\+1 more verse$/)).toBeInTheDocument()
expect(screen.getByText('John 1:1-3')).toBeInTheDocument()
expect(screen.getByTestId('stream-band').textContent).not.toMatch(/more verse/)
})

it('fades out and removes the band when the projector is cleared', async () => {
Expand All @@ -166,7 +167,7 @@ describe('stream overlay', () => {
await waitFor(() => expect(screen.queryByTestId('stream-band')).toBeNull())
})

it('translates the hidden-verse note into Lithuanian', async () => {
it('adds no console-language text to the band (a Lithuanian console here)', async () => {
window.localStorage.setItem(LANGUAGE_STORAGE_KEY, 'lt')
render(
<I18nProvider>
Expand All @@ -176,9 +177,9 @@ describe('stream overlay', () => {
push(socket, { type: 'display_settings', data: { verse_limit: 3, theme: 'dark' } })
push(socket, { type: 'reference', data: reference() })

const note = await screen.findByText('dar 1 eilutė')
expect(note.textContent).toBe(' dar 1 eilutė')
expect(screen.queryByText('In him was life.')).toBeNull()
await screen.findByText('All things were made by him.')
expect(screen.getByText('John 1:1-3')).toBeInTheDocument()
expect(screen.getByTestId('stream-band').textContent).not.toMatch(/eilut/)
})

it('never shows the idle picture, even when the server sends one (it sits over a camera)', async () => {
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/display/display.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ body {
opacity: 0.8;
}

/* "+N more verses" note when a passage is longer than the chosen limit */
.display-range-note {
font-family: var(--font-sans);
font-size: clamp(0.75rem, 1.2vw, 1rem);
color: var(--color-text-muted);
text-transform: uppercase;
letter-spacing: 0.12em;
opacity: 0.7;
}

/* Idle state: the themed background, and the operator's picture when one is set.
Covers the whole screen, so the picture is not bound by the stage padding. */
.display-idle {
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/display/streamOverlay.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ html.stream-overlay-page #root {
color: #e0a63a;
}

.stream-more {
font-weight: 500;
letter-spacing: 0.06em;
color: rgba(255, 255, 255, 0.7);
}

/* The verse block takes the rest of the band; its font is fitted to it. */
.stream-verses {
flex: 1 1 auto;
Expand Down
13 changes: 8 additions & 5 deletions frontend/src/operator/App.followAlong.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,8 @@ describe('+1 verse button', () => {

const expandButton = () => screen.getByRole('button', { name: '+1 verse' })

it('shows the optional control only when enabled and sends the rolling range', () => {
it('shows the control by default and sends the rolling range', () => {
openWith(onScreen)
expect(screen.queryByRole('button', { name: '+1 verse' })).not.toBeInTheDocument()

setExpandButton('On')
fireEvent.click(expandButton())

expect(sentActions()).toEqual([
Expand All @@ -359,6 +356,13 @@ describe('+1 verse button', () => {
expect(expandButton()).toBeEnabled()
setExpandButton('Off')
expect(screen.queryByRole('button', { name: '+1 verse' })).not.toBeInTheDocument()
expect(window.localStorage.getItem('biblelive.expandPassage')).toBe('false')
})

it('stays hidden on a console that turned it off', () => {
window.localStorage.setItem('biblelive.expandPassage', 'false')
openWith(onScreen)
expect(screen.queryByRole('button', { name: '+1 verse' })).not.toBeInTheDocument()
})

it('restores the preference and disables expansion with no verse or connection', () => {
Expand All @@ -380,7 +384,6 @@ describe('+1 verse button', () => {

it('shows the usual error notice when the server rejects a verse past the chapter end', () => {
openWith(reference('last', [29, 30, 31]))
setExpandButton('On')
fireEvent.click(expandButton())
vi.spyOn(console, 'error').mockImplementation(() => {})

Expand Down
5 changes: 3 additions & 2 deletions frontend/src/operator/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ import './styles/responsive.css'

const EXPAND_PASSAGE_STORAGE_KEY = 'biblelive.expandPassage'

/** On unless this console turned it off: it is how the operator shows verses the limit cut. */
function readExpandPassagePreference() {
try {
return window.localStorage.getItem(EXPAND_PASSAGE_STORAGE_KEY) === 'true'
return window.localStorage.getItem(EXPAND_PASSAGE_STORAGE_KEY) !== 'false'
} catch {
return false
return true
}
}

Expand Down
25 changes: 25 additions & 0 deletions frontend/src/shared/verseText.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
readStoredDisplayTheme,
readStoredVerseLimit,
selectVerses,
shownReference,
writeStoredDisplayTheme,
writeStoredVerseLimit,
} from './verseText'
Expand Down Expand Up @@ -193,3 +194,27 @@ describe('display theme', () => {
expect(coerceDisplayTheme(undefined)).toBe('dark')
})
})

describe('shownReference', () => {
it('cuts the range to the verses shown', () => {
const passage = ref({ verses: verses(8) })
const cited = shownReference(passage, selectVerses(passage, 3))
expect([cited.verse_start, cited.verse_end]).toEqual([1, 3])
})

it('keeps the reference when every verse is shown', () => {
const passage = ref({ verses: verses(3), verse_end: 3 })
expect(shownReference(passage, selectVerses(passage, 5))).toBe(passage)
})

it('narrows a whole-chapter reference to the verses shown', () => {
const chapter = ref({ verse_start: null, verse_end: null, verses: verses(6) })
const cited = shownReference(chapter, selectVerses(chapter, 3))
expect([cited.verse_start, cited.verse_end]).toEqual([1, 3])
})

it('keeps the reference for the joined-text fallback', () => {
const passage = ref({ text: 'In the beginning.' })
expect(shownReference(passage, selectVerses(passage, 3))).toBe(passage)
})
})
12 changes: 12 additions & 0 deletions frontend/src/shared/verseText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ export function hiddenVerseCount(ref: BibleReference | null, limit: VerseLimit):
return Math.max(0, total - shown.length)
}

/**
* The reference for the verses actually on screen. When only part of a passage is
* shown (the verse limit, or a band too small for all of it), the range is cut to
* the first and last shown verse, so the citation never names a verse the audience
* cannot see.
*/
export function shownReference(ref: BibleReference, shown: VerseText[]): BibleReference {
const total = ref.verses?.length ?? 0
if (shown.length === 0 || shown.length >= total) return ref
return { ...ref, verse_start: shown[0].verse, verse_end: shown[shown.length - 1].verse }
}

/** Read a stored verse limit, ignoring unknown or malformed values. */
export function readStoredVerseLimit(storage?: Storage): VerseLimit {
try {
Expand Down